akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<iomanip>
#include<unordered_map>
#define deg(x) cerr<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=998244353;
const int inf=1e9+7;
const double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return (r+m)%m;}
//const double pi=acos(-1);
 
int main()
{
    TB
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll a1=a*c,a2=a*d,a3=b*c,a4=b*d;
	a1=max(a1,a2);a1=max(a1,a3);a1=max(a1,a4);
	cout<<a1<<'\n';
	return 0;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func toInt(value string) int {
	num, _ := strconv.Atoi(value)
	return num
}

func splitWithInt(value string) []int {
	vals := strings.Split(value, " ")
	nums := make([]int, len(vals))
	for index, elem := range vals {
		nums[index] = toInt(elem)
	}
	return nums
}

func main() {
	ins := splitWithInt(gets())
	fmt.Println(ins[0]*ins[1], (ins[0]+ins[1])*2)
}



Measured memory_bytes: 1092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  map<char, int> mp;
  rep(i, h) rep(i, w) {
    char c;
    cin >> c;
    mp[c]++;
  }
  if (h%2 && w%2) {
    for (auto& e : mp) {
      if (e.second%2) {
        e.second--;
        break;
      }
    }
  }
  int cnt = 0;
  for (auto& e : mp) {
    cnt += e.second/4;
    e.second %= 4;
  }
  if (cnt < (h/2*2)*(w/2*2)/4) {
    cout << "No" << endl;
    return 0;
  }
  for (auto& e : mp) {
    if (e.second%2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;
using ld = long double;

bool comp (pair<int, int> p1, pair<int, int> p2) {
	if (p1.first != p2.first) {	
		return p1.first < p2.first;
	}
	return p1.second < p2.second;
}

int main () {
	int n, m;
	cin >> n >> m;
	string st;	
	cin >> st;
	if (st[0] == '1' || st[n] == '1') {
		cout << "-1\n";
		return 0;
	}
	deque <pair<int, int>> q;
	int par[n + 1] = {}, ans[n + 1] = {};
	q.push_back (make_pair (0, n));
	for (int i = n - 1; i >= 0; i--) {
		while (q.size () && q.front ().second - i > m) {
			q.pop_front ();
		}
		if (st[i] == '0') {
			if (q.size ()) {
				par[i] = q.front ().second;
				pair<int, int> pp;
				pp.first = q.front ().first + 1;
				ans[i] = pp.first;
				pp.second = i;
				while (q.size () && comp (pp, q.back ())) {
					q.pop_back ();
				}
				q.push_back (pp);
			}
			else {
				cout << "-1\n";
				return 0;
			}
		}
	}
	if (par[0]) {
		int x = 0;
		while (x < n) {
			cout << par[x] - x << " ";
			x = par[x];
		}
	}
	else {
		cout << "-1";
	}
	cout << "\n";
}


Measured memory_bytes: 1408
#include <iostream>
#include<vector>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
unordered_set<string> set1;
unordered_set<string> set2;
void expand(string str, int low, int high, auto &set)
{
	while (low >= 0 && high < str.length()&& str[low] == str[high])
	{	
		set.insert(str.substr(low, high - low + 1));
		low--, high++;
	}
}

void all1(string str)
{
	for (int i = 0; i < str.length(); i++)
	{
		
		expand(str, i, i, set1);
		expand(str, i, i + 1, set1);
	}

}
void all2(string str)
{
	for (int i = 0; i < str.length(); i++)
	{
		
		expand(str, i, i, set2);
		expand(str, i, i + 1, set2);
	}

}
int main(){
   int a,b;
   cin>>a>>b;
   if(2*b>=a) cout<<0<<endl;
   else {
       int aa=abs(2*b-a);
       cout<<aa<<endl;
   }
    return 0;
}



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

int main(){
  int n, m, xx, yy;
  cin >> n >> m >> xx >> yy;
  int x[n], y[m];
  for(int i = 0; i < n; i++) cin >> x[i];
  for(int i = 0; i < m; i++) cin >> y[i];
  for(int z = xx + 1; z <= yy; z++){
    bool flag = true;
    for(int i = 0; i < n; i++) if(x[i] >= z) flag = false;
    for(int i = 0; i < m; i++) if(y[i] < z) flag = false;
    if(flag){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))
const long long MOD = 1e9 + 7;

int main() {
    ll n;
    string s;
    cin >> n >> s;
    mll dp(n, vll(n, 0));
    dp[0][0] = 1;
    for (int size = 1; size < n; size++) {
        char comparator = s[n - size - 1];
        if (comparator == '>') {
            ll cumulative = 0;
            for (int start = 1; start <= size; start++) {
                cumulative = (cumulative + dp[size - 1][start - 1]) % MOD;
                dp[size][start] = cumulative;
            }
        } else if (comparator == '<') {
            ll cumulative = 0;
            for (int start = size - 1; start >= 0; start--) {
                cumulative = (cumulative + dp[size - 1][start]) % MOD;
                dp[size][start] = cumulative;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
        ans = (ans + dp[n - 1][i]) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)
#define MOD (1000000007LL)

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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

#define vv(t) vector< vector< T > >
#define pb push_back
#define pu push
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define EQ(a,b) (abs((a)-(b))<EPS)

int n;
double dp[100001][21];

int main(void){
  ios_base::sync_with_stdio(0);
  while(cin >> n, n){
    memset(dp, 0, sizeof(dp));

    double e = 0.0;
    dp[1][1] = 1.0;

    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= min(i, 20); j++){
        e += dp[i][j] * pow(0.5, j - 1);
        if(j == 1){
          dp[i+1][j+1] += dp[i][j];
          continue;
        }
        dp[i+1][1] += dp[i][j] * (1.0 - pow(0.5, j - 1));
        dp[i+1][j+1] += dp[i][j] * pow(0.5, j - 1);
      }
    }
    cout << fixed << setprecision(8) << e << endl;
  }
  return 0; 
}

Measured memory_bytes: 17676
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int d,m = 0;
		for(int i = 0;i < n;i ++) {
			d = in.nextInt();
		    while(d % 2 == 0) {
		    	d /= 2;
		    	m ++;
		    }
		}
		System.out.println(m);
	}
}


Measured memory_bytes: 34004
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

string s;

int main(){
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i, n) if(s[i] == 'p') ans--;
  ans += n/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{

	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==7 && b==5 && c==5)
	{
	printf("YES");
	}
else if(a==7 && b==5 && c==5)
	{
	printf("YES");
	}
else if(b==7 && a==5 && c==5)
	{
	printf("YES");
}
else if(c==7 && a==5 && b==5)
	{
	printf("YES");
	}
else
{
	printf("NO\n");
}
	return 0;
}

Measured memory_bytes: 128
r,c = map(int,input().split())

spread = [[0]*(c+1) for _ in range(r+1)]

#number = input().split()

for k in range(r):
    number = input().split()
    for i in range(c):
        spread[k][i] = int(number[i])
        spread[k][i+1] = sum(spread[k])

for l in range(r):
    for m in range(c+1):
        spread[r][m] += spread[l][m] 

for n in range(r+1):
    print(*spread[n])


Measured memory_bytes: 6204
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,s;
const int mx=1000000000;
int main()
{
	scanf("%d%d%d",&n,&k,&s);
	for(int i=1;i<=k;i++)printf("%d ",s);
	for(int i=k+1;i<=n;i++)
	{
		if(s==1000000000)printf("1 ");
		else printf("1000000000 ");
	}
	return 0;
}

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

signed main(){
  lint N; cin >> N;
  for(lint h = 1; h <= 3500; h++){
    for(lint n = 1; n <= 3500; n++){
      lint x = N * h * n;
      lint y = 4 * h * n - N * n - N * h;
      if(y > 0 && x % y == 0){
        lint w = x / y;
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
}

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

struct UnionFind{
    vector<int> par;

    UnionFind(int N) : par(N){
        rep(i,N)par[i]=i;
    }

    int root(int x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }

    void unite(int x, int y){
        if(root(x)==root(y))return;
        par[root(x)]=root(y);
    }

    bool same(int x, int y){
        return root(x)==root(y);
    }
};

int main(){
    int n,q; cin>>n>>q;
    UnionFind tree(n);
    rep(i,q){
        int a; cin>>a;
        if(a==0){
            int x,y; cin>>x>>y;
            tree.unite(x,y);
        }
        if(a==1){
            int x,y; cin>>x>>y;
            cout<<tree.same(x,y)<<endl;
        }
    }
    return 0;
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const ll INF = 1LL<<60;

int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	
	vector<VI> c(3, VI(3));
	rep(i, 3) rep(j, 3) cin >>c[i][j];
	
	VI a(3), b(3);

	rep(i, 101) rep(j, 101) rep(k, 101){
		bool ng = false;
		a = VI{i, j, k};
		b[0] = c[0][0] - a[0];
		b[1] = c[0][1] - a[0];
		b[2] = c[0][2] - a[0];
		rep(p, 3) if(b[p]<0 || b[p]>100) ng=true;
		if(ng) continue;
		
		rep(p, 3) rep(s, 3) if(a[p] + b[s] != c[p][s]) ng =true;
		if(ng) continue;
	
		puts("Yes");
		return 0;
	}

	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    for(int i=0; i<Q; i++){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--; B[i]--;
    } 
    vector<vector<int>> V[11];
    for(int i=1; i<=M; i++) V[1].push_back({i});
    for(int i=1; i<N; i++) for(auto& v : V[i]){
        int b = v.back();
        for(int a=b; a<=M; a++){
            auto v2 = v;
            v2.push_back(a);
            V[i+1].push_back(v2);
        }
    } 
    int ans = 0;
    for(auto& v : V[N]){
        int res = 0;
        for(int i=0; i<Q; i++) if(v[B[i]] - v[A[i]] == C[i]) res += D[i];
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N, K;
	cin >> N >> K;
	int now = 1;
	rep(i,0,N){
		now = min(2*now, now+K);
	}
	cout << now << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,t;
	cin>>n>>t;
	int minc,f=0;
	for(int i=0;i<n;i++){
		int c,tt;
		cin>>c>>tt;
		if(tt<=t){
			if(f==0){
				minc=c;
				f=1;
			}
			else{
				minc=min(minc,c);
			}
		}
	}
	if(f==0)
		cout<<"TLE"<<endl;
	else 
		cout<<minc<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String[] d = new String[k];
        for (int i=0;i<k;i++){
            d[i]=sc.next();
        }
        boolean b = true;
        while (b){
            String[] s = Integer.toString(n).split("");
            boolean c = true;
            for (int i=0;i<s.length&&c;i++){
                for (int j=0;j<k&&c;j++){
                    if (s[i].equals(d[j]))c=false;
                }
            }
            if (c){
                b=false;
                System.out.println(n);
            }
            n++;
        }
    }
}

Measured memory_bytes: 59156
#include <iostream>
using namespace std;
int main () {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a <= k) {
    cout << "Yay!" << endl;
  }else {
    cout << ":(" << endl;
  }
  return 0;
}

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

using namespace std;

static const int prime_n = 10000;
static bool sieve[prime_n];

vector<int> primes;

void init_primes(){
    sieve[0] = true;
    sieve[1] = true;
    for(int i = 2; i < prime_n; i++){
        if(!sieve[i]){
            for(int j = i*i; j < prime_n; j+=i){
                sieve[j] = true;
            }
        }
    }
    primes = vector<int>();
    for(int i = 2; i < prime_n; i++){
        if(!sieve[i]){
            primes.push_back(i);
        }
    }
}

bool isPrime(int n){
    if(n < prime_n){
        return !sieve[n];
    }
    for(auto p: primes){
        if(n%p == 0){
            return false;
        }
    }
    return true;
}

int main(){
    init_primes();
    int n;
    cin >> n;
    int c = 0;
    int x = 0;
    while(n--){
        cin >> x;
        if(isPrime(x)){
            ++c;
        }
    }
    cout << c << '\n';
    return 0;
}

Measured memory_bytes: 1236
n = int(input())
lst = ["a"]
abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
for i in range(n - 1):
    lst_ = lst
    lst = []
    for s in lst_:
        for t in abc[: len(set(s)) + 1]:
            lst.append(s + t)
for s in lst:
    print(s)


Measured memory_bytes: 14172
import sys

# N 数字の数
n = int(input())

# An お姉ちゃんの言う数字
a = [int(input()) for i in range(n)]

dic = {}

for i in a:
    if i in dic.keys():
        # あるので削除する
        dic.pop(i)
    else:
        dic[i] = i
        
print(len(dic))

Measured memory_bytes: 16272
#include <stdio.h>
#include <stack>

int main(){
	std::stack<int> st;

	int n;

	while(scanf("%d", &n) != EOF){
		if(n == 0){
			printf("%d\n", st.top());
			st.pop();
		}
		else{
			st.push(n);
		}
	}

	return 0;
}
		
	

Measured memory_bytes: 1036
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a[7],b[7];
cin>>a[0]>>b[0];
cin>>a[1]>>b[1];
cin>>a[2]>>b[2];
cin>>a[3]>>b[3];
cin>>a[4]>>b[4];
cin>>a[5]>>b[5];
cin>>a[6]>>b[6];
cout<<a[0]-b[0]<<endl;
cout<<a[1]-b[1]<<endl;
cout<<a[2]-b[2]<<endl;
cout<<a[3]-b[3]<<endl;
cout<<a[4]-b[4]<<endl;
cout<<a[5]-b[5]<<endl;
cout<<a[6]-b[6]<<endl;
         return 0;
      }

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||
 
    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
 
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}
 
 
     int solve()
     {
        int w,h,x,y;
        cin>>w>>h>>x>>y;
        float ans=(w*h)/2.0;
        cout<<ans<<" "<<(w==2*x&&(h==2*y))?1:0;
         
     }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 384
#include<iostream>
 
using namespace std;
 
int main()
{
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	int dx=x2-x1;
	int dy=y2-y1;
	int x3=x2-dy,y3=y2+dx,x4=x1-dy,y4=y1+dx;
	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
int a,b,c,d;
bool i[100];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a;
  cin >>s>>w;
  for(int n=0;n<a;n++){
    cout <<s[n]<<w[n];
  }
  cout <<'\n';
  
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define fgx cerr<<"-------------"<<endl
#define N 666
#define add(a,b,c,d) adde(a,b,c,d),adde(b,a,0,-(d))
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,ll> pii;
void dbg(){cerr<<endl;}
template<typename A,typename... B>void dbg(A x,B... y){cerr<<x<<" ";dbg(y...);}
#define debug(...) cerr<<#__VA_ARGS__<<"=",dbg(__VA_ARGS__)
int T,tot,head[N],vis[N],pre[N],xl[N],xr[N],yl[N],yr[N],n,m; ll dis[N]; char c[10];
struct Edge{int u,v,w,f,next;ll c;}edge[N*N];
inline void adde(int x,int y,int w,ll c){edge[++tot]=Edge{x,y,w,0,head[x],c};head[x]=tot;}
inline int spfa()
{	for(rint i=0;i<=T;i++) dis[i]=-1e18; queue<int> q; q.push(0); dis[0]=0; pre[T]=-1;
	while(!q.empty())
	{	int x=q.front(); vis[x]=0; q.pop();
		for(rint i=head[x];i;i=edge[i].next)
		if(dis[to]<dis[x]+edge[i].c&&edge[i].f<edge[i].w)
		{	dis[to]=dis[x]+edge[i].c; pre[to]=i;
			if(!vis[to])q.push(to),vis[to]=1;
		}
	}
	return pre[T]!=-1;
}
inline pii mcmf(int f=0,ll c=0)
{	while(spfa())
	{	int mn=1e9; for(rint i=pre[T];i;i=pre[edge[i].u]) mn=min(mn,edge[i].w-edge[i].f);
		f+=mn; c+=dis[T]*mn; for(rint i=pre[T];i;i=pre[edge[i].u]) edge[i].f+=mn,edge[i^1].f-=mn;
	}
	return mp(f,c);
}
struct P{int x,y;ll v;}p[N]; struct Q{char c;int x,y;}q[N];
inline ll gao(int k)
{	for(rint i=0;i<=k+1;i++) xl[i]=yl[i]=1,xr[i]=yr[i]=100;
	for(rint i=1;i<=m;i++)
	if(q[i].c=='L'&&q[i].y!=100) xl[q[i].y+1]=max(xl[q[i].y+1],q[i].x+1);
	else if(q[i].c=='R'&&k>q[i].y) xr[k-q[i].y]=min(xr[k-q[i].y],q[i].x-1);
	else if(q[i].c=='D'&&q[i].y!=100) yl[q[i].y+1]=max(yl[q[i].y+1],q[i].x+1);
	else if(q[i].c=='U'&&k>q[i].y) yr[k-q[i].y]=min(yr[k-q[i].y],q[i].x-1);
	for(rint i=1;i<=k;i++) xl[i]=max(xl[i],xl[i-1]),yl[i]=max(yl[i],yl[i-1]);
	for(rint i=k;i>=1;i--) xr[i]=min(xr[i],xr[i+1]),yr[i]=min(yr[i],yr[i+1]);
	tot=1; memset(head,0,sizeof(head));
	for(rint i=1;i<=k;i++) add(0,i,1,0);
	for(rint i=1;i<=k;i++) for(rint j=xl[i];j<=xr[i];j++) add(i,k+j,1,0);
	for(rint i=1;i<=n;i++) add(k+p[i].x,k+100+p[i].y,1,p[i].v);
	for(rint i=1;i<=k;i++) for(rint j=yl[i];j<=yr[i];j++) add(k+100+j,k+200+i,1,0);
	T=2*k+201; for(rint i=1;i<=k;i++) add(k+200+i,T,1,0);
	pii ans=mcmf(); return ans.first==k?ans.second:0;
}
int main()
{	cin>>n; for(rint i=1;i<=n;i++) scanf("%d%d%lld",&p[i].x,&p[i].y,&p[i].v);
	cin>>m; for(rint i=1;i<=m;i++) scanf("%s%d%d",c+1,&q[i].x,&q[i].y),q[i].c=c[1];
	ll ans=0; for(rint i=1;i<=n;i++) ans=max(ans,gao(i)); cout<<ans;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

void TentoAny(LL num,int k)//十进制数转化为 k进制(2<=k<=36)
{
	vector<char> v;//不定长数组
	LL t;//余数 
	while(num)
	{
		t=num%k;
		if(t>=10)v.push_back((char)('A'+t-10));//向尾部添加元素
		else v.push_back((char)(t+'0'));
		num/=k;
	}
	int ans=0;
	for(int i=v.size()-1;i>=0;i--)//先算出来的余数最后输出（逆序列）
		++ans;
	cout<<ans;
}
int main()
{
	LL n;
	int k;
	cin>>n>>k;
	TentoAny(n,k);
	return 0;
}


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

using namespace std;

int res;

int main() {

    int N;
    cin >> N;

    vector<int> v(N);
    vector<int> c(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

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

    vector<int> vp;
    for (int i = 0; i < N; i++)
        vp.push_back(v[i] - c[i]);
    
    
    int res = 0;
    for (auto &i : vp)
        if (i > 0)
            res += i;
    cout << res << '\n'; 
    return 0;
}


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

int main(){
int N, Q;
string S;
  cin >> N >> Q >> S;
int c[N];
c[0] = 0;
  for(int i = 0;i < N - 1;i++){
  if((S.at(i) == 'A') && (S.at(i+1) == 'C')){
  c[i + 1] = c[i] + 1;
  }
    else{
      c[i + 1] = c[i];
    }
  }
  while(Q){
  int l, r;
    cin >> l >> r;
    cout << c[r -1] - c[l - 1] << endl;
    Q--;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,m,i,j,sum=0,ans=0;
    vector<pair <ll,ll> >arr;
    cin>>n>>m;
    ll a[n],b[n];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
        arr.push_back(make_pair(a[i],b[i]));
    }
    sort(arr.begin(),arr.end());
    for(i=0;i<n;i++){
        if(sum==m)
            break;
        else if(sum>m){
            ans=ans-(sum-m)*arr[i-1].first;
            sum=m;
            break;
        }
        else{
            ans+=(arr[i].second*arr[i].first);
            sum+=arr[i].second;
        }
    }
    if(sum!=m){
        ans=ans-(sum-m)*arr[n-1].first;
        sum=m;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3568
n = int(input())


def div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


ans = 0
for i in range(1, n+1):
    k = n//i
    if 1 < k:
        ans += i*k*(k+1)//2
    else:
        ans += (n+i)*(n-i+1)//2
        break

print(ans)


Measured memory_bytes: 63484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            for (int i = 1; i <= 100; ++i) {
                if ((b * i + c) % a == 0) {
                    out.println("YES");
                    return;
                }
            }
            out.println("NO");
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b; a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int Q;
	cin >> Q;
	vector<vector<int>> dp(N, vector<int>(11, -1));
	vector<int> d(Q), c(Q);
	for (int i = 0; i < Q; i++) {
		int v;
		cin >> v >> d[i] >> c[i]; v--;
		dp[v][d[i]] = i;
	}
	for (int i = 0; i < 10; i++) {
		auto tmp = dp;
		for (int v = 0; v < N; v++) {
			for (auto to : G[v]) {
				for (int j = i + 1; j <= 10; j++) {
					dp[v][j] = max(dp[v][j], tmp[to][j]);
				}
			}
		}
	}
	for (int i = 0; i < N; i++) {
		int id = *max_element(dp[i].begin(), dp[i].end());
		printf("%d\n", id != -1 ? c[id] : 0);
	}
	return 0;
}


Measured memory_bytes: 24152
n,k,q,*a=map(int,open(0).read().split())
s=sorted
m=1e9
for b in a:
 i=[i for i,t in enumerate(a)if t<b];l=s(sum([s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])],[]))
 if len(l)>=q:m=min(m,l[q-1]-b)
print(m)

Measured memory_bytes: 115036
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  while(1){
    int n, x; cin >> n >> x;
    if(!n && !x) break;
    int ans = 0;
    rep2(i, 1, n+1){
      rep2(j, i+1, n+1){
        if(i == j) continue;
        rep2(k, j+1, n+1){
          if(i == k || j == k) continue;
          if(i + k + j == x){
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
}  



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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

int N;
const int maxn = 2e5+5;
int B[maxn];
int A[maxn];

int main()
{
    cin >> N;
    _rep(i,1,N) cin >> B[i];
    int k = 0;
    for(int i = N; i >= 1;i--){
        int sum = 0;
        for(int j = i*2; j<= N;j+=i){
            sum += A[j];
        }
        sum%=2;
        A[i] = sum^B[i];
        if(A[i]) k++;
    }
    cout << k << endl;
    int first = true;
    _rep(i,1,N){
        if(!first) printf(" ");
        else first = false;
        if(A[i]) printf("%d",i);
    }

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <set>

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  map<char, int> mp[n];
  map<map<char, int>, ll> a;

  string str;
  rep(i, n) {
    cin >> str;
    rep(j, str.length()) { ++mp[i][str[j]]; }
  }

  rep(i, n) { ++a[mp[i]]; }

  ll ans = 0;
  for (auto p : a) { ans += p.second * (p.second - 1) / 2; }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 93312
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans[200010];
	ll N,A[200010];
	multimap<int,int> M;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	REP(i,N){
		cin>>A[i];
		M.insert({A[i],i});
	}
	sort(A,A+N);
	int cnt=0;
	for(auto x:M){
		DEB(x.first)DEB(x.second)DEB(A[N/2-1])DEB(A[N/2])END
		if(cnt>=N/2){
			ans[x.second]=A[N/2-1];
		}else{
			ans[x.second]=A[N/2];
		}
		cnt++;
	}
	REP(i,N)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 14720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	r := getNextInt(scanner)
	c := getNextInt(scanner)
	k := getNextInt(scanner)
	g := makeGrid(r+1, c+1)
	for i := 0; i < k; i++ {
		rr := getNextInt(scanner) - 1
		cc := getNextInt(scanner) - 1
		v := getNextInt64(scanner)
		g[rr][cc] = v
	}
	dp := make([][][4]int64, r+1)
	for i := 0; i < r+1; i++ {
		dp[i] = make([][4]int64, c+1)
	}
	dp[0][0][1] = g[0][0]
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			for p := 0; p < 4; p++ {
				dp[i][j+1][p] = max(dp[i][j+1][p], dp[i][j][p])
				dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][p])
				dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][p]+g[i+1][j])
				if p+1 < 4 {
					dp[i][j+1][p+1] = max(dp[i][j+1][p+1], dp[i][j][p]+g[i][j+1])
				}
			}
		}
	}
	var ans int64
	for i := 0; i < 4; i++ {
		ans = max(ans, dp[r-1][c-1][i])
	}
	fmt.Fprintln(writer, ans)
}

func makeGrid(h, w int) [][]int64 {
	index := make([][]int64, h, h)
	data := make([]int64, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}
func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 373668
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let h = read::<i64>();
  let w = read::<i64>();

  let mut ans = 10000000;

  for i in 1..w {
    let a = h * i;

    // 縦方向に2分割
    let b1 = h * (((w - i) + (w - i) % 2) / 2);
    let c1 = h * (((w - i) - (w - i) % 2) / 2);
    let max1_v = max(a, max(b1, c1));
    let min1_v = min(a, min(b1, c1));
    ans = min(max1_v - min1_v, ans);

    // 縦方向 -> 横方向
    let b2 = (w - i) * ((h + (h % 2)) / 2);
    let c2 = (w - i) * ((h - (h % 2)) / 2);
    let max2_v = max(a, max(b2, c2));
    let min2_v = min(a, min(b2, c2));
    ans = min(max2_v - min2_v, ans);
  }

  for i in 1..h {
    let a = w * i;

    // 横方向に2分割
    let b1 = w * (((h - i) + (h - i) % 2) / 2);
    let c1 = w * (((h - i) - (h - i) % 2) / 2);
    let max1_v = max(a, max(b1, c1));
    let min1_v = min(a, min(b1, c1));
    ans = min(max1_v - min1_v, ans);

    // 横方向 -> 縦方向
    let b2 = (h - i) * ((w + (w % 2)) / 2);
    let c2 = (h - i) * ((w - (w % 2)) / 2);
    let max2_v = max(a, max(b2, c2));
    let min2_v = min(a, min(b2, c2));
    ans = min(max2_v - min2_v, ans);
  }

  println!("{}", ans);
}


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

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

vector<ll> pw2(51,1);

vector<ll>ans(33,0);
void solve(ll x){
	if(x==0) return;
	if(x<0){
		ll i=-1;
		ll tmp=0;
		while(tmp>x){
			i+=2;
			tmp-=pw2[i];
		}
		ans[i]=1;
		solve(x+pw2[i]);
	}
	else{
		ll i=-2;
		ll tmp=0;
		while(tmp<x){
			i+=2;
			tmp+=pw2[i];
		}
		ans[i]=1;
		solve(x-pw2[i]);
	}
}

//a,b x
int main(){
	rep1(i,50) pw2[i]=2*pw2[i-1];
    ll N; cin>>N;
	/*
	-32 16 -8 4 -2 1

	-6:1110  ooox
	-5:1111  oooo
    -4:1100  ooxx
	-3:1101  ooxo
	-2:  10  xxox
	-1:  11  xxoo
	0:    0  xxxx
    1:    1  xxxo
	2:  110  xoox
	3:  111  xooo
	4:  100  xoxx
	5:  101  xoxo
	6:11010 ooxox

	*/
	if(N==0) cout<<0;
	else if(N==1) cout<<1;
	else{
		solve(N);
		ll flag=false;
		for(int i=32;i>=0;i--){
			if(!flag && ans[i]==1) flag=true;

			if(flag) cout<<ans[i];
		}
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	char N[4];
	int i;
	for (i = 0; i < 4; i++) {
		cin >> N[i];
	}
	if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
		cout << "Yes";
	}
	else { cout << "No"; }
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	cout<<"ABC"<<n<<endl;
}

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

int main()
{
	string s;cin>>s;
	int l = 1e9,r = s.length()-1;
	for(int i = 0; i<r; i++)if(s[i+1]!=s[i])l = min(l,max(i+1,r-i));
	cout<<(l==1e9?r+1:l);
	return 0;
}

Measured memory_bytes: 512
X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(X[K - 1])


Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	ans := 10000

	for i := 0; i <= len(s)-len(t); i++ {
		c := 0
		for j := 0; j < len(t); j++ {
			if s[i+j] != t[j] {
				c++
			}
		}
		ans = min(ans, c)
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define mx 1000000007
#define ll long long int

using namespace std;

ll visited[100010]={0},dp[100010]={0};

ll dfs(ll node,vector< vector <ll >> &adlist){
    if(visited[node]==1)
        return dp[node];
    visited[node]=1;
    if(adlist[node].size()==0)
    	return 0;
    ll maxi=0;
    for(ll i: adlist[node]){
        ll tmp=dfs(i,adlist);
        if(tmp>maxi)
            maxi=tmp;
    }
    return dp[node]=(1+maxi);
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m;
    cin >> n >> m ;
    vector< vector < ll > > adlist(n+1);
    for(ll i=0;i<m;++i){
        ll u,v;
        cin>> u >> v;
        adlist[u].push_back(v);
    }
    for(ll i=1;i<=n;++i){
        if(visited[i]==0)
            dp[i]=dfs(i,adlist);
    }
    ll ans=0;
    for(ll i=0;i<=n;++i){
        if(ans<dp[i])
            ans=dp[i];
    }
    cout<< ans ;
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n + 2);
  a[0] = k;
  for (int i = 1; i <= q; i++) {
    int t; cin >> t;
    a[1] += -1;
    a[t] +=  1;
    a[t + 1] += -1;
  }
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    if (a[i] <= 0) {
      cout << "No" << '\n';
    } else {
      cout << "Yes" << '\n';
    }
  }
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 



int main() {
	int ans = -1;
	int N; cin >> N;
	string S; cin >> S;

	int b[N+2] = {};//i以下に存在する黒石の数
	int w[N+2] = {};//i以上に存在する白石の数
	int a = 0;
	for (int i = 0; i < N; i++)
	{
		if(S[i] == '#'){a++;}
		b[i]=a;
	}
	a = 0;
	for (int i = N-1; 0 <= i; i--)
	{
		if(S[i] == '.'){a++;}
		w[i] = a;
	}

	for (int i = 0; i < N; i++)
	{
		int n_ans = b[i] + w[i+1];
		if(ans == -1 or n_ans < ans){ans = n_ans;}
	}
	ans = min(abs(b[N-1]-N),ans);//全てを黒で塗るケース
	//ans = min(abs(w[0]-N),ans);//全てを白で塗るケース
	

	cout << ans << endl;
	}


Measured memory_bytes: 2180