akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int a, b;
	b = 1;
	char n;
	char s[100];
	cin >> a;
	if (a % 2 == 1)b = 0;
	for (int i = 0; i < a / 2; ++i) {
		cin >> s[i];
	}
	for (int i = 0; i < a / 2; ++i) {
		cin >> n;
		if (s[i] != n) {
			b = 0;
			break;
		}
	}
	if (b == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  string names[4] = {"AC", "WA", "TLE", "RE"};
  map<string, int> mp;
  for (int i = 0; i < 4; i++) {
    mp[names[i]] = 0;
  }

  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    mp[s]++;
  }

  for (int i = 0; i < 4; i++) {
    string name = names[i];
    cout << name << " x " << mp[name] << endl;
  }
}

Measured memory_bytes: 3632
#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>;

const int mod = 1000000007;

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

ll choose(ll n, ll r) {
    ll ret = 1;
    for (ll i = n; i > n-r;--i){
        ret *= i;
        ret %= mod;
    }
    for (ll i = 1; i < r+1; ++i) {
        // ret /= i;
        ret %= mod;
        ret = ret * modinv(i,mod) % mod;
    }
    return ret;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((x+y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll n, m; // n:(+1,+2), m:(+2,+1)の回数
    n = (2*y-x)/3; m = (2*x-y)/3;
    if (n<0 || m<0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = choose(ll(n+m),ll(n));
    cout << ans << endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAXN (int)(1e6)+1
#define MOD 998244353

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<int> > matrix;

class Compare{

public:
    bool operator()(plli a,plli b){
        if(a.f == b.f) return a.s<b.s;
        return a.f<b.f;
    }

};

int n,m;
vector<pair<lli,lli>> ar;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(6);

    cin>>n>>m;

    priority_queue<plli,vector<plli>,Compare> pq;
    set<int> s;

    rep(i,n){
        int a,b;
        cin>>a>>b;
        pq.push(mp(b,a));
    }
    rep(i,m){
        s.insert(i);
    }
    s.insert(m);
    lli res = 0;

    while(!pq.empty()){
        auto it = s.lower_bound(pq.top().s);
        if(it != s.end()){
            res+=pq.top().f;
            s.erase(it);
        }
        pq.pop();
    }

    cout<<res<<endl;

    return 0;

}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
      ll n,x,i,j,k,ans=0;
      cin>>n>>x;
      ll a[n],b[n];
      for(i=0;i<n;i++) cin>>a[i],b[i]=a[i],ans+=a[i];
      for(k=0;k<n;k++){
        j=0;
        for(i=0;i<n;i++) j+=b[i]=min(b[i],a[(i+n-k)%n]);
        ans=min(ans,x*k+j);
      }
      cout << ans << endl;
      return 0;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
int n;
long long res, D[410][410], w[410], S[410];
int main() {
	int i, a, j, k;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%lld", &w[i]);
		S[i] = S[i - 1] + w[i];
	}
	for (int L = 2; L <= n; L++) {
		for (i = 1; i <= n - L + 1; i++) {
			j = i + L - 1;
			D[i][j] = 1e18;
			for (k = i; k < j; k++) {
				D[i][j] = min(D[i][j], D[i][k] + D[k + 1][j] + S[j] - S[i - 1]);
			}
		}
	}
	printf("%lld\n", D[1][n]);
}

Measured memory_bytes: 1408
n=gets.to_i
vrray=gets.split.map(&:to_i)
grray=gets.split.map(&:to_i)
array=[]
i=0
while i<n
  array.push(vrray[i]-grray[i])
  i+=1
end
brray = array.select{|x| x>0 }
if brray == []
  puts 0
else
  puts brray.inject(:+)
end

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

int main() {
    long long n,a,b;
    cin >>n >> a>> b;
    if((b-a)%2==0){
        cout << (b-a)/2 << endl;
    }
    else{
        cout << min(a-1,n-b)+((b-a-1)/2)+1 << endl;
    }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = list(map(lambda x: int(x)*2, readline().split()))
ans = [0] * n
for i in range(n):
    if i % 2 == 0:
        ans[0] += a[i]
    else:
        ans[0] -= a[i]
ans[0] //= 2
for i in range(1, n):
    ans[i] = a[i - 1] - ans[i - 1]
print(*ans)


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

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

	public class Question
	{
		public void Exec()
		{
			long time_sec = long.Parse(Console.ReadLine());
			long sec = time_sec % 60;
			long min = time_sec / 60;
			long hour = min / 60;
			min = min % 60;

			Console.WriteLine($"{hour}:{min}:{sec}");
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 17888
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100];
int mid[100];
int main()
{
    int t,ans=0,sum=0;
    scanf("%d",&t);
    for(int i=0; i<t; i++)
    {
        scanf("%d",&a[i]);
        ans+=a[i];
    }
    for(int i=0; i<t; i++)
    {
        sum+=a[i];
        ans-=a[i];
        if(ans-sum<0)
            mid[i]=-ans+sum;
        else
            mid[i]=ans-sum;
    }
    sort(mid,mid+t);
    printf("%d\n",mid[0]);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = 46
for i in range(1, n):
    tmp = 0
    j = n - i
    while i > 0:
        tmp += i % 10
        i //= 10
    while j > 0:
        tmp += j % 10
        j //= 10
    ans = min(tmp, ans)
print(ans)

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

int main() {
    int N; cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
    }
    
    int M = 0, S = 0;
    for (int i = 0; i < N; i++) {
        M = max(M, L.at(i));
        S += L.at(i);
    }
    S -= M;
    
    if (M < S) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10;
char s[20];
int n,ans,p[maxn];
signed main()
{
	scanf("%lld",&n);
	for(register int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		int len=strlen(s+1);
		sort(s+1,s+len+1);
		for(register int j=1;j<=len;j++)
			p[i]=(p[i]*13331+s[j]-96)%9223372036854775807;
	}
	sort(p+1,p+n+1);
	int pre=-1,cnt=0;
	for(register int i=1;i<=n;i++)
		if(p[i]==pre)
			cnt++;
		else
		{
			ans+=cnt*(cnt-1)/2;
			cnt=1;
			pre=p[i];
		}
	ans+=cnt*(cnt-1)/2;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

void swap(int *x, int *y);

int main(void)
{
	int r[1000];
	int data[3];
	int n;
	int i;
	
	while (1){
		for (i = 0; i < 3; i++){
			scanf("%d", &data[i]);
		}
		if (data[0] > data[2]){
			swap(&data[0], &data[2]);
		}
		for (i = 0; i < 2; i++){
			if (data[i] > data[i + 1]){
				swap(&data[i], &data[i + 1]);
			}
		}
				
		if (data[0] == 0 && data[1] == 0 && data[2] == 0){
			break;
		}
		scanf("%d", &n);
		
		for (i = 0; i < n; i++){
			scanf("%d", &r[i]);
		}
		
		for (i = 0; i < n; i++){
			if ((r[i] * r[i] * 4) <= ((data[0] * data[0]) + (data[1] * data[1]))){
				printf("NA\n");
			}
			else {
				printf("OK\n");
			}
		}
	}
	
	return (0);
}

void swap(int *x, int *y)
{
	int tmp;
	
	tmp = *x;
	*x = *y;
	*y = tmp;
}

Measured memory_bytes: 584
(* O(√n) *)
let n = read_int () in
let f a b =
  let rec f acc n = if n = 0 then acc else f (acc + 1) @@ n / 10 in
  f 0 @@ max a b in
let m = int_of_float @@ sqrt @@ float n in
for i = 1 to m do
  let j = m - i + 1 in
  if n mod j = 0 then (f j @@ n / j |> Printf.printf "%d\n"; exit 0)
done

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



int main()
{
    int A, B;
    cin >> A >> B;
    int not_used = 1;
    int count = 0;
    while(true)
    {
        if(not_used >= B)
            break;

        not_used--;
        not_used += A;
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[6];
string s;
void C(int i,int j,int k,int l){
  int t;t=a[i];a[i]=a[j];a[j]=a[k];a[k]=a[l];a[l]=t;
}
int main(){
  for(int i=0;i<6;i++)cin>>a[i];
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='E')for(int j=0;j<3;j++)C(0,2,5,3);
    if(s[i]=='W')C(0,2,5,3);
    if(s[i]=='S')for(int j=0;j<3;j++)C(0,1,5,4);
    if(s[i]=='N')C(0,1,5,4);
  }
  cout<<a[0]<<endl;
}


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

int main()
{
    long long A, B, K;
    cin >> A >> B >> K;

    long long a = A;
    long long b = B;
    if (A < K) {
        a = 0;
        if (B < (K - A)) {
            b = 0;
        }
        else {
            b = B - (K - A);
        }
    }
    else {
        a = A - K;

    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

x, y = MAP()

if 0 <= x < y:
    ans = y - x
elif 0 <= y < x:
    ans = min(y+x+1, -y+x+2)
elif x <= 0 <= y:
    if abs(x) <= abs(y):
        ans = min(y-x, y+x+1)
    else:
        ans = min(y-x, -y-x+1)
elif y <= 0 <= x:
    if abs(x) <= abs(y):
        ans = - y - x + 1
    else:
        ans = y + x + 1
elif x < y <= 0:
    ans = y - x
elif y < x <= 0:
    ans = min(-y-x+1, -y+x+2)

print(ans)

Measured memory_bytes: 10300
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
	get_number(N),
    get_number(M),
    (N mod M =:= 0) -> writeln("0") ; writeln("1").


Measured memory_bytes: 8044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int,P> P3;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}



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

int main(){
    int a, b, c;
    int ans;
    cin >> a >> b >> c;

    ans = b/a;
    if(ans>=c){
        cout << c << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int mabs(int x)
{
    if (x >= 0) return x;
    else return -x;
}

int main()
{
    int x,a,b;

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

    int y = mabs(x - a);
    int z = mabs(x - b);

    if (y < z) printf("A");
    else printf("B");


    return 0;
}


Measured memory_bytes: 128
<?php

$is_honban = 1;

if ($is_honban) {
  //----------------------------------------------------------------------------------
  // Input for honban
  //----------------------------------------------------------------------------------
  $sc = new Scanner();
  $a = $sc->nextInt();
  $b = $sc->nextInt();
  $c = $sc->nextInt();
  $d = $sc->nextInt();
  $e = $sc->nextInt();
  $k = $sc->nextInt();

//  $t = array();
//  $d = array();
//  for ($i = 0; $i < $n; $i++) {
//    $t[] = $sc->next();
//    $d[] = $sc->next();
//  }


} else {
  //----------------------------------------------------------------------------------
  // Input for test
  //----------------------------------------------------------------------------------
  error_reporting(E_ERROR | E_WARNING | E_PARSE);

  $n = 8;
  $q = 3;
  $s = 'AABCBDBA';
  $t = array('A','B','A');
  $d = array('L','R','R');



}
//----------------------------------------------------------------------------------
// Main
//----------------------------------------------------------------------------------

$ans = 0;

$ans = ($e - $a <= $k ? "Yay!" : ":(");



//----------------------------------------------------------------------------------
// Output
//----------------------------------------------------------------------------------
out::println($ans);



//----------------------------------------------------------------------------------
// Ref: https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
//----------------------------------------------------------------------------------
class Scanner {
  private $arr = array();
  private $count = 0;
  private $pointer = 0;
  public function next() {
    if($this->pointer >= $this->count) {
      $str = trim(fgets(STDIN));
      $this->arr = explode(' ', $str);
      $this->count = count($this->arr);
      $this->pointer = 0;
    }
    $result = $this->arr[$this->pointer];
    $this->pointer++;
    return $result;
  }
  public function hasNext() {
    return $this->pointer < $this->count;
  }
  public function nextInt() {
    return (int)$this->next();
  }
  public function nextDouble() {
    return (double)$this->next();
  }
}

class out {
  public static function println($str = "") {
    echo $str . PHP_EOL;
  }
}

?>


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        char[] S = scanner.next().toCharArray();
        char[] T = scanner.next().toCharArray();

        int count = 0;
        if (S[0] == T[0]) count++;
        if (S[1] == T[1]) count++;
        if (S[2] == T[2]) count++;
        System.out.println(count);
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	//積としてありえるのは、1,2,3,...,10^8通り。
	// 全部10^9して考えても良いかも。そうすれば、2の数,5の数の和が18以上のやつだけ考えれば良い。1
	ll n;
	cin >> n;
	vector<vector<ll>> mas(21,vector<ll>(21,0));
	ll ans = 0;

	rep(i,n){
		string s;
		cin >> s;
		vector<int> neko(14,0);
		int ind = s.size(); 
		rep(j,s.size()){
			if(s[j] == '.'){
				ind = j;
			}
		}
		int k = 5;
		if(ind == -1){
			// 整数だから、neko[5]より後は全部0
			;
		} else {
			for(int j = ind + 1; j < s.size(); j++){
				neko[k] = s[j]-'0';
				k++;
			}
		}
		k = 4;
		for(int j = ind - 1; j >= 0; j--){
			neko[k] = s[j]-'0';
			k--;
		}
		ll tmp = 0;
		ll ten = 1;
		rep(j,14){
			tmp += neko[13-j] * ten;
			ten *= 10;
		}
		int ni = 0;
		int go = 0;
		while(tmp%2==0){
			ni++;
			tmp/=2;
		}
		while(tmp%5==0){
			go++;
			tmp/=5;
		}
		ni=min(18,ni);
		go=min(18,go);
		int needt = 18 - ni;
		int needg = 18 - go;
		for(int N = needt; N <= 18; N++){
			for(int G = needg; G <= 18; G++){
				ans += mas[N][G];
			}
		}
		mas[ni][go]++;
	}
	cout << ans << endl;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

unsigned long long gcd_extended(unsigned long long a, unsigned long long b, long long &x, long long &y)
{
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long x0, y0;
    unsigned long long d = gcd_extended(b, a % b, x0, y0);
    x = y0;
    y = x0 - a / b * y0;
    return d;
}

int main(void)
{
    long long a, b, x, y, x1, y1, x2, y2, d1, d2;
    cin >> a >> b;
    gcd_extended(a, b, x1, y1);
    if (x1 > 0) {
        x2 = x1 - b;
        y2 = y1 + a;
    } else {
        x2 = x1 + b;
        y2 = y1 - a;
    }
    d1 = abs(x1) + abs(y1);
    d2 = abs(x2) + abs(y2);
    if (d1 < d2) {
        x = x1;
        y = y1;
    } else if (d2 < d1) {
        x = x2;
        y = y2;
    } else if (x1 <= y1) {
        x = x1;
        y = y1;
    } else {
        x = y2;
        y = y2;
    }
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
const long long mod = 1000000007;
int main(){
    int n;
    scanf("%d",&n);
    long long a[n + 1];
    long long ans = 0, p;
    for(int i = 0; i < n; i++)
        scanf("%lld",&a[i]);
    for(int i = 0; i < 60; i++){
        long long x = 0;
        for(int j = 0; j < n; j++)
            if(a[j] >> i & 1)
                x ++;
        p = x * (n - x) % mod;
        for(int j = 0; j < i; j++)
            p = p * 2 % mod;
        ans += p;
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2560
N, K = map(int, input().split())
a = tuple(map(int, input().split()))

def main():
    l = [False] * (K+1)
    for i in range(a[0] -1, K+1):
        l[i] = any(not l[i-j] if i >= j else False for j in a)
    if l[-1]:
        print('First')
    else:
        print('Second')


main()


Measured memory_bytes: 3828
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 1005
const ll MOD=1e9+7;
using namespace std;

int main() {
  ll H,W;
  cin >> H >> W;
  if(H%3==0||W%3==0){
    cout << 0 << endl;
    return 0;
  }
  ll ans=max(H,W);
  ll a[3];
  if(H%3!=0){
    ans=min(ans,1*W);
  }
  if(W%3!=0){
    ans=min(ans,1*H);
  }
  for(ll i=1;i<H;i++){
    a[0]=i*W;
    if(W%2==0){
      a[1]=a[2]=(H-i)*(W/2);
    }else{
      a[1]=(H-i)*(W/2);
      a[2]=(H-i)*(W/2+1);
    }
    sort(a,a+3);
    ans=min(ans,a[2]-a[0]);
  }
  for(ll i=1;i<W;i++){
    a[0]=i*H;
    if(H%2==0){
      a[1]=a[2]=(W-i)*(H/2);
    }else{
      a[1]=(W-i)*(H/2);
      a[2]=(W-i)*(H/2+1);
    }
    sort(a,a+3);
    ans=min(ans,a[2]-a[0]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

using lint = long long;
using ll = pair < lint, lint >;

ll ms(lint n) {
	ll r;
	while (n) {
		r.first = n % 10;
		r.second++;
		n /= 10;
	}
	return r;
}

lint po(lint a, lint b) {
	lint r = 1;
	for (lint i = 0; i < b; i++) {
		r = r * a;
	}
	return r;
}

lint go(lint n) {
	if (n < 10)return n;
	ll t = ms(n);//가장 높은 자리, 전체 길이
	lint r = t.first - 1 + 9 * (t.second - 1);
	r = max(r, t.first + go(n - t.first * po(10,t.second - 1)));
	return r;
}

int main() {
	lint n;
	scanf("%lld", &n);
	if (n < 10) {
		printf("%lld", n);
	}
	else {
		printf("%lld\n", go(n));
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	b := make([]int, 2)
	l := len(a) - 1
	for i, _ := range a {
		b[i%2] += a[l-i]
	}
	fmt.Println(b[0] - b[1])
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

ll chk (ll p, vector<ll> w, int n, int k) { //何個まで運べるか
    int j = 0;
    rep (i, 0, k) {
        ll sum = 0;
        while (sum + w[j] <= p) {
            sum += w[j];
            j++;
            if (j == n) return j;
        }
    }
    return j;
}

ll solve (int n, vector<ll> w, int k) {
    ll left = 0, right = 1000000000;
    while (right - left > 1) {
        ll mid = (left + right) / 2;
        int v = chk (mid, w, n, k);
        if (v >= n) right = mid;
        else
            left = mid;
    }
    return right;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> w (n);
    rep (i, 0, n) cin >> w[i];
    int ans = solve (n, w, k);
    cout << ans << "\n";
}


Measured memory_bytes: 5272
#include <stdio.h>
#include <stdlib.h>

#define int long long
#define max_size (int)(2 * 1e5 + 1)

int main(){
	int i, j, N, ans = 1;
	char *A = (char *)malloc(sizeof(char) * max_size);
	scanf("%s", A);
	for(i = 0; A[i] != '\0'; i++){}
	N = i;
	int **sum = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		sum[i] = (int *)malloc(sizeof(int) * 26);
		for(j = 0; j < 26; j++){
			sum[i][j] = 0;
		}
	}
	for(i = 0; i < N; i++){
		sum[i][(int)A[i] - (int)'a']++;
	}
	for(i = 1; i < N; i++){
		for(j = 0; j < 26; j++){
			sum[i][j] += sum[i - 1][j];
		}
	}
	for(i = N - 1; i >= 0; i--){
		ans += i - sum[i][(int)A[i] - (int)'a'] + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 45696
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <iomanip>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#include <ios>
#include <cstdlib>
using namespace std;
int main() {
    int N,K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] = S[K-1] - 'A' + 'a';
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='+')a++;
		else b++;
	}
	cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n,m;
  cin>>n>>m;
  UnionFind uni(n+m);
  int k,l;
  REP(i,n){
    cin>>k;
    REP(j,k){
      cin>>l;
      l--;
      uni.connect(i,l+n);
    }
  }
  
  bool flag = true;
  int root;
  REP(i,n){
    if(i==0){
      root = uni.root(0);
    }else{
      if(root==uni.root(i)){
        continue;
      }else{
        flag = false;
        break;
      }
    }
  }
  
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<algorithm>
using namespace std;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
char str[15][10];
int UF[100];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		for(int i=0;i<12;i++)scanf("%s",str[i]);
		bool chg;
		int ret=0;
		do{
			chg=false;
			for(int i=0;i<72;i++)UF[i]=-1;
			for(int i=0;i<12;i++)for(int j=0;j<6;j++){
				if(str[i][j]=='.'||str[i][j]=='O')continue;
				for(int k=0;k<4;k++){
					if(0<=i+dx[k]&&i+dx[k]<12&&0<=j+dy[k]&&j+dy[k]<6&&str[i][j]==str[i+dx[k]][j+dy[k]]){
						UNION(i*6+j,(i+dx[k])*6+j+dy[k]);
					}
				}
			}
			for(int i=0;i<12;i++){
				for(int j=0;j<6;j++){
					if(str[i][j]=='.')continue;
					if(str[i][j]=='O'){
						for(int k=0;k<4;k++){
							if(0<=i+dx[k]&&i+dx[k]<12&&0<=j+dy[k]&&j+dy[k]<6&&UF[FIND((i+dx[k])*6+j+dy[k])]<=-4){
								str[i][j]='.';chg=true;
							}
						}
					}else{
						if(UF[FIND(i*6+j)]<=-4){str[i][j]='.';chg=true;}
					}
				}
			}
			for(int i=0;i<6;i++){
				int at=11;
				for(int j=11;j>=0;j--){
					if(str[j][i]!='.'){
						str[at--][i]=str[j][i];
					}
				}
				for(int j=0;j<=at;j++)str[j][i]='.';
			}
			if(chg)ret++;
			//for(int i=0;i<12;i++)printf("%s\n",str[i]);printf("\n");
		}while(chg);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)

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

    int d, a;
    set<int> s;
    for (int i=0; i<k; i++) {
        cin >> d;
        for (int j=0; j<d; j++) {
            cin >> a;
            s.insert(a);
        }
    }

    cout << n-s.size() << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

ll gcd(ll n,ll m){
    if(n%m==0) return m;
    else return gcd(m,n%m);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll g = gcd(N,M);
    cout << N/g*M << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;
int main() {
	int x[5];
	int index;
	rep(i,5){
		cin >> x[i];
		if(x[i]==0)
			index=i;
	}
	cout << index+1 << endl;

	return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <climits>
#include <algorithm>

using namespace std;

int main() {

	//先頭の数値（データ数）をnumに取得
	int num;
	cin >> num;

	int* R;

	R = new int[num];

	for (int i = 0; i < num; i++)
	{
		cin >> R[i];
	}

	int minValue = R[0];
	int maxValue = INT_MIN;

	for (int i = 1; i < num; i++)
	{
		maxValue = max(maxValue, R[i] - minValue);
		minValue = min(minValue, R[i]);

	}
	cout << maxValue << endl;

	delete[] R;

	return 0;
}


Measured memory_bytes: 3612
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10);
  const AN = input[1].split(' ').map((n) => {
    return parseInt(n,10);
  });
  let ans = 0;
  for (var i = 0; i < N; i++) {
    for (var j = 0; j < N; j++) {
      if (i === j) continue;
      let sub = Math.abs(AN[i] - AN[j]);
      ans = Math.max(ans,sub);
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32672
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main(){
	int r,g,b,n[6],p[8],q[8];
	char a[7];
	
	while(1){
		gets(a);
		if(a[0]=='0'){
			return 0;
		}
		for(int i=1;i<7;i++){
			if(a[i]=='0'){
				n[i-1]=0;
			}
			if(a[i]=='1'){
				n[i-1]=1;
			}
			if(a[i]=='2'){
				n[i-1]=2;
			}
			if(a[i]=='3'){
				n[i-1]=3;
			}
			if(a[i]=='4'){
				n[i-1]=4;
			}
			if(a[i]=='5'){
				n[i-1]=5;
			}
			if(a[i]=='6'){
				n[i-1]=6;
			}
			if(a[i]=='7'){
				n[i-1]=7;
			}
			if(a[i]=='8'){
				n[i-1]=8;
			}
			if(a[i]=='9'){
				n[i-1]=9;
			}
			if(a[i]=='a'){
				n[i-1]=10;
			}
			if(a[i]=='b'){
				n[i-1]=11;
			}
			if(a[i]=='c'){
				n[i-1]=12;
			}
			if(a[i]=='d'){
				n[i-1]=13;
			}
			if(a[i]=='e'){
				n[i-1]=14;
			}
			if(a[i]=='f'){
				n[i-1]=15;
			}
		}
		r=n[0]*16+n[1];
		g=n[2]*16+n[3];
		b=n[4]*16+n[5];
		
		p[0]=r*r+g*g+b*b;
		p[1]=r*r+g*g+(255-b)*(255-b);
		p[2]=r*r+(255-g)*(255-g)+b*b;
		p[3]=r*r+(255-g)*(255-g)+(255-b)*(255-b);
		p[4]=(255-r)*(255-r)+g*g+b*b;
		p[5]=(255-r)*(255-r)+g*g+(255-b)*(255-b);
		p[6]=(255-r)*(255-r)+(255-g)*(255-g)+b*b;
		p[7]=(255-r)*(255-r)+(255-g)*(255-g)+(255-b)*(255-b);
		
		for(int i=0;i<8;i++){
			q[i]=i;
		}
		for(int i=1;i<8;i++){
			for(int j=0;j<8-i;j++){
				if(p[j]>p[j+1]){
					r=p[j]; p[j]=p[j+1]; p[j+1]=r;
					b=q[j]; q[j]=q[j+1]; q[j+1]=b;
				}
			}
		}
		
		if(q[0]==0){
			cout << "black\n";
		}
		if(q[0]==1){
			cout << "blue\n";
		}
		if(q[0]==2){
			cout << "lime\n";
		}
		if(q[0]==3){
			cout << "aqua\n";
		}
		if(q[0]==4){
			cout << "red\n";
		}
		if(q[0]==5){
			cout << "fuchsia\n";
		}
		if(q[0]==6){
			cout << "yellow\n";
		}
		if(q[0]==7){
			cout << "white\n";
		}
	}
	
return 0;
}

Measured memory_bytes: 1084
from math import ceil
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

total = sum(b) - sum(a)

one = 0
two = 0
for i, j in zip(a, b):
  if i > j:
    one += i - j
  elif i < j:
    two += ceil((j - i) / 2)
    
if total >= one and total >= two:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 4596
// think twice code once
// Start:2016-12-12 11:02:48
// End  :
#include <bits/stdc++.h>
using namespace std;

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); T f = 1; a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}

template <class T> void write(T a) {
	static int stk[60]; 
	int tp = 0;
	if(a < 0) putchar('-'), a = -a;
	do {
		stk[++ tp] = a % 10;
		a /= 10;
	}while(a);
	
	while(tp) putchar(stk[tp--] + '0');
}

const int maxN = 3005, mo = 1e9 + 7;

int dp[maxN][maxN];
int N, M;
int a[maxN], b[maxN];
char s[maxN];

void move1(int l, int r) {
	int tot1 = 0;
	rep(i, l, r) tot1 += a[i];
	rep(i, l, l + tot1 - 1) a[i] = 1;
	rep(i, l + tot1, r) a[i] = 0;
}

void move2(int l, int r) {
	int tot0 = 0;
	rep(i, l, r) tot0 += b[i] == 0;
	rep(i, l, l + tot0 - 1) b[i] = 0;
	rep(i, l + tot0, r) b[i] = 1;
}

int main() {
#ifdef Leeson
	freopen("tmp.in", "r", stdin);
	freopen("tmp.out", "w", stdout);
#endif

	read(N); read(M);
	scanf("%s", s + 1);
	rep(i, 1, N) a[i] = b[i] = s[i] - '0';
	rep(i, 1, M) {
		int x, y;
		read(x); read(y);
		move1(x, y);
		move2(x, y);
	}

//	rep(i, 1, N) printf("%d", a[i]); puts("");
//	rep(i, 1, N) printf("%d", b[i]); puts("");

	rep(i, 1, N) a[i] += a[i - 1], b[i] += b[i - 1];

	dp[0][0] = 1;
	rep(i, 1, N) rep(j, b[i], a[i]) {
		dp[i][j] = dp[i - 1][j];
		if(j) dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mo;
	}
	cout << dp[N][a[N]] << endl;

	return 0;
}


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

int selectionSort(int A[], int N){
	int swap_cnt = 0, min_id, tmp;
	for (int i=0; i<N; i++){
		min_id = i;
		for (int j=i+1; j<N; j++){
			if (A[j] < A[min_id]) min_id = j;
		}
		if (min_id != i){
			tmp = A[min_id];
			A[min_id] = A[i];
			A[i] = tmp;
			swap_cnt++;
		}
	}
	return swap_cnt;
}

int main(){
	int A[100], N, swap_cnt;
	cin >> N;
	for (int i=0; i<N; i++) cin >> A[i];

	swap_cnt = selectionSort(A,N);

	for (int i=0; i<N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << swap_cnt << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n,d1,d2,n1,n2,c;
int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	while (d1%(1<<(n1+1))==0) n1++;
	while (d2%(1<<(n2+1))==0) n2++;
	for(int i=0;i<2*n&&c<n*n;i++){
    for(int j=0;j<2*n&&c<n*n;j++){
      if((n1%2==0?(i>>(n1/2))%2==(j>>(n1/2))%2:(i>>(n1/2))%2==0)
	 &&(n2%2==0?(i>>(n2/2))%2==(j>>(n2/2))%2:(i>>(n2/2))%2==0)){
	printf("%d %d\n",i,j);
	c++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>   
using namespace std;   
typedef long long ll;
ll n, ans, nlen;
void f(ll val, ll len) {
	if (val > n)
		return;
	if (len == nlen) {
		ll a3, a5, a7;
		a3 = a5 = a7 = 0;
		ll t = val, i = 0;
		while (t) {
			ll tt = t % 10;
			if (tt == 3)a3++;
			if (tt == 5)a5++;
			if (tt == 7)a7++;
			t/=10;
		}
		if (a3 == 0 or a5 == 0 or a7 == 0)
			return;
		else {
			//cout << val << endl;
			ans++;
		}
		return;
	}
	f(val*10+3, len+1);
	f(val*10+5, len+1);
	f(val*10+7, len+1);
}
ll numLen(ll v) {
	int t = 0;
	while (v) {
		t++;
		v/=10;
	}
	return t;
}
int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	//freopen("input.txt", "rt", stdin);
	cin >> n;
	nlen = numLen(n);
	
	for (ll i = nlen; i >= 3; i--) {
		f(0,0);
		ll vt = 0;
		for (ll j = 0; j < nlen-1; j++) {
			vt = vt*10 + 9;
		}
		n = vt;
		nlen--;
	}
	cout << ans << '\n';


	
	return 0;   
}  


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n, m, c;
    scanf("%d%d%d",&n,&m,&c);
    int b[m];
    int a[n][m];
    for(int i = 0; i < m; i++)
        scanf("%d",&b[i]);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            scanf("%d",&a[i][j]);
    int ans = 0;
    int sum;
    for(int i = 0; i < n; i++){
        sum = 0;
        for(int j = 0; j < m; j++)
            sum += a[i][j] * b[j];
        sum += c;
        if(sum > 0)
            ans ++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
/////////////////////////////////
//                             //
//           /(.^.)\           //
//                             //
/////////////////////////////////

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define BYTE unsigned char
#define DWORD unsigned int
#define QWORD unsigned long long
#define LL long long

//デバッグプリント
void xxxcoutxxx(int a, int f = 0)
{
    cout << a << " "; if (f) cout << endl;
    return;
}

//int L[2000];

//main
int main()
{
    int rtn = 0;
    
    int n;
    vector<int> L;

    cin >> n;

    int tmp;
    for (int i = 0; i < n; ++i)
    {
        cin >> tmp;
        //++L[tmp];
        L.push_back(tmp);
    }

    sort(L.begin(),L.end());

    ///////////////////////////////
    // for (int i = 0; i < n; ++i)
    // {
    //     cout << L[i] << " ";    
    // }
    // cout << endl;

    int A,B,C;
    for (int a = 0; a < n; ++a)
    {
        A = L[a];
        for (int b = a + 1 ; b < n; ++b)
        {
            B = L[b];
            for (int c = b + 1; c < n; ++c)
            {
                C = L[c];
                // xxxcoutxxx(A);
                // xxxcoutxxx(B);
                // xxxcoutxxx(C,1);

                if (A + B > C)
                {
                    ++rtn;
                } 
                else 
                {
                    break;
                }
            }
        }
    }

    cout << rtn;
    return 0;
    cout << "/(.^.)\\" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int max(int a,int b){
    int max = a;
    if (max < b){
        max = b;
    }
    return max;
}
int min(int a,int b){
    int min = a;
    if (min > b){
        min = b;
    }
    return min;
}
int main(){
    int A,B;
    int fir,sec;
    cin >> A >> B;
    fir = max(A,B);
    sec = max(fir-1,min(A,B));
    cout << fir+sec << endl;

}

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

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

  ll k, n;
  cin >> k >> n;

  vector<int> v(n+1);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  v.at(n) = v.at(0) + k;
  int dist = 0;
  for (int i = 0; i < v.size()-1; i++)
  {
    dist = max(dist, v.at(i+1) - v.at(i));
  }
  cout << k - dist << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll x;
	cin >> x;
	ll cur = 100;
	int cnt = 0;
	while(cur < x) cur += cur / 100, cnt++;
	cout << cnt << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
void fun()
{

}
/// check for test case before submitting
void vfun()
{
    ll n;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];
    sort(v.begin(),v.end());
    ll mincs=INT_MAX;
    for(ll k=-100;k<=100;k++)
    {
        ll cst=0;
         fo(i,n)
         {
             cst+=pow(abs(v[i]-k),2);
         }
         mincs=min(mincs,cst);
    }
    cout<<mincs;

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {

        ll n;
        cin>>n;
        ll a=sqrt(n);
        cout<<a*a<<endl;
        //fun();
       // vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int N,M;
    cin>>N>>M;
    int ans = (N*(N-1))/2 + (M*(M-1))/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	int n;
	cin>>n;
	if(n == 3 || n == 5 || n == 7)
		cout<<"YES";
	else
		cout<<"NO";

  	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
        using namespace std;
        #define mod 1000000000000000000
        #define MOD 		1000000007
        #define ll long long
        #define ull unsigned ll
        #define mp 		make_pair
        #define pb 		push_back
        #define forn(i,n) 	for(ll i=0;i<n;i++)
        #define for1(i,n) 	for(ll i=1;i<=n;i++)
        #define forn1(i,n) 	for(int i=1;i<n;i++)
        #define rep(i,x,n)  for(ll i=x;i<=n;i++)
        #define repr(i,x,j) for(ll i=x;i>=j;i--)
        #define vi vector<ll>
        #define mii map<ll,ll>
        #define vii vector<pair<ll,ll>>
        #define vvi vector<vector<ll>>
        #define pii pair<ll,ll>
        #define F first
        #define S second
        #define fill(a,x) memset(a,x,sizeof a);
        #define all(x) x.begin(),x.end()
        #define test ll t;cin>>t;while(t--)
        #define yes cout<<"YES"<<endl
        #define no cout<<"NO"<<endl
        #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll flag[100000];
        #define R return 0
        int main()
        {
          IOS;
          ll n,x,y;
          vi v,vs;
          cin>>n;
          forn(i,n)
          {
              cin>>x>>y;
              v.pb(x);
              vs.pb(y);
          }
          rep(i,0,n-3)
          {
              if(v[i]==vs[i]&&v[i+1]==vs[i+1]&&v[i+2]==vs[i+2])
              {
                  cout<<"Yes"<<endl;
                  R;
              }
          }
          cout<<"No"<<endl;
           R;

        }

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mod 998244353
#define int long long int
int gcd(int a,int b){
	return b==0 ? a : gcd(b,a%b);
}


int32_t main(){
    
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int t=1;
	// cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int a[k][2];
		for(int i=0;i<k;i++) cin>>a[i][0]>>a[i][1];
		vector<int> dp(n+1,0);
		vector<int> prev(n+1,0);
		dp[1]=1;
		prev[1]=1;
		for(int i=2;i<=n;i++){
			for(int j=0;j<k;j++){
				int l = i-a[j][0];
				int r = i-a[j][1]-1;
				if(l<=0){
					continue;
				}
				r=max(r,0LL);
				// cout<<i<<" "<<l<<" "<<r<<" "<<prev[l]-prev[r]<<endl;
				dp[i] = (dp[i]%mod + (prev[l]-prev[r])%mod + mod)%mod;
				// cout<<dp[i]<<endl;

			}
			prev[i]=(dp[i]%mod+prev[i-1]%mod + mod)%mod;
			// cout<<prev[i]<<" ";
		}
		cout<<dp[n]%mod<<endl;
		
	}	
}
// 1 1 1 2 4
// 1 2 3 5 9   



Measured memory_bytes: 6372