akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

		if (H % 3 == 0 || W % 3 == 0) {
			System.out.println(0);
			return;
		}

		long answer = H * W;
		long[] abc = new long[]{0, 0, 0};

		for (int i = 0; i < 2; i++) {
			if (i == 1) {
				long t = W;
				W = H;
				H = t;
			}

			for (long h = 1; h < H; h++) {
				abc[0] = h * W;
				abc[1] = (H - h) * (W / 2);
				abc[2] = (H - h) * (W - (W / 2));
				Arrays.sort(abc);
				answer = Math.min(answer, abc[2] - abc[0]);

				abc[0] = h * W;
				abc[1] = ((H - h) / 2) * W;
				abc[2] = ((H - h - ((H - h) / 2))) * W;
				Arrays.sort(abc);
				answer = Math.min(answer, abc[2] - abc[0]);
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
vector<int>hu[100005];
int work(int u,int pre)
{
    int ret=0;
    for(int i=0;i<hu[u].size();i++)
    {
        if(hu[u][i]!=pre)
            ret^=(1+work(hu[u][i],u));
    }
    return ret;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        hu[i].clear();
    for(int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        hu[x].push_back(y);
        hu[y].push_back(x);
    }
    if(work(1,-1))
        puts("Alice");
    else
        puts("Bob");
    return 0;
}


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

using namespace std;

void insertion_sort(vector<int> &A, int n, int g, int& cnt);
void shell_sort(vector<int>& A, int n);

int main(){
    int n; cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    shell_sort(A, n);
    
    return 0;
}
void shell_sort(vector<int>& A, int n){
    int cnt = 0;
    int m = floor(log2(n))+1;
    vector<int> G(m);
    for(int i=m-1; i>=0; i--) G[m-1-i] = pow(2,i);
    for(int i=0; i<m; i++) insertion_sort(A, n, G[i], cnt);
    
    //print
    cout << m << endl;
    for(int i=0;i<m;i++) cout << G[i] << " \n"[i==m-1];
    cout << cnt << endl;
    for(int i=0;i<n;i++) cout << A[i] << endl;
}
void insertion_sort(vector<int>& A, int n, int g, int& cnt){
    for(int i=g; i<n; i++){
        int v = A[i];
        int j = i-g;
        while(j>=0 && A[j]>v){
            A[j+g] = A[j];
            j = j -g;
            cnt++;
        }
        A[j+g] = v;
    }
}


Measured memory_bytes: 6788
#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++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/sort.h"

/*std::tuple<int, int> swap(int num1, int num2){
     return std::forward_as_tuple(num1, num2);
}
void traceArray(int A[], int N){
    for(int i=0; i<N; i++){
        cout << A[i];
        if(i!=N-1){
            cout  << " ";
        }
    }
    cout << endl;
}*/

int main(){
    /*int  N;
    cin >> N;
    int  A[N];
    REP(i, N) cin >> A[i];*/
    //sort::Sort test;
    //test.sortByIntention(A, N);
    //test.sortByBubble(A, N);
    //test.sortBySelection(A, N);
    //traceArray(A, N);

    ll n;
    cin >> n;;

    ll s[n+1];
    REP(i, n){
        cin >> s[i]; 
    }

    ll q;
    cin >> q;
    
    ll tmp, j=0, ans=0;
    REP(i, q){
        cin >> tmp;
        j = 0;
        s[n+1] = tmp;
        while(s[j]!=tmp) j++;
        if(j!=n+1) ans++;
    }

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


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int gcd(Int a, Int b) {
 return b != 0 ? gcd(b, a % b) : a;
}//gcd


int main(){
  int n;cin >> n;
  vector<Int> a(n,-1),b(n,-1);//aは与えられた配列,bはその伏字を含まないGCD
  vector<Int> left(n,-1),right(n,-1);//左からのgcd累積(left),右から...
  rep(i,n){
    cin >> a[i];
  }
  int ldata = a[0];
  left[0] = a[0];
  REP(i,1,n){
    ldata = gcd(ldata,a[i]);
    left[i] = ldata;
  }
    int rdata = a[n-1];
    right[n-1] = a[n-1];
  for(int i=n-1;i>=0;i--){
    rdata = gcd(rdata,a[i]);
    right[i] = rdata;
  }
  /*cout << endl;
  rep(i,n) cout << left[i] << endl;
  cout << endl << endl;
  rep(i,n) cout << right[i] << endl;
*/
  b[n-1] = left[n-2];
  b[0] = right[1];
  REP(i,1,n-1){
    b[i] = gcd(left[i-1],right[i+1]);
  }
  sort(b.begin(),b.end());
  cout << b[n-1] << endl;
  return 0;
}


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

int N, M;
vector<int> A(100000), B(100000);

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++)    cin >> A[i] >> B[i];

    vector< pair<int, int> > C(M);
    for(int i=0;i<M;i++)    C[i] = make_pair(B[i], A[i]);

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

    int64_t ans = 1;
    int j = 0;
    for(int i=0;i<M;i++){
        if( C[j].first <= C[i].second ){
            ans++;
            j = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  
  REP(i,5){
    int x;
    cin >> x;
    if(x==0)
      cout << i+1;
  }
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <bitset>
#include <climits>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){

    double v[128][2];
    double x, y;
    
    int n = 0;
    while(scanf("%lf,%lf", &x, &y) != EOF){
        v[n][0] = x; v[n][1] = y;
        ++n;
    }
    
    double s = 0;
    for(int i=1;i<n-1;++i){
        double ts = fabs((v[i][0] - v[0][0])*(v[i+1][1] - v[0][1])
                         -(v[i+1][0] - v[0][0])*(v[i][1] - v[0][1])) / 2;
        s += ts;
    }
    
    printf("%.7f\n", s);
    
    return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {
	static int cnt=0,pos=0;
	static int[] pre=new int[100];
	static int[] ino=new int[100];
	static int[] post=new int[100];
	public static void rec(int x,int y) {
		if (x>=y) return;
		int root=pre[cnt++],cur;
		for (cur=x;cur<y;cur++) if (ino[cur]==root) break;
		rec(x,cur);
		rec(cur+1,y);
		post[pos++]=root;
	}
	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		int n=in.nextInt();
		for (int i=0;i<n;i++) pre[i]=in.nextInt();
		for (int i=0;i<n;i++) ino[i]=in.nextInt();
		rec(0,n);
		for (int i=0;i<n;i++) {
			System.out.print(post[i]);
			if (i!=n-1) System.out.print(" ");
			else System.out.print("\n");
		}
		in.close();
	}
}


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

int main() {
  int ac=0;
  int wa=0;
  int tle=0;
  int re=0;
  std::string input;
  while(std::cin >> input) {
    if(input == "AC") {
      ++ac;
    } else if(input == "WA") {
      ++wa;
    } else if(input == "TLE") {
      ++tle;
    } else if(input == "RE") {
      ++re;
    }
  }
  std::cout << "AC x " << ac << std::endl;
  std::cout << "WA x " << wa <<std::endl;
  std::cout << "TLE x " << tle <<std::endl;
  std::cout << "RE x " << re <<std::endl;
  return 0;
}

Measured memory_bytes: 3224
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0: break
    for i in range(H):
        for j in range(W):
            if ((i+1) % 2 == 1 and (j+1) % 2 == 1) or ((i+1) % 2 == 0 and (j+1) % 2 == 0):
                print("#",end="")
            else:
                print(".",end="")
        print()
    print("")



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

int main(void){
    int n,k,ans = 1;
    cin >> n >> k;
    for(int i = 0;i < n;i++){
        if((ans + k) > ans*2)ans *= 2;
        else ans += k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
# MOD=1000000007

L,R=gets.split.map(&:to_i)

if L/2019<R/2019
  puts 0
  exit
end

lp=L%2019
rp=R%2019
if rp<=lp# && L<=R
  rp+=2019
end

m=2019
(lp..(rp-1)).each do |i|
  ((i+1)..rp).each do |j|
    m=[m,i*j%2019].min
  end
end

puts m

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000][3] ;

// DP テーブル
long long dp[110000][3];

int main() {
    int N ; cin >> N ;
	rep(i,N)rep(j,3) cin >> h[i][j] ;
    rep(i,N)rep(j,3) dp[i][j] = 0 ;
    for (int i = 0 ; i < N ; ++i) {
        for (int j = 0 ; j < 3 ; ++j) {
          for (int k = 0 ; k < 3 ; ++k){
            if( j == k ) continue ;
            chmax(dp[i+1][k],dp[i][j] + h[i][k]) ;
          }
        }
    }
    long long ret = 0 ;
  
    rep(i,3) ret = max(ret,dp[N][i]) ;
    cout << ret << endl;
}

Measured memory_bytes: 5120
#include <cstdio>

int main(){
    double r,s,l;
    scanf("%lf",&r);
    s = 3.14159265358979 * r * r;
    l = 3.14159265358979 * r * 2;

    printf("%lf %lf\n",s,l);

    return 0;
}


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

typedef complex<double> P;
#define X real()
#define Y imag()

struct Node{
    int l, r;
    double d;
    Node(int l, int r, double d):l(l), r(r), d(d) {};
    bool operator<(const Node &n)const{return d > n.d;};
};

int N;
vector<P> M;

double solve(){
    vector<int> ys;
    for(auto p: M) ys.push_back(p.Y);
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    
    vector<P> M2;
    
    for(int i=0; i<N-1; i++){
        auto p1 = M[i], p2 = M[i+1];
        vector<P> tm;
        bool rev = false;
        
        if(p2.Y != p1.Y){
            if(p1.Y > p2.Y){
                rev = true;
                swap(p1, p2);
            }
            for(auto y: ys){
                if(p1.Y <= y && y <= p2.Y)
                    tm.emplace_back((p2.X-p1.X)*(y-p1.Y)/(p2.Y-p1.Y)+p1.X, y);
            }
        }else{
            tm.emplace_back(p1);
            tm.emplace_back(p2);
        }
        if(rev)
            reverse(tm.begin(), tm.end());
        if(M2.size())
            M2.pop_back();
        M2.insert(M2.end(), tm.begin(), tm.end());
    }
    
    priority_queue<Node> que;
    //vector<vector<int>> done(M2.size(), vector<int>(M2.size()));
    //vector<vector<double>> d(M2.size(), vector<double>(M2.size(), 1e9));
    set<pair<int, int>> done;
    map<pair<int, int>, double> d;
    
    que.push(Node(0, M2.size()-1, 0));
    //d[0][M2.size()-1] = 0;
    d[make_pair(0, M2.size()-1)] = 0;
    
    while(!que.empty()){
        auto v = que.top(); que.pop();
        //if(done[v.l][v.r]++) continue;
        if(v.r == v.l)
            return d[make_pair(v.l, v.r)]; //d[v.l][v.r];
        
        if(done.count(make_pair(v.l, v.r))) continue;
        done.insert(make_pair(v.l, v.r));
        
        
        for(int nl=v.l-1; nl<=v.l+1; nl++){
            for(int nr=v.r-1; nr<=v.r+1; nr++) if(0<=nl&&nl<M2.size()&&0<=nr&&nr<M2.size() && M2[nl].Y == M2[nr].Y){
                double cost = abs(M2[v.l]-M2[nl]) + abs(M2[v.r]-M2[nr]);
                if(d.count(make_pair(nl, nr))==0 || d[make_pair(v.l, v.r)] + cost < d[make_pair(nl, nr)]){
                    d[make_pair(nl, nr)] = d[make_pair(v.l, v.r)] + cost;
                    que.push(Node(nl, nr, d[make_pair(nl, nr)]));
                }
            }
        }
    }
    return -1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(16);
    cout.setf(ios::fixed);
    while(cin >> N, N){
        M.resize(N);
        for(int i=0; i<N; i++){
            int x, y; cin >> x >> y;
            M[i] = P(x, y);
        }
        cout << solve() << endl;
    }
    
    return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) for (auto el : v) { cerr << el << ' '; } cerr << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m;
	scanf("%d%d", &n, &m);
	vi a(m);
	for (int i = 0; i < m; i++) scanf("%d", &a[i]);

	if (n >= m) {
		puts("0");
		return 0;
	}

	sort(all(a));
	int total = a.back() - a.front();
	vi b(m-1);
	for (int i = 0; i < m-1; i++) b[i] = a[i+1] - a[i];
	sort(all(b), greater<int>());
	for (int i = 0; i < n-1; i++) total -= b[i];
	cout << total << endl;
}


Measured memory_bytes: 1024
import sys
from itertools import combinations

input = sys.stdin.readline


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    ans = "Yay!"
    for p, q in combinations([a, b, c, d, e], 2):
        if abs(p - q) > k:
            ans = ":("

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#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 if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  
}

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();
    if(a < b && b < c) {
      System.out.println("Yes");
    }else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26200
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll n, k;
vii res;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k;

	if (3 * n / 2 > 2 * n - k) {
		cout << -1 << endl;
		return 0;
	}

	ll i = 0, j = 3 * n / 2;

	while (i <= j) {
		if (i == j) i--;
		res.emplace_back(i, j);
		i += 2, j--;
	}

	i = 1, j = 2 * n - 1;
	while (j > 3 * n / 2) {
		res.emplace_back(i, j);
		i += 2, j--;
	}

	forn (i, res.size())
		cout << k + res[i].fi << " " << k + res[i].se << " " << k + 2 * n + i << endl;

	return 0;
}

Measured memory_bytes: 3952
a,b,m = map(int,input().split())
als = list(map(int,input().split()))
bls = list(map(int,input().split()))
xls = [list(map(int,input().split())) for i in range(m)]
ans = min(als)+min(bls)

for i in xls:
    # print(i)
    ans = min(ans,als[i[0]-1]+bls[i[1]-1]-i[2])
# print(als,bls,xls)
print(ans)


Measured memory_bytes: 38488
#include <array>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
using ll = long long;
using namespace std;

constexpr int mod = 1e9+7;
int main() {
    // input
    int n; ll a, b; scanf("%d%lld%lld", &n, &a, &b);
    vector<ll> s(n); repeat (i, n) scanf("%lld", &s[i]);
    if (a > b) swap(a, b);
    // solve
    s.insert(s.begin(), s.front() - a - b);
    s.insert(s.begin(), s.front() - a - b);
    s.insert(s.end(),   s.back()  + a + b);
    vector<array<int, 2> > dp(n + 3);
    vector<int> acc(n + 4);
    dp[1][0] = 1;
    acc[2] = 1;
    int l_l = 1, l_r = 0;
    repeat_from (r, 2, n + 3) {
        while (l_r < r - 1 and s[l_r] + b <= s[r]) ++ l_r;
        if (l_l <= l_r) {
            dp[r][0] = (acc[l_r] - acc[l_l] +(ll) mod) % mod;
        }
        if (not (s[r - 1] + a <= s[r])) l_l = r - 1;
        dp[r][1] = (s[r - 1] + b <= s[r]) ? (dp[r - 1][0] + dp[r - 1][1]) % mod : 0;
        acc[r + 1] = (0ll + acc[r]
                + (s[r - 1] + a <= s[r + 1] ? dp[r][0] : 0)
                + dp[r][1] ) % mod;
    }
    // output
    int result = (dp[n + 2][0] + dp[n + 2][1]) % mod;
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 2164
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0 for j in range(s+1)] for i in range(n)]
dp[0][0]=2
if a[0]<=s: dp[0][a[0]]=1

for i in range(1,n):
    for j in range(s+1):
        dp[i][j]+=(dp[i-1][j]*2)
        if j-a[i]>=0: dp[i][j]+=dp[i-1][j-a[i]]
        dp[i][j]%=mod
print(dp[n-1][s]%mod)

Measured memory_bytes: 147204
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
#define Maxn 200010
#define V 1000010
char ch[V];int len;
char *str[Maxn];
int L[Maxn];
int *sum[26][Maxn];
struct Node{
	int son[26],sum;
}tree[V];int root=0,cnt=0;
void Insert(int &k,int at){
	if(!k)k=++cnt;
	if(at==len+1){
		tree[k].sum++;
		return;
	}
	Insert(tree[k].son[ch[at]-'a'],at+1);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",ch+1);
		len=strlen(ch+1);
		L[i]=len;
		str[i]=new char[L[i]+1];
		for(int j=1;j<=L[i];++j)str[i][j]=ch[j];
		for(int j=0;j<26;++j){
			sum[j][i]=new int[L[i]+1];
			sum[j][i][0]=0;
			for(int k=1;k<=L[i];++k){
				sum[j][i][k]=sum[j][i][k-1];
				if((ch[k]-'a')==j)sum[j][i][k]++;
			}
		}
		reverse(ch+1,ch+len+1);
		Insert(root,1);
	}
	ll Ans=-n;
	for(int i=1;i<=n;++i){
		int k=root;
		for(int j=L[i];j>=1;--j){
			for(int z=0;z<26;++z)
			    if(sum[z][i][j])Ans+=tree[tree[k].son[z]].sum;
			k=tree[k].son[str[i][j]-'a'];
		}
	}
	printf("%lld\n",Ans);
}

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

using namespace std;


int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n-1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<n-1;i++)
	{
		cin>>c[i];
	}

	int sum = b[a[0]-1];

	for(int i=1;i<n;i++)
	{
		sum+=b[a[i]-1];
		//cout<<b[a[i]-1]<<endl;

		if(a[i] == a[i-1] + 1 )
		{
			sum+=c[a[i-1]-1];
		}
	}
	cout<<sum<<endl;
	

    return 0;
}


Measured memory_bytes: 256
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A = int(sys.stdin.buffer.readline().rstrip())
    B = int(sys.stdin.buffer.readline().rstrip())
    print('GREATER' if A > B else 'LESS' if A < B else 'EQUAL')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
s = gets.strip.split('')
q = gets.strip.to_i

query_array = Array.new()
(0..q-1).each do
  query_array.push(gets.strip.split(' '))
end
reverse_flag = false

query_array.each do |query|
  case query[0]
  when '1'
    # 反転処理
    reverse_flag = !reverse_flag
  else
    # 追加処理
    case query[1]
    when '1'
      # 先頭に追加
      if !reverse_flag
        s.unshift(query[2])
      else
        s.push(query[2])
      end
    else
      # 末尾に追加
      if !reverse_flag
        s.push(query[2])
      else
        s.unshift(query[2])
      end
    end
  end
end

if !reverse_flag
  puts s.join('')
else
  puts s.reverse.join('')
end


Measured memory_bytes: 51068
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    map<int,int> mp;
    rep(i,n){
        cin>>a.at(i);
        mp[a.at(i)]++;
    }
    sort(all(a),greater<int>());
    vector<int> pow2(30,2);
    rep(i,29)pow2.at(i+1)=pow2.at(i)*2;
    int ans=0;
    rep(i,n){
        int A=a.at(i),B=pow2.at(upper_bound(all(pow2),A)-pow2.begin())-A;
        if(mp[A]<=0)continue;
        mp[A]--;
        if(mp[B]>0){
            ans++;
            mp[B]--;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 26752
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    long long int ans=0;

    long long int a,b;
    cin>>a>>b;

    if((a*b)%2==0){
        ans=(a*b)/2;
    }
    else{
        ans=(a*b)/2+1;
    }

    if(a==1 || b==1){
        ans=1;
    }
    
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    string SA, SB, SC;
    cin >> SA >> SB >> SC;

    reverse(SA.begin(), SA.end());
    reverse(SB.begin(), SB.end());
    reverse(SC.begin(), SC.end());

    // cout << &SA << endl;
    // cout << &SB << endl;
    // cout << &SC << endl;

    string* current = &SA;    

    char currentChar = 'A';

    while (true) {
    // for (int i = 0; i < 5; i++) {

        if (current->empty()) {
            cout << currentChar << endl;
            return 0;
        }

        char c = current->back();
        current->pop_back();

        // cout << c << ", " << current << ", " << currentChar << endl;        

        if (c == 'a') {
            current = &SA;
            currentChar = 'A';
        } else if (c == 'b') {
            current = &SB;
            currentChar = 'B';
        } else {
            current = &SC;
            currentChar = 'C';
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define M 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
const int INF = 1e18L+5;
const int LG = 20;
const int N = 1e5+9;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int power(int x,int y){if(x==0)return 0;int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}
bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}
int32_t main()
{
	//cout.precision(15);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int a,b,c,k,ans=0;
		cin>>a>>b>>c>>k;
		if(k<=a)
		{
			ans=k;
		}
		else
		{
			ans+=a;
			k-=a;
			if(k>b)
			{
				k-=b;
				if(c>=k)
				{
					ans-=k;
				}
			}
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
int N,H[21],max,i,Cnt = 1;
scanf("%d",&N);

for(i = 0; i<N;i++){
scanf("%d",&H[i]);
}

max = H[0];

for(i=1;i<N;i++){
if(max<=H[i]){
Cnt++;
max = H[i];
}
}

printf("%d",Cnt);

return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll N, A, B, ans;
ll h[MAX_10p5];

bool solv(ll K) {
	ll temp = K;
	repi(i, 0, N) {
		ll curHP = h[i];
		curHP = h[i] - K*B;
		if (curHP > 0) {
			temp -= curHP / (A - B);
			if (curHP % (A - B)) temp--;
		}
		if (temp < 0) return false;
	}
	return true;
}

ll binary_search(ll left, ll right) {
	ll next = (left + right) / 2;
	if (next == left) return left + 1;
	if (solv(next)) return binary_search(left, next);
	else return binary_search(next, right);
}

int main() {
	cin >> N >> A >> B;
	ll sum_hp = 0;
	repi(i, 0, N) {
		rd(h[i]);
		sum_hp += h[i];
	}
	ans = binary_search(0, (sum_hp + B - 1) / B);
	wrln(ans);
	return 0;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int main() {
    string s;
    cin >> s;

    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (s == "Rainy") {
        cout << "Sunny" << endl;
    }
    return 0;
}


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

bool used[310];
int scc[310],k;
vector<int> G[310],rev[310],vs;

void add_edge(int from,int to){
	G[from].push_back(to);
	rev[to].push_back(from);
}

void dfs(int v){
	used[v] = true;
	for(int to : G[v]){
		if(!used[to]) dfs(to);
	}
	vs.push_back(v);
}

void rdfs(int v){
	used[v] = true;
	scc[v] = k;
	for(int to : rev[v]){
		if(!used[to]) rdfs(to);
	}
}

int n,m;

void build(){
	for(int i = 0;i < n;i++) used[i] = false;
	for(int i = 0;i < n;i++){
		if(!used[i]) dfs(i);
	}
	for(int i = 0;i < n;i++) used[i] = false;
	k = 0;
	for(int i = n - 1;i >= 0;i--){
		if(!used[vs[i]]){
			rdfs(vs[i]);
			k++;
		}
	}
}

signed main(){
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		add_edge(a,b);
	}
	build();
	for(int i = 0;i < n;i++){
		bool isFirst = true;
		for(int j = 0;j < n;j++){
			if(scc[i] == scc[j]){
				cout << (isFirst ? "" : " ") << j + 1;
				isFirst = false;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 4296
N, Q = map(int, input().split())
S = input()
AC = [0] * (N)
for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i-1]
for _ in range(Q):
    l,r = map(int,input().split())
    l-=1
    r-=1
    print(AC[r]-AC[l])

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> h(n);
    vector<bool> bh(n,true);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(h[a-1]>h[b-1])bh[b-1]=false;
        else if(h[a-1]<h[b-1])bh[a-1]=false;
        else{
            bh[a-1]=false;
            bh[b-1]=false;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(bh[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
int get_dig(long long x){
    int ret = 0 ;
    while(x){
        ret++ ;
        x /= 10 ;
    }
    return ret; 
}
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    long long n ;
    cin >> n ;
    int ans = 15 ;
    for(long long i = 1 ; i*i <= n ; i++){
        if(n%i == 0){
            long long a = i ;
            long long b = n/i ;
            ans = min(ans , max(get_dig(a) , get_dig(b))) ;
        }
    }
    cout << ans << endl ;
    return 0 ; 
}

Measured memory_bytes: 256
import sys
import numpy as np
# from numba import njit#,i8

#@njit(cache=True)
# @jit(返り値の型(引数1の型,引数2の型,．．．,引数nの型))
#@jit(i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:]))
def main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):

	def add(itemCount, items, i, value):
		while i <= itemCount:
			items[i] += value
			i += (i & (-i))

	def sumFromStart(items, end):
		summary = 0
		i = end
		while i > 0:
			summary += items[i]
			i -= (i & (-i))
		return summary

	def sum(items, start,end):
		summary = sumFromStart(items, end) - sumFromStart(items, start-1)
		return summary

	# 答え配列
	ans=np.zeros(Q, dtype=np.int64)
	#ans=[0]*Q
	# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
	qindex = 0

	for n in range(N):
		# 外側のループでは、全部の色をループ

		if Q <= qindex:
			break

		if 0 < mostRightColorIndex[C[n]]:
			# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
			# 今回で、同じ色の一番右側の要素はループ中の要素になる
			# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
			add(N,bitArray,mostRightColorIndex[C[n]], -1 )

		# この要素の色の一番右のindexを、BITに登録
		mostRightColorIndex[C[n]] = n+1
		add(N,bitArray,n+1, 1)

		# while qindex < Q and n+1 == queries[qindex][2]:
		while qindex < Q and n+1 == queries[orderByR[qindex]][1]:
			# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
			tmpIndex = orderByR[qindex]
			start = queries[tmpIndex][0]
			end = queries[tmpIndex][1]
			ans[tmpIndex]=sum(bitArray,start,end)
			# print(tmpIndex,start,end,ans[tmpIndex])
			qindex += 1

	return ans

if sys.argv[-1]=='ONLINE_JUDGE':
	from numba.pycc import CC
	cc=CC('my_module')
	cc.export('main','i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:])')(main)
	cc.compile()
	exit(0)
from my_module import main



def input(): return sys.stdin.readline()

N,Q = map(int,input().split())

C=np.array(input().split(), int)

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=np.empty((Q,2),int)
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = l
	queries[q][1] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

orderByR=np.argsort(queries[:,1])

# 各色の現在の一番右のindex
mostRightColorIndex = np.zeros(N+1, int)
# bit indexed tree
bitArray=np.zeros(N+1,int)

for a in main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):
	print(a)


Measured memory_bytes: 85824
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

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

    int a, b;
    cin >> a >> b;

    if (a == 1) a = 100;
    if (b == 1) b = 100;

    if(a == b) puts("Draw");
    else puts(a > b ? "Alice" : "Bob");

    return 0;
}


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

typedef long long ll;

ll N;
map<ll, ll> A;
ll R;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    ++A[a];
  }
  for (auto an : A) {
    ll a, n;
    tie(a, n) = an;
    R += n >= a ? n - a : n;
  }
  cout << R << endl;
}


Measured memory_bytes: 6272
// https://atcoder.jp/contests/abc100/tasks/abc100_a

package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)

  if a > 8 || b > 8 {
    fmt.Println(":(")
  } else {
    fmt.Println("Yay!")
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const char E = '#';
    const char O = '.';
    while(true) {
        int h, w;
        cin >> h >> w;
        if (h == 0) break;
        REP(i,h)  {
            string s;
            REP(j,w) s.push_back((i+j)%2==0 ? E:O);
            cout << s << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3188
import sys

n = int(sys.stdin.readline().strip())
nums = list(map(int, sys.stdin.readline().strip().split()))
# appear times
d = dict()
for one in nums:
    if one in d:
        d[one] += 1
    else:
        d[one] = 1

def C(a):
    return (a*(a-1)//2 )

accum = 0
for k, v in d.items():
    accum += C(v)

res_history = dict()

for one in nums:
    if one in res_history:
        print(res_history[one])
    else:
        if d[one] == 1:
            print(accum)
        else:
            res = accum 
            delta = C(d[one]) - C(d[one] - 1)
            res -= delta
            res_history[one] = res
            print(res)



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n,t,x,y,tb=0,xb=0,yb=0;
    cin>>n;
    bool ans=true;

    rep(i,n){
        cin>>t>>x>>y;
        if((abs(x-xb)+abs(y-yb))>t-tb||
            (abs(x-xb)+abs(y-yb))%2!=(t-tb)%2){
            ans=false;
            break;
        }
        tb=t;xb=x;yb=y;
    }

    if(ans){
        cout<<"Yes"<<endl;
        return 0;
    }

    cout<<"No"<<endl;

}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,t;
    cin >> n >> t;
    double ans = 0;
    rep(i,n){
        double x,h;
        cin >> x >> h;
        ans = max(ans, t*h/x);
    }
    cout << shosu(10) << ans << endl;

}



Measured memory_bytes: 3288
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-7;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

struct Timer {
  Timer() { reset(); }
  void reset() { beg = chrono::high_resolution_clock::now(); }
  ll elapsed() {
    chrono::high_resolution_clock::time_point en = chrono::high_resolution_clock::now();
    return chrono::duration_cast<chrono::milliseconds>(en - beg).count();
  }
private:
  chrono::high_resolution_clock::time_point beg;
} timer;

int main() {
  int n, k; cin >> n >> k;
  vector<int> x(n), y(n), c(n); REP(i, n) cin >> x[i] >> y[i] >> c[i];
  function<double(double, double)> calc = [&](double X, double Y) {
    vector<double> meet(n);
    REP(i, n) meet[i] = sqrt((x[i] - X) * (x[i] - X) + (y[i] - Y) * (y[i] - Y)) * c[i];
    sort(ALL(meet));
    return meet[k - 1];
  };
  vector<pair<double, pair<int, int> > > lat;
  for (int x = -1000; x <= 1000; x += 10) for (int y = -1000; y <= 1000; y += 5) {
    lat.emplace_back(calc(x, y), make_pair(x, y));
  }
  sort(ALL(lat));
  double ans = lat[0].first;
  for (int idx = 0; idx < lat.size() && timer.elapsed() < 1950; ++idx) {
    int x, y; tie(x, y) = lat[idx].second;
    function<double(double)> f = [&](double X) {
      double lb_y = y - 5, ub_y = y + 5;
      while (ub_y - lb_y > EPS) {
        double mid1 = (lb_y + lb_y + ub_y) / 3, mid2 = (lb_y + ub_y + ub_y) / 3;
        if (calc(X, mid1) < calc(X, mid2)) {
          ub_y = mid2;
        } else {
          lb_y = mid1;
        }
      }
      return calc(X, lb_y);
    };
    double lb_x = x - 5, ub_x = x + 5;
    while (ub_x - lb_x > EPS) {
      double mid1 = (lb_x + lb_x + ub_x) / 3, mid2 = (lb_x + ub_x + ub_x) / 3;
      if (f(mid1) < f(mid2)) {
        ub_x = mid2;
      } else {
        lb_x = mid1;
      }
    }
    chmin(ans, f(lb_x));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2420
import math

A, B = map(int, input().split())

def find_divisor(n):
    answer = n
    for i in range(math.floor(math.sqrt(n))):
        if n % (i+2) == 0:
            answer = (i+2)
            break
        else:
            pass
    return answer

A_q_list = []
B_q_list = []
A_dict = {}
B_dict = {}
LCM_pq_list = []
LCM_dict = {}

q = A
for i in range(A):
    while q >= 2:
        divisor = find_divisor(q)
        A_q_list.append(divisor)
        try:
            A_dict[divisor]
        except KeyError:
            A_dict[divisor] = 1
            if divisor not in LCM_pq_list:
                LCM_pq_list.append(divisor)
        else:
            A_dict[divisor] += 1
        q = q // divisor
q = B
for i in range(B):
    while q >= 2:
        divisor = find_divisor(q)
        B_q_list.append(divisor)
        try:
            B_dict[divisor]
        except KeyError:
            B_dict[divisor] = 1
            if divisor not in LCM_pq_list:
                LCM_pq_list.append(divisor)
        else:
            B_dict[divisor] += 1
        q = q // divisor

LCM = 1
for i in LCM_pq_list:
    try:
        A_dict[i]
    except KeyError:
        A_dict[i] = 0
    else:
        pass
    try:
        B_dict[i]
    except KeyError:
        B_dict[i] = 0
    else:
        pass
    LCM_dict[i] = max(A_dict[i], B_dict[i])
    LCM = LCM * i**LCM_dict[i]

print(LCM)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mx 100000
#define md 1000000007ll
#define prMX 10000000
ll prime[prMX+2];
bool vis[prMX+2];
#define MX 10000000000000ll

int main(){

  int n,m;
  cin>>n>>m;
  ll ar[n+2];
  for(int i=1;i<=n;i++)cin>>ar[i];
  sort(ar+1,ar+n+1);
  pair<ll,ll> br[m+2];

  for(int i=1;i<=m;i++)cin>>br[i].second>>br[i].first;

  sort(br+1,br+m+1);
  int ptr = m;
  ll col[n+2];
  ll x=0;
  int l =0;
  for(int i=m;i>=1 &&l<=n;i--){
      for(int j=1;l<=n&&j<=br[i].second;j++){
          col[++l] = br[i].first;
      }
  }
  col[0]=0;
  for(int i=1;i<=l;i++)col[i]=col[i-1]+col[i];

  ll res=0;
    ll sum=0;
  for(int i=n;i>=0;i--){
    // cout<<sum<<" "<<col[i]<<endl;
     if(i<=l)
      res =max(res,sum+col[i]);
      sum+=ar[i];
  }
  cout<<res<<endl;


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

Measured memory_bytes: 3328
N,K = map(int,input().split())

trees = []

for i in range(N):
    trees.append(int(input()))


trees.sort()

ans = 1000000000
for i in range(N-K+1):
    aa = trees[i+K-1]-trees[i]
    if aa < ans:
        ans = aa

print(ans)


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

int main()
{
    int A, B;
    cin >> A >> B;
    
    if(A>0 && A<10 && B>0 && B<10){
    cout << A*B << endl;
    }
    else{
    cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("out2.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int r;
		cin >> r;
		cout << r*r << endl;
	
	}
	
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
lists=list(map(int,input().split()))
GG=[]
sumlist=[0]
a=0
for i in range(len(lists)):
    a+=lists[i]
    sumlist.append(a) 
for i in range(len(sumlist)):
    for j in range(i+1,len(sumlist)):
        
        G=sumlist[j]-sumlist[i]
        GG.append(G)
        
GG=sorted(GG,reverse=True)      
maxi=format(GG[0],"b")
from collections import deque
d=deque()
e=deque()
for j in range(len(GG)):
    d.append(format(GG[j],"b").zfill(len(maxi)))
answer=0
index=0
 
while index!=len(maxi):
    counter=0
    for some in d:
        if some[index]=="1":
            counter+=1
            e.append(some)
    if counter>=k:
        answer+=2**(len(maxi)-1-index)
        d=e
        e=deque()
    elif counter<k:
        d=d
        e=deque()
        
    index+=1
    counter=0
print(answer)

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int v[n];
  rep(i, n) cin >> v[i];

  sort(v, v + n);
  double ans = v[0];
  rep(i, n - 1) { ans = (ans + v[i + 1]) / 2; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
//	file();
	fast();
	int a, b; cin >> a >> b;
	cout << a * b << endl;

	return 0;
}


Measured memory_bytes: 3652
public class Hello{
    public static void Main(){
        
        var line = System.Console.ReadLine();
        string[] array = line.Split(' ');
        
        int k = int.Parse(array[0]);
        int n = int.Parse(array[1]);
        
        var list = System.Console.ReadLine();
        string[] house = list.Split(' ');
        
        int[] houses = new int[n];
        for(int i = 0; i < n; i++)
        {
            houses[i] = int.Parse(house[i]);
        }
        
        int[] distance = new int[n];
        distance[n-1] = houses[0] + k - houses[n - 1];
        int sum,max = 0;
        sum = distance[n - 1];
        max = distance[n - 1];
        for(int j = 0; j + 1 < n  ; j++)
        {
            distance[j] = houses[j + 1] - houses[j];
            sum += distance[j];
            if(distance[j] > max)
            {
                max = distance[j];
            }
        }
        
        
        System.Console.WriteLine(sum - max);
        
        
    }
}

Measured memory_bytes: 34524
#include<iostream>
#include<map>

using namespace std;

int main(void){
	while(1){
		map<int, int> data;
		int a,n;
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			int b,c,d;
			cin >> b >> c >> d;
			data.insert(pair<int, int>(c+d,b));
		}
		map<int, int>::iterator it = data.end();
		it--;
		cout << (*it).second << " " << (*it).first << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 10010;

// nの約数を昇順に列挙したvectorを返す。計算量はO(√n)
vector<ll> yakusu(ll n) {
    vl res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(all(res));
    return res;  
}
  
int main() {
    ll n;
    cin >> n;

    vl v1 = yakusu(n-1);
    vl v2 = yakusu(n);
    ll ans = v1.size() - 1;
    for(auto d : v2) {
        if(d == 1) {
            continue;
        }
        if(d == n) {
            ans++;
            break;
        }
        ll x = n;
        while(x%d == 0) {
            x /= d;
        }
        if(x%d == 1) {
            ans++;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 384