akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  cin>>s;
  vector<char>ch;
  vector<int>co;
  int c=0;
  rep(i,s.size()){
    c++;
    if(i==s.size()-1||s[i]!=s[i+1]){
      co.pb(c);
      ch.pb(s[i]);
      c=0;
    }
  }
  int out=0;
  if(ch.size()>2){
    rep(i,ch.size()-2){
      if(ch[i]=='J'&&ch[i+1]=='O'&&ch[i+2]=='I')
	if(co[i+1]<=co[i]&&co[i+1]<=co[i+2])
	  out=max(out,co[i+1]);
    }
  }
  cout<<out<<endl;	      
}

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

using namespace std;

const int maxn = 1e3+5;


int pos[maxn];
bool lef[maxn];
bool in[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    int game[maxn][maxn];
    for(int i=1;i<=n;i++)
    {
        pos[i] = 0;
        lef[i] = false;
        for(int j=0;j<n-1;j++)
            scanf("%d",&game[i][j]);
    }
    int team = n;
    int sum = 0;
    while(team)
    {
        sum++;
        bool con = false;
        //bool in[maxn] = {};
        //memset(in,false,sizeof in);
        for(int i=1;i<=n;i++)    in[i] = false;
        for(int i=1;i<=n;i++)
        {
            //cout << i << endl;
            if(in[i]||lef[i])   continue;
            int ne = game[i][pos[i]];
            if(in[ne]||lef[ne]) continue;
            //cout << i << "*" << ne << endl;
            in[i] = true;
            if(i==game[ne][pos[ne]])
            {
                in[ne] = true;
                pos[i]++;
                if(pos[i]==n-1)
                {
                    lef[i] = true;
                    team--;
                }
                pos[ne]++;
                if(pos[ne]==n-1)
                {
                    lef[ne] = true;
                    team--;
                }
                con = true;
            }
        }
        //for(int i=1;i<=n;i++)   cout << pos[i] <<endl;
        if(!con)
            break;
    }
    if(team)
        printf("-1\n");
    else
        printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 4224
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}
bool check(string s)
{
   string t;
   t=s;
   reverse(all(t));
   if(t==s) return true;
   else return false;
}
int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     string s;
     cin>>s;
     n=s.length();
     string a=s.substr(0,n/2);
     ll id=(n+3)/2;
     id--;
     string b=s.substr((n-1)/2+1);
     // cout<<a<<endl<<b<<endl;
     if(check(a)&&check(b)&&check(s)) cout<<"Yes";
     else cout<<"No";
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long[] x = new long[n + 1];

        int mod = 1000000007;

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
        }
        sc.close();

        long ans = 0;
        for (int i = 0; i < n - 1; i++) {
            ans += Math.min((x[i + 1] - x[i]) * a, b);
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 57916
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll a,b,n;
  cin >> n >> a >> b;
 
  if(abs(a-b)%2){
      ll ans=0;
      ans+=min(a-1,n-b);
      ans+=(b-a+1)/2;
      cout << ans << endl;
    }
  else{
    cout << abs(a-b)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  long long ans=1000000000;
  for(int j=-100;j<101;j++){
    long long count=0;
    for(int k=0;k<N;k++){
      count+=pow(A[k]-j,2);
    }
    ans=min(ans,count);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, card[4][13], t, i, j;
  string s;
  cin >>n;
  for(i=0; i<4; i++){
    for(j=0; j<13; j++) card[i][j]=1;
  }
  for(i=1; i<=n; i++){
    cin >>s >>t;
    if(s=="S")card[0][t-1] =0;
    if(s=="H")card[1][t-1] =0;
    if(s=="C")card[2][t-1] =0;
    if(s=="D")card[3][t-1] =0;
  }
  for(i=0; i<4; i++){
    for(j=0; j<13; j++){
      if(card[i][j]){
        if(i==0)cout <<"S "<<j+1<<endl;
        if(i==1)cout <<"H "<<j+1<<endl;
        if(i==2)cout <<"C "<<j+1<<endl;
        if(i==3)cout <<"D "<<j+1<<endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3144
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  int N,M,Q; cin >> N >> M >> Q;
  vector<string> s(N);
  vvl a(N,vl(M)),ns(N+1,vl(M+1));
  rep(i,N){
    cin >> s[i] ; 
    rep(j,M) a[i][j] = int(s[i][j]=='1');
  }
  rep(i,N) rep(j,M) ns[i+1][j+1] = ns[i+1][j] + a[i][j];
  rep(i,N) REP(j,1,M+1) ns[i+1][j] += ns[i][j];
  vvl es1(N+1,vl(M+1)),es2(N+1,vl(M+1));
  rep(i,N) rep(j,M-1) es1[i+1][j+2] += int(s[i][j]=='1' && s[i][j+1]=='1');
  rep(i,N-1) rep(j,M) es2[i+2][j+1] += int(s[i][j]=='1' && s[i+1][j]=='1');
  rep(i,N+1) rep(j,M) es1[i][j+1] += es1[i][j];
  rep(i,N) rep(j,M+1) es1[i+1][j] += es1[i][j];
  rep(i,N+1) rep(j,M) es2[i][j+1] += es2[i][j];
  rep(i,N) rep(j,M+1) es2[i+1][j] += es2[i][j];
  rep(i,Q){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2 ;
    x1--; y1--; x2--; y2--;
    ll e1 = es1[x2+1][y2+1] - es1[x2+1][y1+1] - es1[x1][y2+1] + es1[x1][y1+1];
    ll e2 = es2[x2+1][y2+1] - es2[x2+1][y1] - es2[x1+1][y2+1] + es2[x1+1][y1];
    ll n = ns[x2+1][y2+1] - ns[x2+1][y1] - ns[x1][y2+1] + ns[x1][y1];
    cout << n-e1-e2 << endl;
  }
  return 0;
}


Measured memory_bytes: 132480
#include<bits/stdc++.h>
#define __  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

int main()
{
    __

    int n,k,c;
    cin>>n>>k;
    c=n/2;
    if(n%2==1) c++;
    if(c>=k) cout<<"YES";
    else cout<<"NO";

    return 0;
}


Measured memory_bytes: 256
import sys

data = [0] * (4 * 3 * 10)

def get_index(b, f, r):
    return ((b - 1) * 3 + (f - 1)) * 10 + (r - 1)

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    data[get_index(b, f, r)] += v

for b in range(1, 5):
    for f in range(1, 4):
        for r in range(1, 11):
            sys.stdout.write(" %d" % data[get_index(b, f, r)])
        sys.stdout.write("\n")
    if b != 4:
        print("#" * 20)

Measured memory_bytes: 7696
import java.util.Scanner

fun main(args: Array<String>){
    val scn = Scanner(System.`in`) //Scannerのインスタンスを作成

    val n = scn.nextInt()
    val x = scn.nextInt()
    
    var boundNum = 0
    var distance = 0
    
    while(distance <= x && boundNum < n){
        boundNum++
        distance = distance + scn.nextInt()
    }
    if(distance <= x && boundNum == n){
        boundNum++
    }
    println(boundNum)
}

Measured memory_bytes: 29724
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7


n,d=mdata()
cnt=0
for i in range(n):
    p,q=mdata()
    if (p**2+q**2)**0.5<=d:
        cnt+=1
out(cnt)






Measured memory_bytes: 74616
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>
#include <functional>
#include <iomanip>

using namespace std;
using lint = long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<int>;
using pii = pair<int, int>;
using pll = pair<lint, lint>;
using pqi = priority_queue<int>;
using pql = priority_queue<lint>;
#define mii = map<int, int>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repf(i, f, n) for (int i = (f); i < (n); i++)
#define mp(x, y) make_pair((x), (y))
#define pb(x) push_back((x))
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define foreach(it, x) for (auto it = (x).begin(); it != (x).end(); it++)
#define space (char)0x20
#define yes "Yes"
#define no "No"

constexpr lint MOD = 1e9 + 7;
int A, B, C, D, E, F, G, H, I, J, K, L, M, N;
int O, P, Q, R, S, T, U, V, W, X, Y, Z;
// string s;
// int ans = 1;
int sum = 0;
const double PI = acos(-1);
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> N;
    
	cout << setprecision(20);
    cout << 2 * PI * N << endl;
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(20)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
const ll mod=1e9+7;
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};	
void solve(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(i&1 && x&1) ans++;
	}
	cout<<ans<<endl;
	
		
	
	
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3632
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("avx2")

#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define vs vector<string>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
#define des(x,s1,s2,end1,end2) cout<<((x)?(s1):(s2))<<fl;if(x){end1;}else{end2;}
#define precision(x) cout.setf(ios::fixed);cout.precision(x);
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

   int n;
   cin>>n;
   map<string ,int>mp;

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

   cout<<"AC x "<<mp["AC"]<<fl;
   cout<<"WA x "<<mp["WA"]<<fl;
   cout<<"TLE x "<<mp["TLE"]<<fl;
   cout<<"RE x "<<mp["RE"]<<fl;

return 0;}




Measured memory_bytes: 3664
/*input
3
2 1 2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll INF64=4e15;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
int sum[maxn],cnt[maxn],ans[maxn];
int main(){
    int n;
    cin>>n;
    REP(i,n){
        int a;
        cin>>a;
        ++sum[++cnt[a]];
    }
    int i=0;
    ll acc=0;
    for(int t=n;t>0;t--)
    {
        while(acc>=i*t)acc+=sum[++i];
        ans[t]=i-1;
    }
    REP(i,n) cout<<ans[i+1]<<'\n';
}


Measured memory_bytes: 3200
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }

  if (k == n) {
    println(1)
    return
  }

  val nn = (n-1).toDouble()
  val kk = (k-1).toDouble()
  val ans = Math.ceil(nn / kk)
  println(ans.toInt())


}


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

typedef long long ll;


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

    int N;

    char k[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

    cin >> N;

    queue<string> q;

    q.push("a");

    while(!q.empty()) {
        string x = q.front();
        q.pop();
        if(x.length() != N) {
            int max = x[0] - 'a';
            for(int i = 1; i < x.length(); i++) {
                if(x[i] - 'a' > max) max = x[i] - 'a';
            }
            for(int i = 0; i <= max + 1; i++) {
                q.push(x + k[i]);
            }
        } else {
            cout << x << endl;
        }
    }
}

Measured memory_bytes: 10624
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int a, b, c, d, e;
  vector<int> v;
  scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  v.push_back(d);
  v.push_back(e);
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i];
    if (i < v.size() - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3228
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;

int n,a[100005];

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	a[1]--;
	for(int i=2;i<=n;i++){
		if(a[i]<a[i-1]){
			printf("No\n");
			return 0;
		}
		else
		if(a[i]>a[i-1])
		a[i]--;
	}
	printf("Yes\n");
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n,0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int count=0,i=0;
    b[0]=1;
    while(true) {
        b[i]=0; b[a[i]-1]=1;
        i=a[i]-1;
        count++;
        if(b[1]==1){
            cout << count << endl;
            return 0;
        }
        if(count>n) break;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    ans=0
    cnt=0
    for i in reversed(range(N)):
        p,mod=divmod(A[i]+cnt,B[i])
        if mod==0:
            continue
        else:
            cnt+=B[i]-mod
    print(cnt)







resolve()

Measured memory_bytes: 42460
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s, s2;
    cin >> s;
    s2 = s;
    int c=0, d=0;

    for(int i=0;i<s.size()-1;i+=1) {
        if(s[i] == s[i+1]) {
            if(s[i]=='0') {
                s[i+1]='1';
            } else {
                s[i+1]='0';
            }
            c++;
        }
    }
    for(int i=s2.size()-1;i>=1;i-=1) {
        if(s2[i] == s2[i-1]) {
            if(s2[i]=='0') {
                s2[i-1]='1';
            } else {
                s2[i-1]='0';
            }
            d++;
        }
    }
    cout << min(c,d) << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#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 ll long long  
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
 
#define md          998244353
#define fmd         998244353 
#define M           3011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll F[M],IV[M];

ll dp[M][M];
ll chose(ll n,ll k){
	if(k>n)return 0;
	ll r=F[n];r=r*IV[k];r%=md;r=r*IV[n-k]%md;return r%md;
}
int solve(){
    ll n,i,j,k,m,x,y,z;
    ll s;
    cin>>n>>s;
    vector<ll> v;
    v.pb(0);
    for(i=1;i<=n;++i){
    	cin>>x;v.pb(x);
    }
    ll iv=exp(2,md-2);
    dp[0][0]=1;
    for(i=1;i<=n;++i){
    	for(j=0;j<=s;++j){
    		dp[i][j]+=dp[i-1][j];
    		if(j-v[i]>=0){
    			ll k=dp[i-1][j-v[i]];
    			k=k*iv;k%=md;
    			dp[i][j]+=k;
    		}
    		dp[i][j]%=md;
    	}
    }
    ll p=exp(2,n)*dp[n][s];
    cout<<p%md<<"\n";
 
 
 
 
 
    // trace(f(2,2));
 
 
 
	die();
 
}
void prec(){
	F[0]=IV[0]=1;
	for(int i=1;i<M;++i){
		F[i]=F[i-1]*i%md,F[i]%=md;
		IV[i]=IV[i-1]*exp(i,md-2)%md,IV[i]%=md;
	}
} 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
    int t;
    t=1;;
    prec();
    // cin>>t;
 
    while(t--){
 
        solve();
    }
 
 
 
 
 
 
#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 74292
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
   int a,b,c,d,e,k;
   cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k)
    cout<<":("<<endl;
  else
    cout<<"Yay!"<<endl;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 405
#define MAXM 100010
bool vis[MAXN][MAXN],liv[MAXN];
int x[MAXM],y[MAXM],n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++)
	{
		vis[i][i]=1,liv[i]=1;
		for(int j=m;j;j--)
		{
			if(vis[i][x[j]]&&vis[i][y[j]])
			{
				liv[i]=0;
				break;
			}
			if(vis[i][x[j]]) vis[i][y[j]]=1;
			else if(vis[i][y[j]]) vis[i][x[j]]=1;
		}
	}
	for(int i=1;i<n;i++)
	{
		if(!liv[i]) continue;
		for(int j=i+1;j<=n;j++)
		{
			if(!liv[j]) continue;
			int flag=1;
			for(int k=1;k<=n;k++)
				if(vis[i][k]&&vis[j][k])
				{
					flag=0;
					break;
				}
			ans+=flag;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
const int maxn = 10009;
int n,m,ans;
int a[maxn];
int main()
{
	cin>>n;
	cout<<"Christmas";
	if (n==24) cout<<" Eve";
        if (n==23) cout<<" Eve Eve";
	if (n==22) cout<<" Eve Eve Eve";
	cout<<endl;	  
	return 0;   
}

Measured memory_bytes: 256
#include<stdio.h>
enum{
	PARALLEL,
	NOT_PARALLEL
};

int parallel(float *xs, float *ys);

int main(void){
	float xs[4], ys[4];
	int n;
	scanf("%d", &n);
	while(n--){
		scanf("%f %f %f %f %f %f %f %f", &xs[0], &ys[0],&xs[1],&ys[1],&xs[2],&ys[2],&xs[3],&ys[3]);
		if(parallel(xs,ys)==PARALLEL) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

int parallel(float *xs, float *ys){
	float grad_a, grad_b;
	if(xs[0]==xs[1]){
		if(xs[2]==xs[3]){
			return PARALLEL;
		}
		return NOT_PARALLEL;
	}
	if(xs[2]==xs[3]){
		return NOT_PARALLEL;
	}
	grad_a = (ys[1]-ys[0]) / (xs[1]-xs[0]);
	grad_b = (ys[3]-ys[2]) / (xs[3]-xs[2]);
	if(grad_a == grad_b) return PARALLEL;
	return NOT_PARALLEL;
}

Measured memory_bytes: 616
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N; 
vector<int> G[101010];
map<pair<int, int>, int> mp;
int em[101010];

int k = 0;
void dfs(int u, int c, int p) {
    int i = 1;
    for (int v : G[u]) {
        if (v == p) continue;
        if (i == c) ++i;
        em[mp[make_pair(min(u, v), max(u, v))]] = i;
        k = max(k, i);
        dfs(v, i++, u);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
        mp[make_pair(a, b)] = i;
    }

    dfs(0, 0, -1);

    cout << k << endl;
    for (int i = 0; i < N-1; ++i) {
        cout << em[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 15744
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    string s; cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    int n = s.size();
    if(n < 26){
        vector<bool> used(26,false);
        rep(i,n){
            used[s[i]-'a'] = true;
        }
        rep(i,26){
            if(!used[i]){
                s += i+'a';
                break;
            }
        }
        cout << s << endl;
        return 0;
    }
    for(int i = n-1; i >= 1; i--){
        if(s[i] > s[i-1]){
            vector<bool> used(26,false);
            rep(j,i){
                used[s[j]-'a'] = true;
            }
            repr(j,s[i-1]-'a',26){
                if(!used[j]){
                    s[i-1] = j+'a';
                    break;
                }
            }
            rep(j,i) cout << s[j];
            cout << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  string S;
  cin >> S;
  for(int i=0;i<3;i++){
    if(S.at(i)=='7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
using namespace std;
#define ll long long
#define inf (999999999)
#define fi first
#define se second
#define MOD 1e9+7
#define PI acos(-1.0)
//--------------------------------------------------------------------------------------------------//
int n;
int df[100001];
int ds[100001];
bool pastf[100001];
bool pasts[100001];
vector<int> v[100001];
inline void bfs(int s,int dare) {
	for (int i = 0; i < 100001; i++) {
		pastf[i] = 0;
		pasts[i] = 0;
	}
	pastf[0] = 1;
	pasts[n - 1] = 1;
	queue<pair<int,int>> q;
	q.push(pair<int,int>(s, 0));
	while (!q.empty()) {
		int now = q.front().first;
		int cost = q.front().second;
		q.pop();
		if (dare == 1) {
			df[now] = cost;
		}
		else {
			ds[now] = cost;
		}
		int nowsize = (int)v[now].size();
		//cout <<"nowsize="<< nowsize << endl;
		//cout <<"now="<< now << endl;
		//cout <<"cost="<< cost << endl;
		//cout << "/-----------------/" << endl;
		for (int i = 0; i <v[now].size(); i++) {
			int next = v[now][i];
			//cout << "next=" << next << endl;
			if (dare == 1 && pastf[next]==0) {
				pastf[next] = 1;
				q.push(pair<int,int>(next, cost + 1));
			}
			if (dare != 1 && pasts[next]==0) {
				pasts[next] = 1;
				q.push(pair<int,int>(next, cost + 1));
			}
			else continue;
		}
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		int to, from; cin >> to >> from;
		to--; from--;
		v[to].push_back(from);
		v[from].push_back(to);
	}
	bfs(0, 1);
	//cout << "----------" << endl;
	bfs(n - 1, -1);
	int contf = 0;
	int conts = 0;
	for (int i = 0; i < n; i++) {
		//cout << "df=" << df[i] << "ds=" << ds[i] << endl;
		if (df[i] > ds[i]) {
			conts++;
		}
		else {
			contf++;
		}
	}
	if (contf > conts) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}
	return 0;
}

Measured memory_bytes: 6980
#include<iostream>
#include<math.h>
#include<stdlib.h>

using namespace std;

int v[5];
bool flag[5];

int dfs(int depth){
  if(depth == 5){
    return 0;
  }
  int ans = 100000000;
  for(int i = 0;i < 5;i++){
    if(flag[i] == 1)continue;
    flag[i] = 1;
    if(depth != 4){
      int cost = (v[i] + 9)/10;
      cost *= 10;
      ans = min(ans, dfs(depth+1) + cost);
    }else{
      ans = min(ans, dfs(depth+1) + v[i]);
    }
    flag[i] = 0;
  }
  return ans;
}

int main(){

  for(int i = 0;i < 5;i++){
    cin >> v[i];
    flag[i] = 0;
  }

  cout << dfs(0) << endl;
  

  return 0;
}


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

    # divisors.sort()
    return divisors

def main():
    Min = 2000000000000
    divisors = make_divisors(int(input()))
    if len(divisors)%2==1:
        divisors.append(divisors[len(divisors)-1])
    #print(divisors)
    for i in range(0,len(divisors)-1,2):
        Min = min(divisors[i]+divisors[i+1],Min)
    print(Min-2)

main()

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define MAX 100

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll s,w;
	cin>>s>>w;
	if(w>=s)
		cout<<"unsafe"<<endl;
	else cout<<"safe"<<endl;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long long n;
    long long a;
    long long b;
    long long hoge = 0;
    long long ans = 0;

    cin >> n;
    cin >> a;
    cin >> b;
    for (long long i = 1; i <= n; i++) {
        hoge = 0;
        long long j = i;
        while (j > 0) {
            hoge += j % 10;
            j /= 10;
        }
        if ((hoge >= a) && (hoge <= b)) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
long long gcd(long long a,long long b){
  if(b==0) return a;
  else return gcd(b,a%b);
}
int main(){
  long long A,B;
  cin>>A>>B;
  long long n=gcd(max(A,B),min(A,B));
  long long div=2;
  long long answer=1;
  while(div*div<=n){
    if(n%div==0){
      while(n%div==0) n=n/div;
      answer++;
    }
    div++;
  }
  if(n!=1) answer++;
  cout<<answer<<endl;
  
  return 0;
}

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

int main(){
  int N, K, x;
  cin >> N >> K;
  int L = 0;
  for (int i = 0; i<N; i++){
    cin >> x;
    if (K-x > x)
      L += x*2;
    else
      L += (K-x)*2;
  }
  cout << L <<endl;
}

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

using namespace std;

#define int long long

signed main(){
  set<int> s;
  int n;

  cin>>n;

  for(int i = 0; i < n; i++){
    int x;

    cin>>x;
    s.insert(x);
  }

  cout<<s.size()<<endl;
  return 0;
}


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

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

    multiset<ll> st;
    st.insert(a[0]);
    for (int i = 1; i < N; i++) {
        auto itr = st.lower_bound(a[i]);
        if (itr != st.begin()) {
            st.erase(--itr);
        }
        st.insert(a[i]);
    }

    cout << st.size() << endl;
}


Measured memory_bytes: 5376
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[200010];
map<ll, int> mp;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    rep(i, n) cin >> a[i+1];

    rep(i, n) {
        a[i+1]--;
    }
    rep(i, n) {
        a[i+1] += a[i];
        a[i+1] %= k;
    }

    rep(i, min(ll(n+1),k)) mp[a[i]]++;

    ll cnt = 0;

    rep(i, n+1){
        // for(auto v : mp) cout << v.first << " " << v.second << endl;
        cnt += mp[a[i]] - 1;
        mp[a[i]]--;
        if (i+k < n+1) mp[a[i+k]]++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a;
  cin >>a;
  cout <<fixed<<setprecision(8)<<a*a*acos(-1)<<" "<<fixed<<setprecision(8)<<a*2*acos(-1)<<endl;
  return 0;
}


Measured memory_bytes: 3244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int[] arrM = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int N = arrM[0];
        int M = arrM[1];
        int K = arrM[2];
        var uf = new UnionFind(N);
        var frend = new List<int>[N];
        var block = new List<int>[N];
        for (int i = 0; i < N; i++)
        {
            frend[i] = new List<int>();
            block[i] = new List<int>();
        }
        // 友達関係
        for (int i = 0; i < M; i++)
        {
            arrM = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var a = arrM[0] - 1;
            var b = arrM[1] - 1;
            frend[a].Add(b);
            frend[b].Add(a);
            uf.Union(a, b);
        }
        // ブロック関係
        for (int i = 0; i < K; i++)
        {
            arrM = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var c = arrM[0] - 1;
            var d = arrM[1] - 1;
            block[c].Add(d);
            block[d].Add(c);
        }
        for (int i = 0; i < N; i++)
        {
            if (i > 0) Console.Write(' ');

            // 同一グループのサイズから友達関係の数と自分自身の1を引く
            var ans = uf.Size(i) - frend[i].Count - 1;
            // 同一グループ内のブロック関係の数を引く
            foreach (var b in block[i])
            {
                if (uf.Same(i, b)) ans--;
            }
            Console.Write(ans);
        }
        Console.WriteLine();
    }

   

}

class UnionFind
{
    // 親要素のインデックスを保持する
    // 親要素が存在しない(自身がルートである)とき、マイナスでグループの要素数を持つ
    public int[] Parents { get; set; }
    public UnionFind(int n)
    {
        this.Parents = new int[n];
        for (int i = 0; i < n; i++)
        {
            // 初期状態ではそれぞれが別のグループ(ルートは自分自身)
            // ルートなのでマイナスで要素数(1個)を保持する
            this.Parents[i] = -1;
        }
    }

    // 要素xのルート要素はどれか
    public int Find(int x)
    {
        // 親がマイナスの場合は自分自身がルート
        if (this.Parents[x] < 0) return x;
        // ルートが見つかるまで再帰的に探す
        // 見つかったルートにつなぎかえる
        this.Parents[x] = Find(this.Parents[x]);
        return this.Parents[x];
    }

    // 要素xの属するグループの要素数を取得する
    public int Size(int x)
    {
        // ルート要素を取得して、サイズを取得して返す
        return -this.Parents[this.Find(x)];
    }

    // 要素x, yが同じグループかどうか判定する
    public bool Same(int x, int y)
    {
        return this.Find(x) == this.Find(y);
    }

    // 要素x, yが属するグループを同じグループにまとめる
    public bool Union(int x, int y)
    {
        // x, y のルート
        x = this.Find(x);
        y = this.Find(y);
        // すでに同じグループの場合処理しない
        if (x == y) return false;

        // 要素数が少ないグループを多いほうに書き換えたい
        if (this.Size(x) < this.Size(y))
        {
            var tmp = x;
            x = y;
            y = tmp;
        }
        // まとめる先のグループの要素数を更新
        this.Parents[x] += this.Parents[y];
        // まとめられるグループのルートの親を書き換え
        this.Parents[y] = x;
        return true;
    }
}



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

int main() {
	long long h,w,ans=LLONG_MAX,a,b,c;
	cin>>h>>w;
	for (int i=0; i<2; i++) {
		if(i) swap(h,w);
		for (int i=1; i<h; i++)
			a=i*w,
			b=max((h-i)*(w/2),((h-i)/2)*w),
			c=h*w-a-b,
			ans=min(ans,max({a,b,c})-min({a,b,c}));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int a;cin>>a;
	ll ans=1;
	rep(i,a){
	    ans*=i+1;
	    ans%=MOD;
	}
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;

int main(){
    int N,M,now = 0;
    long long int ans = 0;
    cin >> N >> M;
    vector<pair<int,int>> AB(N);
    for(int i=0;i<N;i++){
        pair<int,int> P;
        cin >> P.first >> P.second;
        AB[i] = P;
    }

    sort(AB.begin(),AB.end());
    priority_queue<int> Q;

    for(int i=1;i<=M;i++){
        while(now!=N && AB[now].first<=i){
            Q.push(AB[now].second);
            now++;
        }

        if(!Q.empty()){
            ans += Q.top();
            Q.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<string.h>
#define LEN 1000000
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head=1, tail=1,n;
 
void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == LEN){
    tail = 0;
  }
  else{ tail++;}
}
 
P dequeue(){
  P x;
  x = Q[head];
  if(head + 1 == LEN){
    head = 0;
  }
  else{ head++;}
  return x;
}
 
 
int main(){
  int elaps = 0, c=0;
  int i, q,a=0;
  scanf("%d %d", &n, &q);
 
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
  while(1){
    elaps++;
    if(n==c)break;
    if(Q[elaps].t - q > 0){
      a += q;
      Q[elaps].t -= q;
      enqueue(Q[elaps]);
    }
    else {
      a += Q[elaps].t;
      printf("%s %d\n",Q[elaps].name,a);
      c++;
      Q[elaps] = dequeue();
    }
  }
  return 0;
}

Measured memory_bytes: 21068
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int n=s.size();
	char c;
	for(int i=0;i<=n;i++){
		c=s[n-1];
		for(int j=n-1;j>0;j--){
			s[j]=s[j-1];
		}
		s[0]=c;
		if(s==t){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    // 値に対して個数を持つ。ペアとして使用する際に個数を数える。
    multiset<int> m;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m.insert(a);
    }

    // 大きい値から順に処理する
    while (!m.empty()) {
        auto it = --m.end();
        int x = *(it);
        m.erase(it);
        // xより大きい２のべき乗を作成
        // while (p <= x)
        //     p *= 2;
        uint32_t p = (1u << (32 - __builtin_clz(x)));

        int y = p - x; // ペアとなるyは1通り
        auto itr = m.find(y);
        if (itr != m.end()) {
            m.erase(itr);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9600
// #include <cstdio>
// #include <cstring>
// #include <cstdlib>
// #include <iostream>
#include <stdio.h>
#include<algorithm>
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    // int a[n];
    
    int MAX = 0, MIN = 1000000000;
    for(int i=0, x;i<n;i++){
        scanf("%d", &x);
        MAX = max(MAX, x);
        MIN = min(MIN, x);
        
    }

    // 確認用
    // for(int i=0;i<n;i++){
    //     printf("%d\n", a[i]);
    // }

    printf("%d\n", MAX-MIN);
    return 0;
}


// #include <iostream>
// #include <algorithm>
// using namespace std;
// #define INF 0x3f3f3f3f

// int main() {
// 	int n;
// 	cin>>n;	
// 	int Max=0,Min=INF;
// 	for (int i=1,x;i<=n;i++)
// 	{
// 		cin>>x;
// 		Max=max(Max,x);
// 		Min=min(Min,x);
// 	}
// 	cout<<Max-Min<<endl;
// 	return  0;
// }


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

int main(){
    int n, a[200000], b[200000], c[200000], dp[200000][5];
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];
    for(int i=2; i<=n; i++){
        dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + a[i];
        dp[i][2] = max(dp[i-1][3], dp[i-1][1]) + b[i];
        dp[i][3] = max(dp[i-1][1], dp[i-1][2]) + c[i];
    }
    cout << max({dp[n][1], dp[n][2], dp[n][3]}) << endl;
}

Measured memory_bytes: 5504
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make2(ll,n,m);
    vector <string> vec(n);
    fr(i,n) cin>>vec[i];
    vector <vector <ll> >dp(n,vector <ll>(m));
    dp[0][0]=(vec[0][0]=='#');
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(i==0 && j==0) continue;
            dp[i][j]=INF;
            if(vec[i][j]=='.'){
                if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]);
                if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]);
            }
            else{
                if(i>0){
                    if(vec[i-1][j]=='#') dp[i][j]=dp[i-1][j];
                    else dp[i][j]=min(dp[i][j],1+dp[i-1][j]);
                }
                if(j>0){
                    if(vec[i][j-1]=='#') dp[i][j]=min(dp[i][j],dp[i][j-1]);
                    else dp[i][j]=min(dp[i][j],1+dp[i][j-1]);
                }
            }

        }
    }
    cout<<dp[n-1][m-1]<<endl;



    return 0;
}


Measured memory_bytes: 3752