akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;


ll a[100005];
ll b[100005];
const ll mod = 998244353;

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

    REP(i,n){
        cin >> a[i];
        b[a[i]]++;
    }

    if(b[0] != 1) cout << 0 << endl;
    else
    {
        ll ans = 1;
        REP(i,n)
        {
            if (i == 0) continue;
            ans *= b[a[i]-1];
            ans %= 998244353;
        }
            
        cout << ans << endl;;   
    }
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< int > V(N), C(N);
  cin >> V >> C;

  int ret = 0;
  for(int i = 0; i < N; i++) {
    ret += max(0, V[i] - C[i]);
  }
  cout << ret << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int guest[4][3][10]={};
    int n;
    in(n);
    int b,f,r,v;
    while(n--){
        in(b,f,r,v);
        guest[b-1][f-1][r-1]+=v;
    }
    rep(i,4){
        rep(j,3){
            rep(k,10){
                cout<<" "<<guest[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3)cout<<"####################";
        if(i!=3)cout<<endl;
    }
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define mp make_pair
typedef long long ll;
using namespace std;
const int inf=1025352128;
int n,d;
int a[200005];
int f[200005];
int rk[200005];
vector <pair<ll,pair<int,int> > >vec;

int find(int x)
{
	if(f[x]==x)
	{
		return x;
	}
	else
	{
		rk[x]=1;
		return f[x]=find(f[x]);
	}
}

void merge(int x,int y)
{
	x=find(x);
	y=find(y);
	if(rk[x]==rk[y])
	{
		if(rand()&1)
		{
			rk[x]++;
			f[y]=x;
		}
		else
		{
			rk[y]++;
			f[x]=y;
		}
		return;
	}
	if(rk[x]>rk[y])
	{
		f[y]=x;
		return;
	}
	if(rk[y]>rk[x])
	{
		f[x]=y;
		return;
	}
}

void init()
{
	for(int i=0;i<n;i++)
	{
		f[i]=i;
		rk[i]=1;
	}
}

inline ll cost(int i,int j)
{
	return 1LL*a[i]+1LL*a[j]+1LL*(j-i)*d;
}

void add(int l,int r)
{
	if(r-l<=1) return;
	int m=l+r+1>>1;
	ll minx=inf,tl,tr;
	for(int i=l;i<m;i++)
	{
		if(1LL*a[i]-1LL*i*d<minx)
		{
			minx=1LL*a[i]-1LL*i*d;
			tl=i;
		}
	}
	minx=1LL*inf*inf;
	for(int i=m;i<r;i++)
	{
		if(1LL*a[i]+1LL*i*d<minx)
		{
			minx=1LL*a[i]+1LL*i*d;
			tr=i;
		}
	}
	for(int i=l;i<m;i++)
	{
		vec.push_back(mp(cost(i,tr),mp(i,tr)));
	}
	for(int i=m;i<r;i++)
	{
		vec.push_back(mp(cost(tl,i),mp(tl,i)));
	}
	add(l,m);
	add(m,r);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>d;
	init();
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	add(0,n);
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	ll res=0;
	int s=1;
	for(int i=0;i<vec.size();i++)
	{
		typeof(vec[i]) x=vec[i];
		if(find(x.second.first)==find(x.second.second)) continue;
		merge(x.second.first,x.second.second);
		s++;
		res+=x.first;
		if(s==n) break;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 70368
n = int(input())
m = 10**4
isp = [1] * m
isp[0] = isp[1] = 0
for i in range(2, int(m**0.5)+1):
    if isp[i]:
        for j in range(i * i, m, i):
            isp[j] = 0

P = [i for i,j in enumerate(isp) if j>0 and i%5 == 1]
print(*P[:n])


Measured memory_bytes: 3188
s=input()
l=[0]*len(s)
t=0
p='R'
for i,c in enumerate(s+'R'):
  if c!=p:
    if c<'R':
      l[i-1]=t-t//2
      l[i]=t//2
      r=i
    else:
      l[r-1]+=t//2
      l[r]+=t-t//2
    t=0
  t+=1
  p=c
print(*l)

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			int n = sc.nextInt();
			int k = sc.nextInt();
			final String base36 = Integer.toString(n, k);
			System.out.println(base36.length());
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int X;
  cin >> X;
  int g = gcd(X, 360);
  ll ans = 360 / g;
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

static const ll mod = 1000000007;
int dp[100010][2];

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

    // 桁DP
    int n = s.length();
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        // a + b のi桁目 = 0 とする場合((a, b) = (0, 0))
        {
            if(s[i] == '1'){
                // dp[i + 1][0]は、この場合はない
                // 前の状態からは両方ともdp[i + 1][1]へ遷移可能
                dp[i + 1][1] = (dp[i][0] + dp[i][1]) % mod;
            }
            else{
                // 
                dp[i + 1][0] = dp[i][0];
                dp[i + 1][1] = dp[i][1];
            }
        }

        // a + b のi桁目 = 1 とする場合((a, b) = (1, 0) or (0, 1))
        {
            if(s[i] == '1'){
                dp[i + 1][0] += dp[i][0] * 2 % mod;
                dp[i + 1][0] %= mod;
                dp[i + 1][1] += dp[i][1] * 2 % mod;
                dp[i + 1][1] %= mod;
            }
            else{
                dp[i + 1][1] += dp[i][1] * 2 % mod;
                dp[i + 1][1] %= mod;
            }
        }
    }
    int ans = (dp[n][0] + dp[n][1]) % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4524
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############
popc = [0] * ((1 << 18) + 1)
for bit in range(1, 1 << 18):
    opt = bin(bit).count('1')
    popc[bit] = bit % opt

f_list = [0] * ((1 << 18) + 1)
for i in range(1, 1 << 18):
    now = popc[i]
    cnt = 1
    while True:
        if now == 0:
            f_list[i] = cnt
            break
        now = popc[now]
        cnt += 1

N = getN()
X = input()
NX = len(X)
time = X.count('1')
t1 = time + 1
t2 = time - 1

lis_left_1 = [0] * NX

now = 1 % t1
lis_left_1[0] = now
for i in range(1, NX):
    now = (2 * now) % t1
    lis_left_1[i] = now

lis_left_2 = [0] * NX

if t2 > 0:
    now = 1 % t2
    lis_left_2[0] = now
    for i in range(1, NX):
        now = (2 * now) % t2
        lis_left_2[i] = now

left_mother_1 = 0
for i in range(NX):
    if int(X[i]) == 1:
        left_mother_1 += lis_left_1[NX - i - 1]

left_mother_2 = 0
for i in range(NX):
    if int(X[i]) == 1:
        left_mother_2 += lis_left_2[NX - i - 1]

for i in range(N):
    # 1が0に left_mother_2, t2
    if int(X[i]) == 1:
        if t2 == 0:
            print(0)
            continue
        opt_mom = left_mother_2
        opt_mom -= lis_left_2[NX - i - 1]
        opt_mom %= t2
        print(f_list[opt_mom] + 1)
    # 0が1に left_mother_1, t1
    else:
        opt_mom = left_mother_1
        opt_mom += lis_left_1[NX - i - 1]
        opt_mom %= t1
        print(f_list[opt_mom] + 1)

Measured memory_bytes: 91492
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	map<int, int>mp;
	for (int i = 2; i <= n; i++) {
		for (auto p : prime_factor(i)) {
			while (p.second--) {
				mp[p.first]++;
			}
		}
	}
	int ans = 1;
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		ans *= itr->second + 1; ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void ABC42(void);
void ABC43(void);
void ABC44(void);

int main(void){
    ABC44();
    return 0;
}

void ABC42(void){
    int a,b,c,n=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7||b==7||c==7){
        if((a==5&&b==5)||(b==5&&c==5)||(c==5&&a==5)){
            printf("YES");
            n++;
    }}
    if(n==0)printf("NO");
}

void ABC43(void){
    int i,n,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        sum+=i;
    }
    printf("%d",sum);
}

void ABC44(void){
    int n,k,x,y,i,sum=0;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(n>k){
        for(i=1;i<=k;i++)sum+=x;
        for(i=k+1;i<=n;i++)sum+=y;
    }else{
        for(i=1;i<=n;i++)sum+=x;
    }
    printf("%d",sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

int main()
{
	int n;
	cin >> n;
	vector<string> str;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		str.push_back(s);
	}
	sort(str.begin(), str.end());

	string before = str[0];
	int count = 1;
	for (int i = 1; i < n; i++)
	{
		if (before != str[i])
		{
			count++;
			before = str[i];
		}
	}
	cout << count;
}



Measured memory_bytes: 42916
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
#define int long long
main()
{
    int m, n, k, a, b, c, d;
    vector<int> v(20);
    cin >> n;
    for( int i = 0; i <n; i++ )cin >> v[i];
    int cnt = 0;
    for( int i = 0; i < n - 2; i++ )
    {
        int a[3];
        a[0] = v[i];a[1] = v[i + 1];a[2] = v[i + 2];
        sort( a, a + 3 );
        if( a[1] == v[i + 1] ) cnt++;
    }
    cout << cnt <<endl;
    return 0;
}

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

#define max(a,b) (a)>(b)?(a):(b)

int main(){
   int k,x;
   cin>>k>>x;
   
   
   for(int i=-k+1;i<k;i++){
	cout<<(x+i)<<" ";
    }
    cout<<endl;
}

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

using i64 = int64_t;

constexpr i64 INF = 1e9;

struct Key{
    int price, box;
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<Key> v;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        int box = 0;
        for(int j=0;j<b;++j){
            int c;
            cin >> c;
            box |= (1<<(c-1));
        }
        v.push_back({a, box});
    }
    vector<i64> dp((1<<n), INF);
    dp[0] = 0;
    for(int i=0;i<m;++i){
        for(int j=0;j<(1<<n);++j){
            int idx = (j | v[i].box);
            dp[idx] = min(dp[idx], dp[j]+v[i].price);
        }
    }

    if(dp[(1<<n)-1] == INF)cout << -1;
    else cout << dp[(1<<n)-1];
    cout << endl;

    return 0;
}


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

using namespace std;

void abc_170a();

void abc_171a();

void abc_172a();

void abc_173a();

void abc_174a();

void abc_175a();

int main()
{
  //abc_170a();
  //abc_171a();
  //abc_172a();
  //abc_173a();
  //abc_174a();
  abc_175a();

}

void abc_170a()
{
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << "\n";
      return;
    }
  }
}


void abc_171a()
{
  char c;
  cin >> c;

  if (c == tolower(c)) cout << "a\n";
  else cout << "A\n";
}

void abc_172a()
{
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << "\n";
}

void abc_173a()
{
  int N;
  cin >> N;

  if (N % 1000) cout << 1000 - N % 1000 << "\n";
  else cout << "0\n";
}

void abc_174a()
{
  int x;
  cin >> x;

  if (x >= 30) cout << "Yes\n";
  else cout << "No\n";
}

void abc_175a()
{
  string s;
  cin >> s;

  int cnt = 0, tmp = 0;
  for (int i = 0; i < s.size(); ++i)
  {
    if (s[i] == 'S')
    {
      tmp = 0;
    }
    else
    {
      ++tmp;
      cnt = tmp;
    }
  }

  cout << cnt << "\n";
}

Measured memory_bytes: 3600
s=input()
def solution(s):
    new = []
    for c in s:
        if c == '0':
            new.append('0')
        elif c == '1':
            new.append('1')
        elif c == 'B':
            try:
                new.pop()
            except:
                pass
    newnew = ''.join(new)
    return newnew
print(solution(s))

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

vector<unsigned long  long> a;

int main() {

	int x, y, z;
	cin >> x >> y >> z;

	int n = 0;

	while (1) {
		//今の長さ
		int now_len = n * y + (n + 1)*z;
		if (x < now_len) {
			break;
		}
		n++;
	}

	cout << n-1 << endl;

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll a[7];
	for(int i=0; i<7; i++) cin >> a[i];
	ll ans=a[1];
	ll p=2*(a[0]/2+a[3]/2+a[4]/2);
	ll q=3+2*((a[0]-1)/2+(a[3]-1)/2+(a[4]-1)/2);
	if(a[0]>0 && a[3]>0 && a[4]>0) ans+=max({p, q});
	else ans+=p;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import re
""" 
よく分からないけれど1つWA
--> reはnon-overlapping にマッチする 
"""

s = input()
K = int(input())

substrings = []
min_s = ''
while True:
    if min_s == '':
        temp_min_s = min(list(s))
    else:
        temp_min_s = min(list(re.sub('[%s]' % min_s, '', s)))
    min_s += temp_min_s

    word_len = 1
    while word_len < K+1:
        if re.search('%s[a-z]{%d}' % (temp_min_s, word_len-1), s) == None:
            break
        substrings.extend(list(set(re.findall('(?=(%s[a-z]{%d}))' %\
                (temp_min_s, word_len-1), s))))
        # 肯定的先読み
        word_len += 1

    if len(substrings) >= K:
        print(sorted(substrings)[K-1])
        exit()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,X;
    cin >> N >> X;
    int L[N];
    for(int i=0;i<N;i++)cin >> L[i];
    int ans=1;
    int d=0;
    for(int i=0;i<N;i++){
        d+=L[i];
        if(d>X)break;
        else ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ll mon = 1000;
    ll k = 0;
    rep(i,n-1){
        if(a[i]<a[i+1]){
            ll get = mon / a[i];
            mon = mon%a[i];
            mon += get * a[i+1];
        }
    }
    cout << mon << endl;
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,OO=0x3f3f3f3f;
typedef long long ll;
int main() {
    string s; cin>>s;
    cout<<(s=="ABC"?"ARC":"ABC");
}

Measured memory_bytes: 3620
# ABC138E - Strings of Impurity
def main():
    S, T = tuple(input() for _ in range(2))
    if not set(T) <= set(S):  # corner case
        print(-1)
        return
    ans, cur, idx, lim = 1, 0, -1, len(T)
    while cur < lim:
        find = S[idx + 1:].find(T[cur])
        if find == -1:
            ans += 1
            idx = -1
        else:
            idx += find + 1
            cur += 1
    ans = (ans - 1) * len(S) + idx + 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int L, mt = 0;
		int gL = 0;
		
		cin >> L;
		if( L == 0 )	break;
		
		for(int i = 0; i < 12; i++) {
			int n, m;
			cin >> n >> m;
			gL += n - m;
			if(gL >= L && mt == 0) {
				mt = i + 1;
			}
		}
		
		if(mt == 0) {
			cout << "NA" << endl;
		} else {
			cout << mt << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 int main(){
    long long A,B,K;cin>>A>>B>>K;
    if(A>=K){
        A-=K;
    }else{
        
        B-=(K-A);
        A=0;
        if(B<0)B=0;
    }
    cout<<A<<" "<<B<<endl;
    }
        






Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)

if n == 0
  p x
  exit
end

ps = gets.split.map(&:to_i)
qs = [*(-200)..200] - ps

mn = -1
mv = 1000000000

qs.each do |q|
  if (q - x).abs < mv
    mn = q
    mv = (q - x).abs
  end
end

p mn


Measured memory_bytes: 14396
package main

import (
	"fmt"
)

func main() {

	var S string
	fmt.Scanf("%s", &S)

	if S == "Sunny" {
		fmt.Println("Cloudy")
	} else if S == "Cloudy" {
		fmt.Println("Rainy")
	} else {
		fmt.Println("Sunny")
	}
}


Measured memory_bytes: 1832
#include<iostream>
int main() {
	int n;
	while (std::cin>>n) {
		int input[4];
		input[0] = n;
		for (int i = 1; i < 4; ++i) {
			std::cin >> input[i];
		}
		int answer[4];
		for (int i = 0; i < 4; ++i) {
			std::cin >> answer[i];
		}
		int e = 0, b = 0;
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (input[i] == answer[j]) {
					if (i == j)++e;
					else ++b;
					break;
				}
			}
		}
		std::cout << e << " " << b << std::endl;
	}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[101010];
int dp[101010][3]; // non/part/fill

void dfs(int cur,int pre) {
	int c=0;
	
	if(E[cur].size()==1) {
		dp[cur][0]=0;
		dp[cur][1]=1<<20;
		dp[cur][2]=1;
	}
	else {
		int count=0;
		FORR(e,E[cur]) if(e!=pre) {
			dfs(e,cur);
			count++;
			if(count==1) {
				dp[cur][0]=dp[e][0];
				dp[cur][1]=dp[e][1];
				dp[cur][2]=dp[e][2];
			}
			else {
				int d[3]={dp[cur][0],dp[cur][1],dp[cur][2]};
				dp[cur][0]=1<<20;
				if(count==2) {
					dp[cur][1]=min(min(d[1],d[2])+dp[e][0],d[0]+min(dp[e][1],dp[e][2]));
					dp[cur][2]=min(d[1],d[2])+min(dp[e][1],dp[e][2]);
				}
				else {
					dp[cur][1]=min(d[2]+dp[e][0],d[1]+min(dp[e][1],dp[e][2]));
					dp[cur][2]=d[2]+min(dp[e][1],dp[e][2]);
				}
			}
		}
		
	}
	//cout<<cur<<" "<<dp[cur][0]<<"  "<<dp[cur][1]<<"  "<<dp[cur][2]<<endl;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	FOR(i,N-1) {
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	FOR(i,N) if(E[i].size()>2) {
		dfs(i,-1);
		cout<<min(dp[i][1],dp[i][2])<<endl;
		return;
	}
	_P("1\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

const int z = 100000;
int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 1) ans += 3*z;
  else if (x == 2) ans += 2*z;
  else if (x == 3) ans += z;
  if (y == 1) ans += 3*z;
  else if (y == 2) ans += 2*z;
  else if (y == 3) ans += z;
  if (x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const ll INF = numeric_limits<ll>::max();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vll sm(n+1);
    rep(i, n) {
        int a;
        cin >> a;
        sm[i+1] = sm[i] + a;
    }
    ll ans = INF;
    rep(i, n-1) {
        ll x = sm[i+1];
        ll y = sm[n] - sm[i+1];
        chmin(ans, abs(x-y));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String	stdin = null;
		int		cnt   = 0;
		int		len   = 0;
		int		fin   = 0;
		boolean	rev   = true;

		while ((stdin = parseStdin()) != null) {
			rev = true;
			len = stdin.length();
			fin = len / 2;
			for (int n = 0; n < fin; n++) {
				if (!(rev = (stdin.charAt(n) == stdin.charAt(len - 1 - n)))) {
					break;
				}
			}

			if (rev) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}

	private static String parseStdin() {
		String	stdin = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					stdin = line;
				}
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 17004
#include <iostream>
#include <vector>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
int main() {
    // input
    int n, k; cin >> n >> k;
    vector<vector<int> > g(n);
    repeat (i,n-1) {
        int a, b; cin >> a >> b;
        -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // compute
    function<int (int, int, int)> dfs = [&](int i, int p, int depth) {
        int cnt = 1;
        if (depth) for (int j : g[i]) if (j != p) {
            cnt += dfs(j, i, depth-1);
        }
        return cnt;
    };
    int cnt = 0;
    if (k % 2 == 0) {
        repeat (i,n) {
            setmax(cnt, dfs(i, -1, k/2));
        }
    } else {
        repeat (i,n) {
            for (int j : g[i]) {
                setmax(cnt, dfs(i, j, k/2) + dfs(j, i, k/2));
            }
        }
    }
    // output
    cout << n - cnt << endl;
    return 0;
}

Measured memory_bytes: 384
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    d = 0
    s = 0
    for _ in range(int(input())):
        a, b = map(int, input().split())
        s += a * b
        d += b
    print(d - 1 + (s - 1) // 9)

main()

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

using namespace std;

typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	int n, k;
	ll ans;
	
	cin >> n >> k;
	
	ans = k;
	
	for(int i = 0; i < n - 1; i++){
		ans *= k - 1;
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int n, v[MAX];
int dp[MAX];

void solve() {
	cin >> n;
	for(int i=0; i<n; i++) cin >> v[i];
	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);
	for(int i=2; i<n; i++) {
		dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
	}
	cout << dp[n-1];
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 4372
N, M = map(int, input().split())

vec = [[] for _ in range(N)]
for _ in range(M) :
    a, b = map(int, input().split())
    vec[a-1].append(b-1)
    vec[b-1].append(a-1)
    
visited = [False] * N

def bfs(cur, l) :
    if all(visited) :
        return 1
        
    ret = 0
    for nex in vec[cur] :
        if not visited[nex] :
            visited[nex] = True
            ret += bfs(nex, l + 1)
            visited[nex] = False
            
    return ret

visited[0] = True    
print(bfs(0, 0))

Measured memory_bytes: 43996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}






int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> ans(n,1);
  rep (i,n-1) {
    if (s[i] == 'R' && s[i+1] == 'R') {
      ans[i+2] += ans[i];
      ans[i] = 0;
    }
  }
  for (int i = n-1;i > 0; i--) {
    if (s[i] == 'L' && s[i-1] == 'L') {
      ans[i-2] += ans[i];
      ans[i] = 0;
    }
  } 
  for (int i = 0;i < n;i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int dp[2][102][2] = {};
inline void add(int &a, int b) {
	a = (a + b % mod) % mod;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; int d;
	cin >> s >> d;
	int len = s.length();
	dp[1][0][1] = 1;
	for (int i = 0; i < len; i++) {
		memset(dp[i&1], 0, sizeof(dp[i&1]));
		for (int j = 0; j < d; j++)
			for (int k = 0; k <= 9; k++)
				if(k < s[i]-'0')
					add(dp[i&1][(j+k)%d][0], dp[!(i&1)][j][0] + dp[!(i&1)][j][1]);
				else if (k == s[i]-'0')
					add(dp[i&1][(j+k)%d][0], dp[!(i&1)][j][0]),
					add(dp[i&1][(j+k)%d][1], dp[!(i&1)][j][1]);
				else
					add(dp[i&1][(j+k)%d][0], dp[!(i&1)][j][0]);
	}
	cout << (dp[!(len&1)][0][0] + dp[!(len&1)][0][1] - 1 + mod) % mod << "\n";
	return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : ll { M = 998244353 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

ll dp[3002][3002];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    auto print = [&](){ 
        for(int i = 1; i <= c; i++){
            for(int j = 1; j <= d; j++){
                printe0(dp[i][j], ' ');
            }
            printe();
        }
    };
    dp[a][b] = 1;

    for(int i = a; i <= c; i++){
        for(int j = b; j <= d; j++){
            // printde(i, j, dp[i][j]);
            // print();

            dp[i][j] += dp[i - 1][j] * j + dp[i][j - 1] * i - dp[i - 1][j - 1] * (i - 1) * (j - 1) + M * 3000 * 3000;
            dp[i][j] %= M;

            // dp[i][j] += dp[i - 1][j] * j + dp[i][j - 1] * i;
        }
    }

    // for(int i = a; i <= c; i++){
    //     for(int j = b; j <= d; j++){
    //         printde(i, j, dp[i][j]);
    //         print();
    //
    //         // dp[i + 1][j] += dp[i][j] * j;
    //         // dp[i][j + 1] += dp[i][j] * a;
    //
    //
    //         // dp[i + 1][j] += dp[i][j] * (j - b + 1);
    //         dp[i + 1][j] += dp[i][j] * (1 + 0);
    //         // dp[i + 1][j] += dp[i][j] * (j - b);
    //         dp[i][j + 1] += dp[i][j] * i;
    //
    //         // dp[i + 1][j] += dp[i][j] * b;
    //         // dp[i][j + 1] += dp[i][j] * i;
    //
    //
    //         // dp[i + 1][j] += dp[i][j];
    //         // dp[i][j + 1] += dp[i][j];
    //
    //         // dp[i + 1][j] += dp[i][j] * j;
    //         // dp[i][j + 1] += dp[i][j] * i;
    //
    //         dp[i + 1][j] %= M;
    //         dp[i][j + 1] %= M;
    //     }
    // }

    cout << dp[c][d] << '\n';
}
/*
2 1 3 4
.
.

....
o...
o...
*/


Measured memory_bytes: 73376
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;


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

	int A, B, C;
	cin >> A >> B >> C;

	if ((A*B*C) % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	array<int,3> t = { A*B,B*C,C*A };
	sort(ALL(t));
	cout << t[0] << endl;
}



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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;
ll n,a,b;

ll ele(ll b, ll e) {
    ll ans = 1;

    while(e) {
        if(e&1) ans = (ans * b) % MOD;
        b = (b * b) % MOD;
        e >>= 1;
    }

    return ans % MOD;
}

ll f(ll n, ll x) {
    ll a = 1;
    ll b = 1;
    for(ll i = n-x+1; i <= n; i++) a = (a * i) % MOD;
    for(ll i = 1; i <= x; i++) b = (b * i) % MOD;
    return (a * ele(b,MOD-2))%MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> a >> b;
    ll ans = ele(2,n);
    ans = (ans - f(n,a) + MOD) % MOD;
    ans = (ans - f(n,b) + MOD) % MOD;
    cout << (ans-1+MOD)%MOD << endl;
    return 0;
}



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

int main() 
{   
  

 
long long int n,k;
scanf("%lld %lld",&n,&k);
long long int h[n];

    for(long long int i = 0; i <n; i++){
   
scanf("%lld",&h[i]);
}
long long int dp[n];
dp[0]=0;
dp[1]=abs(h[0]-h[1]);
 for(long long int i = 2; i <n; i++){dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
   for(long long int j=2;j<=k;j++)
   {if(i-j>=0)
dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

   }

}
printf("%lld\n",dp[n-1]);


}

  
 

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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
    std::ios_base::sync_with_stdio(0);

    u32 N;
    std::string S;
    std::cin >> N >> S;

    u32 answer = 0;

    for (u32 i = 0; i < 10; i++)
    {
        char digit = '0' + i;
        u32 index1 = std::distance(S.begin(), find(S.begin(), S.end(), digit));

        if (index1 == N)
        {
            continue;
        }

        for (u32 j = 0; j < 10; j++)
        {
            char digit = '0' + j;
            u32 index2 = std::distance(S.begin(), find(S.begin() + index1 + 1, S.end(), digit));

            if (index2 == N)
            {
                continue;
            }

            for (u32 k = 0; k < 10; k++)
            {
                char digit = '0' + k;
                if (find(S.begin() + index2 + 1, S.end(), digit) != S.end())
                {
                    answer++;
                }
            }
        }
    }

    std::cout << answer << std::endl;

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int n;
const int mxN=1e7+5;
int lf[mxN];
ll numFactors[mxN];

void calcFactors() {
    lf[1]=1;
    for (int i = 2; i <= n; i++) {
        if (!lf[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i) {
                if(!lf[j])
                    lf[j] = i;
            }
        }
    }
}

void calcNumFactors(int val) {
    if(!lf[val]) {
        numFactors[val]=2;
        return;
    }
    int oval=val;
    int cnt=0;
    int div=lf[val];
    while(val%div==0) {
        val/=div;
        cnt++;
    }
    numFactors[oval]=(cnt+1)*1LL*numFactors[val];
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    cin >> n;
    calcFactors();
    numFactors[1]=1;
    FOR(i,2,n+1)
        calcNumFactors(i);
    ll tot=0;
    FOR(i,1,n+1)
        tot+=i*numFactors[i];
    cout << tot;

    return 0;
}


Measured memory_bytes: 120712
#include<stdio.h>
#include<math.h>
int main(){
int a[1099999],b=0,c=3,i,j=0,d,e=0;
for(i=2;i<1099999;i++){
if(i==2){
}
else if(i%2==0){
b=1;
}
else{
while(c<=sqrt(i)){
if(i%c==0){
b=1;
break;
}
c=c+2;
}
c=3;
}
if(b==0){
a[j]=i;
j++;
}
b=0;
}
while(scanf("%d\n",&d)!=EOF){
for(i=0;a[i]<=d;i++){
e++;
}
printf("%d\n",e);
e=0;
}
return 0;
}


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

int main()
{
	string s1, s2, temp;
	int sum, flag;
	int a, b;
	vector<int> v;
	int T;
	cin >> T;
	while (T--)
	{
		cin >> s1 >> s2;
		v.clear();
		sum = 0;
		flag = 0;
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());
		if (s1.size() < s2.size())
		{
			temp = s1;
			s1 = s2;
			s2 = temp;
		}
		for (int i = 0; i < s1.size(); ++i)
		{
			if (s1[i] == '0')a = 0;
			else if (s1[i] == '1')a = 1;
			else if (s1[i] == '2')a = 2;
			else if (s1[i] == '3')a = 3;
			else if (s1[i] == '4')a = 4;
			else if (s1[i] == '5')a = 5;
			else if (s1[i] == '6')a = 6;
			else if (s1[i] == '7')a = 7;
			else if (s1[i] == '8')a = 8;
			else if (s1[i] == '9')a = 9;
			if (i >= s2.size())b = 0;
			else
			{
				if (s2[i] == '0')b = 0;
				else if (s2[i] == '1')b = 1;
				else if (s2[i] == '2')b = 2;
				else if (s2[i] == '3')b = 3;
				else if (s2[i] == '4')b = 4;
				else if (s2[i] == '5')b = 5;
				else if (s2[i] == '6')b = 6;
				else if (s2[i] == '7')b = 7;
				else if (s2[i] == '8')b = 8;
				else if (s2[i] == '9')b = 9;
			}
			sum = a + b + flag;
			if (sum > 9)
			{
				sum = sum - 10;
				flag = 1;
			}
			else
			{
				flag = 0;
			}
			v.push_back(sum);
		}
		if (flag == 1)
			v.push_back(1);
		if (v.size() > 80)
			cout << "overflow" << endl;
		else
		{
			for (int i = v.size() - 1; i >= 0; --i)
			{
				cout << v[i];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

template <typename T>
T modpow(T a, T n, T mod) {
    T ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

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

    Int n, k;
    cin >> n >> k;

    vector<Int> dd(k + 1), d(k + 1);
    for (Int i = 1; i <= k; i++) {
        dd[i] = modpow(Floor(k, i), n, MOD);
    }

    for (Int i = k; i >= 1; i--) {
        d[i] = dd[i];

        for (Int x = 2 * i; x <= k; x += i) {
            d[i] -= d[x];
            d[i] = (d[i] + MOD) % MOD;
        }
    }

    Int ans = 0;

    for (Int i = 1; i <= k; i++) {
        ans += d[i] * i % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4792