akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
bool check(string s)
{
    string res = s;
    reverse(all(res));

    return (res==s);
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    string s;
    cin>>s;
    int flag=0;
    if(!check(s))
        flag++;
    int n = s.size();
    if(!check(s.substr(0,(n/2))))
        flag++;
    if(!check( s.substr((n/2+1),(n/2))))
        flag++;
    if(flag)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    printclock;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define mod 1000000007;
#define my_mod 2019;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans;
    if(a + b > k) ans = k;
    else ans = a - (k-a-b);
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e9+10;

/*----------------------------------------------*/

signed main(){
  int n;
  cin>>n;
  vi h(n);
  rep(i,n) cin>>h[i];
  vi dp(n+3,INF);
  dp[0]=0;
  rep(i,n){
    chmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    chmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }

  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

// 約数列挙
//  (O√n)
std::vector<long long> divisor(const long long n, const bool to_sort) {
    std::vector<long long> ret;
    if (n > 1) for(long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
             ret.emplace_back(i);
             if (i != n / i && i != 1) {
                 ret.emplace_back(n / i);
             }
        }
    }

    if (to_sort) {
        std::sort(std::begin(ret), std::end(ret));
    }

    return ret;
}

bool check(LL N, LL K) {
    while (N >= K) {
        if (N % K == 0) {
            N /= K;
        } else {
            N %= K;
        }
    }

    return N == 1;
}

void naive(LL N) {
    cerr << endl;
    int cnt = 0;
    for (LL i = 2; i <= N; i++) {
        if (check(N, i)) {
            DEBUG(i)
            cnt++;
        }
    }

    DEBUG(cnt)
}

int main(void) {
    LL N;
    cin >> N;

    const auto n_div = divisor(N, true);
    const auto n_1_div = divisor(N - 1, true);
    LL res = n_1_div.size();
    FORE(e, n_div) {
        if (e == 1) continue;
        res += check(N, e);
    }

    cout << res + 1 << endl;
}


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

int n;
ll k;
vector<ll> a;

bool check(ll x){
  ll cnt=0;
  for(int i=0;i<n;++i){
    if(a[i]>x){
      if(a[i]%x==0)cnt+=(a[i]/x)-1;
      else cnt+=a[i]/x;
    }
  }
  return cnt<=k;
}

int main(){
  cin >> n >> k;
  //a=vector<ll>(n);
  for(int i=0;i<n;++i){
    ll aa;
    cin >> aa;
    a.push_back(aa);
  }

  sort(a.rbegin(),a.rend());
  ll high=a[0];
  ll row=1;
  while(high-row>0){
    ll mid=(high+row)/2;
    if(check(mid)) high=mid;
    else row=mid+1;
  }

  cout << row << endl;
  return 0;
}


Measured memory_bytes: 5336
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>
#include <map>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};
int main(){
	string s[26][26];
	int h, w;
	cin >> h >> w;
	REP(i, h){
		REP(j, w){
			cin >> s[i][j];
		}
	}
	REP(i, h){
		REP(j, w){
			if(s[i][j] == "snuke"){
				cout << (char)(j+'A') << i+1 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int64_t a;
  long double b;
  cin >> a >> b;
  int64_t ans = (int64_t)a*b;
  cout << ans << endl;
}


Measured memory_bytes: 3732
import java.util.ArrayList;
import java.util.Scanner;

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

        ArrayList<Integer> data = new ArrayList<Integer>();

        while(true) {

        	int read = sc.nextInt();

        	if(read==0) {
        		break;
        	}

        	data.add(read);

        }


        for(int i=1;i<=data.size();i++) {
        	System.out.println("Case "+i+": "+data.get(i-1));
        }
    }
}


Measured memory_bytes: 44044
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		long c1 = Math.Min(A+B+1,C);
		long ans = c1+B;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main{
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;
	
	int max(int a,int b){
		return Math.max(a,b);
	}
	
	String nextToken(){
		while(st==null||!st.hasMoreTokens()){
			try{
				st=new StringTokenizer(br.readLine());
			}catch (Exception e){
				eof=true;
				return null;
			}
		}
		return st.nextToken();
	}
	String nextString(){
		try{
			return br.readLine();
		}catch (IOException e){
			eof=true;
			return null;
		}
	}
	int nextInt() throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException{
		return Double.parseDouble(nextToken());
	}
	
	Main() throws IOException{
		br=new BufferedReader(new InputStreamReader(System.in));
		out=new PrintWriter(System.out);
		solve();
		out.close();
	}
	public static void main(String[] args) throws IOException{
		new Main();
	}
	
	final int inf=1000000;
	int a[]=new int[1010];
	int N;
	
	ArrayList<Integer> vals=new ArrayList<Integer>();
	int dp[][]=new int[1010][257];
	public class edge{
		int to,cost;
		edge(){}
		edge(int a,int b){
			to=a;cost=b;
		}
	};
	int dp2[][]=new int[1010][1010];
	edge G[]=new edge[1010*1010];
	int sz[]=new int[1010];
	int c;
	
	boolean check(int x){
		while(x%2==0) x/=2;
		return x==1;
	}
	int put(int mi){
		int res=0;
		c=0;
		vals=new ArrayList<Integer>();
		for(int i=0;i<N;i++){
			if(a[i]%mi==0&&check(a[i]/mi)) vals.add(a[i]/mi);
		}
		int n=vals.size();
		if(n==0) return 0;
		int m=1;
		while(m*2<=n) m*=2;
		for(int le=0;le<n;le++){
			for(int i=le;i<=n;i++) for(int j=0;j<=256;j++) dp[i][j]=-inf;
			dp[le][0]=0;
			int prev=-1;
			sz[le]=0;
			for(int ri=le;ri<n;ri++){
				for(int j=0;j<256;j++){
					int ac=j&(-j);
					int v=vals.get(ri);
					if(v<=ac||j==0){
						dp[ri+1][j+v]=max(dp[ri+1][j+v],dp[ri][j]+1);
					}
					dp[ri+1][j]=max(dp[ri+1][j],dp[ri][j]);
				}
			}
			for(int j=1;j<=256;j*=2){
				res=max(res,dp[n][j]);
			}
			for(int ri=le+1;ri<=n;ri++){
				if(dp[ri][256]==-inf) continue;
				if(prev<dp[ri][256]){
					prev=dp[ri][256];
					sz[le]++;
					G[c]=new edge(ri,dp[ri][256]);
					c++;
				}
			}
		}
		for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) dp2[i][j]=-inf;
		dp2[0][0]=0;
		int id=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<=m;j++){
				for(int k=0;k<sz[i];k++){
					int to=G[id+k].to;
					int cost=G[id+k].cost;
					dp2[to][j+1]=max(dp2[to][j+1],dp2[i][j]+cost);
				}
				dp2[i+1][j]=max(dp2[i+1][j],dp2[i][j]);
			}
			id+=sz[i];
		}
		for(int i=1;i<=n;i*=2) res=max(res,dp2[n][i]);
		return res;
	}
	int solve_(){
		int res=0;
		for(int i=1;i<=500;i+=2){
			int tmp=put(i);
			res=max(res,tmp);
		}
		return res;
	}
	void solve() throws IOException{
		while(true){
			N=nextInt();
			if(N==0) return;
			for(int i=0;i<N;i++) a[i]=nextInt();
			int ans=solve_();
			out.println(ans);
		}
	}
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int maxN = 1e5 + 5;
int colors[maxN];
vector<pi> to[maxN];

void dfs(int id, int color, int pa) {
  colors[id] = color;
  for (auto &p : to[id])
    if (p.first != pa)
      dfs(p.first, (color ^ p.second), id);
}

signed main() {
  int n = read();
  REP(i, n - 1) {
    int u, v, w;
    u = read();
    v = read();
    w = read();
    to[u].EB(v, (w & 1));
    to[v].EB(u, (w & 1));
  }
  colors[1] = 0;
  dfs(1, colors[1], 0);
  FOR(i, 1, n + 1) std::cout << colors[i] << std::endl;
}


Measured memory_bytes: 11264
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t A,B,C,D,E,F;
std::pair<int32_t, int32_t> dp[3001][3001];//重さ佐藤
bool used[3001][3001];//重さ佐藤
std::pair<int32_t, int32_t> func(int w, int s)
{
	if (w > F) { return { 1,-1000 }; }
	if (used[w][s]) { return dp[w][s]; }
	used[w][s] = true;

	std::pair<int32_t, int32_t> tmp{ w,s };
	dp[w][s] = tmp;
	double score = (double)(s) / w;
	if (w == 0) { score = -1; }
	tmp = func(w + 100 * A, s);
	if (score < (double)(tmp.second) / tmp.first) {
		score = (double)(tmp.second) / tmp.first;
		dp[w][s] = tmp;
	}
	tmp = func(w + 100 * B, s);
	if (score < (double)(tmp.second) / tmp.first) {
		score = (double)(tmp.second) / tmp.first;
		dp[w][s] = tmp;
	}
	if (s + C <= (w - s)*E/100)
	{
		tmp = func(w + C, s + C);
		if (score < (double)(tmp.second) / tmp.first) {
			score = (double)(tmp.second) / tmp.first;
			dp[w][s] = tmp;
		}
	}
	if (s + D <= (w - s)*E / 100)
	{
		tmp = func(w + D, s + D);
		if (score < (double)(tmp.second) / tmp.first) {
			score = (double)(tmp.second) / tmp.first;
			dp[w][s] = tmp;
		}
	}
	return dp[w][s];
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> A >> B >> C >> D >> E >> F;;
	auto res = func(0, 0);
	out << res.first << ' ' << res.second << endl;
	return 0;
}
#endif


Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    
    float sum = 0;
    for(int i=0; i<n; i++)
        sum += (1/float(arr[i]));
    
    // cout<<sum;
    cout<<1/sum;
}

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

using namespace std;

int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    int a=0;
    for(int i=0 ; i<n/2 ; i++){
        if( s[i]==s[ (n/2) + i ] ){
            a++;
        }
    }
    if(n%2==0){
            if(a==(n/2)){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    else{
         cout<<"No";
    }
    
}


Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))

l = A[-1]
m = A[-1]//2
r = 0
tmp = 0
for i in range(N):
    d = min(abs(l-A[i]), abs(0-A[i]))
    if tmp < d:
        r = A[i]
        tmp = d

print(l, r)

Measured memory_bytes: 62704
#include<stdio.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>

int main()
{
	long long n;
	scanf("%lld", &n);
	if (n % 2) printf("%lld\n", n * 2);
	else printf("%lld\n", n);
	

	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec) {
    char c;
    cin >> c;
    v = c - '0';
  }

  set<int> s1;
  set<int> s2;
  set<int> s3;
  s1.insert(vec[0]);
  s1.insert(vec[1]);
  s2.insert(vec[0] * 10 + vec[1]);

  for (int i = 2; i < n; ++i) {
    for (auto &v2 : s2)
      s3.insert(v2 * 10 + vec[i]);
    for (auto &v1 : s1)
      s2.insert(v1 * 10 + vec[i]);
    s1.insert(vec[i]);
  }
  cout << static_cast<int>(s3.size()) << endl;
}

Measured memory_bytes: 3752
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<endl;}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
const int MOD=1e9+7;
void solve(){
    int n;
    string s;
    cin>>n>>s;
    set<char> c;
    map<char,int> m;
    for(auto it:s){
    	c.insert(it);
    	m[it]++;
    }
    if((int)c.size()==n){
    	int ans=(1<<n);
    	ans--;
    	cout<<ans%MOD<<endl;
    	return;
    }
    int ans=1;
    for(auto it:m){
    	ans*=(it.s+1);
    	ans%=MOD;
    }
    cout<<(ans-1)<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

Measured memory_bytes: 640
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

x = k()
if x % 2 ==0:
    print(x)
else:
    print(x*2)


Measured memory_bytes: 10340
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  bool first = true;
  while(N--){
    if(first) first = false;
    else cout << endl;
    int f[9][9];
    for(int i = 0; i < 9; i++){
      for(int j = 0; j < 9; j++){
        cin >> f[i][j];
        f[i][j]--;
      }
    }
    vector< vector<bool> > wrong(9, vector<bool>(9, false));
    vector<bool> used(9, false);
    //columm
    for(int i = 0; i < 9; i++){
      used = vector<bool>(9, false);
      list<int> t;
      for(int j = 0; j < 9; j++){
        if(used[ f[i][j] ] == true){
          t.push_back(f[i][j]);
        }else{
          used[ f[i][j] ] = true;
        }
      }
      for(int j = 0; j < 9; j++){
        for(list<int>::iterator it = t.begin(); it != t.end(); it++){
          if(f[i][j] == *it){
            wrong[i][j] = true;
          }
        }
      }
    }
 
    //row
    for(int j = 0; j < 9; j++){
      used = vector<bool>(9, false);
      list<int> t;
      for(int i = 0; i < 9; i++){
        if(used[ f[i][j] ] == true){
          t.push_back(f[i][j]);
        }else{
          used[ f[i][j] ] = true;
        }
      }
      for(int i = 0; i < 9; i++){
        for(list<int>::iterator it = t.begin(); it != t.end(); it++){
          if(f[i][j] == *it){
            wrong[i][j] = true;
          }
        }
      }
    }
 
    //sp area
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
 
        used = vector<bool>(9, false);
        list<int> t;
        for(int k = 0; k < 3; k++){
          for(int l = 0; l < 3; l++){
            if(used[ f[i*3+k][j*3+l] ] == true){
              t.push_back(f[i*3+k][j*3+l]);
            }else{
              used[ f[i*3+k][j*3+l] ] = true;
            }
          }
        }
        for(int k = 0; k < 3; k++){
          for(int l = 0; l < 3; l++){
            for(list<int>::iterator it = t.begin(); it != t.end(); it++){
              if(f[i*3+k][j*3+l] == *it){
                wrong[i*3+k][j*3+l] = true;
              }
            }
          }
        }
      }
    }
 
    for(int i = 0; i < 9; i++){
      for(int j = 0; j < 9; j++){
        if(wrong[i][j]) cout << "*";
        else cout << " ";
        cout << f[i][j]+1;
      }
      cout << endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

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

  if(a == 'H' && b == 'H') cout << "H" << endl;
  else if(a == 'H' && b == 'D') cout << "D" << endl;
  else if(a == 'D' && b == 'H') cout << "D" << endl;
  else if(a == 'D' && b == 'D') cout << "H" << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(9**9)
n=int(input())
C=[0 for _ in range(n)]
L=[[] for _ in range(n)]
for j in range(n-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  L[u].append([v,w])
  L[v].append([u,w])
def a(n,v,d):
  for i in L[n]:
    if d%2==1:C[n]=1
    if v!=i[0]:a(i[0],n,d+i[1])
a(0,0,0)
for c in C:print(c)

Measured memory_bytes: 87132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    vector<int> w,s;
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            int q=(i*a+j*b)*100;
            if(q>f)break;
            if(i==0&&j==0)continue;
            w.push_back(q);
        }
    }
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int q=i*c+j*d;
            if(q>f)break;
            s.push_back(q);
        }
    }
    int ans1=0,ans2=0;
    double max=-1.0;
    for(int i=0;i<w.size();i++){
        for(int j=0;j<s.size();j++){
            if(w[i]+s[j]>f)continue;
            if(w[i]/100*e<s[j])continue;
            double p=(double)s[j]/(double)(w[i]+s[j]);
            if(max<p){
                max=p;
                ans1=w[i]+s[j];
                ans2=s[j];
            }
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(ALL(a));
  vector<mint> two(n + 1);
  two[0] = 1;
  REP(i, n) two[i + 1] = two[i] * 2;

  mint ans;
  REP(i, n) {
    int l = i, r = n - 1 - i;
    mint now = two[r];
    if (r != 0) now += two[r - 1] * r;
    now *= two[l];
    now *= a[i];
    ans += now;
  }

  ans *= two[n];

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;int main(){cin.tie(0);ios::sync_with_stdio(false);long long i,a,N,s,A=INT_MAX,l=0,r=0,S[100002]={0};cin>>N>>s;for(i=1;i<=N;i++){cin>>a;S[i]+=S[i- 1]+a;}for(;;){if(S[r]-S[l]>=s){A=min(A,r-l);l++;}else(r++);if(r>N){if(A==INT_MAX)A=0;cout<<A<<endl;return 0;}}}

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

#define mod 998244353
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p; 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int
using namespace std;
ll a[500005],n;
vector<ll>v; 
void solve() 
{ 
  ll n,i,ans=0;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)
  cin>>a[i];
  for(i=1;i<n;i++)
  {
          if(a[i]>=a[i-1])
          continue;
          else
         { ans+=a[i-1]-a[i];
           a[i]=a[i-1];
         }
  }
  cout<<ans;
}
 
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
solve();
 
return 0;
}

Measured memory_bytes: 5200
package main

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

var X int

func readVariables() {
	X = nextInt()

}

func main() {
	readVariables()
	if 3*5*7%X == 0 && X != 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ull = unsigned long long int;
using ll = long long int; 

int main(){
    ll N;
    std::cin >> N;
    int cnt=1;
    int max_cnt=0;

    for(int i=0;i<N;i++){
        int A;
        std::cin >> A;
        if(A==0) cnt=1;
        if(A==1) cnt++;
        if(cnt>max_cnt) max_cnt=cnt;
    }

    std::cout << max_cnt << std::endl;

    return 0;
}


Measured memory_bytes: 3100
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var s = ReadLine();
            var t = ReadLine();
           
            long ans = 0;
            for (int i = 0; i <= n; i++)
            {
                var f = false;
                for (int j = 0; j < n-i; j++)
                {
                    if (s[j + i] != t[j]) f = true;               
                }
                if (!f)
                {
                    ans = n+i;
                    break;
                }
            }
            WriteLine(ans);
          









          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 17344
#include <iostream>
#include <cstdio>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int ans;
int n,a,b;
char s;
int main() {
  cin >> n >> a >> b;
  rep(i,n){
    cin >> s;
    if(s == 'a')
      if(a>0){
        a--;
        cout <<	"Yes" << endl;
      }else if(b>0){
        b--;
        cout <<	"Yes" << endl;
      }else cout << "No" << endl;
    if(s == 'b')
      if(b>0){
        b--;
        cout << "Yes" << endl;
      }else cout << "No" << endl;
    if(s == 'c') cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll l,r;cin>>l>>r;
  if(r-l>2020){
    cout<<0<<endl;
    return 0;
  }
  ll MIN=INF;
  for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
      ll part=(i%2019)*(j%2019)%2019;
      MIN=min(MIN,part);
    }
  }
  cout<<MIN<<endl;
}

Measured memory_bytes: 256
a, b = list(map(int, input().split()))
num = []
for n in range(a,b+1):
    num.append(str(n))
count = 0
for i in range(len(num)):
    hantei = 0
    for j in range(len(num[i])//2):
        if num[i][j] == num[i][-(j+1)]:
            #print(num[i][j],num[i][-(j+1)],num[i])
            hantei += 1
    if hantei == len(num[i])//2:
        count += 1
print(count)

Measured memory_bytes: 8728
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N + 10, vector<ll>(W + 10, 0));

    rep(j, W + 1) if(j >= w[0]) dp[0][j] = v[0];

    rep(i, N) rep1(j, W){
        ll nextw = w[i + 1], nextv = v[i + 1];
        
        if(j - nextw < 0) dp[i + 1][j] = dp[i][j];
        else dp[i + 1][j] = max({dp[i][j], dp[i + 1][j], dp[i][j - nextw] + nextv});
    }

    print(dp[N - 1][W]);

    return 0;
}

Measured memory_bytes: 87296
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
rep = sorted([tuple(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
i = 0
for count, val in rep:
    if i == n or a[i] >= val:
        print(sum(a))
        exit()
    while i < n and count > 0 and a[i] < val:
        a[i] = val
        i += 1
        count -= 1
print(sum(a))

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

int main() {
	int n;
	int x[100], y[100], x_y[100];
	double d[3];

	for(int i=0; i< 100; i++) {
		x[i] = 0;
		y[i] = 0;
	}
	for(int i=0; i<3; i++) d[i] = 0.0;

	cin >> n;
	for(int i=0; i<n; i++) cin >> x[i];
	for(int i=0; i<n; i++) cin >> y[i];
	for(int i=0; i<n; i++) x_y[i] = abs(x[i]-y[i]);

	for(int p=1; p<=3; p++) {
		for(int i=0; i<n; i++) {
			d[p-1] += pow(x_y[i], p);
		}
		d[p-1] = pow(d[p-1], 1.0/p);
	}

	cout.precision(6);
	for(int i=0; i<3; i++) cout << fixed << d[i] << endl;

	cout << fixed << (double)*max_element(x_y, x_y+n) << endl;

	return 0;
}


Measured memory_bytes: 3484
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      int h = sc.nextInt();
      int w = sc.nextInt();
      if(h == 0 && w == 0) return;
      for(int i = 0; i<h; i++) {
        for(int j = 0; j<w; j++) {
          System.out.print("#");
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 35076
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,x,y;cin>>n>>x>>y;x--;y--;
    vector<int> t(n,-1);//0との最短距離
    t[0]=0;
    map<int,int> mp;
    rep(i,n)rep(j,n){
        if(i>=j)continue;
        int buf1=j-i;
        int buf2=abs(x-i)+abs(y-j)+1;
        int buf=min(buf1,buf2);
        mp[buf]++;
    }
    
    vector<int> d(n,0);
    for(auto&p: mp){
        d[p.first]+=p.second;
    }
    rep(i,n){
        if(i==0)continue;
        cout<<d[i]<<endl;
    }
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[510];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) {
        int num = i + 2;
        int cnt = 1;
        while(num >= 1) {
            if (num % 2 == 0) {
                ans[i] = cnt;
                break;
            }
            num = (num + 1) / 2;
            cnt++;
        }
    }
    rep(i, N - 1) {
        rep(j, N - i - 1) {
            cout << ans[j] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		ArrayList<Pair> list = new ArrayList<Pair>();
		while(true){
			String str = cin.next();
			if(str.equals("0,0")){
				break;
			}
			String[] s = str.split(",");
			list.add(new Pair(Integer.parseInt(s[0]), Integer.parseInt(s[1])));
		}
		Object[] o =  list.toArray();
		Pair[] p = new Pair[o.length];
		for(int i = 0; i < o.length;i++){
			p[i] = (Pair)o[i];
		}
		Arrays.sort(p);
		int count=1;
		int[] scores = new int[31];
		for(int i = 0; i < p.length; ){
			scores[p[i].score]=count;
			int dx=1;

			while(true){
				if(i+dx == p.length)
					break;

				if(p[i].score == p[i+dx].score){


					dx++;
				}
				else{
					break;
				}
			}
			i+=dx;
			count++;
		}

		int[] henkan = new int[p.length+1];
		for(int i = 1; i < p.length+1; i++){
			for(int j = 0; j < p.length; j++){
				if(p[j].team == i){
					henkan[i] = j+1;
					break;
				}
			}
			
			
		}
		while(cin.hasNext()){
			int c = cin.nextInt();

			System.out.println( scores[p[henkan[c]-1].score]);
		}

	}

}
class Pair implements Comparable{
	int team;
	int score;
	Pair(int a, int b){
		team = a;
		score = b;
	}
	public int compareTo(Object o) {
		Pair p = (Pair)o;
		return (-this.score + p.score);

	}

}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-
from itertools import combinations

d,g = map(int, input().split())
p = []
c = []
for _ in range(d):
    a,b = map(int, input().split())
    p.append(a)
    c.append(b)

res = 100*10
for i in range(d+1):
    for cc in combinations(range(d), i):
        t = 0
        s = 0
        for pi in cc:
            s += (pi+1)*100*p[pi] + c[pi]
            t += p[pi]
        if s<g:
            pi = max(set(range(d)) - set(cc))
            for j in range(1,p[pi]):
                s += (1+pi)*100
                t += 1
                if s>=g:
                    break
        if s>=g:
            res = min(res, t)
print(res)


Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    vector<int> a;
    int tmp_a;
    int ans=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    for(int i=0; i<n; i++){
        ans+=a[i]-1;
    }
    cout << ans << endl;
}


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

int main()
{
  long long int n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  long long int minn = min(a, min(b, min(c, min(d, e) ) ) );
  long long int ans = 4;
  if(n%minn == 0)
  {
    ans += n/minn;
  }
  else
  {
    ans += (n/minn) + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

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

ll h,w;
ll m1,m2,m3=INF,m4=INF;

int main(){
	cin>>h>>w;
	if(h%3==0){
		m1=0;
	}else{
		m1=w;
	}
	if(w%3==0){
		m2=0;
	}else{
		m2=h;
	}
	
	for(ll i=1;i<h;i++){
		ll a1=i*w;
		ll a2=(h-i)*(w/2);
		ll a3=(h-i)*(w-(w/2));
		ll ii=min(min(a1,a2),a3);
		ll aa=max(max(a1,a2),a3);
		m3=min(aa-ii,m3);
	}
	for(ll i=1;i<w;i++){
		ll a1=i*h;
		ll a2=(w-i)*(h/2);
		ll a3=(w-i)*(h-(h/2));
		//cout<<a1<<" "<<a2<<" "<<a3<<endl;
		ll ii=min(min(a1,a2),a3);
		ll aa=max(max(a1,a2),a3);
		m4=min(aa-ii,m4);
	}
	
	cout<<min(min(m1,m2),min(m3,m4))<<endl;
	return 0;
}
		

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;

bool is_prime[1000001];
int minfactor[1000001];

void sieve(int n){
	for(int i = 0;i <= n;i++){
		is_prime[i] = true;
		minfactor[i] = -1;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i = 2;i <= n;i++){
		if(is_prime[i]){
			minfactor[i] = i;
			for(int j = 2 * i;j <= n;j += i){
				is_prime[j] = false;
				if(minfactor[j] == -1)minfactor[j] = i;
			}
		}
	}
}

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

	sieve(n);
	ll ans = 0;
	for(int c = 1;c <= n-1;c++){
		ll ab = n - c;
		unordered_map<int,int> mp;
		while(ab > 1){
			mp[minfactor[ab]]++;
			ab /= minfactor[ab];
		}
		ll mul = 1;
		for(auto p:mp){
			mul *= (p.second + 1);
		}
		ans += mul;
	}

	cout << ans << endl;
}


Measured memory_bytes: 8372
#include<bits/stdc++.h>
#define rep(X,A,B) for(int X=A;X<=B;X++)
#define tep(X,A,B) for(int X=A;X>=B;X--)
#define LL long long
#define DB double
const int N=400010;
const int M=800010;
const int maxn=200000;
const LL MOD=998244353;
using namespace std;

int n,K;

int GET(int x){
	if(x==0)return n/K;
	if(n%K==0)return n/K;
	if(n%K<x)return n/K;
	else return n/K+1;
}

LL CHK(LL i,LL j){
	if(i==j){
		LL c=GET(i);
		return c+c*(c-1)*3+c*(c-1)*(c-2);
	}
/*	else{
		LL ci=GET(i),cj=GET(j);
		return ci*cj*3+cj*(cj-1)*ci*6;
	}*/
}

LL SOLVE(){
	LL res=0;
	res+=CHK(0,0);
	rep(i,1,K-1){
		if(K-i==i)res+=CHK(i,i);
	}
	return res;
}

int main(){
	scanf("%d%d",&n,&K);
	printf("%lld\n",SOLVE());
	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 d = sc.nextInt();
        sc.close();

        if(d == 25){
            System.out.println("Christmas");
        }else if(d == 24){
            System.out.println("Christmas Eve");
        }else if(d == 23){
            System.out.println("Christmas Eve Eve");
        }else{
            System.out.println("Christmas Eve Eve Eve");
        }
    }
}

Measured memory_bytes: 23636
n, k = map(int, input().split())
s = str(input())
h = 0
for i in range(1, n):
    if s[i] == 'L' and s[i-1] == 'L':
        h += 1
for i in range(n-1):
    if s[i] == 'R' and s[i+1] == 'R':
        h += 1
print(min(h + 2 * k, n - 1))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,w;
  cin>>n>>w;
  ll wt[n],val[n];
  fo(i,n)
  cin>>wt[i]>>val[i];
  vector <vector<ll>> v(n+1,vector<ll>(w+1,0));
  for(ll i=1;i<=n;i++)
  {
    for(ll j=1;j<=w;j++)
    {
      if(wt[i-1]<=j)
        v[i][j]=max(val[i-1]+v[i-1][j-wt[i-1]],v[i-1][j]);
      else
        v[i][j]=v[i-1][j];
    }
  }
  cout<<v[n][w];
  return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;

#define int long long
#define MAX 110000

const long long MOD = (long long)1e9 + 7;

long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD) if(n&1)ans*=x;
	return ans%MOD;
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string L;
	int three = 1, two = 1, ans = 1, it;
	
	cin>>L;
	
	three = power(3,L.size()-1);
	it = power(3,MOD-2);
	
	for(int i = 0; i < L.size(); i++, three = three*it%MOD){
		if(L[i] == '1'){
			ans = (ans + (three + 1)*two)%MOD;
			two = 2*two%MOD;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include "stdio.h"

int main(void)
{
    int i,n;
    int m = 0;
    scanf("%d",&n);
    int v[n];
    int c[n];
    int a = 0;
    
    for(i=0;i<n;i++)
    {
        scanf("%d",&v[i]);
        if(v[i]%2 == 0)
        {
            c[m] = v[i];
            m++;
        }
    }
    for(i = 0;i < m;i++)
    {
        if(c[i]%3 == 0 || c[i]%5 == 0)
        {}
        else
        {
            a = 1;
        }   
    }
    if(a == 1)
    {
        printf("DENIED");
    }
    else if(a == 0)
    {
        printf("APPROVED");
    }
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a =s.nextInt(),b=s.nextInt(),c=s.nextInt(),d=s.nextInt();
        System.out.println(Math.max(a*b,c*d));
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25400