akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,k;
    cin>>n>>k;
    if(n<10){
        cout<<(10-n)*100+k;
    }else{
        cout<<k;
    }
}


Measured memory_bytes: 256
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
//end of libraries ;
#define INF 9999999999
#define N 300003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
string s;
int main(){
fcin;
	cin>>s;
	// cout<<s[3]<<" "<<s[2]<<endl;
	if(s[3]==s[2] && s[5]==s[4]) cout<<"Yes\n";
	else cout<<"No\n";
 
}

Measured memory_bytes: 256
#abc174_e

n,k=map(int,input().split())
a=[int(i) for i in input().split()]
    
ok=1001001001
ng=0
def check(x):
  cnt=0
  for q in a:
    cnt+=(q-1)//x
  return cnt<=k

while ok-ng>1:
  mid=(ok+ng)//2
  if check(mid):
    ok=mid
  else:
    ng=mid
print(ok)

Measured memory_bytes: 30712
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    long long n;
    cin>>n;
    long long a[n],cntr=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]==cntr+1){
            cntr++;
        }
    }
    
    if(cntr==0){
        cout<<-1<<endl;
    }else{
        cout<<n-cntr<<endl;
    }
    return 0;
}

Measured memory_bytes: 5132
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    const int INF = 1000000000;
    int n, m, l;
    cin >> n >> m >> l;
    vector < vector < pair<int,int> > > g (n+1);
    int a, b, c;
    for (int i=0; i<m; i++){
        cin >> a >> b >> c;
        g[a].push_back(make_pair(b,c));
        g[b].push_back(make_pair(a,c));
    }
    vector <int> th(n+1, -1);
    vector <vector <int> > answ (n+1, th);
    for (int i=1; i<n+1; i++){
        int s = i; // стартовая вершина

        vector<pair<int, int> > d (n+1, make_pair(INF, INF));
        d[s] = make_pair(0, -l);
        set < pair<pair<int,int>, int> > q;
        q.insert (make_pair (d[s], s));
        while (!q.empty()) {
            int v = q.begin()->second;
            q.erase (q.begin());

            for (size_t j=0; j<g[v].size(); ++j) {
                int to = g[v][j].first;
                int len = g[v][j].second;
                int step_l = 0;
                int kol_l = d[v].first;
                if (len <= l) {
                    if (d[v].second + len <= 0) {
                        step_l = d[v].second + len;
                    } else {
                        step_l = -l + len;
                        kol_l += 1;
                    }
                    if (make_pair(kol_l, step_l) < d[to]) {
                        q.erase(make_pair(d[to], to));
                        d[to] = make_pair(kol_l, step_l);
                        q.insert(make_pair(d[to], to));
                    }
                }
            }
        }
        for (int jj=1; jj<=n; jj++){
            if (d[jj].first != INF){
                answ[i][jj] = d[jj].first;
            }
        }
    }
    int q;
    cin >> q;
    int ss, tt;
    for (int i=0; i<q; i++){
        cin >> ss >> tt;
        cout << answ[ss][tt] << '\n';
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <set>

using namespace std;
using ll = long long ;
int min(int a, int b){
    if(a<b) return a ;
    else return b ;
}

const int D = 60 ;
const int MAX_N = 200005 ;
int t[D][MAX_N] ;

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

    for (int i = 0; i < n; i++){
        cin >> t[0][i] ;
        t[0][i]-- ;
    } 
    for (int i = 0; i < D-1; i++)
    {
        for(int j=0;j<n;j++){
            t[i+1][j] = t[i][t[i][j]] ;
        }
    }
    
    int v = 0 ;
    for(int i=D-1;i>=0;i--){
        ll l = 1ll<<i ;
        if(l<=k){
            v = t[i][v] ;
            k -= l ;
        }
    }
      cout << v+1 << endl ;
   
  return 0 ;
}

Measured memory_bytes: 50500
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))



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

  string s;
  cin >> s;
  
  vector<vector<int> > work(n,vector<int>(n,0));
  
  int ans = 0;
  rep(i,n-1) if(s[0] == s[i+1])work[0][i+1] = 1;  
  for(int i=1;i<n;i++){
	//cout << "[" << i << "]" << endl;
	for(int j=i+1;j<n;j++){
	  if(s[i] == s[j]){
		work[i][j] = work[i-1][j-1]+1;
		if(i < j-work[i-1][j-1] && ans < work[i][j]) ans = work[i][j];
	  }
	  /*cout << j << ": ";
	  rep(k,work[i][j].size()) cout << work[i][j][k] << " ";
	  cout << endl;*/
	}
  }
  
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 98176
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n,m = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
if s>n:
    print(-1)
else:
    print(n-s)

Measured memory_bytes: 27760
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
  
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K: break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
  
print(ans)

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

int main() {
int K, X; cin >> K >> X;
int ans;
for (int i = 0; i < 2 * K - 1; i++) {
    ans = X - K + 1 + i;
    if (ans >= -1000000 && ans <= 1000000) {
        cout << ans << " ";
    }
}
cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b, c;
  cin>>a>>b>>c;
  cout<<(a+b+c>=22 ? "bust" : "win")<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;

int main(){

    int n, k, s;

    cin >> n >> k >> s;

    
    vector<int> v;

    if(k == 0){

        if(s == 999999937){
            rep(i,n){
                v.pback(982451653);
            }
        }else{
            rep(i,n){
                v.pback(999999937);
            }
        }

    }else{

        int m = n - k + 1;

        int base = s / m;
        int modu = s % m;

        if(base > 0){

        rep(i,n){
            if(i % m == 0){
                v.pback(base + modu);
            }else{
                v.pback(base);
            }
        }

        }else{
            rep(i,k){
                v.pback(modu);
            }

            rep(i, n - k){
                v.pback(100000000);
            }
        }
    }

    rep(i, n){
        cout << v[i] << " ";
    }
    cout << endl;

    

    return 0;
}

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

using namespace std;

struct Node {
	int parent, left, right;
};

int NIL = -1;

void calcDepth(int D[], Node T[], int i, int depth) {

	D[i] = depth;

	if (T[i].right != NIL) {
		calcDepth(D, T, T[i].right, depth);
	}
	if (T[i].left != NIL) {
		calcDepth(D, T, T[i].left, depth + 1);
	}
}

int main() {

	int MAX = 100000;

	Node T[MAX];
	int D[MAX];

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		T[i].parent = T[i].left = T[i].right = NIL;
	}

	int id, k, c, preC;

	for (int i = 0; i < n; ++i) {
		scanf("%d", &id);
		scanf("%d", &k);
		for (int j = 0; j < k; ++j) {
			scanf("%d", &c);
			if (j == 0) {
				T[id].left = c;
			} else {
				T[preC].right = c;
			}
			T[c].parent = id;
			preC = c;
		}
	}

	int root;
	for (int i = 0; i < n; ++i) {
		if (T[i].parent == NIL) {
			root = i;
			break;
		}
	}

	calcDepth(D, T, root, 0);

	for (int i = 0; i < n; ++i) {
		cout << "node " << i << ": parent = " << T[i].parent << ", depth = " << D[i] << ", ";
		if (i == root) {
			cout << "root";
		} else if (T[i].left == NIL) {
			cout << "leaf";
		} else {
			cout << "internal node";
		}
		cout << ", [";

		int j = 0;
		for (int c = T[i].left; c != NIL; c = T[c].right) {
			if (j) {
				cout << ", ";
			}
			cout << c;
			++j;
		}

		cout << "]" << endl;

	}

	return 0;
}

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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str[] = br.readLine().split("\\s+");
			int array[] = new int[str.length];

			for(int i = 0; i < str.length; i++){
				array[i] = Integer.parseInt(str[i]);
			}

			Dice dice = new Dice();
			dice.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);

			String order = br.readLine();

			for(int i = 0; i < order.length(); i++){
				dice.roll(order.charAt(i));
			}

			System.out.println(dice.getTop());

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


class Dice{

	private int number[];
	private int work[];

	Dice(){
		number = new int[6];
		work = new int[6];
	}


	public void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	public int getTop(){
		return number[0];
	}

	public void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}
};



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

namespace ConsoleApp1
{
    static class DSummerVacation
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            int n = nm[0];
            int m = nm[1];

            var abList = new List<int>[100001];
            for (int i = 1; i <= 100000; i++)
            {
                abList[i] = new List<int>();
            }

            for (int i = 0; i < n; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
                int a = ab[0];
                int b = ab[1];
                abList[a].Add(b);
            }

            var pq = new PriorityQueue<long>();
            long sum = 0;

            for (int i = 1; i <= m; i++)
            {
                foreach (var b in abList[i])
                {
                    pq.Enqueue(b);
                }
                if (1 <= pq.Count)
                {
                    sum += pq.Dequeue();
                }
            }

            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }

    public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }
 
}

Measured memory_bytes: 25732
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main(void) {

  int n, q;
  cin >> n >> q;

  string name; int t;
  queue< pair<string, int> > qu;
  for(int i=0; i<n; i++){
    cin >> name >> t;
    qu.push( make_pair(name, t) );
  }
  int cnt = 0;
  while( !qu.empty() ){
    pair< string, int > p = qu.front();
    qu.pop();

    if( p.second > q ){
      p.second -= q;
      qu.push( p );
      cnt += q;
    }else{
      cnt += p.second;
      cout << p.first << " " << cnt << endl;
    }

  }

  return 0;
}






// EOF

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

int main() {
	int n,x,m[110],min=2000,sum=0,ans=0,i;
	cin>>n>>x;
	for(i=1;i<=n;i++){
		cin>>m[i];
		sum=sum+m[i];
		if(m[i]<min) min=m[i];
	}
	x=x-sum;
	ans=n;
	ans=ans+x/min;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
S = input()

if S[0] == 'R':
  if S[1] == 'R':
    if S[2] == 'R':
      #RRR
      print('3')
    else:
      #RRS
      print('2')
  else:
    #RSR or RSS
    print('1')
else:
  if S[1] == 'R':
    if S[2] == 'R':
      #SRR
      print('2')
    else:
      #SRS
      print('1')
  else:
    if S[2] == 'R':
      #SSR
      print('1')
    else:
      print('0')

Measured memory_bytes: 9040
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {

	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final String S = sc.next();
			final String T = sc.next();
			
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			final String U = sc.next();
			
			if(S.equals(U)) {
				System.out.println((A - 1) + " " + (B));
			}else {
				System.out.println((A) + " " + (B - 1));
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22612
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Integer.parseInt(in.next()),A[]=new int[n];
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		int q=Integer.parseInt(in.next());
		for(int i=0;i<q;i++) {
			int key=Integer.parseInt(in.next());
			if(Arrays.binarySearch(A, key)>=0) {
				out.println(1);
			}
			else {
				out.println(0);
			}
		}
		out.flush();
	}

}



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

int main(){
    long long int N;
    int ans = 0;
    cin >> N;
    int route_N = sqrt(N); 
    for(int i=1;i<=route_N;i++){
        if(i*i<N) ans += 1;
    } 
    for(int i=1;i<route_N;i++){
        if(N%i==0) ans += 2*(N/i-1-i);
        else ans += 2*(N/i-i);
    }
    if((route_N+1)*route_N<N) ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 3636
from bisect import bisect_left

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

t = [[] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(ans-1, -1, -1):
        idx = bisect_left(t[j], A[i])
        if idx != len(t[j]):
            if abs(t[j][idx] - A[i]) <= K:
                t[j + 1].insert(bisect_left(t[j + 1], A[i]), A[i])
                ans = max(ans, j+2)
                break
        if idx > 0:
            if abs(t[j][idx-1] - A[i]) <= K:
                t[j + 1].insert(bisect_left(t[j + 1], A[i]), A[i])
                ans = max(ans, j+2)
                break
    else:
        t[0].insert(bisect_left(t[0], A[i]), A[i])
        ans = max(ans, 1)

print(ans)


Measured memory_bytes: 125916
#include <bits/stdc++.h>
#define il inline
const int N=2005;

int n,ans=1e9,s[N],f[N],dis[N],sz[N];
int to[N+N],nx[N+N],hd[N],sze;

il void add(int u,int v){to[++sze]=v,nx[sze]=hd[u],hd[u]=sze;}

il void dfs(int u,int F)
{
	sz[u]=s[u]; int i,v,mx=0;
	for (i=hd[u]; i; i=nx[i]) if ((v=to[i])!=F)
	{
		dfs(v,u),sz[u]+=sz[v],dis[u]+=dis[v]+=sz[v];
		if (dis[mx]<=dis[v]) mx=v;
	}
	if (!mx) return;
	if (dis[u]>=2*dis[mx]) f[u]=dis[u]/2;
    else f[u]=dis[u]-dis[mx]+std::min(f[mx],(2*dis[mx]-dis[u])/2);
}

int main()
{
	scanf("%d\n",&n); int i,j,u,v;
	for (i=1; i<=n; i++) s[i]=getchar()^48;
	for (i=1; i<n; i++) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	
	for (i=1; i<=n; i++)
	{
        memset(dis,0,4*n+4),memset(sz,0,4*n+4),memset(f,0,4*n+4),dfs(i,0);
		if (dis[i]&1^1) (2*f[i]>=dis[i])&&(ans=std::min(ans,dis[i]/2));
	}
	if (ans==1e9) puts("-1");
	else printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 3892
import java.io.IOException;
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a == 5 && a == b && c == 7) {
            System.out.println("YES");
            return;
        }
        
        if (b == 5 && b == c && a == 7) {
            System.out.println("YES");
            return;
        }
        
        if (c == 5 && c == a && b == 7) {
            System.out.println("YES");
            return;
        }

        System.out.println("NO");
    }
}

Measured memory_bytes: 22100
function Main(input) {
    input = input.split("\n");
  	var N = input[0].split(" ")[0]-0;
  	var X = input[0].split(" ")[1]-1;
  	var Y = input[0].split(" ")[2]-1;
  	var ans = [];
  	var sk = Y-X-1;
  	for(var i=0;i<N;i++){
      	for(var j=i+1;j<N;j++){
      	    var an = j-i;
      	    an = Math.min(an, Math.abs(i-X)+Math.abs(j-Y)+1);
      	    if(!ans[an])ans[an]=0;
      	    ans[an]++;
      	}
  	    
  	}
  	for(var i=1;i<=N-1;i++){
      	console.log(ans[i]||0);
  	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  
  ll ans = 0;
  rep(i, n-1){
    ll dist = a[i] - a[i+1];
    if(dist > 0){
      ans += dist;
      a[i+1] += dist;
    }
  }
  
  cout << ans << endl;
  
return 0;
}

Measured memory_bytes: 4828
#include<iostream>
using namespace std;
int main()
  {
    int h,n,a;
    cin>>h>>n;
    int d=h;
    for(int i=1;i<=n;i++){
      cin>>a;
      d=d-a;
      }
  if(d<=0)cout<<"Yes";
  else cout<<"No";
    return 0;
  }


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int n,k;
  cin >> n >> k;
  
  vector<ll> p(n);
  rep(i,n){
  ll x;
  cin>>x;
  p[i]=x+1;
  }
  
  ll ans=0;
  rep(i,k){
  ans+=p[i];
  }
  
  ll x=ans;
  repo(i,n-k+1){
  x+=p[k+i-1]-p[i-1];
  ans=max(ans,x);
  }
  
  cout << fixed << setprecision (20);  
  cout << (ld)ans/2 << endl;
}


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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=2*1e5+5;
int a[MAX_N];
int main(){
	int n;
	cin>>n;
	rep(i,n)cin>>a[i+1];
	int now=n;
	while(now>1){
		cout<<a[now]<<" ";
		now-=2;
	}
	cout<<a[1];
	now=n%2==0?now=3:2;
	while(now<=n){
		cout<<" ";
		cout<<a[now];
		now+=2;
	}
	cout<<endl;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,m,k;
int a[maxn],b[maxn],p[maxn];

int32_t main()
{
    IOS
    cin>>n>>m>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=m;i++) cin>>b[i],p[i]=p[i-1]+b[i];

    int ans=0;
    int r=m,sum=0;
    while (p[r]>k) r--;
    ans=max(ans,r);

    for (int i=1;i<=n;i++)
    {
        sum+=a[i];
        if (sum>k) break;

        while (p[r]+sum>k) r--;
        ans=max(ans,r+i);
    }
    cout<<ans<<endl;
}



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

int main() {
    string s;
    cin >> s;
    if (s.at(1) != s.at(0) || s.at(1) != s.at(2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

int main()
{
    long long int n,i,j,p,q,min,s,r;
    cin>>n;
    min=n;
    r=sqrt(n);
    for(i=1;i<=r;++i){

        if(n%i==0){

            p=n/i;
            q=i;
            s=((p-1)+(q-1));
            if(s<min)min=s;

        }

    }
    cout<<min<<endl;

    return 0;

}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
int main(void){
  char a[3];
  int i,ans=0;
  for(i=0;i<3;i++){
    a[i] = getchar();
    ans+=a[i]-'0';
  }
  printf("%d\n",ans);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  string words[N];
  for (int i=0 ; i<N ; i++) cin >> words[i];
  
  set<string> st;
  st.insert(words[0]);
  for (int i=0 ; i<N-1 ; i++) {
    decltype(st)::iterator it = st.find(words[i+1]);
    
    if (words[i].substr(words[i].size()-1) != words[i+1].substr(0,1) || it != st.end()) {
      printf("No\n");
      return 0;
    }
    st.insert(words[i+1]);
  }
  printf("Yes\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

ll f1(ll x, ll y){
    // ll res = abs(x - y);
    ll res = x - y;
    return res;
}

ll f2(ll x, ll y){
    // ll res = abs(x + y); 
    ll res = x + y;
    return res;
}

int main(){
    ll n;
    cin >> n;
    ll x[n], y[n];
    rep(i, n) cin >> x[i] >> y[i];
    ll a[n], b[n];
    rep(i, n){
        a[i] = f1(x[i], y[i]);
        b[i] = f2(x[i], y[i]);
    }
    sort(a, a + n);
    sort(b, b + n);
    ll ans = max(a[n-1] - a[0], b[n-1] - b[0]);
    cout << ans << endl;
}

Measured memory_bytes: 9816
#include<stdio.h>
int max(int a,int b){return a>b?a:b;}
int main(){
	int i,j;
	int n;
	char c;
	int jc=0;
	int oc=0;
	int ic=0;
	int lev=0;
	int ans=0;
	scanf("%d",&n);
	while(scanf("%c",&c)!=EOF){
		switch(c){
		case 'J':
			if(jc==0){
				oc=0;
				ic=0;
				lev=0;
			}
			jc++;
			break;
		case 'O':
			if(oc==0){
				if(jc>0)lev=jc;
				if(ic>0)lev=0;
				jc=0;
				ic=0;
			}
			oc++;
			if(lev<oc){
				oc=0;
				lev=0;
			}
			break;
		case 'I':
			if(ic==0){
				if(lev>0)lev=oc;
				jc=0;
				oc=0;
			}
			ic++;
			if(ic>=lev)ans=max(ans,lev);
			break;
		}
	}
	printf("%d\n",ans);
}
			

Measured memory_bytes: 976
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,p,i,j,cnt[101]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&p);
		for(j=p;j>=1;j--){
			cnt[j]++;
		}
	}
	for(i=100;i>=1;i--){
		if(cnt[i]>=i){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, 0, x) cin >> a[i];
    rep(i, 0, y) cin >> b[i];
    rep(i, 0, z) cin >> c[i];

    sort(all(a), greater<ll>());
    sort(all(b), greater<ll>());
    sort(all(c), greater<ll>());

    priority_queue<tuple<ll, int, int, int>> pq;
    pq.push(make_tuple(a[0] + b[0] + c[0], 0, 0, 0));
    set<ll> used;
    used.insert(0);
    vector<ll> ans;

    while ((int)ans.size() < k) {
        ans.push_back(get<0>(pq.top()));
        int A = get<1>(pq.top());
        int B = get<2>(pq.top());
        int C = get<3>(pq.top());
        pq.pop();

        if (A < x - 1) {
            ll hash = (ll)((A + 1) * 1e8 + B * 1e4 + C);
            if (!used.count(hash)) {
                pq.push(make_tuple(a[A + 1] + b[B] + c[C], A + 1, B, C));
                used.insert(hash);
            }
        }

        if (B < y - 1) {
            ll hash = (ll)(A * 1e8 + (B + 1) * 1e4 + C);
            if (!used.count(hash)) {
                pq.push(make_tuple(a[A] + b[B + 1] + c[C], A, B + 1, C));
                used.insert(hash);
            }
        }

        if (C < z - 1) {
            ll hash = (ll)(A * 1e8 + B * 1e4 + C + 1);
            if (!used.count(hash)) {
                pq.push(make_tuple(a[A] + b[B] + c[C + 1], A, B, C + 1));
                used.insert(hash);
            }
        }
    }

    sort(all(ans), greater<ll>());
    rep(i, 0, k) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 896
#include<cstdio>

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

using namespace std;

int dx[4],dy[4];

int dfs(int y,int x,bool used[4][4]){
	if(y==4) return 1;
	if(x==4) return dfs(y+1,0,used);
	if(used[y][x]) return dfs(y,x+1,used);

	used[y][x]=true;

	int res=0;
	rep(i,4){
		int yy=y+dy[i];
		int xx=x+dx[i];
		if(0<=yy && yy<4 && 0<=xx && xx<4 && !used[yy][xx]){
			used[yy][xx]=true;
			res+=dfs(y,x+1,used);
			used[yy][xx]=false;
		}
	}

	used[y][x]=false;

	return res;
}

int main(){
	while(1){
		rep(i,4) scanf("%d%d",dx+i,dy+i);
		if(dx[0]>4) break;
		bool used[4][4]={};
		printf("%d\n",dfs(0,0,used));
	}
	return 0;
}

Measured memory_bytes: 0
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                cnt+=1

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
//251103FD
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define read(x) ((scanf("%s", &_), (x) = _))
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
#define HASH 1543 
#define FAST ios_base::sync_with_stdio(0)

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;
typedef vector<vector<ll> > matrix;

using namespace std;

inline int in() 
{
    int x=0, c;
    while((uint)((c=getchar())-48)>=10) 
		if(c=='-') 
			return -in();
    do 
	{ x=(x<<3)+(x<<1)+(c^48); }
	while((uint)((c=getchar())^48)<10);
    return x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}
using namespace std;
int n , a[100005], b[100005], l, r, mid;
int sum[200005];
ll need;
inline void update(int x)
{
    while(x<=n*2)
        sum[x]++, x+=x&-x;
}
inline int ss(int x)
{
    int res=0;
    while(x>0)
        res+=sum[x], x&=x-1;
    return res;
}
inline bool chk(int val)
{
    memset(sum, 0, sizeof(sum));
    int s=n;
    update(s);
    ll res=0;
    Forn(i, n)
    {
        if(a[i]>=val)
            s++;
        else 
            s--;
        res+=ss(s);
        update(s);
    }
    return res>=(need>>1)+(need&1);
}
int main()
{
    n=in();
    need=(1ll*n*(n+1))>>1;
    Forn(i, n)
    {
        a[i]=in();
        b[i]=a[i];
    }
    sort(b+1, b+1+n); 
    l=0;
    r=n+1;
    while(l+1<r)
    {
        mid=(l+r)>>1;
        if(!chk(b[mid]))
            r=mid;
        else 
            l=mid;
    }
    printf("%d\n", b[l]);
    return 0;
}


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

int main(void){
    std::string s;
    cin >> s;
    int n = s.size();
    int N=0,E=0,W=0,S=0;
    
    for(int i=0;i<n;i++){
        if     ("N" == s.substr(i,1)) N += 1;
        else if("E" == s.substr(i,1)) E += 1;
        else if("W" == s.substr(i,1)) W += 1;
        else if("S" == s.substr(i,1)) S += 1;
    }
    N > 0 && S == 0 ? cout << "No"  <<  endl :
    N == 0 && S > 0 ? cout << "No"  <<  endl :
    E > 0 && W == 0 ? cout << "No"  <<  endl :
    E == 0 && W > 0 ? cout << "No"  <<  endl :
                                  cout << "Yes" <<  endl ;
}

Measured memory_bytes: 256
num = input().split()
x = int(num[0])
y = int(num[1])
cr = ((4 * x) - y) / 2
tur = (y - (2 * x)) / 2
if cr - int(cr) == 0 and tur - int(tur) == 0 and tur >= 0 and cr >= 0:
    if cr + tur == x and (2 * cr) + (4 * tur) == y:
        print("Yes")
else:
  print("No")


Measured memory_bytes: 9196
#![allow(dead_code, unused_imports, unused_variables)]

use proconio::*;
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.sort();
    a.reverse();
    let mut alice = 0;
    let mut bob = 0;
    for i in 0 .. n {
        if i % 2 == 0 {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }
    println!("{}", alice - bob);
}


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

int main(){
  char c;
  cin >> c;

  if(c>=65&&c<=90) cout << 'A' << endl;
  else cout << 'a' << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 11;

int n,m;
int a[maxn],p[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int c;
    cin>>c;
    int tt = 0;
    while(c--){
      int x;
      cin>>x;
      tt|=(1<<(x-1));
    }
    a[i]=tt;
  }
  for(int i=0;i<m;i++)cin>>p[i];
  int ret = 0;
  for(int i=0;i<(1<<n);i++){
    int cnt = 0;
    for(int j=0;j<m;j++){
      int sum = 0;
      for(int k=0;k<n;k++)
        if((i&(1<<k))&&(a[j]&(1<<k)))sum++;
      if(sum%2==p[j])cnt++;
    }
    if(cnt==m)ret++;
  }
  cout<<ret<<endl;
  return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long H;
  scanf("%lld", &H);

  ll ans = 0;
  ll cnt = 1;
  while (H > 1) {
    H = H / 2;
    ans += cnt;
    cnt = cnt * 2;
  }

  put(ans + cnt);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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 T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
s=input()
mod=10**9+7

dp=[[0]*13 for i in range(len(s)+1)]
dp[0][0]=1

for i in range(len(s)):
  if s[i]=='?':
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13]+=dp[i][k]
        dp[i+1][(k*10+j)%13]%=mod
        
  else:
    for k in range(13):
      dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]
      dp[i+1][(k*10+int(s[i]))%13]%=mod
      
      
print(dp[-1][5])

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int> 
#define piii pair<pair<int,int>,int> 

#define chalne_de continue
int mod=1000000007;
const int N = 1000005;

ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}
ll solve( ll h, ll w)
{
	ll ans = INT_MAX;
	for ( ll i = 1; i < h; i++)
	{
		ll s1 = i * w;
		ll s2 = (h-i)*(w/2);
		ll s3 = ( h -i) * ( w/2+w%2);
		ans = min(ans, max(s1,max(s2,s3)) - min(s1,min(s2,s3)));
		s2 = (h-i)/2 * w;
		s3 = ((h-i)/2 + (h-i)%2)* w;
		ans = min(ans, max(s1,max(s2,s3)) - min(s1,min(s2,s3)));

	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	ll h , w;
	cin >> h >> w;
	if ( h % 3 == 0 || w % 3 == 0)
	{
		cout << 0;
		return 0;
	}
	ll ans = solve(h,w);
	ans = min(ans,solve(w,h));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
<?php
list($n) = ints();
$p = new Prime(25);
$p->makeTable();
for ($i = 0; $i < $n; ++$i) {
    list($a) = strs();
    $t = explode('.', $a);
    $t[1] = str_pad($t[1] ?? '0', 9, '0', STR_PAD_RIGHT);
    $a = $t[0] * 10 ** 9 + $t[1];
    if ($a > 0) {
        $f = $p->factor($a);
        $f2[] = $f[2] ?? 0;
        $f5[] = $f[5] ?? 0;
    } else {
        $f2[] = 18;
        $f5[] = 18;
    }
}
$ans = 0;
for ($i = 0; $i < $n; ++$i) ++$cusum[min($f2[$i], 18)][min($f5[$i], 18)];
for ($i = 18; $i >= 0; --$i) {
    for ($j = 17; $j >= 0; --$j) {
        $cusum[$i][$j] += $cusum[$i][$j + 1];
    }
}
for ($j = 18; $j >= 0; --$j) {
    for ($i = 17; $i >= 0; --$i) {
        $cusum[$i][$j] += $cusum[$i + 1][$j];
    }
}
$ans = 0;
for ($i = 0; $i < $n; ++$i) {
    $s2 = max(0, 18 - $f2[$i]);
    $s5 = max(0, 18 - $f5[$i]);
    $ans += $cusum[$s2][$s5];
    if ($f2[$i] >= $s2 && $f5[$i] >= $s5) --$ans;
}
echo $ans / 2;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 素数関係
class Prime
{
    private $n;
    private $table; // 素数の添字にtrueが格納された配列

    function __construct($n)
    {
        $this->n = $n;
        $this->makeTable();
    }

    function makeTable()
    {
        $n = $this->n;
        $table = array_fill(2, $n - 1, true);
        $rn = (int) floor(sqrt($n));
        for ($i = 2; $i <= $rn; $i++) {
            if (!isset($table[$i])) continue;
            for ($j = 2 * $i; $j <= $n; $j += $i) {
                unset($table[$j]);
            }
        }
        $this->table = $table;
    }

    // 素数
    function primes()
    {
        return array_keys($this->table);
    }

    function table()
    {
        return $this->table;
    }

    // 素数判定
    function isPrime($x)
    {
        return isset($this->table[$x]);
    }

    // 素因数分解
    function factor($x)
    {
        $res = [];
        if ($x === 1) return $res;
        $primes = $this->primes();
        foreach ($primes as $prime) {
            while ($x % $prime === 0) {
                if (isset($res[$prime])) $res[$prime]++;
                else $res[$prime] = 1;
                $x /= $prime;
            }
        }
        if ($x > 1) {
            if (isset($res[$x])) $res[$x]++;
            else $res[$x] = 1;
        }
        return $res;
    }
}


Measured memory_bytes: 31036
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
  int N; cin>>N;
  vector<int> a(N);
  REP(i,N) cin>>a[i];
  int ans=0;
  for(int i=0;i<N;i=i+2){
    if(a[i]%2==1) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(){
    int a, b, c, i, total = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(i = a; i <= b; i++){
        if(c % i == 0){
            total++;
        }
    }
    printf("%d\n", total);
}

Measured memory_bytes: 1820
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let mut ans = std::usize::MAX;

    let mut v = vec![1];
    let mut b = 1;
    while b <= n{
        b *= 6;
        v.push(b);
    }

    let mut b = 1;
    while b <= n{
        b *= 9;
        v.push(b);
    }

    let dummy = std::usize::MAX;
    let mut dp: Vec<usize> = vec![dummy;n+1];
    dp[0] = 0;
    for i in 1..dp.len(){
        for &amount in &v{
            if i < amount{
                continue;
            }
            dp[i] = cmp::min(dp[i], dp[i-amount]+1);
        }
    }

    println!("{}", dp[n]);
}


Measured memory_bytes: 4352
fn func(input_str: &str) -> i32 {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let l_s: Vec<i32> = iter.take(n).map(|x| x.parse().unwrap()).collect();

    let c1 = [a, b, c];
    let mut ans = std::i32::MAX;
    let mut queue: Vec<Vec<i32>> = vec![Vec::new()];
    while !queue.is_empty() {
        let x = queue.pop().unwrap();
        if x.len() == n {
            let (mut l_a, mut l_b, mut l_c) = (0, 0, 0);
            let (mut cnt_a, mut cnt_b, mut cnt_c) = (0, 0, 0);
            for i in 0..n {
                match x[i] {
                    0 => { l_a += l_s[i]; cnt_a += 1; }
                    1 => { l_b += l_s[i]; cnt_b += 1; }
                    2 => { l_c += l_s[i]; cnt_c += 1; }
                    _ => {},
                }
            }
            if cnt_a * cnt_b * cnt_c == 0 {
                continue;
            }
            let cost = 10 * ((cnt_a - 1) + (cnt_b - 1) + (cnt_c - 1))
                 + (a - l_a).abs() + (b - l_b).abs() + (c - l_c).abs();
            if cost < ans {
                ans = cost;
            }
        } else {
            for z in 0..4 {
                let mut y = x.clone();
                y.push(z);
                queue.push(y);
            }
        }
    }
    ans
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
void _(ll&a , ll b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll n;
void dfs(string s,char c)
{

	if(s.size()==n)cout << s<< "\n";
	else
	{
		for(char i='a';i<=c;i++)
		{
			if(i==c){dfs(s+c,c+1);}
			else {dfs(s+i,c);}
		}
	}
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    dfs("",'a');
    }

Measured memory_bytes: 1536