akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd

N,ma,mb=map(int,input().split())
med=[]
for i in range(0,N):
    a,b,c=map(int,input().split())
    med.append((a,b,c))

dp=[[[float("inf") for i in range(0,401)] for j in range(0,401)] for k in range(0,N)]
dp=[[float("inf") for i in range(0,401)] for j in range(0,401)]

for i in range(0,401):
    for j in range(0,401):
        if not (i==0 and j==0):
            g=gcd(i,j)
            I=i//g
            J=j//g
            if I==ma and J==mb:
                dp[i][j]=0
            else:
                g=gcd(i+med[0][0],j+med[0][1])
                I=(i+med[0][0])//g
                J=(j+med[0][1])//g
                if I==ma and J==mb:
                    dp[i][j]=med[0][2]

for i in range(1,N):
    a,b,c=med[i]
    for j in range(0,401-a):
        for k in range(0,401-b):
            dp[j][k]=min(dp[j][k],c+dp[j+a][k+b])

if dp[0][0]==float("inf"):
    print(-1)
else:
    print(dp[0][0])


Measured memory_bytes: 135256
#include<stdio.h>
int main(){
    while(1){
    int H,W,i,j;
    scanf("%d%d",&H,&W);
        if(H==0&&W==0)
        break;
        for(i=0;i<H;i++)
        {
            for(j=0;j<W;j++)
            {
				if(i == 0||i == H - 1||j == 0||j == W - 1)
                printf("#");
				else
				printf(".");
             }
            printf("\n");
        }
        printf("\n");
         
         
    }
return 0;
}


Measured memory_bytes: 2104
package main

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

func main() {
    var N, M int 
    fmt.Scanln(&N, &M) 

    sc := bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)

    var maxL, minR int 
    minR = 1 << 31
    for i := 0; i < M; i++ {
        sc.Scan()
        L, _ := strconv.Atoi(sc.Text())
        sc.Scan()
        R, _ := strconv.Atoi(sc.Text())

        maxL = max(maxL, L)
        minR = min(minR, R)
    }   

    var ans int 
    if maxL <= minR {
        ans = minR - maxL + 1 
    }   
    fmt.Println(ans)
}

func max(a, b int) int {
    return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
    return int(math.Min(float64(a), float64(b)))
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;


vector<vector<int> > dp;

int main(){

    string s;
    cin >> s;
    int n = s.size();
    dp.resize(n+1, vector<int>(13));

    dp[0][0] = 1;
    rep(i, n){
        rep(j, 10){
            if(s[i] != '?' and s[i]-'0' != j) continue;
            rep(k, 13){
                (dp[i+1][(10*k+j)%13] += dp[i][k]) %= MOD;
            }
        }
    }
    ppp(dp[n][5]);

    return 0;
}


Measured memory_bytes: 8912
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <map>
#include <cstring>
using namespace std;
int n, a[100010],dp[100010];
int main(){
	scanf("%d",&n);
	for(int i=1 ; i<=n ; i++){
		scanf("%d",a+i);
	}
	dp[2] = abs(a[2]-a[1]);
	for(int i=3 ; i<=n ; i++){
		dp[i] = min( dp[i-2] + abs(a[i]-a[i-2]) , dp[i-1] + abs(a[i]-a[i-1]) );
	}
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a); 
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


//~ map<int,int> h;
//~ int dp[2007];
//~ vector <int> arraySort(vector <int> v) {
	//~ vector<int> ans;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ dp[i] = 1;
	//~ }
	
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ for(int j = 1; j < i; j++){
			//~ if(v[j-1] <= v[i-1]){ 
				//~ if(dp[i] < dp[j] + 1){
					//~ dp[i] = dp[j] + 1;
					//~ h[i] = j;
				//~ }
				//~ else if(dp[i] == dp[j] + 1){					
					//~ int index = h[i];
					//~ int val = v[index-1];
					//~ if(v[j-1] < val){
						//~ h[i] = j;
					//~ }
				//~ }
			//~ }
		//~ }
	//~ }
	//~ int index, maxi = 0, minval = inf;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ if(maxi <= dp[i] ){
			//~ maxi = dp[i];
		//~ }
	//~ } 
	
	//~ for(int i = 1; i<= (int)v.size(); i++){
		//~ if(maxi == dp[i]){
			//~ if(minval > v[i-1]){
				//~ minval = v[i-1];
				//~ index = i;
			//~ }
		//~ }
	//~ }
	
	//~ cout<<minval<<" "<<index<<endl;
	
	//~ int next = index;
	
	//~ while(next){
		//~ cout<<next<<" ";
		//~ next = h[next];
	//~ }
	//~ return ans;
//~ }

vector<bool> prefixesDivBy5(vector<int>& A) {
	vector<bool> ans;
	for(int i = 0; i < (int)A.size(); i++){
		int sum = 0;
		for(int j = i,k=0; j >= 0; j--,k++){
			sum += A[j]*(1<<k);
		}
		cout<<sum<<endl;
		if(sum%5 == 0)
			ans.push_back(true);
		else
			ans.push_back(false);
	}   
	for(int x:ans)
		cout<<x<<" ";
		
	return ans;
}

int dp[1000][1000];
int uniquePaths(int m, int n) {
	clr(dp,0);
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
			if(i == 1 && j == 1)
				dp[i][j] =1;
			else{
				dp[i][j] = dp[i-1][j] + dp[i][j-1];
			}
		}
	}
	return dp[m][n];
}
    
int main(){
	int n;cin>>n;
	cout<<n/2 + n%2;
	return 0;
}













Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();
        int sum = 0;
    
    	if(K<=A) System.out.println(K);
    	else if(K <= A+B) System.out.println(A);
    	else System.out.println(A-(K-A-B));
    }
}

Measured memory_bytes: 35716
#include <stdio.h>
#define max(a, b) ((a)>(b)?(a):(b))
int n, m, la, lb;
char S[55][55];
int d[52][52][52][52];
int ax[26][11], ay[26][11], an[26];
inline bool match(char A, char B) {
	la = 'a' <= A && A <= 'z';
	lb = 'a' <= B && B <= 'z';
	if (la && !lb && A - 'a' == B - 'A') return 1;
	return 0;
}
int f(int ux, int uy, int dx, int dy) {
	if (ux > dx || uy > dy) return -1;
	if (d[ux][uy][dx][dy] != -2) return d[ux][uy][dx][dy];
	d[ux][uy][dx][dy] = -1;
	if (S[ux][uy] != '#' && S[dx][dy] != '#') {
		if (ux == dx && uy == dy) return d[ux][uy][dx][dy] = 0;
		if (S[ux][uy] == '.' || ('A' <= S[ux][uy] && S[ux][uy] <= 'Z')) d[ux][uy][dx][dy] = max(f(ux + 1, uy, dx, dy), f(ux, uy + 1, dx, dy));
		else {
			d[ux][uy][dx][dy] = max(f(ux + 1, uy, dx, dy), f(ux, uy + 1, dx, dy));
			int p = S[ux][uy] - 'a', v, nx, ny, ff;
			for (int i = 1; i <= an[p]; i++) {
				v = -1;
				nx = ax[p][i];
				ny = ay[p][i];
				if ((ux == nx && uy + 1 == ny) || (uy == ny && ux + 1 == nx)) {
					ff = f(nx, ny, dx, dy);
					if (match(S[ux][uy], S[nx][ny]) && ff != -1) d[ux][uy][dx][dy] = max(d[ux][uy][dx][dy], 1 + ff);
				}
				else {
					if (ux <= nx && nx <= dx && uy <= ny && ny <= dy) {
						v = max(v, f(ux + 1, uy, nx - 1, ny));
						v = max(v, f(ux + 1, uy, nx, ny - 1));
						v = max(v, f(ux, uy + 1, nx - 1, ny));
						v = max(v, f(ux, uy + 1, nx, ny - 1));
						ff = f(nx, ny, dx, dy);
						if (v != -1 && ff != -1) d[ux][uy][dx][dy] = max(d[ux][uy][dx][dy], v + 1 + ff);
					}
				}
			}
		}
	}
	return d[ux][uy][dx][dy];
}
int main() {
	while (scanf("%d%d", &n, &m), n&&m) {
		for (int i = 1; i <= n; i++) scanf("%s", S[i] + 1);
		for (int i = 0; i < 26; i++) an[i] = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if ('A' <= S[i][j] && S[i][j] <= 'Z') {
					int p = S[i][j] - 'A';
					an[p]++;
					ax[p][an[p]] = i;
					ay[p][an[p]] = j;
				}
			}
		}
		for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) for (int k = 1; k <= n; k++) for (int l = 1; l <= m; l++) d[i][j][k][l] = -2;
		printf("%d\n", f(1, 1, n, m));
	}
}

Measured memory_bytes: 28400
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 200005
bool cmp(long long int x,long long int y)
{
   return x>y;
}
int main(void)
{
   long long int t,n,m,k,x,y,a[100001];
   vector<long long int> v,v1,v2;
   vector< pair <long long int,long long int> >p,p1,p2;
   set<long long int> st;
   priority_queue<long long int> pq;
   priority_queue< long long int,vector<long long int>,greater<long long int> > lpq;
   priority_queue< pair<long long int,long long int>,vector< pair<long long int,long long int> >,greater< pair <long long int,long long int> > > plpq;
   string s;
   //cin>>t;
   //while(t--)
   //{
      cin>>n;
      if(n>=30)
         cout<<"Yes"<<endl;
      else
         cout<<"No"<<endl;
   //}
   return 0;
}


Measured memory_bytes: 3592
# coding: utf-8
from collections import Counter


def main():
    n = int(input())
    polls_list = []
    for _ in range(n):
        polls_list.append(input())
    polls_dict = Counter(polls_list)
    max_poll = max(polls_dict.values())

    polls_set = set()
    for key, value in polls_dict.items():
        if value == max_poll:
            polls_set.add(key)

    polls_set = sorted(polls_set)
    for poll in polls_set:
        print(poll)

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 44272
#include<iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    double c = a*1.0/b;
    cout << a/b << " " << a%b << " " ;
    printf("%.8lf\n", c);
    cout << endl;  
    return 0;
}


Measured memory_bytes: 3228
import numpy as np

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353

dp = np.array([[0] * 3 for _ in range(s + 1)], dtype=np.int64)
dp[0][0] = 1

for i, e in enumerate(a):
    cp = dp.copy()
    dp[:, 1] += cp[:, 0]
    dp[:, 2] += cp[:, 0] + cp[:, 1]

    dp[e:, 1] += cp[:-e, 0] + cp[:-e, 1]
    dp[e:, 2] += cp[:-e, 0] + cp[:-e, 1]

    dp %= mod

ans = dp[s][2]
print(ans)


Measured memory_bytes: 21392
n,m=list(map(int,input().split()))
l=[]
for i in range(n):
    a=list(map(int,input().split()))
    a.pop(0)
    l.append(a)
counter=0
tmp=0
for i in range(m):
    for j in range(n):
        if i+1 in l[j]:
            tmp+=1
    if tmp==n:
        counter+=1
    tmp=0
print(counter)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var a, b, k int64
	fmt.Scan(&a, &b, &k)
	if k < a {
		fmt.Println(a-k, b)
		return
	}
	if a+b < k {
		fmt.Println(0, 0)
		return
	}
	fmt.Println(0, b-(k-a))
	return
}


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

using namespace std;
std::string s, s2;
std::map<char, int> m;


int main() {
    std:cin >> s;
    for (int i = 0; i < s.size(); i++) {
        m[s[i]]++;
    }
    for (int i = 97; i <= 122; i++) {
        if (m[(char)i] == 0) {
            s2 += (char)i;
        }
    }
    std::sort(s2.begin(), s2.end());
    if (s2.size() < 1) {
        std::cout << "None" << std::endl;
        return 0;
    }
    std::cout << s2[0] << std::endl;
    
    
    
}

Measured memory_bytes: 512
# import itertools
# import math


def solve(A, B):
    AA = ''
    for b in range(B):
        AA += str(A)

    BB = ''
    for a in range(A):
        BB += str(B)
    ans = sorted([AA, BB])
    return ans[0]


# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(A, B))


Measured memory_bytes: 38256
n = int(input())
X = list(map(int, input().split()))
a = min(X)
b = max(X)

res = 10**8

for i in range(a, b + 1):
    k = 0
    for j in range(n):
        k += (i - X[j])**2
    res = min(res, k)
    
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int a; string s;

void solve()
{
    cin >> a >> s;
    if (a<3200) nout("red");
    else nout(s);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define MAX 1000000
//78498
using namespace std;

bool prime[MAX+1];
int data[78499];

int count(int p, int m){
  int tmp=0;
  int d, u;
  d=p-m;
  if(d<0) d=0;
  u=p+m;
  if(u>MAX) u=MAX;
  /*for(int i=d;i<=u;i++){
    if(prime[i]) tmp++;
    }*/
  int i;
  for(i=0;;i++){
    if(data[i]==-1) break;
    if(data[i]>=d) break;
  }
  for(;;i++){
    if(data[i]==-1) break;
    if(data[i]>u) break;
    tmp++;
  }
  if(tmp==0){
    return -1;
  }else{
    return tmp-1;
  }
}

void eratos(){
  int n=MAX;
  for(int i=0;i<=n;i++) prime[i]=false;
  for(int i=3;i<=n;i+=2) prime[i]=true;
  prime[2]=true;
  int limit=(int)sqrt((double)n)+1;
  for(int i=3;i<=limit;i+=2){
    if(!prime[i]) continue;
    for(int j=i+i;j<=n;j+=i)
      prime[j]=false;
  }
}

main(){
  int n;
  eratos();
  data[0]=2;
  for(int i=3, j=1;i<=MAX;i+=2){
    if(prime[i]){
      data[j++]=i;
    }
  }
  data[78498]=-1;
  while(1){
    cin >> n;
    if(n==0) break;
    int ans=0;
    for(int i=0;i<n;i++){
      int p, m;
      cin >> p >> m;
      ans+=count(p, m);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
int X, N,i, a[110], ans=110, pre=110;
map<int,bool>visited;
int main()
{
    cin >> X >> N;
    for(i=0;i<N;i++)
    {
        cin >> a[i];
        visited[a[i]] = true;
    }
    sort(a, a+N);
    for(i=-1;i<=101;i++)
    {
        if(!visited[i] && abs(X-i)<pre)
            pre = abs(X-i), ans = i;

    }
    if(ans==110)
        cout << 0 << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 3588
/**
 *    author:  zjsdut
 *    created: 2020/03/09 12:21:19
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define rep(n)                                                                 \
  for (int _iter_##n = 0, _num_##n = (int)n; _iter_##n < _num_##n; ++_iter_##n)
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}
template <typename int_t> inline int_t lowbit(int_t x) { return x & -x; }

inline unsigned h_bit(unsigned long long x) {
  return sizeof(unsigned long long) * 8 - __builtin_clzll(x);
}

unsigned long long pow2(unsigned long long x) { // round up to power of 2
  return x == lowbit(x) ? x : 1ull << h_bit(x);
}
int main() {
#if defined LOCAL
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  ll h;
  scan(h);
  println((1ll << h_bit(h)) - 1);
  return 0;
}

Measured memory_bytes: 256
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def insert(tree:Node, key:Node) = {
    val keyNode = key
    def loop(node:Node):Node =
      if(node.key > keyNode.key) {
        if(node.left == null) node
        else loop(node.left)
      } else {
        if(node.right == null) node
        else loop(node.right)
      }

    val target = loop(tree)

    if(keyNode.key < target.key) target.left = keyNode
    else target.right = keyNode
  }

  def inOrder(root:Node):Unit = {
    var stack:List[Node] = Nil
    var curr = root
    var flg = true

    while(flg) {
      while(curr != null) {
        stack = curr::stack
        curr = curr.left
      }
      if(curr == null && stack != Nil) {
        val item = stack.head
        stack = stack.tail
        out.write(" ")
        out.write(item.key.toString)
        if(count<100) count += 1
        else {
          out.flush
          count = 0
        }
        curr = item.right
      } else {
        flg = false
      }
    }
  }

  def scan(list:List[Node]):Unit = {
    list match {
      case Nil => ()
      case hd::tl => {
        out.write(" ")
        out.write(hd.key.toString)
        if(count<100) count += 1
        else {
          out.flush
          count = 0
        }
        val hd2 = if(hd.right!=null) hd.right::tl else tl
        val hd3 =if(hd.left!=null) hd.left::hd2 else hd2
        scan(hd3)
      }
    }
  }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else  scan(tree::Nil)

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 300600
import collections
n = int(input())
d = collections.Counter(map(lambda x: str(x)[0]+" "+str(x)[-1], list(range(1,n+1))))
ans = 0
for k, v in d.items():
	a,b = map(int, k.split())
	if a==b:
		ans += v*v
	elif a<b:
		s = str(b) + " " + str(a)
		if s in d:
			u = d[s]
			ans += 2*v*u
print(ans)

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

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

  int count = 0;
for(int i=a;i<=b;i++){
  if( c % i == 0) count++;
}
cout << count << endl;

}


Measured memory_bytes: 3100
#include <iostream>
#include <limits>
#include <queue>
#include <tuple>
#include <vector>
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
using namespace std;

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int s = 0, const int d = 0, const Weight w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  const Edges &operator[](const int i) const { return g[i]; }
  void addArc(const int src, const int dst, const Weight w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int node1, const int node2, const Weight w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
};

template<int inf = std::numeric_limits<Weight>::max() / 8> std::vector<Weight> dijkstra(const Graph &g, const int src) {
  using state = std::pair<Weight, int>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> q;
  std::vector<Weight> dist(g.size(), inf);
  dist[src] = 0;
  q.emplace(0, src);
  while (q.size()) {
    Weight d;
    int v;
    std::tie(d, v) = q.top();
    q.pop();
    if (dist[v] < d) continue;
    for (auto &e : g[v]) {
      if (cmin(dist[e.dst], dist[v] + e.weight)) q.emplace(dist[e.dst], e.dst);
    }
  }
  return dist;
}

signed main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  --s, --t;
  Graph g(n);
  rep(i, m) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b, --c;
    g.addEdge(a, b, d);
    g.addEdge(b, c, d);
    g.addEdge(c, a, d);
  }
  cout << dijkstra(g, s)[t] << endl;
}



Measured memory_bytes: 28856
import java.util.*;

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

        int X = A + B + C;

        if(X > 21) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if((A+B)>(C+D))
    cout << "Left" << endl;
  else if((A+B)<(C+D))
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
	"strings"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	var dp [4][4][4][101]int
	dp[3][3][3][0] = 1
	str := []string{"A", "G", "C", "T"}
	for cur := 0; cur < N; cur++ {
		for i := 0; i < 4; i++ {
			for j := 0; j < 4; j++ {
				for k := 0; k < 4; k++ {
					for next := 0; next < 4; next++ {
						if isOk([]rune(str[i] + str[j] + str[k] + str[next])) {
							dp[j][k][next][cur+1] += dp[i][j][k][cur]
							dp[j][k][next][cur+1] %= MOD
						}
					}
				}
			}
		}
	}
	ans := 0
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				ans += dp[i][j][k][N]
				ans %= MOD
			}
		}
	}
	fmt.Fprintln(wtr, ans)
}

func isOk(before4 []rune) bool {
	for i := 0; i < 4; i++ {
		runes := make([]rune, len(before4))
		copy(runes, before4)
		if i != 0 {
			runes[i], runes[i-1] = runes[i-1], runes[i]
		}
		if strings.Contains(string(runes), "AGC") {
			return false
		}
	}
	return true
}


Measured memory_bytes: 3072
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int r, a;
	while (scanf("%d%d", &r, &a), r|a)
	{
		set<int> s;
		int d[] = { 1, 10, 100, 1000 };
		for (int i = 0; i < 4; ++i)
			s.insert((r / d[i]) % 10);

		int hit = 0, blow = 0;
		for (int i = 0; i < 4; ++i, r /= 10, a /= 10)
			if (r % 10 == a % 10)
				++hit;
			else if (s.count(a % 10))
				++blow;
		printf("%d %d\n", hit, blow);
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll a,b;
    cin >> a >> b;
    ll waru,amari;
    waru = n/(a+b);
    amari=n%(a+b);
    ll ao=waru*a;
    if(amari>=a) cout << ao+a <<endl;
    else cout << ao+amari << endl;

    return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  vi a(3);
  rep(i,0,3) cin>>a[i];
  map<pair<int, ii>, int> mm;
  int cnt = 0;
  int flag = 0;
  while(true) {
    sort(all(a));
    debug(mm);
    if(mm[{a[0], {a[1], a[2]}}]) {
            flag = 1;
      break;
    }
    mm[{a[0], {a[1], a[2]}}] = 1;
    if(a[0]%2 || a[1]%2 || a[2]%2) {
      break;
    }
    int aa = (a[1]+a[2])/2;
    int bb = (a[0]+a[2])/2;
    int cc = (a[0]+a[1])/2;
    a[0] = aa; a[1] = bb; a[2] = cc;
    cnt++;
  }
  if(flag) cout<<-1<<endl;
  else
  cout<<cnt<<endl;
}



Measured memory_bytes: 256
pub fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

pub struct UnionFind {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> UnionFind {
        let par = (0..n).collect::<Vec<usize>>();
        let rank = vec![0; n];
        UnionFind { par: par, rank: rank }
    }

    pub fn root(&mut self, x: usize) -> usize {
        let cand = self.par[x];
        if cand == x {
            return x;
        } else {
            let ret = self.root(cand);
            self.par[x] = ret;
            return ret;
        }
    }

    pub fn same(&mut self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    pub fn unite(&mut self, x: usize, y: usize) {
        let root_x = self.root(x);
        let root_y = self.root(y);
        if root_x == root_y { return; }

        if self.rank[root_x] < self.rank[root_y] {
            self.par[root_x] = self.par[root_y];
        } else {
            self.par[root_y] = self.par[root_x];
            if self.rank[root_y] == self.rank[root_x] {
                self.rank[root_x] += 1;
            }
        }
    }
}

fn main() {
    let n = read1::<usize>();
    let mut xy = (0..n).map(|i| {
        let temp = readn::<usize>(" ");
        (temp[0], temp[1], i)
    }).collect::<Vec<(usize, usize, usize)>>();
    let mut yx = xy.iter().map(|&t| (t.1, t.0, t.2)).collect::<Vec<(usize, usize, usize)>>();

    xy.sort();
    yx.sort();

    let mut edge = Vec::with_capacity((n - 1) * 2);
    for i in 0..(n-1) {
        let xy0 = xy[i];
        let xy1 = xy[i+1];
        edge.push((xy0.2, xy1.2, xy1.0 - xy0.0));
        let yx0 = yx[i];
        let yx1 = yx[i+1];
        edge.push((yx0.2, yx1.2, yx1.0 - yx0.0));
    }
    edge.sort_by(|a, b| (a.2).cmp(&(b.2)));

    let mut uf = UnionFind::new(n);
    let mut ans = 0;
    for &e in edge.iter() {
        let a = e.0;
        let b = e.1;
        let c = e.2;
        if !uf.same(a, b) {
            uf.unite(a, b);
            ans += c;
        }
    }

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

Measured memory_bytes: 20120
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    int x, y;
    cin >> x >> y;
    int a, b;
    a = 4 * x - y;
    a /= 2;
    b = x - a;
    if(a>=0 && b>=0 && a*2+b*4==y) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
using System;
class aoj
    
{
    static void Main()
    {
        string a = Console.ReadLine();
        double b = double.Parse(a);
        double e = 100000;
        for(double i = 0; i < b; i++)
        {
            e = e * 1.05;
            e = e / 1000;
            e = Math.Ceiling(e);
            e = e * 1000;
        }
        Console.WriteLine(e);
    }

}

Measured memory_bytes: 9076
#include <set>
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int n;
    cin >> n;
    set<string> s;
    while (n--)
    {
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size();
    return 0;
}


Measured memory_bytes: 19204
def s()
  gets()
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ls()
  gets.split
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

H, W =li()

def getMovePos(pos)
  res = [[pos[0]+1, pos[1]], [pos[0]-1, pos[1]], [pos[0], pos[1]+1], [pos[0], pos[1]-1]]
  if pos[0] == 0
    res -= [[pos[0]-1, pos[1]]]
  end
  if pos[0] == H-1
    res -= [[pos[0]+1, pos[1]]]
  end
  if pos[1] == 0
    res -= [[pos[0], pos[1]-1]]
  end
  if pos[1] == W-1
    res -= [[pos[0], pos[1]+1]]
  end
  res
end


s = []
H.times{
  s << s()
}
que = [[0, 0]]
visited = []
dist = []
H.times{
  visited << Array.new(W, 0)
  dist << Array.new(W, 0)
}
white_count = 0
H.times{|i|
  W.times{|j|
    if s[i][j] == "."
      white_count += 1
    end
  }
}

visited[0][0] = 1

goal = false
while que.length > 0
  current = que.shift
  movePos = getMovePos(current)
  movePos.each{|m|
    if s[m[0]][m[1]] == "." && visited[m[0]][m[1]] == 0
      visited[m[0]][m[1]] = 1
      que.push(m)
      dist[m[0]][m[1]] = dist[current[0]][current[1]] + 1
    end
    if m[0] == H-1 && m[1] == W-1
      goal = true
      break
    end
  }
end
if goal && s[0][0] != "#" && s[H-1][W-1] != "#"
  puts white_count - dist[H-1][W-1] -1
else
  puts -1
end





Measured memory_bytes: 1788
def gcd(x,y):
    while y != 0:
        x, y = y, x%y
#        print(x,y)
    return(x)

n = int(input())
a = list(map(int,input().split()))

s = a[0]
for i in range(1,n):
    ss = gcd(s,a[i])
    s = s*a[i]//ss

ans = 0
for i in range(n):
    ans += s//a[i]
print(ans%(10**9+7))

Measured memory_bytes: 4084
import math

def resolve():
    
    N,K=map(int,input().split())
    A=list(map(int,input().split()))

    # dp=[1]*202020
    # for i in range(K):
    #     dp[K]*=A[i]

    for i in range(K+1,N+1):
        #dp[i]=dp[i-1]/A[i-K-1]*A[i-1]
        if(A[i-1]>A[i-K-1]):
            print("Yes")
        else:
            print("No")


resolve()


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
    int s,w;cin >> s >>w;
    cout << ((w>=s)?"unsafe":"safe") <<"\n";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
    int N;
    //旅行者の人数N人を定義
    int A;
    //電車を使う場合の一人当たりの料金A円を定義
    int B;
    //タクシーを使う場合の料金B円を定義
    cin >> N >> A >> B;
    //N,A,Bの順で標準入力
    if(N * A < B){
        cout << N * A << endl;
        //N * AよりBの料金の方が高い場合N * Aを出力
    } else if(N * A > B){
        cout << B << endl;
        //BよりN * Aの料金の方が高い場合Bを出力
    } else if(N * A == B){
        cout << B << endl;
        //N * Aの料金とBの料金が同じの時はBを出力
    }
}

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

int main(){
    int A,B;
    cin>>A>>B;
    if(A+B==3){
        cout<<"3"<<endl;
    }else if(A+B==4){
        cout<<"2"<<endl;
    }else if(A+B==5){
        cout<<"1"<<endl;
    }
}

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

using namespace std;

int main(){
  int n, k;
  cin >> n;
  cin >> k;
  vector<int> h(n, 0);
  for(int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  vector<int> dp(n, 0);
  for(int i = 0; i < n; i++)
  {
    int min_cost = 1e9;
    for(int j = 1; j <= k; j++)
    {
      if(i - j < 0) break;
      min_cost = min(abs(h[i] - h[i - j]) + dp[i - j], min_cost);
    }
    if(i == 0)
    {
      dp[0] = 0;
    }else{
      dp[i] = min_cost;
    }
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
# 01BFS
INF = 10**9 + 7


def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]

    def bfs_2d(c, sy, sx, gh, gw, H, W):
        que0 = deque()
        que1 = deque()
        dist = [[INF]*W for i in range(H)]

        dist[sy][sx] = 0
        que0.append((sy, sx))
        while que0 or que1:
            if que0:
                uh, uw = que0.popleft()
            else:
                uh, uw = que1.popleft()
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    next_h = uh + dh
                    next_w = uw + dw
                    cost = 0 if abs(dh) + abs(dw) <= 1 else 1
                    if not(0 <= next_h < H and 0 <= next_w < W):
                        continue
                    if c[next_h][next_w] == "#":
                        continue
                    if dist[next_h][next_w] > dist[uh][uw] + cost:
                        dist[next_h][next_w] = dist[uh][uw] + cost
                        if cost == 0:
                            que0.append((next_h, next_w))
                        else:
                            que1.append((next_h, next_w))
        return dist[gh][gw] if dist[gh][gw] != INF else -1

    ans = bfs_2d(A, Ch, Cw, Dh, Dw, H, W)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 100328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  cin >> K >> S;
  int n = S.length();
  if(K >= n) cout << S << endl;
  else{
    string s = S.substr(0,K);
    cout << s << "..." << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b;
    cin>>a>>b;
    int add=a+b;
    int sub=a-b;
    int mul=a*b;
    int res=max(max(add,sub),mul);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000007LL
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;

int n,m;
string s;



int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  cin >> s;
  vector<int> ans;

  int pos = n;
  while (pos > 0) {
    int i = max(0, pos - m);
    while (s[i] == '1') i++;
    if (pos - i == 0) {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(pos - i);
    pos = i;
  }
  reverse(ans.begin(), ans.end());
  FOR(i, ans.size()) cout << ans[i] << ' ';
  cout << endl;

  return 0;
}


Measured memory_bytes: 1096
#include <stdio.h>

int a, b, c;
int main(){
    scanf("%d %d %d", &a, &b, &c);
    if(a<b && b<=c){
	   	printf("%d %d %d\n",a,b,c);
	}
    
	else if(a<=c && c<=b){
	    printf("%d %d %d\n",a,c,b);
	}
	
	else if(b<=a && a<=c ){
	    printf("%d %d %d\n",b,a,c);
	}
	
	else if(b<=c && c<=a ){
		printf("%d %d %d\n",b,c,a);	
	}
	
	else if(c<=a && a<=b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<=b && b<=a){
		printf("%d %d %d\n",c,b,a);
	}
	return 0;
}
	
	


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <tuple>
#include <queue>
#include <map>

using namespace std;

int dx[][7] = {
	{ 0, 1, 1, 0, -1, -1 }, // even
	{ 0, 1, 1, 0, -1, -1 }, // odd
};

int dy[][7] = {
	{ 1, 0, -1, -1, -1, 0 }, // even
	{ 1, 1, 0, -1, 0, 1 },  // odd
};

const int N = 110;

int dist[N * 3][N * 3][6];
int obj[N * 3][N * 3];

int main(){
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;
	sx += N, sy += N, gx += N, gy += N;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		int x, y;
		cin >> x >> y;
		obj[x + N][y + N] = 1;
	}
	int lx, ly;
	cin >> lx >> ly;

	priority_queue<tuple<int, int, int, int>> q;
	q.emplace(0, sx, sy, 0);
	memset(dist, -1, sizeof(dist));
	dist[sx][sy][0] = 0;
	int ans = -1;
	while (!q.empty()){
		int d, x, y, t;
		tie(d, x, y, t) = q.top();
		d = -d;
		q.pop();

		if (dist[x][y][t] < d) continue;
		if (x == gx && y == gy){
			ans = d;
			break;
		}

		for (int i = 0; i < 7; ++i){
			int nx = x + dx[x & 1][i], ny = y + dy[x & 1][i], nt = (t + 1) % 6;
			int nd = d + (i != abs((x-N)*(y-N)*t%6));
			if (nx - N < -lx || nx - N > lx || ny - N < -ly || ny - N > ly) continue;
			if (obj[nx][ny]) continue;
			if (dist[nx][ny][nt] >= 0 && dist[nx][ny][nt] <= nd) continue;
			dist[nx][ny][nt] = nd;
			q.emplace(-nd, nx, ny, nt);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4092
using System;

namespace Testcode
{
    class Program
    {
        
        static void Main(string[] args)
        {         
           
                string[] d = Console.ReadLine().Split();
                var a = long.Parse(d[0]);
                var b = long.Parse(d[1]);
                                
                var x = a / b;
                var y = a % b;
                var z = (decimal) a / b; 


                Console.WriteLine("{0} {1} {2}", x, y, z);
                 

            
        
            
        }
       
    }
}


Measured memory_bytes: 16028
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int p[8][8];
vl a;

ll bfs(vl a){
  ll k=a.size();
  if(a[0]!=0){
    return 0;
  }
  rep(i,k-1){
    if(p[a[i]][a[i+1]]==0){
      return 0;
    }
  }
  return 1;
}

int main() {
  ll n,m;
  cin >> n >> m;
  a.resize(n);
  rep(i,n){
    a[i]=i;
  }
  rep(i,n){
    rep(j,n){
      p[i][j]=0;
    }
  }
  rep(i,m){
    ll x,y;
    cin >> x >> y;
    x--;y--;
    p[x][y]=1;
    p[y][x]=1;
  }
  ll ans=bfs(a);
  while(next_permutation(a.begin(),a.end())){
    if(bfs(a)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

class Main{
    static int hour(int x){
	return (x /(60 * 60));
    }
    static int minu(int x){
	return((x % (60 * 60)) / 60);
    }
    static int sec(int x){
	return(x % 60);
    }
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int x = stdIn.nextInt();
	System.out.println(hour(x) + ":" + minu(x) + ":" + sec(x));
    }
    
}

Measured memory_bytes: 17328
#include <stdio.h>

typedef struct{
    int a;
    int b;
} NUM;

int main(void)
{
    NUM set[100];
    NUM tmp;
    int i,j,k,n,m;

    i = 0;
    while (1){
        scanf("%d,%d", &n, &m);
        if (n == 0 && m == 0){
            break;
        }
        set[i].a = n;
        set[i].b = m;
        i++;
    }
    n = i;
    for (j = 0; j < n - 1; j++){
        for (k = n - 1; k > j; k--){
            if (set[k].b > set[k - 1].b){
                tmp = set[k];
                set[k] = set[k - 1];
                set[k - 1] = tmp;
            }
        }
    }

    
    while (scanf("%d", &m) != EOF){
        i = 0;
        j = 1;
        while (1){
        if (i != 0){
            if (set[i].b == set[i - 1].b){
                j--;
            }
        }
        if (set[i].a == m){
            printf("%d\n", j);
            break;
        }
        i++;
        j++;
        }
    }
    return (0);
}


Measured memory_bytes: 1976
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; i++)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  cout << max(60 * (h2-h1) + m2-m1 - k, 0) << "\n";
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

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

		Long h = Long.parseLong(sc.next());
		
		
		int cnt = 0;
		while(h!=0) {
			
			h = h/2;
			cnt++;
		}
		
		Long ans = (1l << cnt) -1 ;
		
		System.out.println(ans);
	}

}

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

int main(void)
{
    int N;
    cin >> N;
    int differenceCount = 0;
    int p;
    for (int i = 1; i <= N; i++) {
        cin >> p;
        if (i != p) {
            differenceCount++;
        }
    }
    if (differenceCount == 0 || differenceCount == 2) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256