akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
 
 
int main(void){
	int n,m,i,j,k;
	char s[100];
	cin>>s;
	int y,d;
	y = (s[0]-'0')*1000 + (s[1]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0')*1;
	m = (s[5]-'0')*10 + (s[6]-'0')*1;
	d = (s[8]-'0')*10 + (s[9]-'0')*1;
	if(y>=2020){
		cout<<"TBD"<<endl;
		return 0;
	}
	if(y<=2018){
		cout<<"Heisei"<<endl;
		return 0;
	}
	if(m>=5){
		cout<<"TBD"<<endl;
		return 0;
	}
	if(m<=4){
		cout<<"Heisei"<<endl;
		return 0;
	}
 
	return 0;
}

Measured memory_bytes: 764
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int la = a.size();
	int lb = b.size();

	if (la > lb) {
		cout << "GREATER" << endl;
		return 0;
	}

	if (la < lb) {
		cout << "LESS" << endl;
		return 0;
	}

	if (a > b) {
		cout << "GREATER" << endl;
		return 0;
	}

	if (a < b) {
		cout << "LESS" << endl;
		return 0;
	}

	cout << "EQUAL" << endl;
	
	
	return 0;
}

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pi 3.1415926535
#define mod1 1000000007
#define mod2 1000000009
#define no_of_digits(n) floor(log10(n)) + 1
#define lcm(a, b) (a/__gcd(a,b)*b

using namespace std;


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


	int n;
	cin >> n;
	vector<int > v(n);
	for(int i =0; i < n; i++){
		cin >> v[i];
	}
	int ans = 0;
	int mn =1e9;
	for(int i = 0; i < n; i++){
		if(v[i] <= mn){
			ans++;
			mn = v[i];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int X, N;
    bool b[102];
    cin >> X >> N;
    for(int i = 0; i <= 101; i++){
        b[i] = true;
    }
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        b[t] = false;
    }
    int n = 3;
    for(int x = 0; 0 != n; x++){
        int i = X - x;
        if(i < 0) n &= 2;
        else{
            if(b[i]){
                cout << i << endl;
                return;
            }
        }
        int a = X + x;
        if(101 < a) n &= 1;
        else{
            if(b[a]){
                cout << a << endl;
                return;
            }
        }
    }
}


Measured memory_bytes: 3632
n=int(input())
p=list(map(float,input().split()))
#dp[i][j] i tells u i coins from 0, j tells u j heads 
#dp[n+1][n+1]
dp=[[0 for i in range(n+1)]for j in range(n+1)]

dp[0][0]=1.0
# for i in range(1,n+1):
#     dp[0][i]=0.0
for i in range(1,n+1):
    for j in range(0,n+1):
        if(j==0):
            dp[i][j]=(1.0-p[i-1])*dp[i-1][j]
        else:
            dp[i][j]=p[i-1]*dp[i-1][j-1]+(1.0-p[i-1])*dp[i-1][j]

k=(n//2)+1
ans=0.0
for i in range(k,n+1):
    ans+=dp[n][i]
print(ans)




Measured memory_bytes: 259848
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  if (a == "H") {
    if (b == "H") {
      cout << "H" << endl;
    } else if (b == "D") {
      cout << "D" << endl;
    }
  } else if (a == "D") {
    if (b == "H") {
      cout << "D" << endl;
    } else if (b == "D") {
      cout << "H" << endl;
    }
  }
}

Measured memory_bytes: 384
using static System.Math;
using System;

public class hello
{
    public static int[,] map;
    public static int h, w;
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            h = int.Parse(line[0]);
            w = int.Parse(line[1]);
            if (h == 0 && w == 0) break;
            map = new int[h, w];
            for (int i = 0; i < h; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < w; j++)
                    map[i, j] = int.Parse(line[j]);
            }
            getRect();
        }
    }
    static int getMin(int x, int y, int x2, int y2)
    {
        var tmin = 100;
        for (int i = y; i <= y2; i++)
        {
            tmin = Min(tmin, Min(map[x, i], map[x2, i]));
            if (tmin == 0) return 0;
        }
        for (int i = x; i <= x2; i++)
        {
            tmin = Min(tmin, Min(map[i, y], map[i, y2]));
            if (tmin == 0) return 0;
        }
        return tmin;
    }
    static int getAns(int x, int y, int x2, int y2, int tmin)
    {
        var tmax = 0;
        for (int i = x + 1; i <= x2 - 1; i++)
            for (int j = y + 1; j <= y2 - 1; j++)
            {
                tmax = Max(tmax, map[i, j]);
                if (tmax >= tmin) return 0;
            }
        var ans = 0;
        for (int i = x + 1; i <= x2 - 1; i++)
            for (int j = y + 1; j <= y2 - 1; j++)
                ans += tmin - map[i, j];
        return ans;
    }
    static void getRect()
    {
        var ans = 0;
        for (int i = 0; i < h - 2; i++)
            for (int j = 0; j < w - 2; j++)
                for (int k = i + 2; k < h; k++)
                    for (int L = j + 2; L < w; L++)
                    {
                        var gmin = getMin(i, j, k, L);
                        if (gmin >= 1)
                        {
                            var res = getAns(i, j, k, L, gmin);
                            ans = Max(ans, res);
                        }
                    }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 15944
//gauravsinghh
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

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

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    if(w == 2*x && h == 2*y){
        cout << fixed << setprecision(9) << (w*h)/2.0 << " " << 1 << endl;
    }
    else{
        cout << fixed << setprecision(9) << (w*h)/2.0 << " " << 0 << endl;
    }
    return 0;
}



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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> b, c;
  rep(i, n) {
    if (i % 2 == 0)
      b.push_back(a[i]);
    else
      c.push_back(a[i]);
  }

  if (n % 2 == 0)
    swap(b, c);

  reverse(b.begin(), b.end());

  rep(i, b.size()) {
    printf("%d%c", b[i], (i == b.size() - 1 && c.size() == 0) ? '\n' : ' ');
  }
  rep(i, c.size()) {
    printf("%d%c", c[i], (i == c.size() - 1) ? '\n' : ' ');
  }
}

Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;
typedef pair <int, int> pii;
int mem[1 << 15];
int dep[100010];
int cnt[20];
int val[1 << 17];


int dp(int mask) {
	if(mask == 0) return 0;
	if(mem[mask] != -1) return mem[mask];
	int ans = 0;
	for(int submask = mask; submask > 0; submask = (submask - 1) & mask) {
		if(val[submask] == 0) {
			ans = max(ans, 1 + dp(mask ^ submask));
		}
	}
	return mem[mask] = ans;
}

int main(int argc, char const *argv[])
{
	memset(mem, -1, sizeof mem);
	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		int p, q, r;
		cin >> p >> q >> r;
		dep[p] ^= r;
		dep[q] ^= r;
	}	
	vector <int> v;
	int comp = 0;
	for(int i = 0; i < n; i++) {
		cnt[dep[i]] += 1;
	}
	for(int i = 1; i < 16; i++) {
		if(cnt[i] & 1) {
			v.push_back(i);
		}
		comp += cnt[i] >> 1;
	}
	comp += cnt[0];
	// for(auto i : v) cout << i << endl;
	for(int i = 0; i < (1 << v.size()); i++) {
		for(int j = 0; j < v.size(); j++) {
			if((i >> j) & 1) {
				val[i] ^= v[j];
			}
		}
	}

	int check = 0;
	for(auto i : v) {
		check ^= i;
	}
	assert(check == 0);

	comp += dp((1 << v.size()) - 1);
	cout << n - comp << endl;
	return 0;
}

Measured memory_bytes: 896
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int[] mfb = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int m = Max(0, mfb[2] - mfb[0]);
        Console.WriteLine(m > mfb[1] ? "NA" : m.ToString());
    }
}



Measured memory_bytes: 8284
n = int(input())
can = False
c = 4
d = 7
for i in range(100//4):
    for j in range(100//7):
        if i * 4 + j * 7 == n:
            can = True
            break
    if can:
        break
if can:
    print('Yes')
else:
    print('No')
  

Measured memory_bytes: 2940
#include<iostream>

using namespace std;

const int MAX_W = 1001;
const int MAX_T = 1001;

int dp[MAX_T][MAX_W];

void init(){
  for(int i = 0; i < MAX_T; i++){
    fill(dp[i],dp[i]+MAX_W,0);
  }
}

int main(){
  int rev = 0, max;
  while(cin >> max && max){
    rev++;
    init();
    int num;
    cin >> num;
    for(int i = 1; i <= num; i++){
      char trash;
      int price, weight;
      cin >> price >> trash >> weight;
      for(int j = 0; j <= max; j++){
	if(weight <= j){
	  dp[i][j] = price + dp[i-1][j-weight];
	}
	if(dp[i][j] < dp[i-1][j]) dp[i][j] = dp[i-1][j];
      }
    }
    int ablep = 0, ablew = 0;
    for(int i = 0; i <= num; i++){
      for(int j = 0; j <= max; j++){
	if(ablep < dp[i][j]){
	  ablep = dp[i][j];
	  ablew = j;
	}else if(ablep == dp[i][j]){
	  if(ablew > j) ablew = j;
	}
      }
    }
    cout << "Case " << rev << ":" << endl;
    cout << ablep << endl << ablew << endl;

  }
  return 0;
}

Measured memory_bytes: 0
n,w = gets.chomp.split.map(&:to_i)
wv_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

dp = Array.new(w+1, 0)

wv_arr.each do |wi, vi|
  w.downto(0) do |sum_w|
    if sum_w - wi >= 0 && dp[sum_w - wi] + vi > dp[sum_w]
      dp[sum_w] = dp[sum_w - wi] + vi
    end
  end
end

puts dp[w]

Measured memory_bytes: 2556
class Tree:
    def __init__(self):
        self.root = None

    def insert(self, key):
        z = Node(key)
        y = None  # x?????????????´????????????°
        # z???parent???????´?
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        # z??????????????´??????????´?
        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        x = self.root
        while x and key != x.key:
            if key < x.key:
                x = x.left
            else:
                x = x.right
        return x

    def getSuccessor(self, x):
        if x.right is not None:
            return self.getMinimum(x.right)

        y = x.parent
        while y and x == y.right:
            x = y
            y = y.parent
        return y

    def getMinimum(self, x):
        while x.left is not None:
            x = x.left
        return x

    def delete(self, key):
        #??????????±????y???????´?
        z = self.find(key)
        if z.left is None or z.right is None:
            y = z
        else:
            y = self.getSuccessor(z)

        # y??????x????????????
        if y.left is not None:
            x = y.left
        else:
            x = y.right

        if x is not None:
            x.parent = y.parent

        if y.parent is None:
            self.root = x
        elif y == y.parent.left:
            y.parent.left = x
        else:
            y.parent.right = x

        if y != z:
            z.key = y.key


    def show(self):
        print(" ", end="")
        print(*list(map(str, self.root.inwalk())))
        print(" ", end="")
        print(*list(map(str, self.root.prewalk())))


class Node:
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None

    def prewalk(self):
        nodeList = [self.key]
        if self.left:
            nodeList += self.left.prewalk()
        if self.right:
            nodeList += self.right.prewalk()
        return nodeList

    def inwalk(self):
        nodeList = []
        if self.left:
            nodeList += self.left.inwalk()
        nodeList += [self.key]
        if self.right:
            nodeList += self.right.inwalk()
        return nodeList


tree = Tree()
n = int(input())
for i in range(n):
    cmd = list(input().split())
    if cmd[0] == 'insert':
        tree.insert(int(cmd[1]))
    elif cmd[0] == 'find':
        if tree.find(int(cmd[1])):
            print("yes")
        else:
            print("no")
    elif cmd[0] == 'print':
        tree.show()
    elif cmd[0] == 'delete':
        tree.delete(int(cmd[1]))

Measured memory_bytes: 156584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

long long gcd(unsigned long long int x, unsigned long long int y){
	return y == 0 ? x: gcd(y, x%y);
}

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int size = (n + 1) * n / 2;
		vector<unsigned long long int> Vecodd;
		vector<unsigned long long int> Veceven;
		for(int i = 0; i < size; ++i)
		{
			unsigned long long int temp;
			cin >> temp;
			if(temp % 2 == 0)
			{
				Veceven.push_back(temp);
			}
			else
			{
				Vecodd.push_back(temp);
			}
		}
		sort(Veceven.begin(), Veceven.end());
		sort(Vecodd.begin(), Vecodd.end());
		unsigned long long int  minodd = Vecodd[0];
		unsigned long long int mineven[2] = {Veceven[0], Veceven[1]};
		unsigned long long int g = gcd(mineven[0], minodd);
		unsigned long long int Even = (unsigned long long int)sqrt((double)mineven[0] / g * (mineven[1] / (minodd / g)));
		cout << Even << endl;
		size = Veceven.size();
		for(int i = 0; i < size - 1; ++i)
		{
			cout << Veceven[i] / Even << " ";
		}
		cout << Veceven[size - 1] / Even << endl;
	}
}

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

Measured memory_bytes: 1424
#include<iostream>
#include<map>
#include<string>
#include<stdlib.h>

int OFA();//Operation of Frequency of Appearance

void listen_nums(int nums[],const int count_nums);
void calc_appearance(int nums[],int appearance[],const int count_nums);
void write_calcedArray(int nums[],int appearance[],const int count_nums);
bool is_notMoved(int nums[],int appearance[],const int count_nums);
void echo_intArray(int array[],const int length);

//-------------------------main-------------------------------
int main()
{
	while(OFA());
	return 0;
}

int OFA()
{
	using namespace std;
	int count_nums;
	cin>>count_nums;
	if(!count_nums)
	{
		return 0;
	}
	int nums[count_nums];
	listen_nums(nums,count_nums);
	int appearance[count_nums];
	
	int calcCount=0;
	for(;1;)
	{
		calc_appearance(nums,appearance,count_nums);
		if(is_notMoved(nums,appearance,count_nums))
		{
			cout<<calcCount<<endl;
			echo_intArray(appearance,count_nums);
			return 1;
		}
		else
		{
			calcCount++;
			write_calcedArray(nums,appearance,count_nums);//numsの先頭ポインタを操作後文字列に置き換え
		}
	}
	
}
//-----------------------------------------------------------

void listen_nums(int nums[],const int count_nums)
{
	using namespace std;
	int i=0;
	string str;
	while(i<count_nums-1)
	{
		getline(cin,str,' ');
		nums[i]=atoi(str.c_str());
		i++;
	}
	cin>>nums[i];
}

void calc_appearance(int nums[],int appearance[],const int count_nums)
{
	using namespace std;
	
	map<int,int> count_eachNums;
	
	int i;
	for(i=0;i<count_nums;i++)
	{
		if(count_eachNums.find(nums[i])==count_eachNums.end())
		{
			count_eachNums.insert(map<int,int>::value_type(nums[i],1));
		}
		else
		{
			count_eachNums[nums[i]]++;
		}
	}
	for(i=0;i<count_nums;i++)
	{
		appearance[i]=count_eachNums[nums[i]];
	}
}

void write_calcedArray(int nums[],int appearance[],const int count_nums)
{
	for(int i=0;i<count_nums;i++)
	{
		nums[i]=appearance[i];
	}
}

bool is_notMoved(int nums[],int appearance[],const int count_nums)
{
	for(int i=0;i<count_nums;i++)
	{
		if(nums[i]!=appearance[i])
		{
			return false;
		}
	}
	return true;
}
void echo_intArray(int array[],const int length)
{
	using namespace std;
	
	cout<<array[0];
	for(int i=1;i<length;i++)
	{
		cout<<" "<<array[i];
	}
	cout<<endl;
}

Measured memory_bytes: 1216
import java.util.Scanner


object Main {

  // 切り上げる
  def roundUp10(x:Int): Int ={
    if(x % 10 == 0) x
    else (x/10 + 1)*10
  }
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val minList = for (_ <- 0 until 5) yield sc.nextInt
    val sortedMinList = minList.sortBy(n => if(n%10==0) 10 else n%10)
    println(sortedMinList.tail.map(roundUp10).sum + sortedMinList(0))
  }
}

Measured memory_bytes: 27456
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  if (H % 3 == 0 || W % 3 == 0)
    cout << 0 << endl;
  else
  {
    ll ans = INF;
    for (int i = 1; i <= H - 1; i++)
    {
      ll Smax = 0, Smin = INF, Smax2 = 0, Smin2 = INF;
      ll S1 = 0, S2 = 0, S3 = 0, S4 = 0, S5 = 0;
      S1 = i * W;
      S2 = (H - i) * (W / 2);
      S3 = (H - i) * ((W + 1) / 2);
      S4 = ((H - i) / 2) * W;
      S5 = ((H - i + 1) / 2) * W;
      Smax = max(S1, max(S2, S3));
      Smin = min(S1, min(S2, S3));
      Smax2 = max(S1, max(S4, S5));
      Smin2 = min(S1, min(S4, S5));
      ans = min(ans, min(Smax - Smin, Smax2 - Smin2));
    }
    for (int j = 1; j <= W - 1; j++)
    {
      ll Smax = 0, Smin = INF, Smax2 = 0, Smin2 = INF;
      ll S1 = 0, S2 = 0, S3 = 0, S4 = 0, S5 = 0;
      S1 = H * j;
      S2 = (W - j) * (H / 2);
      S3 = (W - j) * ((H + 1) / 2);
      S4 = ((W - j) / 2) * H;
      S5 = ((W - j + 1) / 2) * H;
      Smax = max(S1, max(S2, S3));
      Smin = min(S1, min(S2, S3));
      Smax2 = max(S1, max(S4, S5));
      Smin2 = min(S1, min(S4, S5));
      ans = min(ans, min(Smax - Smin, Smax2 - Smin2));
    }
    cout << ans << endl;
  }
  return 0;
}

// 分割面を決め打ち　縦で分割と横で分割　各分割面に対してSmaxとSminを求める．


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

vll as, ans;
vvll to;
ll n;
void dfs(ll u, ll par, vll& dp){
  ll a = as[u];
  ll idx = Lower_bound(dp, a);
  ll apre = -1;
  if(idx < n) {
    apre = dp[idx];
    dp[idx] = a;
  }
  ans[u] = Lower_bound(dp, INF);
  for(ll v : to[u]){
    if(v == par) continue;
    dfs(v, u, dp);
  }
  if(apre != -1) dp[idx] = apre;
}

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  cin >> n;

  as.resize(n);
  rep(i,n) cin >> as[i];

  to.resize(n);
  rep(i,n-1){
    ll u, v;
    cin >> u >> v;
    u--, v--;
    to[u].push_back(v);
    to[v].push_back(u);
  }

  ans.resize(n);
  vll dp(n, INF);
  stack<T> stk;
  dfs(0, -1, dp);
  rep(i, n) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 33176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt(), B = sc.nextInt();
        if (B%A==0) {
            System.out.println(A+B);
            return;
        }
        System.out.println(B-A);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

int main() {
    ll R, C, K;
    cin >> R >> C >> K;

    vector<vector<ll>> itemtbl(R, vector<ll>(C));
    for (ll r = 0; r < R; r++) {
        for (ll c = 0; c < C; c++) {
            itemtbl[r][c] = 0;
        }
    }

    for (ll i = 0; i < K; i++) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        itemtbl[r][c] = v;
    }

    vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4)));
    for (ll r = 0; r < R; r++) {
        for (ll c = 0; c < C; c++) {
            for (ll i = 0; i <= 3; i++) {
                if (r == 0) {
                    if (c == 0) {
                        dp[r][c][0] = itemtbl[r][c];
                        dp[r][c][1] = itemtbl[r][c];
                        dp[r][c][2] = itemtbl[r][c];
                        dp[r][c][3] = 0;
                    } else {
                        dp[r][c][0] = max(dp[r][c - 1][1] + itemtbl[r][c], dp[r][c - 1][0]);
                        dp[r][c][1] = max(dp[r][c - 1][2] + itemtbl[r][c], dp[r][c - 1][1]);
                        dp[r][c][2] = max(dp[r][c - 1][3] + itemtbl[r][c], dp[r][c - 1][2]);
                        dp[r][c][3] = dp[r][c - 1][3];
                    }
                } else {
                    if (c == 0) {
                        dp[r][c][0] = itemtbl[r][c] + dp[r - 1][c][0];
                        dp[r][c][1] = itemtbl[r][c] + dp[r - 1][c][0];
                        dp[r][c][2] = itemtbl[r][c] + dp[r - 1][c][0];
                        dp[r][c][3] = dp[r - 1][c][0];
                    } else {
                        dp[r][c][0] = max(
                            max(dp[r][c - 1][1] + itemtbl[r][c], dp[r][c - 1][0]),
                            dp[r - 1][c][0] + itemtbl[r][c]);
                        dp[r][c][1] = max(
                            max(dp[r][c - 1][2] + itemtbl[r][c], dp[r][c - 1][1]),
                            dp[r - 1][c][0] + itemtbl[r][c]);
                        dp[r][c][2] = max(
                            max(dp[r][c - 1][3] + itemtbl[r][c], dp[r][c - 1][2]),
                            dp[r - 1][c][0] + itemtbl[r][c]);
                        dp[r][c][3] = max(dp[r][c - 1][3], dp[r - 1][c][0]);
                    }
                }
            }
        }
    }
    print(dp[R - 1][C - 1][0]);
}


Measured memory_bytes: 706732
data class Task(val needTime: Int, val deadline: Int)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val tasks = (0.until(n)).map {
        val arr = readLine()!!.split(' ').map { it.toInt() }
        Task(arr[0], arr[1])
    }.sortedBy { it.deadline }
    var sum = 0
    for (i in 0.until(tasks.size)) {
        sum += tasks[i].needTime
        if (tasks[i].deadline < sum) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 117600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    string s,t;
    cin >> s >> t;

    int mincount=inf;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int count=0;
        for(int j=i;j<t.size()+i;j++){
            if(s.at(j)!=t.at(j-i)){
                count++;
            }
        }
        mincount=min(mincount,count);
    }

    cout << mincount << endl;

    return 0;
}


Measured memory_bytes: 3640
N = int(input())


def num2alpha(num):
    if num <= 26:
        return chr(96 + num)
    elif num % 26 == 0:
        return num2alpha(num // 26 - 1) + chr(122)
    else:
        return num2alpha(num // 26) + chr(96 + num % 26)


print(num2alpha(N))


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> cnt(m, 0);
    ll ind=1, size, check;
    ll now = x;
    ll res = 0;
    while(1){
        if (ind > n) {
            size = n;
            check = n+1;
            break;
        }
        if(cnt[now]==0){
            res += now;
            cnt[now] = ind;
            ind++;
            now = (now * now) % m;
        }else{
            size = ind - cnt[now];
            check = cnt[now];
            break;
        }
        
    }
    for(ll i=0;i<m;i++){
        if(cnt[i]>=check){
            if(cnt[i]-check<(n-check+1)%size){
                res += i * ((n-check+1) / size);
            }else{
                res += i * (((n-check+1) / size) - 1LL);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4044
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        int idx = 0;
        long sum = 0;
        long max = 0;
        for (int i = 0; i < n; i++) {
            if (i < k) {
                sum += p[i];
                max = sum;
                idx = i;
            } else {
                sum = sum - p[i - k] + p[i];
                if (max < sum) {
                    max = sum;
                    idx = i;
                }
            }
        }
        double ans = 0;
        for (int i = idx - k + 1; i < idx + 1; i++) {
            ans += (p[i] * (p[i] + 1) / 2.0) / p[i];
        }
        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long ll;

int get(int x)
{
    int lim=sqrt(x),ret=1;
    for(int i=2;i<=lim;i++)
    {
        if(x%i==0)
        {
            int cnt=0;
            while(x%i==0) ++cnt,x/=i;
            ret*=(cnt+1);
        }
    }
    if(x>1) ret*=2;
    return ret;
}

int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i+=2)
        if(get(i)==8) ++ans;
    cout<<ans;
}

Measured memory_bytes: 256
// AtCoder150 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

int main(void)
{
    int i,j,n;

    int x = 0;
    int N;

    scanf("%d", &N);
    char* s = (char*)malloc(sizeof(char) * (N+1));
    scanf("%s", s);


    int max = 0;
    for(i=0;i<N;i++){
        if(s[i] == 'I'){
            x++;
        }else{
            x--;
        }
        if(x > max) max = x;
    }
    printf("%d", max);

    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s=0,x,y,k;
    cin>>n;
    cin>>k;
    vector<int> v(n);
   for(int i=0;i<n;i++)
   {
       cin>>v[i];
   }
   
   for(int i=0;i<n;i++)
   {   x=abs(k-v[i]);
       y=abs(v[i]-0);
       s+=min(2*x,2*y);
   }
   cout<<s<<"\n";
   return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define INF LONG_LONG_MAX
#define int long long
#define ar array
const int mxn=5e5+4;
int t[mxn];
int n,q;
void upd(int u,int d)
{
    while(u<=n)
    {
        t[u]+=d;
        u+=u&-u;
    }
}
int sum(int u)
{
    int s=0;
    while(u)
    {
       s+=t[u];
       u-=u&-u; 
    }
    return(s);
}
int que(int l,int r)
{
    return(sum(r)-sum(l-1));
}
int c[mxn];
vector<int> qr[mxn],qi[mxn];
int pos[mxn],ans[mxn];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for (int i=1;i<=n;i++) cin>>c[i];
    for (int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;
        qr[r].push_back(l);
        qi[r].push_back(i);
    }
    for (int i=1;i<=n;i++)
    {   
        if (pos[c[i]]>0) upd(pos[c[i]],-1);
        upd(i,1);   
        pos[c[i]]=i;
        for (int j=0;j<qr[i].size();j++)
        {
            ans[qi[i][j]]=que(qr[i][j],i);
        }
    }
    for (int i=0;i<q;i++) cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 62768
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

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

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int x = vs[1];
			int t = vs[2];

			int ans = (int)Math.Ceiling((double)n / x) * t;
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 28312
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int answer = k;
	for(int i = 0; i < n - 1; i++)
	{
		answer *= k - 1;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  ll N;in(N);
  vector<ll>A(N);
  map<ll,ll>cnt;
  set<ll>kind;
  rep(i,N){
    ll t;in(t);
    A[i]=t;
    cnt[t]++;
    kind.insert(t);
  }
  ll sum=0;
  for(auto e:kind)sum+=cnt[e]*(cnt[e]-1)/2;
  rep(i,N)out(sum-cnt[A[i]]*(cnt[A[i]]-1)/2+(cnt[A[i]]-1)*(cnt[A[i]]-2)/2);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 17024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("2 4 4 0 2");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("7");
            WillReturn.Add("6 4 0 2 4 0 2");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("8");
            WillReturn.Add("7 5 1 1 7 3 5 3");
            //16
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int N = int.Parse(InputList[0]);
        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        Array.Sort(AArr);

        bool IsCorrect = true;

        for (int I = 1; I <= N; I++) {
            int wkNum;

            //Nが偶数の場合
            if (N % 2 == 0) {
                wkNum = (I % 2 == 0 ? I - 1 : I);
            }
            else { //Nが奇数の場合
                wkNum = (I % 2 == 1 ? I - 1 : I);
            }
            if (AArr[I - 1] != wkNum)
                IsCorrect = false;
        }

        if (IsCorrect) {
            Console.WriteLine(DeriveBekijyou(2, N / 2, 1000000007));
        }
        else Console.WriteLine(0);
    }

    //繰り返し2乗法で、(NのP乗) Mod Mを求める
    static long DeriveBekijyou(long pN, long pP, long pM)
    {
        long CurrJyousuu = pN % pM;
        long CurrShisuu = 1;
        long WillReturn = 1;

        while (true) {
            //対象ビットが立っている場合
            if ((pP & CurrShisuu) > 0) {
                WillReturn = (WillReturn * CurrJyousuu) % pM;
            }

            CurrShisuu *= 2;
            if (CurrShisuu > pP) return WillReturn;
            CurrJyousuu = (CurrJyousuu * CurrJyousuu) % pM;
        }
    }
}


Measured memory_bytes: 10968
// https://atcoder.jp/contests/arc094/tasks/arc094_a

#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  V<ll> vs(3);
  rep(i, 0, 3) cin >> vs[i];
  sort(vs.begin(), vs.end());

  ll diff = (vs[2] - vs[0]) + (vs[2] - vs[1]);
  ll res = diff % 2 == 0 ? diff / 2 : diff / 2 + 2;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, 0, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int fl[10001] = {0};

void isfl(int);
void twlf(int);

int main(void) {
  int tag;

  while(1){
    cin >> tag;
    if(tag == 0) break;
    isfl(tag);
    twlf(tag);
  }
  return 0;
}

void isfl(int tag){
  int i,lim,idx = 2;
  fl[0] = 1;
  fl[1] = 1;

  lim = sqrt(tag);

  while(idx <= lim){
    if(fl[idx] == 0) for(i = idx*2;i<=tag;i+=idx) fl[i] = 1;
    idx++;
  }
  return;
}

void twlf(int tag){
  int k=0,data[10000];
  for(int i=1;i<=tag;i++) if(fl[i] == 0){
    data[k] = i;
    k++;
  }
  for(int i=k-1;i>=0;i--){
    if(data[i] - data[i-1] == 2){
      cout << data[i-1] << " " << data[i] << endl;
      break;
    }
  }
  return;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0,c=0;

	int i,j,k,x;

	bool flag;

	string s,s2,s3;

	//char s[100000];

	int ara[n_size],ara2[n_size];


	cin>>s>>s2;

	int len1=s.length();
	int len2=s2.length();

	if(len1<len2) cout<<"UNRESTORABLE"<<endl,exit(0);

    for(i=len1-len2;i>=0;i--)
    {
        flag=true;

        f(j,0,len2-1)
        {
            if(s[i+j]==s2[j] || s[i+j]=='?') continue;
            else {
                flag=false;
                break;
            }
        }
        if(flag==true){
            f(j,0,len2-1) s[i+j]=s2[j];
            f(j,0,len1-1){
                if(s[j]=='?') s[j]='a';
            }
            cout<<s<<endl,exit(0);
        }



    }


    cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<Integer> s;
	static int count;

	public static void binarySearch(int value) {
		int left = 0, right = s.size();
		while (left < right) {
			int mid = (left + right) / 2;
			if (s.get(mid).intValue() == value) {
				count++;
				break;
			} else if(value < s.get(mid)){
				right = mid;
			} else {
				left = mid + 1;
			}
			mid = (left + right) / 2;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		s = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			s.add(sc.nextInt());
		}
		int q = sc.nextInt();
		count = 0;
		for (int i = 0; i < q; i++) {
			binarySearch(sc.nextInt());
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 84072