akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	int a[n]; 
	map<int,int> m;
	rep(i,n){
		cin>>a[i];
		m[a[i]]++;
	}
	foreach(itr,m){
		if(itr->se>1){
			cout<<"NO";
			re 0;
		}
	}
	cout<<"YES";
	re 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int NumStr(const string &str)
{
	int n = str.size();
	int sum = 0;
	for(int i=0; i<n; i++){
		if(str[i] == 'A')sum += pow(4.,i) * 1;
		else if(str[i] == 'C')sum += pow(4.,i) * 2;
		else if(str[i] == 'G')sum += pow(4.,i) * 3;
		else if(str[i] == 'T')sum += pow(4.,i) * 4;
	}
	return sum;
}

void InsertFlag(vector<bool> &flag, const string &str)
{
	int num_str = NumStr(str);
	flag[num_str] = true;
}
void FindFlag(vector<bool> &flag, const string &str)
{
	int num_str = NumStr(str);
	if(flag[num_str] == true)cout << "yes" << endl;
	else if(flag[num_str] == false)cout << "no" << endl;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<bool> flag;
	flag.resize(16777216);
	
	for(int i=0; i<n; i++){
		string command, str;
		cin >> command >> str;
		if(command == "insert")InsertFlag(flag, str);
		else if(command == "find")FindFlag(flag, str);
	}
}

Measured memory_bytes: 3120
#include <stdio.h>


int main(){
  int a,b;
  int add,sub,mul;
  int max = 0;

  scanf("%d%d", &a, &b);

  add = a+b;
  sub = a-b;
  mul = a*b;

  if(add >= sub && add >= mul){
    max = add;
  }
  else if(sub >= add && sub >= mul){
    max = sub;
  } else {
    max = mul;
  }


  printf("%d", max);
}

Measured memory_bytes: 128
N, *A = map(int, open(0).read().split())
A = sorted(A)
MOD = 1000000007
if N & 1 != 0:
  K = 2
  F = True
  for i in range(1, N, 2):
    if A[i] != A[i+1] or A[i] != K:
      F = False
      break
    K += 2
  if A[0] != 0:
    F = False
  print(2 ** (N // 2) % MOD if F else 0)
else:
  K = 1
  F = True
  for i in range(0, N, 2):
    if A[i] != A[i+1] or A[i] != K:
      F = False
      break
    K += 2
  print(2 ** (N // 2) % MOD if F else 0)


Measured memory_bytes: 14324
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=1004535809;
const long long LMOD=154590409516822759;
//const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Beg begin
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)cout<<"bust";
	else cout<<"win";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int A,B; cin >>A >> B;
    cout << max(A+B, max(A*B, A-B)) << endl;
    return 0;
}



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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000
//3
typedef long long ll;
typedef pair<int,int> pii;
priority_queue< int > pq;
priority_queue< int , vector<int> , greater<int> > rpq;
set<int>s;
set <int > :: iterator itr; 
vector<int> vec[1001];
int r,n,m,inp,tc;
int arr[1000007]= {};
map<int , int> mymap;


int main()
{
	int n;
	int arr[3];
	int dp[3];
	cin>>n;
	for(int i=0 ; i< n ; i++){
		cin>>arr[0]>>arr[1]>>arr[2];
		if(i == 0 ) {
			dp[0] = arr[0];
			dp[1] = arr[1];
			dp[2] = arr[2];
		}
		else{
			int a = dp[0];
			int b = dp[1];
			int c = dp[2];
			dp[0] = max(arr[0] + b , arr[0] + c);
			dp[1] = max(arr[1] + c , arr[1] + a);
			dp[2] = max(arr[2] + a , arr[2] + b);
		}
		//cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
	}
	cout<<max(max(dp[0],dp[1]),dp[2])<<endl;
    return 0;
}

//65 900 17 13

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

    string res = "Yes";

    //0文字目がL(奇数)ならout
    REP(i,S.size())
    {
        if(i % 2 == 0)
        {
            if(S[i] == 'L')
            {
                res = "No";
                break;
            }
        }
        else
        {
            if(S[i] == 'R')
            {
                res = "No";
                break;
            }
        }
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n;
    cin>>n;
    vector<ll> v(n+1),sum(n+1);
    for(int i=1;i<=n;i++) cin>>v[i],sum[i]=sum[i-1]+v[i];
    vector<vector<ll>> dp(n+1,vector<ll>(n+1));
    for(int i=1;i<n;i++)
    {
        for(int j=1;j+i<=n;j++)
        {
            dp[j][j+i]=1e18;
            for(int k=j;k<j+i;k++)
                dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]+sum[j+i]-sum[j-1]);
        }
    }
    cout<<dp[1][n]<<'\n';
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;



int main() {
	int n,m,temp=0,ans=0,t;
	cin >> n >> m;
	vector<vector<int>>table(m);
	vector<int>p(m);

	for (int i = 0; i < m; i++) {
		int k,l;
		cin >> k;
		rep0(j, k) {
			cin >> l;
			table[i].push_back(l);
		}
	}
	for (int i = 0; i < m; i++) cin >> p[i];
	
	vector<int > vec(n, 0);
	rep1(i,(1 << n)) {
		temp = 0;
		for (int j = 0; j < m; j++) {
			t=0;
			for (const auto& e : table[j]) {
				if ((1 << (e - 1))&i)t++;
			}
			if (t % 2 != p[j]) {
				temp = -1;
				break;
			}
		}
		if (temp == 0)ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
import math

N = int(input())

#nの約数を行いリストを返す
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

li = make_divisors(N)

#Nが素数
if len(li) == 1:
    print(N-1)
    exit()
#Nが乗数
n = math.sqrt(N)
str_n = str(n)
if str_n[-1] == '0':
    x = int(n) -1
    y = int(n) -1
    print(x+y)
    exit()


if len(li) % 2 == 0:
    ind = int(len(li) / 2)
else:
    ind = int(len(li) / 2 + 1)

x = li[ind]
y = int(N / x)

x -= 1
y -= 1

print(x+y)


Measured memory_bytes: 38640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string si = s.substr(0, 1);
    int idx = 1;
    vvi dp(n + 1, vi(2, 0));
    dp[1][0] = 1;
    dp[1][1] = 0;
    dp[2][0] = (s[0] == s[1] ? -1 : 2); // -1?
    dp[2][1] = 1;

    for (int i = 3; i <= n; ++i) {
        chmax(dp[i][0], dp[i - 1][1] + 1);
        if (s[i - 1] != s[i - 2])
            chmax(dp[i][0], dp[i - 1][0] + 1);
        chmax(dp[i][1], dp[i - 2][0] + 1);
        if (s.substr(i - 1, 2) != s.substr(i - 3, 2))
            chmax(dp[i][1], dp[i - 2][1] + 1);
    }
    cout << max(dp[n][0], dp[n][1]) << "\n";
    return 0;
}

Measured memory_bytes: 11396
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, x) = readListOfInt()
    val l = readListOfInt()
    val d = (0..n).map { 0 }.toMutableList()
    d[0] = 0
    for(i in 1 .. n) {
        d[i] = d[i-1] + l[i-1]
    }
    val count = d.count { it <= x }
    println(count)
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 38000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << '+' << endl;
  }
  else if(a*b==15){
    cout << '*' << endl;
  }
  else{
    cout << 'x' << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			var dict = new Dictionary<int, int>();

			for (var i = 0; i < n; ++i) {
				for (var j = -1; j <= 1; ++j) {
					int b = a[i] + j;
					if (dict.ContainsKey(b)) {
						++dict[b];
					} else {
						dict.Add(b, 1);
					}
				}
			}

			int max = dict.Values.Max();

			Console.WriteLine($"{max}");
			Console.ReadKey();
		}
	}
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int CONTEST_NUM=26;

int score_function(const vector<int> &t,const vector<vector<int>> &s,const vector<int> &c,const int &d){
    vector<int> last(27);
    int manzoku=0;
    for(int i=1;i<=d;i++){
        manzoku+=s[i][t[i]];
        last[t[i]]=i;
        int sum=0;
        for(int j=1;j<=CONTEST_NUM;j++){
            sum+=c[j]*(i-last[j]);
        }
        manzoku-=sum;
    }
    return manzoku;
}

void set_ans(const vector<int> &t,vector<int> &ans,const int &d){
    for(int i=1;i<=d;i++){
        ans[i]=t[i];
    }
}

int main() {
    int d;cin>>d;
    vector<int> c(27);
    for(int i=1;i<=CONTEST_NUM;i++){
        cin>>c[i];
    }
    vector<vector<int>> s(d+1,vector<int>(27));
    for(int i=1;i<=d;i++){
        for(int j=1;j<=CONTEST_NUM;j++){
            cin>>s[i][j];
        }
    }
    vector<int> t(d+1);
    vector<int> ans(d+1);
    int old_ans=-1000000000;
    std::random_device rnd;
    std::mt19937 mt(rnd());
    std::uniform_int_distribution<> rand26(1,26);
    std::uniform_int_distribution<> randd(1,d);

    for(int i=1;i<=d;i++){
        int max_contest=-1;
        for(int j=1;j<=CONTEST_NUM;j++){
            if(max_contest<s[i][j]){
                max_contest=s[i][j];
                t[i]=j;
            }
        }
    }
    vector<int> seed_ans(d+1);
    vector<int> tmp_ans(d+1);
    set_ans(t,seed_ans,d);
    int k=0;
    int kk=0;
    int zantei_ans=-100000000;
    while(k<320000){
        int che=randd(mt);
        int old_f=t[che];
        t[che]=rand26(mt);
        int tmp=score_function(t,s,c,d);
        if(tmp>old_ans){
            //set_ans(t,ans,d);
            old_ans=tmp;
        }
        else{
            t[che]=old_f;
            kk++;
            if(kk>1000){
                if(tmp>zantei_ans){
                    set_ans(t,tmp_ans,d);
                    zantei_ans=tmp;
                }
                kk=0;
            }
        }
        k++;
    }
    set_ans(t,ans,d);
    if(score_function(t,s,c,d)>score_function(tmp_ans,s,c,d)){   
        set_ans(t,ans,d);
    }
    else{
        set_ans(tmp_ans,ans,d);
    }
    //cout<<old_ans<<endl;
    for(int i=1;i<=d;i++){
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3688
n,m=map(x->parse(Int,x),split(readline()))
s=map(x->parse(Int,x),split(readline()))
t=map(x->parse(Int,x),split(readline()))
sum=ones(Int,m+1)
mod=10^9+7
for ss=s
	sum[2:m+1]+=cumsum([ss==tt?sum%mod:0 for (tt,sum) in zip(t,sum[1:m])])
end
println(sum[m+1]%mod)

Measured memory_bytes: 154124
#include <bits/stdc++.h>
using namespace std;
#define fo(int, i, a, b)        for (int i=a; i<(b); i++)
#define forev(int, i, b, a)     for (int i = (b)-1; i >= a; i--)
#define uns                     unsigned
#define lli                     long long int
#define ld                      long double
#define all(x)                  x.begin(), x.end()
#define sortall(x)              sort(all(x))
#define enl                     "\n"
#define dbg(x)                  cout << #x << ": " << x << enl;
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; const lli INF = 1e18; const int MX = 100001;

void solve() {
    lli a, b, c, d; cin >> a >> b >> c >> d;
    lli ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << enl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // int testcase; cin >> testcase; for (int i = 1; i <= testcase; ++i)
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	Int a, b;
	a = (s[0] - '0') * 10 + (s[1] - '0');
	b = (s[2] - '0') * 10 + (s[3] - '0');

	DMP(a, b);

	Int flag;
	if (a==0||a>12) {
		flag = 1;
	}
	else {
		flag = 0;


	}

	if (flag) {
		if (b == 0 || b > 12) {
			cout << "NA" << "\n";
		}
		else {
			cout << "YYMM" << "\n";
		}
	}
	else {
		if (b == 0 || b > 12) {
			cout << "MMYY" << "\n";
		}
		else {
			cout << "AMBIGUOUS" << "\n";
		}
	}
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<int> V;
typedef vector<V> VV;
V ret;
bool solve(int N,int U,int D) {
	ret = V(U,1);
	N -= U + D - 1;
	ret.front() = D;
	if (N < 0) {
		return false;
	}

	for (int i : range(U)) {
		int k = min(N, D - ret[i]);
		N -= k;
		ret[i] += k;
	}
	if (N > 0) {
		return false;
	}
	return true;
}
void ans() {
	int N, U, D;
	cin >> N >> U >> D;
	if (solve(N, U, D)) {
		int id = 0;
		for (int i : range(U)) {
			int bg = id + ret[i];
			while (bg > id) {
				cout << bg << " "; bg--;
			}
			id += ret[i];
		}
		cout << endl;
	}
	else cout << -1 << endl;
}
void test() {
	for (int N = 1; N < 11; N++) {
		set<pair<int,int>> s;
		vector<int> v(N);
		iota(ALL(v), 1);
		do {
			vector<int> u(N, 1);
			vector<int> d(N, 1);
			for (int i : range(N)) {
				for (int j : range(i)) {
					if (v[i] > v[j])chmax(u[i], u[j] + 1);
					if (v[i] < v[j])chmax(d[i], d[j] + 1);
				}
			}
			s.insert({ *max_element(ALL(u)), *max_element(ALL(d)) });
		} while (next_permutation(ALL(v)));
		for (int A : range(1, N + 5)) {
			for (int B : range(1, N + 5)) {
				bool answer = (s.count({ A,B }) == 1);
				bool received = solve(N, A, B);
				assert(answer == received);
			}
		}

	}
}
int main() {
	ans();
	//test();
	return 0;
}


Measured memory_bytes: 3072
#C
import sys
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
if len(a)==2:
    print(max(a))
    sys.exit()
g=gcd(a[0],a[1])
b=[]
for i in range(2,n):
    l=gcd(g,a[i])
    if l!=g:
        b.append(i)
        g=l
s=[]
g=gcd(a[0],a[2])
for i in range(3,n):
    g=gcd(g,a[i])
s.append(g)
g=gcd(a[1],a[2])
for i in range(3,n):
    g=gcd(g,a[i])
s.append(g)
for i in range(len(b)):
    g=gcd(a[0],a[1])
    for j in range(2,n):
        if j==b[i]:
            continue
        g=gcd(g,a[j])
    s.append(g)
print(max(s))

Measured memory_bytes: 16124
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

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

const long long INF = 1LL << 60;
const long long P = 1000000007;

long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int n,k;
    cin >> n >> k;
    int p[n];
    double e[n];
    double s[n];
    //sは累積和だよ
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        e[i] = p[i]+1;
        e[i] = e[i]/2;
        if(i > 0) {
            s[i] = s[i-1] + e[i];
        }else if(i == 0){
            s[i] = e[i];
        }
    }
    double ans = s[k-1];
    for(int i = k; i < n; i++) {
        ans = max(ans,s[i]-s[i-k]);
    }
    printf("%.6f",ans);
    return 0;
}


Measured memory_bytes: 4096
n, c, k = map(int, input().split())

lt = list()
for i in range(n):
    lt.append(int(input()))
lt.sort()

b = 1  #the number of buses
p = 0  #passengers
m = lt[0]

for i in range(n):
    if p < c and lt[i]-m <= k:
        p += 1
    else:
        p = 1
        b += 1
        m = lt[i]

print(b)

Measured memory_bytes: 7384
fun main(args: Array<String>) {
    val S = readLine()!!

    val a = S.filter { it in 'A' .. 'Z' }

    if (a.length == 2 && S[0] == 'A' && S.drop(2).dropLast(1).contains('C')) {
        println("AC")
    } else {
        println("WA")
    }
}


Measured memory_bytes: 33784
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>


#define rep(i, a, b) for ( ll i = (a); i < (b); i++ )
#define per(i, a, b) for ( ll i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %lld\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) rep(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;


ll N, K;
ll c[65];
ll A[100005];
ll dp[65][2];

int main(void) {
    scanf("%lld %lld", &N, &K);
    for (ll i = 0; i < N; i++) scanf("%lld", &A[i]);
    
    rep(i, 0, 65)  dp[i][0] = dp[i][1] = -1;
    dp[61][0] = 0;

    per(i, 0,61) {
      ll t = 1LL<<i;
      ll D = K & t;
      ll c = 0;
      rep(j, 0, N) if (t&A[j]) c++;
      
      if (dp[i+1][1] >= 0) dp[i][1] = dp[i+1][1] + t * max(c, N-c);
      
      if (dp[i+1][0] >= 0) {
        if (D>0) {
          dp[i][0] = dp[i+1][0] + t * (N-c);
          dp[i][1] = max(dp[i][1], dp[i+1][0] + t * c);
        } else {
          dp[i][0] = dp[i+1][0] + t * c;
        }
      
      }
      
    }
    printf("%lld\n", max(dp[0][0], dp[0][1]));
    return 0;
}


Measured memory_bytes: 1024
# include<stdio.h>
# include<string.h>
int main()
{
	int i,n,count=0;
	char ch[55];
	scanf("%d",&n);
	scanf("%s",ch);
	for(i=0;i<=n-3;i++)
	{
		if(ch[i]=='A'&&ch[i+1]=='B'&&ch[i+2]=='C')
			count++;
	}
	printf("%d\n",count);

	return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    string S, T;
    cin >> S >> T;
    i32 sum = 0;
    for (i32 i = 0; i < S.size(); i++) {
        if (S[i] == T[i]) sum++;
    }
    cout << sum << endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int64_t lcm(uint64_t L, uint64_t T) {
  return L / __gcd(L, T) * T;
}

int main() {
  int N; cin >> N;
  int64_t L = 1;
  while(N--) {
    int64_t T; cin >> T;
    L = lcm(L, T);
  }
  cout << L << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if (A == 1) {
    A = 14;
  }
  if (B == 1) {
    B = 14;
  }
  if (A > B) {
    cout << "Alice";
  } else if (A == B) {
    cout << "Draw";
  } else {
    cout << "Bob";
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    S = input()

    if len(S) == len(set(S)):
        print('yes')
    else:
        print('no')


if __name__ == '__main__':
    main()


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

using namespace std;
typedef unsigned long long ll;

ll solve(int a , int b){
    ll ans = b;
    for(int i = 0 ; i < a - 1 ; i++){
        ans *= b - 1;
    }
    
    return ans;
}
int main(){
    int n,k; cin >> n >> k;
    
    if(n == 1){
        cout << k << endl;
    }
    
    else{
        ll ans = solve(n, k);
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int K;
	queue<ll> q;

	cin >> K;

	for (int i = 1; i <= 9; i++) {
		q.push(ll(i));
	}

	for (int i = 0; i < K - 1; i++) {
		ll x = q.front();
		q.pop();
		if (x % 10 != 0) {
			q.push(10 * x + x % 10 - 1);
		}
		q.push(10 * x + x % 10);
		if (x % 10 != 9) {
			q.push(10 * x + x % 10 + 1);
		}
	}

	cout << q.front() << endl;

	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r, l, c, a;
string s;

// <------------- Implement Functions Here ----------> //

  

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=n-2;i>=0;i--) {
		if(a[i+1] < a[i]) {
			a[i]--;
		}
		if(a[i+1] < a[i]) {
			cout<<"No\n";return;
		}
	}
	cout<<"Yes\n";
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


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

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

    int a, b;
    cin >> a >> b;
    if (a < 6)
    {
        cout << 0 << endl;
    }
    else if (a < 13)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}

int main(){
  string s,w; cin>>w;
  REP(i,w.size()){ if(w[i]>='A' && w[i]<='Z'){ w[i] += ('a'-'A');} }
  int ans =0;
  while(cin>>s){
    if(s=="END_OF_TEXT"){break;}
    REP(i,s.size()){ if(s[i]>='A' && s[i]<='Z'){ s[i] += ('a'-'A');} }
    if(s==w){ ++ans;}
  }
  cout << ans <<"\n";
}


Measured memory_bytes: 3152
N = int(input())
D = list(map(int,input().split()))

if D[0] != 0:
    print(0)
    exit(0)
    
max_D = max(D)
    
c = [0] * (max_D+1)
for i in range(N):
    c[D[i]] += 1
   
# 他の要素に 0 があるとバツ 
if c[0] > 1:
    print(0)
    exit(0)
   
ans = 1 
for i in range(max_D):
    ans *= c[i] ** c[i+1]
print(ans % 998244353)


Measured memory_bytes: 54196
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char s[20];
int main(){
	int a,b,i=0;
	cin>>a>>b;
	scanf("%s",s);
	for(i=0;i<a;i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No";
			return 0;
		}
	}
	if(s[a]!='-'){
		cout<<"No";
		return 0;
	}
	for(i=a+1;i<a+b+1;i++){
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}
 

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
26進数で考えればいい
*/

void	solve(long long num)
{
	if (num == 0) return ;
	num--;
	solve(num / 26);
	cout << (char)(num % 26 + 'a');
}

int		main(void)
{
	long long n;
	cin >> n;
	solve(n);
	cout << endl;
	return (0);
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			int L = sc.nextInt();
			
			if (N + M + L == 0)
				break;
		
			int[][] D = new int[N+1][N+1];
			int[][] P = new int[N+1][N+1];
			for (int i = 0; i <= N; i++) {
				Arrays.fill(D[i], Integer.MAX_VALUE);
				Arrays.fill(P[i], Integer.MAX_VALUE);
			}
		
			for (int i = 0; i < M; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				D[a][b] = sc.nextInt();
				D[b][a] = D[a][b];
				P[a][b] = sc.nextInt();
				P[b][a] = P[a][b];
			}
			
			System.out.println(solve(N, M, L, D, P));
		}
	}
	
	public static int solve(int N, int M, int L, int[][] D, int[][] P) {
		boolean[][] visit = new boolean[N+1][L+1];
		PriorityQueue<Node> que = new PriorityQueue<Node>(11, new Comparator<Node>() {
			public int compare(Node n1, Node n2) {
				return n1.enemy - n2.enemy;
			}
		});
		que.add(new Node(1, L, 0));
		while(que.isEmpty() == false) {
			Node node = que.poll();
			if (visit[node.pos][node.money])
				continue;
			
			visit[node.pos][node.money] = true;
			if (node.pos == N)
				return node.enemy;
			
			for (int i = 1; i <= N; i++) {
				if (D[node.pos][i] == Integer.MAX_VALUE)
					continue;
				
				que.add(new Node(i, node.money, node.enemy + P[node.pos][i]));
				if (node.money >= D[node.pos][i]) {
					que.add(new Node(i, node.money - D[node.pos][i], node.enemy));
				}
			}
		}
		return 0;
	}
}

class Node {
	int pos;
	int money;
	int enemy;
	public Node(int p, int m, int e) {
		this.pos = p;
		this.money = m;
		this.enemy = e;
	}
}

Measured memory_bytes: 60836
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;


int main(){
	ll n, q; cin >> n >> q;
	string s; cin >> s;
	vl ngo(n, 0);
	for (int i = 1; i < n; ++i){
		if (s[i - 1] == 'A' && s[i] == 'C') ngo[i] = ngo[i - 1] + 1;
		else ngo[i] = ngo[i - 1];
	}for (int i = 0; i < q; ++i){
		ll l, r; cin >> l >> r;
		cout << ngo[r-1] - ngo[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll N, M;
    cin >> N >> M;
    debug(N, M);

    ll ans = min(N, M/2);
    M -= 2*ans;
    debug(ans);

    ans += M/4;
    p(ans);

    return 0;
}

Measured memory_bytes: 256
/*input
2
6 8
3 3
*/

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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003

long  divisors(long x) {
    long limit = x;
    long numberOfDivisors = 0;

    if (x == 1) return 1;

    for (long i = 1; i < limit; ++i) {
        if (x % i == 0) {
            limit = x / i;
            if (limit != i) {
                numberOfDivisors++;
            }
            numberOfDivisors++;
        }
        if(numberOfDivisors>=4)
        {
            break;
        }
    }

    return numberOfDivisors;
}
 bool isPrime(long n)
{
   
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
#define max_a 100001
bool visit[max_a]={false};
vector<long> a[max_a];
long sum=0;
long cost[max_a];
void dfs(long node)
{
    visit[node]=true;
    
    for(int i=0;i<(int)a[node].size();i++)
    {
        if(visit[a[node][i]]==false)
        {
            sum+=cost[a[node][i]];
            dfs(a[node][i]);
            
        }
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long sum=0;
    for(int i=0;i<n;i++)
    {
        long l,r;
        cin>>l>>r;
        sum+=(r-l+1);
     }
     cout<<sum<<endl;
    return 0;
}




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

using namespace std;

int const N = 1e5 + 41;
int const MOD = 1e9 + 7;

int n, t[N], a[N], ans = 1;
pair<int, int> bt[N], ba[N];

int get(pair<int, int> a, pair<int, int> b){
	int le = max(a.first, b.first);
	int ri = min(a.second, b.second);
	if(le > ri){
		return 0;
	}
	return ri - le + 1;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	if(n == 1){
		if(t[0] != a[0]){
			ans = 0;
		}
		printf("%d\n",ans);
		return 0;
	}

	bt[0] = make_pair(t[0], t[0]);
	for(int i=1;i<n;++i){
		if(t[i] > t[i-1]){
			bt[i] = make_pair(t[i], t[i]);
		}else{
			bt[i] = make_pair(1, t[i]);
		}
	}

	ba[n-1] = make_pair(a[n-1], a[n-1]);
	for(int i=n-2;i>=0;--i){
		if(a[i] > a[i+1]){
			ba[i] = make_pair(a[i], a[i]);
		}else{
			ba[i] = make_pair(1, a[i]);
		}
	}

	for(int i=0;i<n;++i){
		ans = ans * 1LL * get(bt[i], ba[i]) % MOD;
	}
	printf("%d\n",ans);


	return 0;
}

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

string Judge(int a, int b) {
  if (0 < a)
    return "Positive";
  if (a <= 0 && 0 <= b)
    return "Zero";
  if ((b - a) % 2)
    return "Positive";
  return "Negative";
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << Judge(a, b) << "\n";
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

long MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    
    vector<int> a;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        a.push_back(m);
    }
    
    bool valid = true;
    sort(a.begin(), a.end());
    
    if (n % 2) {
        valid = a[0] == 0;
        for (int i = 1; i < n; i+=2) {
            valid = valid && a[i] == i + 1 && i + 1 == a[i+1];
        }
    } else {
        for (int i = 0; i < n; i+=2) {
            valid = valid && a[i] == i + 1 && i + 1 == a[i+1];
        }
    }
    
    if (!valid) {
        cout << 0 << endl;
        return 0;
    }
    
    if (n % 2) {
        long ans = 1;
        for (int i = 0; i < (n - 1) / 2; i++) {
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    } else {
        long ans = 1;
        for (int i = 0; i < n / 2; i++) {
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, r;
    cin >> n >> r;
    if(n < 10){
        r += 100 * (10 - n);
    }
    out(r);
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, M;

int main()
{
  scanf( "%lld%lld", &N, &M );
  
  ll ans;

  if( N == 1 && M == 1 )
    ans = 1;
  else if( N == 1 )
    ans = M-2;
  else if( M == 1 )
    ans = N-2;
  else
    ans = N*M-(M*2+(N-2)*2);

  printf( "%lld\n", ans );
  
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    cout << h * w << ' ' << h * 2 + w * 2 << endl;
}


Measured memory_bytes: 3068
#include <cstdint>

class runtime_modint {
  using u64 = std::uint_fast64_t;

  static u64 &mod() {
    static u64 mod_ = 0;
    return mod_;
  }

public:
  u64 a;

  runtime_modint(const u64 x = 0) : a(x % get_mod()) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  runtime_modint operator+(const runtime_modint rhs) const {
    return runtime_modint(*this) += rhs;
  }
  runtime_modint operator-(const runtime_modint rhs) const {
    return runtime_modint(*this) -= rhs;
  }
  runtime_modint operator*(const runtime_modint rhs) const {
    return runtime_modint(*this) *= rhs;
  }
  runtime_modint operator/(const runtime_modint rhs) const {
    return runtime_modint(*this) /= rhs;
  }
  runtime_modint &operator+=(const runtime_modint rhs) {
    a += rhs.a;
    if (a >= get_mod()) {
      a -= get_mod();
    }
    return *this;
  }
  runtime_modint &operator-=(const runtime_modint rhs) {
    if (a < rhs.a) {
      a += get_mod();
    }
    a -= rhs.a;
    return *this;
  }
  runtime_modint &operator*=(const runtime_modint rhs) {
    a = a * rhs.a % get_mod();
    return *this;
  }
  runtime_modint &operator/=(runtime_modint rhs) {
    u64 exp = get_mod() - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  static void set_mod(const u64 x) { mod() = x; }
  static u64 get_mod() { return mod(); }
};

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  using mint = runtime_modint;

  mint::set_mod(1000000007);

  int n, x;
  std::cin >> n >> x;
  std::vector<int> s(n);
  for (auto &e : s) {
    std::cin >> e;
  }
  std::sort(s.begin(), s.end());

  std::vector<std::vector<mint>> dp(n + 1, std::vector<mint>(x + 1));

  for (int i = 0; i <= x; ++i) {
    dp[0][i] = i;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= x; ++j) {
      dp[i + 1][j] = dp[i][j] * i + dp[i][j % s[i]];
    }
  }

  std::cout << dp[n][x].value() << std::endl;

  return 0;
}


Measured memory_bytes: 158592
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
vector<P> v;
int cnt[20][20];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        double x;
        scanf("%lf",&x);
        ll res=(ll)(x*INF+0.5);
        int cnt2=-9,cnt5=-9;
        while(res%2==0) res/=2,cnt2++;
        while(res%5==0) res/=5,cnt5++;
        cnt2=min(cnt2,9); cnt5=min(cnt5,9);
        v.push_back(P(cnt2,cnt5));
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        int x=v[i].F,y=v[i].S;
        for(int j=-9;j<=9;j++)
            for(int k=-9;k<=9;k++)
            {
                if(j+x<0||k+y<0) continue;
                ans+=cnt[j+9][k+9];
            }
        cnt[x+9][y+9]++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 5340