akhauriyash/Code-Regression huggingface dataset:
def edu_dp_d_matching():
    n = int(input())
    a = []
    for _ in range(n):
        a.append(list(map(int, input().split())))
    dp = [[0] * (1 << n) for _ in range(n)]
    for i in range(n):
        if a[0][i] == 1: dp[0][(1 << i)] = 1
    for i in range(1, n):
        for k in range(1 << n):
            if dp[i - 1][k] == 0: continue
            for j in range(n):
                if a[i][j] == 0 or k & (1 << j) != 0: continue
                dp[i][k | (1 << j)] += dp[i - 1][k]

    print(dp[-1][-1] % (pow(10, 9) + 7))


edu_dp_d_matching()

Measured memory_bytes: 452684
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val abList = mutableListOf<Pair<Long, Long>>()
    (1..n).forEach {
        val (a, b) = readLine()!!.split(' ').map(String::toLong)
        abList.add(Pair(a, b))
    }
    abList.sortBy { it.second }

    var sum = 0L
    for (i in 0 until n) {
        sum += abList[i].first
        if (sum > abList[i].second) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 135332
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000"]

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>

#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
//#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

using namespace std;

#ifdef __LOCAL
    #define dbg(x) cerr << #x << " : " << x << '\n'
    const int maxn = 110 + 10;
#else
    #define dbg(x)
    const int maxn = 110;
#endif

//tg: @galebickosikasa

const ll inf = (ll) 1e9 + 10;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll) 1e9 + 7;
const ll ns = 97;
const int MAXLOG = 20;
const int N = 45;

#define int ll

random_device rd;
mt19937 SuperRandom(rd());



signed main(){
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<set<int>> nums (26);

    for (int i = 0; i < n; ++i) {
        int x = s[i] - 'a';
        nums[x].insert(i);
    }

    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char y;
            cin >> i >> y;
            --i;
            int prev = s[i] - 'a';
            nums[prev].erase(i);
            nums[y - 'a'].insert(i);
            s[i] = y;
        } else {
            int l, r;
            cin >> l >> r;
            --l, --r;
            int ans = 0;
            for (auto &x: nums) {
                auto it = x.lower_bound(l);
                if (it != x.end() && *it <= r) ++ans;
            }
            cout << ans << '\n';
        }
    }





}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    int n,x;
    cin>>n>>x;
    vint l(n);
    rep(i,n)cin>>l[i];
    int sum=0;
    int count=1;
    rep(i,n){
        sum+=l[i];
        if(sum<=x){
            count++;
        }
        else{
            break;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#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;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream cin("input.txt")
//#define of1 ofstream cout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

vector< vector<ll> >adj(100005);
vector<ll>visited(100005,0);

ll n,k;
ll ans=1;

void dfs(ll curr,ll par)
{
    visited[curr]=1;
    ll i=0;
    for(auto &nei:adj[curr])
    {
        if(visited[nei])
            continue;
        if(par==-1)
        {
            ans*=(k-1-(i++));
            ans%=mod;
        }
        else
        {
            ans*=(k-2-(i++));
            ans%=mod;
        }
        dfs(nei,curr);
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>k;
	for(ll i=0;i<n-1;i++)
	{
	    ll a,b;
	    cin>>a>>b;
	    adj[a].eb(b);
	    adj[b].eb(a);
	}
	dfs(1,-1);
	ans*=k;
	ans%=mod;
	cout<<ans;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  if(N == 1){
    cout << 1 << endl;
  }
  else if(N % 2 == 0){
    cout << 0.5 << endl;
  }
  else {
    cout << ((double)(N + 1) / 2) / N << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,min=0,max=0,mini,maxi;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (max<a[i]){
            max=a[i];
            maxi=i;
        }
        if (min>a[i]){
            min=a[i];
            mini=i;
        }
    }
    if (min==0){
        printf("%d\n",n-1);
        for (int i=1; i<n; i++){
            printf("%d %d\n",i,i+1);
        }
    } else if (max==0){
        printf("%d\n",n-1);
        for (int i=n; i>1; i--){
            printf("%d %d\n",i,i-1);
        }
    } else if (abs(max)>abs(min)){
        printf("%d\n",n*2-1);
        for (int i=0; i<n; i++){
            printf("%d %d\n",maxi+1,i+1);
        }
        for (int i=1; i<n; i++){
            printf("%d %d\n",i,i+1);
        }
    } else {
        printf("%d\n",n*2-1);
        for (int i=0; i<n; i++){
            printf("%d %d\n",mini+1,i+1);
        }
        for (int i=n; i>1; i--){
            printf("%d %d\n",i,i-1);
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] aMid = new int[N];
        Queue<Integer> zenhan = new PriorityQueue<>();
        Queue<Integer> kouhan = new PriorityQueue<>((o1, o2) -> o2 - o1);
        long[] zenhanSums = new long[N + 1];
        long[] kouhanSums = new long[N + 1];
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            zenhan.add(a);
            zenhanSums[0] += a;
        }
        for (int i = 0; i < N; i++) {
            aMid[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            kouhan.add(a);
            kouhanSums[N] += a;
        }
        for (int i = 0; i < N; i++) {
            int min = zenhan.poll();
            int added = Math.max(min, aMid[i]);
            zenhan.add(added);
            zenhanSums[i + 1] = zenhanSums[i] - min + added;
        }
        for (int i = 0; i < N; i++) {
            int max = kouhan.poll();
            int added = Math.min(max, aMid[N - i - 1]);
            kouhan.add(added);
            kouhanSums[N - i - 1] = kouhanSums[N - i] - max + added;
        }
        long ans = Long.MIN_VALUE;
        for (int i = 0; i < N + 1; i++) {
            ans = Math.max(ans, zenhanSums[i] - kouhanSums[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 102020
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int N, ans = 0;
	cin >> N;
	vector<int>a(N);
	for (int i = 0; i < N; i++)cin >> a[i];
	for (int i = 0; i < N; i++)
	{
		if (a[a[i] - 1] == i + 1)ans++;
	}
	cout << ans / 2;
}


Measured memory_bytes: 768
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

bool cmp(pair<int , int> A , pair<int , int> B)
{
    return A.second>B.second;
}

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

    int n , m;
    cin >> n >> m;
    vector<ll>v(n);
    for(auto &x:v)cin >> x;
    sort(v.begin() , v.end());
    vector<pair<int , int> > s;
    for(int i=0;i<m;i++){
        int in1 , in2;
        cin >> in1 >> in2;
        s.push_back({in1 , in2});
    }
    sort(s.begin(), s.end() , cmp);
    int idx = -1 , now = 0 , val = -1;
    for(int i=0;i<n;i++){
        if(now==0){
            idx++;
            if(idx>=m)break;
            now = s[idx].first;
            val = s[idx].second;
        }
        if(v[i]<val)v[i] = val;
        else break;
        now--;
    }
    ll tot = 0;
    for(int i=0;i<n;i++)tot+=v[i];
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
#define NIL -1

stack<int>S;
int A[1000][1000]={};
string color[1000]={"WHITE"};
int d[1000]={},f[1000]={},nt[1000];
int n,tt=0;

int next(int u){
    for(int v=nt[u];v<=n;v++){
        nt[u] = v+1;
        if(A[u][v]){
            return v;
        }
    }
    return NIL;
}


void dfs(int u){
    S.push(u);
    color[u]="GRAY";
    d[u] = ++tt;

    int v;
    while(!S.empty()){
        u=S.top();
        v=next(u);
        if(v != NIL){
            if(color[v] == "WHITE"){
                color[v] = "GRAY";
                S.push(v);
                d[v] = ++tt;
            }
        }
        else{
            color[u] = "BLACK";
            S.pop();
            f[u] = ++tt;
        }
        
    }

}

    void dfs_init(){
        REP(i,n){
            color[i]="WHITE";
            nt[i]=0;
        }
    }

int main() 
{
    cin >> n;

    int p,k;
    rep(i,n){
        cin >> p >> k;
        int q;
            rep(j,k){
                cin >> q;
                A[p][q] = 1;
            }
    }

    dfs_init();
    for(int i=1;i<=n;i++){
        if(color[i] == "WHITE")dfs(i);
    }

    REP(i,n){
        cout << i <<" " << d[i] << " " << f[i] << endl;
    }

}


Measured memory_bytes: 3592
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

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

// constant
const ll MOD = 1e9 + 7;
const ll INF = 1e12;
const int dx[4] = {0, -1, 1, 0};
const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define debug(x) cout << #x << " = " << x << endl

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


int main()
{
    char s;
    int sum = 0;
    SREP(3)
    {
        cin >> s;
        sum += (s == '1');
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define init_random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define sd(n) scanf("%lld", &n)
#define pd(n) printf("%lld\n", n)
#define MOD ((long long) (1000*1000*1000 + 7))
#define exit(a, b) return cout << a, b;
#define eps (double)1e-9
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

const int N = (int) 1e5 + 100;
int fac[N + 1], invfac[N + 1];
const int M = MOD;

int modexp (int a, int b) {
	if (b == 0) return 1;
	int ans = modexp(a, b/2);
	ans = (ans * ans) % M;
	if (b % 2) ans = (ans * a) % M;
	return ans;
}

inline int inv (int a) {
	return modexp(a, M - 2);
}

void prec () {
	fac[0] = 1;
	for (int i = 1; i <= N; i++) fac[i] = (fac[i - 1] * i) % M;
	invfac[N] = inv(fac[N]);
	for (int i = N - 1; i >= 0; i--) invfac[i] = (invfac[i + 1] * (i + 1)) % M;	
}

int c (int n, int r) {
	int ans = fac[n];
	ans *= invfac[n - r], ans %= M;
	ans *= invfac[r], ans %= M;
	return ans;
}
const int inf = (int) 1e15;

signed main()
{
  start_routine;
  #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  #endif
  prec();

  int n, m, x, y; cin >> n >> m >> x >> y;

  int inp;
  int mx = -inf, mn = inf;
  for (int i = 1; i <= n; i++) {
  	cin >> inp;
  	mx = max(mx, inp);
  }
  for (int i = 1; i <= m; i++) {
  	cin >> inp;
  	mn = min(mn, inp);
  }

  mx = max(mx, x);
  mn = min(mn, y);

  if (mx < mn) cout << "No War";
  else cout << "War";
  end_routine;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
int main()
{
    long long i, k,a,b,s=0;
    scanf("%lld%lld%lld",&k,&a,&b);
    for(i=a;i<=b;i++)
    {
        if(i%k==0){
            s=1;
            break;
        }
    }
    if(s==1)
        printf("OK\n");
    else
        printf("NG\n");
        return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

const long long MOD = 1000000007;

int N, K;
ll x[60], y[60];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    ll ans = 1l << 62;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (K == 2) {
                ans = min(ans, abs(x[i] - x[j]) * abs(y[i] - y[j]));
            } else {
                for (int k = j + 1; k < N; k++) {
                    if (K == 3) {
                        ll xx[3] = {x[i], x[j], x[k]};
                        ll yy[3] = {y[i], y[j], y[k]};
                        sort(xx, xx + 3);
                        sort(yy, yy + 3);
                        ans = min(ans, (xx[2] - xx[0]) * (yy[2] - yy[0]));
                    } else {
                        for (int l = k + 1; l < N; l++) {
                            ll xx[4] = {x[i], x[j], x[k], x[l]};
                            ll yy[4] = {y[i], y[j], y[k], y[l]};
                            sort(xx, xx + 4);
                            sort(yy, yy + 4);
                            int cnt = 0;
                            for (int m = 0; m < N; m++) {
                                if (xx[0] <= x[m] && x[m] <= xx[3] && yy[0] <= y[m] && y[m] <= yy[3]) {
                                    cnt++;
                                }
                            }
                            if (cnt >= K) {
                                ans = min(ans, (xx[3] - xx[0]) * (yy[3] - yy[0]));
                            }
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const double PI=3.14159265358979323846;

int mod = 1e9+7;
const long long INF = 1LL<<60;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> snuke(N);
  rep(i, K){
    int d;
    cin >> d;
    rep(j, d){
      int tmp_snuke;
      cin >> tmp_snuke;
      tmp_snuke--;
      snuke[tmp_snuke]++;
    }
  }

  int ans = 0;
  rep(i, N){
    if(snuke[i] == 0){
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int i = n; i > 0; i--) {
        if (s.substr(n - i, i) == t.substr(0, i)) {
            cout << i + (n - i) * 2 << EOL;
            return;
        }
    }
    cout << n * 2 << EOL;
}


Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		var t = 1900L * I[1] + 100 * (I[0] - I[1]);
		Console.WriteLine(t << I[1]);
	}
}


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

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  int x;
  double p;
  cin>>x>>p;
  p/=100;
  double ans=(x&1);
  if(x&1){
    ans+=p*(1/p)*(x-1)/2;
    ans+=(1.-p)*(1/p)*(x+1)/2;    
  }else{
    ans+=(1/p)*x/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
a=[]
def b(x):
  if len(x)!=0:
    x=x[:len(x)-1]
  return x
for i in range(len(s)):
  if s[i]=='B':
    a=b(a)
  else:
    a.append(s[i])
for _ in range(len(a)):
  print(a[_],end='')

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int N;
string S;
/*==================================================*/
/*function*/

/*==================================================*/

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

    int ans = 0;
    REP(i,1,S.size()-1){
        string s1 = S.substr(0,i);
        string s2 = S.substr(i,S.size()-i);

        int cnt = 0;
        set<char> st;
        REP(j,0,s1.size()){
            REP(k,0,s2.size()){
                if(s1[j] == s2[k] && st.find(s1[j])==st.end()) {
                    st.insert(s1[j]);
                    cnt++;
                }
            }
        }
        ans = max(ans, cnt);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)
#define MAX (200010)
using namespace std;

typedef long long int Int;

int A[MAX],B[MAX];
int N;

int main(void) {
    cin>>N;
    for(int i = 0;i < N;i++) {
        cin>>A[i];
    }
    for(int i = 0;i < N;i++) {
        cin>>B[i];
    }
    
    int ans = 0;
    for(int bit = 28;bit >= 0;bit--)
    {
        int v = 1<<(bit+1);
        for(int i = 0;i < N;i++) {
            A[i] &= (v-1);
            B[i] &= (v-1);
        }

        sort(B,B+N);
        int cnt = 0;
        v = 1<<bit;
        for(int i = 0;i < N;i++) {
            cnt += (lower_bound(B,B+N,2*v-A[i]) - lower_bound(B,B+N,v-A[i]));
            cnt += (lower_bound(B,B+N,4*v-A[i]) - lower_bound(B,B+N,3*v-A[i]));
        }
        ans += ((cnt & 1) << bit);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int mp[25][25];
int mod = 1e9+7;
int main(){
  int n;cin>>n;
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      cin>>mp[i][j];
    }
  }
  vector<int> dp(1<<n);
  dp[0] = 1;
  for(int man=0;man<n;++man){
    vector<int> currDp(1<<n);
  	for(int mask=0;mask<(1<<n);++mask){
       if(__builtin_popcount(mask) != man ){
         continue;
       }
		for(int women = 0;women<n;++women){
          if(mp[man][women]==1 && ((mask & (1<<women)) == 0)){
            int next = mask ^ (1<<women);
            currDp[next] += dp[mask];
            currDp[next] %= mod;
          }
        }
    }
    dp = currDp;
  }
  /*
  for(int i=0;i<(1<<n);++i){
    cout<<dp[i]<<" ";
  }
  */
  cout<<dp[(1<<n) - 1]<<endl;
  return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

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

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n, m;
  cin >> n >> m;

  vector<int> condition(n, -1);
  int ans = 0;
  for(int i=0; i<m; i++) {
    int s, c;
    cin >> s >> c;
    if(condition[s - 1] != -1 && condition[s - 1] != c) {
      ans = -1;
    }
    else if(n > 1 && s == 1 && c == 0) {
      ans = -1;
    }
    else {
      condition[s - 1] = c;
    }
  }
  
  if(ans >= 0) {
    for(int i=0; i<n; i++) {
      if(i != 0) {
        ans *= 10;
      }
      if(i == 0 && n != 1 && condition[0] == -1) {
        ans = 1;
      }
      else if(condition[i] != -1) {
        ans += condition[i];
      }
    }
  }
  cout << ans << endl;
}

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

#define MAX_N 200000

using namespace std;

typedef long long lint;

int n;

struct elem
{
    lint r;
    lint st, dr;
};

int m;
elem v[MAX_N + 1 + 1];

lint x, d;

struct cmp
{
    bool operator () (const elem &a, const elem &b) const
    {
        if(a.r != b.r)
            return a.r < b.r;

        return a.st < b.st;
    }
};

lint rez;

int main()
{
    cin >> n >> x >> d;
/*
    if(d < 0)
    {
        x = -x;
        d = -d;
    }*/

    if(d == 0)
    {
        rez = (x == 0 ? 1 : n + 1);

        cout << rez << "\n";

        return 0;
    }

    v[++ m] = {0, 0, 0};
    for(int k = 1; k <= n; k ++)
    {
        v[++ m] = {1LL * k * x % d, 1LL * k * x / d + ((1LL * (k - 1) * k) >> 1), 1LL * k * x / d + 1LL * n * k - (((1LL * k) * (k + 1)) >> 1)};
    }

    sort(v + 1, v + m + 1, cmp());

    int ant = -1;
    lint st = 0, dr = -1;
    for(int i = 1; i <= m; i ++)
    {
        //cout << v[i].r << " " << v[i].st << " " << v[i].dr << "\n";

        if(ant != v[i].r)
        {
            rez += (dr - st) + 1;
            ant = v[i].r;
            st = v[i].st;
            dr = v[i].dr;
        }

        else
        {
            if(v[i].st <= dr)
                dr = max(dr, v[i].dr);

            else
            {
                rez += (dr - st) + 1;
                st = v[i].st;
                dr = v[i].dr;
            }
        }
    }

    rez += (dr - st) + 1;

    cout << rez <<  "\n";

    return 0;
}


Measured memory_bytes: 4992
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i, n, a[N];

void solve()
{
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int ans = 0, sum = a[n];
    for (i = n - 1; i >= 1; i--)
    {
        ans += a[i] * sum;
        ans %= mod;
        sum += a[i];
        sum %= mod;
    }
    cout << ans;
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int s = (a==b?1:0) + (b==c?1:0) + (c==a?1:0);
        System.out.println(s==1?"Yes":"No");
    }
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    private static final int MOD = (int) (1e9 + 7);

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        System.out.println(dfs(n, new Long[n + 1]) % MOD);
    }

    private static long dfs(int n, Long[] dp) {
        if (n < 3) {
            return n == 0 ? 1 : 0;
        }
        if (dp[n] != null) {
            return dp[n];
        }
        long res = 0;
        for (int k = 3; k <= n; k++) {
            res += dfs(n - k, dp) % MOD;
        }
        return dp[n] = res;
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

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


Measured memory_bytes: 35324
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <stdio.h>
using namespace std;
using ll =long long;

int main (void) {
  int N;
  cin >> N;
  int A[100010];
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  int ans=0;
  for(int i=1;i<=N;i++){
    if(A[A[i]]==i){
      ans++;
    }
  }
  cout << ans/2;
}

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

string itos(int num){
  string res;
  if(num == 0) return "0";
  while(num!=0) res+=num%10+'0',num/=10;
  reverse(res.begin(),res.end());
  return res;
}

int main() {
  int n,a[1001]={};
  cin>>n;
  for(int i=0;i<n;i++) cin >> a[i];

  int  num=0;
  while(1){
    string str=itos(num);
    int flg=0;
    for(int i=0;i<n;i++){
      flg = 0;
      while(flg+i<n&&a[i+flg]==str[flg]-'0')flg++;
      if(flg == str.size())break;
    }
    if(flg != str.size())break;
    num++;
  }
  cout << num <<endl;
}

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

int main() {
    int k, n;
    cin>>k>>n;
    int houses[n];
    for (int i=0; i<n; i++){
        cin>>houses[i];
        houses[i] %= k;
    }
    sort(houses,houses+n);
    int max_dis = houses[1]-houses[0];
    for (int i=2; i<n; i++){
        max_dis = max(max_dis, houses[i]-houses[i-1]);
    }
    max_dis = max(max_dis, k-houses[n-1]+houses[0]);
    cout<<k-max_dis;

}




Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int len;
ll p;
ll most;

ll ansdif;
ll ans;

bool b[10];
char dig[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

void stbil(string s) {
    int slen = s.size();
    if (slen == len) {
        ll a = stoll(s);
        ll diff = min(abs(most - a), p - abs(most - a));
        if (diff < ansdif) {
            ans = a;
            ansdif = diff;
        } else if (diff == ansdif) {
            ans = min(ans, a);
        }
    } else {
        for (int i = 0; i < 10; i++) {
            if (!b[i]) {
                b[i] = true;
                string ss = dig[i] + s;
                stbil (ss);
                b[i] = false;
            }
        }
    }
}

int main() {
    string s;
    cin >> s;
    ll N = stoll(s);
    len = s.size();
    p = 1;
    for (int i = 0; i < len; i++) {
        p *= 10;
    }
    most = (N + p / 2) % p;
    fill(b, b + 10, false);
    ansdif = llmax;
    ans = llmax;
    stbil("");
    string ss = to_string(ans);
    int lenss = ss.size();
    for (int i = 0; i < len - lenss; i++) {
        ss = '0' + ss;
    }
    cout << ss << endl;
}



Measured memory_bytes: 3288
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	
	//n頂点m枝に対して隣接リストをつくる。
	int n, m, s;
	cin >> n >> m >> s;
	int u, v, a;
	ll b;
	//vector< vector <int> > ls(n); //0-origin
	vector< vector <tuple<int, ll, int> > > ls(n+1); //1-origin
	REP(i, m){ 
		cin >> u >> v >> a >> b; 
		ls[u].push_back(make_tuple(v, b, a)); 
		ls[v].push_back(make_tuple(u, b, a));
	}
	//
	vector< pair< ll, int > > ta;
	int c;
	ll d;
	ta.push_back(make_pair(INF, INF));
	REP(i, n){
		cin >> c >> d;
		ta.push_back(make_pair(d, c));
	}
	ll res[51][2501];
	REP(i, 51)REP(j, 2501) res[i][j] = (ll)INF * (ll)INF;
	s = min(s, 2500);
	res[1][s] = 0;
	priority_queue< tuple< ll, int, int>, vector <tuple< ll, int, int> >, greater<tuple< ll, int, int> > > q;
	q.push(make_tuple((ll)0, 1, s));
	while(!q.empty()){
		ll tim;
		int sil, now;
		tie(tim, now, sil) = q.top();
		q.pop();
		ll tak;
		int to, cos;
		REP(i, ls[now].size()){
			tie(to, tak, cos) = ls[now][i];
			if(cos > sil) continue;
			ll next_t = tim + tak;
			if(next_t < res[to][sil - cos]){
				res[to][sil - cos] = next_t;
				q.push(make_tuple(next_t, to, sil - cos));
			}
		}
		int traded = min(2500, sil + ta[now].second);
		if(res[now][traded] > tim + ta[now].first){
			res[now][traded] = tim + ta[now].first;
			q.push(make_tuple(tim + ta[now].first, now, traded));
		}
	}
	ll mi;
	for(int i = 2; i<=n; i++){
		mi= (ll)INF * (ll)INF;
		REP(j, 2501) mi= min(mi, res[i][j]);
		cout << mi << endl;
	}
}

Measured memory_bytes: 6264
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngll(chrono::steady_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	if(k % 2){
		int d = n / k;
		cout << 1LL * d * d * d;
	}
	else{
		int d = n / (k / 2);
		cout << 1LL * (d / 2) * (d / 2) * (d / 2) + 1LL * (d - d / 2) * (d - d / 2) * (d - d / 2);
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
W,H,N = map(int,input().split())
x_r = W
x_l = 0
y_r = H
y_l = 0

for _ in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        x_l = max(x,x_l)
    elif a == 2:
        x_r = min(x,x_r)
    elif a == 3:
        y_l = max(y,y_l)
    else:
        y_r = min(y,y_r)


print(max(0,(x_r-x_l))*max(0,(y_r-y_l)))


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int memo[2005][2];

int rec(int ix, int turn, int x, int y, vector<int>& A)
{
  int n = A.size();
  if (ix == n) { return abs(x - y); }
  if (memo[ix][turn] != -1) { return memo[ix][turn]; }

  if (turn == 0) {
    int score = -1;
    for (int i = ix; i < n; ++i) {
      score = max(score, rec(i + 1, 1 - turn, A[i], y, A));
    }
    return memo[ix][turn] = score;
  }
  else {
    int score = INF;
    for (int i = ix; i < n; ++i) {
      score = min(score, rec(i + 1, 1 - turn, x, A[i], A));
    }
    return memo[ix][turn] = score;
  }
}

int main()
{
  int N, Z, W;
  scanf("%d %d %d", &N, &Z, &W);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); }
  fill(memo[0], memo[2005], -1);
  int ans = rec(0, 0, Z, W, A);
  printf("%d\n", ans);
  return 0;
}


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

int main(){
    string str;
    cin>>str;
    str+=str;
    string sagasu;
    cin>>sagasu;
    if(str.find(sagasu)==string::npos){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming
{
    class Program
    {
        private const int mx = 1000001;

        static void Main()
        {
            string str;
            int n, cnt;
            bool[] prime = new bool[mx];
            prime[0] = prime[1] = false;
            for (int i = 2; i < mx; i++)
            {
                prime[i] = true;
            }
            for (int i = 2; i < mx; i++)
            {
                if (prime[i])
                {
                    for (int j = i * 2; j < mx; j += i)
                    {
                        prime[j] = false;
                    }
                }
            }
            while ((str = Console.ReadLine()) != null)
            {
                n = int.Parse(str);
                cnt = 0;
                for (int i = 2; i <= n; i++)
                {
                    if (prime[i])
                    {
                        cnt++;
                    }
                }
                Console.WriteLine(cnt);
            }

        }
    }
}

Measured memory_bytes: 10084
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    LL a, b, c;
    cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0) {
        cout<<0<<endl;
    } else {
        LL r=min(a*b, min(b*c, a*c));
        cout<<r<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N;
	float T,A,ans,l,x;
	ans = 1000000.0;
	cin >> N >> T >> A;
	for (int i = 0;i < N;i++){
		cin >> l;
		if (ans > abs(A - (T - l * 0.006))){
			ans = abs(A - (T - l * 0.006));
			x = i + 1;
		}
	}
	cout << x <<endl; 
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
ans=0
for i in range(1,a):
   for j in range(1,13):
      if i==j:
         ans+=1
for i in range(a,a+1):
   for j in range(1,b+1):
      if i==j:
         ans+=1
print(ans)

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

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

    int S, W;
    cin >> S >> W;

    if(S>W){
        cout << "safe" << endl;
    }else{
        cout << "unsafe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
n, m = gets.split.map &:to_i # m本飲みたい
arr = []
n.times do
  arr << gets.split.map(&:to_i)
  # 金額、限度
end
arr.sort! { |a, b| a[0] != b[0] ? a[0] <=> b[0] : -(a[1] <=> b[1]) }
# 安い順、たくさん買える順
count = 0
price = 0
arr.each do |ar|
  until count == m || ar[1].zero?
    price += ar[0]
    count += 1
    ar[1] -= 1
  end
end
p price

# 12
# 130
# 100000000000000


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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int gcd(int a,int b){
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

signed main(){
    
    int n,X;
    cin >> n >> X;

    vector<int> x;
    REP(i,n){
        int a;
        cin >> a;
        x.push_back(a);
    }
    
    x.push_back(X);
    n++;
    SORT(x);

    int ans = x[1]-x[0];
    cerr << ans << endl;
    for(int i = 2;i <= n-1;i++){
        ans = gcd(ans,x[i]-x[i-1]);
    cerr << ans << endl;

    }
    REP(i,n-1){
        //cerr << x[i+1] - x[i] << endl;
    }



    cout << ans;
    
    
    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 1400
N, A, B = map(int, input().split())
v = list(map(int, input().split()))

dp = [[-1 for _ in range(N + 1)] for _ in range(N + 1)]
cnt = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0] = 0
cnt[0][0] = 1

for i in range(N):
    for j in range(N - 1, -1, -1):
        if dp[i][j] == -1:
            continue
        dp[i+1][j] = dp[i][j]
        cnt[i+1][j] = cnt[i][j]

        ncost = dp[i][j] + v[i]
        if dp[i+1][j+1] < ncost:
            dp[i+1][j+1] = ncost
            cnt[i+1][j+1] = cnt[i][j]
        elif dp[i+1][j+1] == ncost:
            cnt[i+1][j+1] += cnt[i][j]

maxVal = 0
maxCnt = 0
for i in range(A, B + 1):
    if maxVal < dp[N][i] / i:
        maxVal = dp[N][i] / i
        maxCnt = cnt[N][i]
    elif maxVal == dp[N][i] / i:
        maxCnt += cnt[N][i]

print(maxVal)
print(maxCnt)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int ans = 0;

		for(int x = 0;x <= K;x++) {
			for(int y = 0;y <= K;y++) {
				int z = S - x - y;
				if(z < 0) continue;
				if(z > K) continue;
				if(x+y+z == S)ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996