akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

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

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

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

//aのp乗を求めるアルゴリズム
long modpow(long a, int p) {
	if (p == 0)return 1;
	if (p % 2 == 0) {
		//pが偶数のとき
		int halfP = p / 2;
		long half = modpow(a, halfP);
		return half * half % mod;
	}
	else {
		//pが奇数の時は、
		//pを偶数にするために1減らす
		return a * modpow(a, p - 1) % mod;
	}

}


//(10*9*8)/(3*2*1);
//10*9*8 -> ansMul
//3*2*1 -> ansDiv;
long calcComb(int a, int b) {
	if (b > a - b) return calcComb(a, a - b);
	long ansMul = 1;
	long ansDiv = 1;
	rep(i, 0, b) {
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	//ansMul /ansDivをやりたい
	//ansDivの逆元を使って求めよう。

	long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
	return ans;

}

bool is_war(const vector<int>& x, const vector<int>& y) {
	for (int Z = -100; Z <= 100; Z++) {
		bool is_ok = true;
		rep(i, 0, x.size()) {
			if (x[i] >= Z) {
				is_ok = false;
			}
			rep(i, 0, y.size()) {
				if (y[i] < Z) {
					is_ok = false;
				}
			}
			
		}
		if (is_ok)return false;
		
	}
	return true;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;

	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}


}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;

	set<int> st;
	for (int i = 0; i < n; i++)
	{
		int c;
		cin >> c;
		st.insert(c);
	}

	if (st.size() == n) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}



	return 0;
}



Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;

	int ans = 999;

	int N = S.size();

	for (int i = 0; i <= N - 3; ++i) {
		int num = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + S[i + 2] - '0';
		ans = min(ans, abs(num - 753));
	}
	cout << ans;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var x int
        fmt.Scan(&x)

        max := 1
        for b := 2; b <= 100; b++ {
                for e := b * b; e <= 1000; e *= b {
                        if e <= x && e > max {
                                max = e
                        }
                }
        }
        fmt.Println(max)
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int N,x;
    scanf("%d", &N);
    x = N % 10;
    if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9 ){
        printf("hon\n");
    }
    else if(x == 0 || x == 1 || x == 6 || x == 8){
        printf("pon\n");
    }
    else{
        printf("bon\n");
    }
}

Measured memory_bytes: 1644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c[] = s.toCharArray();
		sc.close();
		int a = 0;

		for (int i = 0; i < s.length(); i++) {
			if (i % 2 == 0) {
				if (c[i] == 'L') {
					a++;
				}
			} else {
				if (c[i] == 'R') {
					a++;
				}
			}
		}
		if (a == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
[n,k] = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
dp = [1000000000] * n
dp[0] = 0
for i in range(1,n):
    for j in range(1,min(k,i)+1):
        dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]))
print(dp[n-1])
#print(dp)


Measured memory_bytes: 52448
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};



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

    int x,n;
    cin >> x >> n;
    set<int> se;
    rep(i,n){
        int t;
        cin >> t;
        se.insert(t);
    }
    ll count = 0;
    while(1){
        if(se.count(x-count)){
            if(se.count(x+count)){
                count++;
            }else {
                cout << x+count << endl;
                break;
            }
        }else {
            cout << x-count << endl;
            break;
        }
    }


    cout << endl;
    return 0;
}


Measured memory_bytes: 3656
object Main extends App {
    val in = readLine.split(" ").map(_.toInt)
    val x = in(0)
    val a = in(1)
    val b = in(2)

    val ret = if (b - a <= 0) {
      "delicious"
    } else if (b - a <= x){
      "safe"
    } else {
      "dangerous"
    }
    println(ret)

}


Measured memory_bytes: 25408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin>>a;
  if(a<=111) cout<<"111";
  else{
    if(a<=222) cout<<"222";
    else{
      if(a<=333) cout<<"333";
      else{
	if(a<=444) cout<<"444";
	else{
	  if(a<=555) cout<<"555";
	  else{
	    if(a<=666) cout<<"666";
	    else{
	      if(a<=777) cout<<"777";
	      else{
		if(a<=888) cout<<"888";
		else cout<<"999";
	      }
	    }
	  }
	}
      }
    }
  }
  cout<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  double L;
  cin>>L;
  double A=0.4;
  double B=0.4;
  double C=L-0.8;
  rep(i,1e8){
    if(i%3==0){
      A=(B=(A+B)/2);
    }else if(i%3==1){
      B=(C=(B+C)/2);
    }else{
      C=(A=(C+A)/2);
    }
  }
  cout<<setprecision(10)<<A*B*C<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define fix  cout<<std::fixed;
#define mk make_pair
#define N 100005
#define mod 1000000007
#define time  cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
#define IOS        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
    ll n;cin>>n;
    if(n%10 == 3)cout<<"bon";
    else if(n%10 == 0 ||n%10 == 1||n%10 == 6||n%10 == 8)cout<<"pon";
    else cout<<"hon";
}

Measured memory_bytes: 3624
#include <iostream>

int main()
{
  int N, M, city[50] = {0};
  std::cin >> N >> M;
  
  int start, end;
  for(int i = 0; i < M; i++)
  {
    std::cin >> start >> end;
    city[start - 1]++;
    city[end - 1]++;
  }

  for(int i = 0; i < N; i++)
  {
    std::cout << city[i] << "\n";
  }  

  return 0;
}

Measured memory_bytes: 3192
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), res(N, 0);
    REP(i, N) {
        cin >> A[i];
        if (i % 2 == 0) {
            res[0] += A[i];
        } else {
            res[0] -= A[i];
        }
    }
    FOR(i, 1, N, 1) {
        res[i] += A[i - 1] * 2 - res[i - 1];
    }
    REP(i, N) {
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        List<Integer> xL = new ArrayList<>();
        List<Integer> yL = new ArrayList<>();
        char[][] map = new char[h][w];
        int cnt = 0;
        for (int i = 0; i < h; i++) {
            map[i] = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if (map[i][j] == '.') {
                    xL.add(j);
                    yL.add(i);
                } else {
                    cnt++;
                }
            }
        }
        if (cnt <= 2) {
            System.out.println(h - 1 + w - 1);
            return;
        }
        int ans = 0;
        for (int i = 0; i < xL.size(); i++) {
            Point start = new Point(xL.get(i), yL.get(i));
            for (int j = 0; j < xL.size(); j++) {
                Point goal = new Point(xL.get(j), yL.get(j));
                ans = Math.max(ans, bfs(start, goal, map.clone(), h, w));
            }
        }
        System.out.println(ans);
    }

    private static int bfs(Point start, Point goal, char[][] baseMap, int h, int w) {
        int[] dx = {1, 0, -1, 0};
        int[] dy = {0, 1, 0, -1};
        Deque<Point> dq = new ArrayDeque<>();
        dq.add(start);
        char[][] map = deepCopy(baseMap);
        int[][] moves = new int[h][w];
        map[start.getY()][start.getX()] = '#';
        while (dq.size() > 0) {
            Point p = dq.removeFirst();
            for (int i = 0; i < 4; i++) {
                int x = p.getX() + dx[i];
                int y = p.getY() + dy[i];
                if (x < 0 || x > w - 1 || y < 0 || y > h - 1) {
                    continue;
                }
                if (map[y][x] == '.') {
                    dq.addLast(new Point(x, y));
                    map[y][x] = '#';
                    moves[y][x] = moves[p.getY()][p.getX()] + 1;
                }
            }
        }
        return moves[goal.getY()][goal.getX()];
    }

    private static char[][] deepCopy(char[][] org) {
        if (org == null) {
            return null;
        }

        final char[][] result = new char[org.length][];
        for (int i = 0; i < org.length; i++) {
            result[i] = Arrays.copyOf(org[i], org[i].length);
        }
        return result;
    }
}

class Point {

    private int x;
    private int y;

    Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
}

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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int N;
    vector<int> V;
    vector<int> C;

    cin >> N;

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

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] > C[i]) {
            ans += V[i] - C[i];
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> x(n + 1);
  for (int i = 0; i < n + 1; i++) cin >> x[i];
  int d = abs(x[0] - x[1]);
  for (int i = 1; i < n; i++) {
    d = gcd(d, x[i+1] - x[i]);
  }
  cout << d << '\n';
  return 0;
}

Measured memory_bytes: 640
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt();
    set<string> a;
    for (int i = 0; i < n; i+=1){
        string s;
        cin >> s;
        a.insert(s);
    }
    printf("%d\n", a.size());
    return 0;
}



Measured memory_bytes: 19332
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int Ma=sc.nextInt();
		int Mb=sc.nextInt();
		int[][][] dp=new int[41][401][401];
		int INF=1000000007;
		for(int i=0; i<=40; i++) {
			for(int j=0; j<=400; j++) {
				Arrays.fill(dp[i][j],INF);
			}
		}
		dp[0][0][0]=0;
		int[][] kusuri=new int[N][3];
		for(int i=0; i<N; i++) {
			kusuri[i][0]=sc.nextInt();
			kusuri[i][1]=sc.nextInt();
			kusuri[i][2]=sc.nextInt();
		}
		for(int i=0; i<N; i++) {
			for(int j=0; j<=400; j++) {
				for(int k=0; k<=400; k++) {
					if(dp[i][j][k]<INF) {
						dp[i+1][j][k]=Math.min(dp[i+1][j][k],dp[i][j][k]);
						dp[i+1][j+kusuri[i][0]][k+kusuri[i][1]]=Math.min(dp[i+1][j+kusuri[i][0]][k+kusuri[i][1]],dp[i][j][k]+kusuri[i][2]);
					}
				}
			}
		}
		int min=114514810;
		int counter=1;
		while(Ma*counter<=400 && Mb*counter<=400) {
			min=Math.min(dp[N][Ma*counter][Mb*counter],min);
			counter++;
		}
		if(min==114514810){
			System.out.println(-1);
		}
		else{
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 58068
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int N;
		int[] a;

		try(Scanner sc = new Scanner(System.in)){
			N = sc.nextInt();
			a = new int[N];
			for(int i = 0; i < a.length; i++){
				a[i] = sc.nextInt();
			}
		}

		Arrays.sort(a);

		int point = 0;

		for(int i = a.length -1; i >= 0; i-=2){
			point += a[i];
		}
		for(int i = a.length -2; i >= 0; i-=2){
			point -= a[i];
		}

		System.out.println(point);
	}

}


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

if n == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

st = factorization(n)


count = 0
temp = 1


for a,b in st:

    while 1/2*(temp)*(temp +1) <= b:
        temp += 1
    count += temp-1
    temp = 1

print(count)


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


int main() {
    int gr[3][3];
    for (auto &i : gr) {
        for (int &j : i) {
            cin >> j;
        }
    }
    int a=gr[0][1]-gr[0][0],b=gr[0][2]-gr[0][0],c=gr[1][0]-gr[0][0],d=gr[2][0]-gr[0][0];
    for(int i=1;i<3;i++){
        if(gr[i][1]-gr[i][0]!=a){
            cout<<"No\n"<<endl;
            return 0;
        }
        if(gr[i][2]-gr[i][0]!=b){
            cout<<"No\n"<<endl;
            return 0;
        }
        if(gr[1][i]-gr[0][i]!=c){
            cout<<"No\n"<<endl;
            return 0;
        }
        if(gr[2][i]-gr[0][i]!=d){
            cout<<"No\n"<<endl;
            return 0;
        }
    }
    cout<<"Yes\n"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();

        int p = n * a;
        if(b < p) p = b;
        
        scan.close();
        System.out.println(p);
    }
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){

	int n;cin >> n;
	vector<int> v(n);
	REP(i,n)cin >> v[i];

	deque<ll> q;
	sort(ALL(v));

	ll ans = 0;
	if(n % 2 == 0){
		REP(i,n){
			ll tmp = 2;
			if(i == n / 2 || i == n / 2 - 1)tmp = 1;
			if(i < n / 2)ans -= v[i] * tmp;
			else ans += v[i] * tmp;
		}
	}
	else{
		ll now = 0;
		REP(i,n){
			ll tmp = 2;
			if(i == n / 2 || i == n / 2 - 1)tmp = 1;
			if(i <= n / 2)now -= v[i] * tmp;
			else now += v[i] * tmp;
		}
		ans = now;
		now = 0;
		REP(i,n){
			ll tmp = 2;
			if(i == n / 2 || i == n / 2 + 1)tmp = 1;
			if(i < n / 2)now -= v[i] * tmp;
			else now += v[i] * tmp;
		}
		ans = max(ans,now);
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 768
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200050;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

void Yes() {
	cout<<"Yay!"<<endl; exit(0);
}
void No() {
	cout<<":("<<endl; exit(0);
}

void solve() {
	int N; cin >> N;
	string S; cin >> S;
	ll ans = 0;
	REP(i, 10) {
		REP(j, 10) {
			REP(k, 10) {
				int now = 0;
				REP(l, N) {
					int num = S[l] - '0';
					if (now == 0) {
						if (num == i) {
							now++;
						}
					}
					else if (now == 1) {
						if (num == j)now++;
					}
					else if (now == 2) {
						if (num == k) {
							ans++; break;
						}
					}
				}
			}
		}
	}
	print(ans);
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 拡張 Euclid の互除法
// ap + bq = gcd(a, b) となる (p, q) を求め、d = gcd(a, b) をリターンします
long long extGcd(long long a, long long b, long long &p, long long &q) {  
    if (b == 0) { p = 1; q = 0; return a; }  
    long long d = extGcd(b, a%b, q, p);  
    q -= a/b * p;  
    return d;  
}

// 中国剰余定理
// リターン値を (r, m) とすると解は x ≡ r (mod. m)
// 解なしの場合は (0, -1) をリターン
pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
  long long p, q;
  long long d = extGcd(m1, m2, p, q); // p is inv of m1/d (mod. m2/d)
  if ((b2 - b1) % d != 0) return make_pair(0, -1);
  long long m = m1 * (m2/d); // lcm of (m1, m2)
  long long tmp = (b2 - b1) / d * p % (m2/d);
  long long r = mod(b1 + m1 * tmp, m);
  return make_pair(r, m);
}

int main(){
    ll N,M;cin>>N>>M;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    pair<ll,ll> num=make_pair(A[0]/2,A[0]);
    ll ans=1;
    REP(i,N) {
        if(num.second==-1){
            cout<<0<<endl;
            return 0;
        }
        if(num.second>2*M){
            cout<<0<<endl;
            return 0;
        }
        num=ChineseRem(num.first,num.second,A[i]/2,A[i]);
        
    }
    ans=(M+num.first)/num.second;
    cout<<max(ans,0LL)<<endl;
}


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

select_num = 0
count_num = [0]*(N+1)
for i in A:
  count_num[i] += 1
for i in range(1,N+1):
  select_num += (count_num[i])*(count_num[i] - 1)//2
for i in A:
  print(select_num -count_num[i] + 1)

Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    while (cin >> n && n) {
        int k, s;
        cin >> k >> s;
        
        int dp[13][200][23] = {0};
        // 数列, sum, 最後の数
        
        dp[0][0][0] = 1;
        rep(i, k) rep(j, s + 1) rep(l, n + 1) {
            rep3(m, l + 1, n + 1) {
                if (j + m <= s) dp[i + 1][j + m][m] += dp[i][j][l];
            }
        }
        int ans = 0;
        rep(i, n + 1) ans += dp[k][s][i];
        cout << ans << endl;
        /*
        rep(i, k + 1) {
            cout << "i " << i << endl;
            rep(j, s + 1) { rep(l, n + 1) cout << dp[i][j][l] << " "; cout << endl; }
        }*/
    }
}



Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }

  ll ans = 0;
  REP(i,1,n-1){
    set<int> st;
    ll ret = 0;
    for(int j=0; j<n; j++){
      if(n-1-i*j < i) break;
      ret += a[i*j];
      ret += a[n-1-i*j];
      if(st.find(i*j)!=st.end() ) break;
      st.insert(i*j);
      if(st.find(n-1-i*j)!=st.end()) break;
      st.insert(n-1-i*j);
      ans = max(ans, ret);
    }
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 8784
s = input()
d = True
f = '' # Front
b = '' # Back
q = int(input())
for _ in range(q):
    a = input().split()
    if a[0] == '1':
        d = not d
    else:
        if a[1] == '1':
            if d:
                f = f + a[2]
            else:
                b = b + a[2]
        else:
            if d:
                b = b + a[2]
            else:
                f = f + a[2]

if not d:
    print(''.join([b[::-1], s[::-1], f]))
else:
    print(''.join([f[::-1], s, b]))


Measured memory_bytes: 4340
k, n = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)

i = 0
j = 1

max = nums[0] + (k - nums[-1])

until j >= nums.size do
  max = [nums[j] - nums[i], max].max
  i += 1
  j += 1
end

puts k - max

Measured memory_bytes: 19332
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
vec(pr,200000);
//
void solve(long long X){
  repf(i,2,100000){
    if(pr[i]==0){
      for(ll j=i+i;j<200000;j+=i){
        pr[j]=1;
      }
    }
  }
  ll i=X;
  while(1){
    if(pr[i]==0){
      cout<<i<<endl;
      return;
    }
    i++;
  }
  return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
A = [int(a) for a in input().split()]
B = [1 if _ > 0 else 0 for _ in A]
D = [abs(d) for d in A]
i = B.count(0)

if i % 2 != 0:
    D[D.index(min(D))] *= -1

print(sum(D))

Measured memory_bytes: 14412
#include<stdio.h>
#include<algorithm>
using namespace std;
int lowbit(int x){return x&-x;}
int a[100010],c[20],v[32768],s[32768],f[32768];
int main(){
	int n,i,j,x,y,z,res,M;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d%d",&x,&y,&z);
		a[x+1]^=z;
		a[y+1]^=z;
	}
	for(i=1;i<=n;i++)c[a[i]]++;
	res=M=0;
	res+=c[0];
	for(i=1;i<16;i++){
		res+=c[i]/2;
		if(c[i]&1)v[1<<(M++)]=i;
	}
	for(i=1;i<1<<M;i++)s[i]=s[i^lowbit(i)]^v[lowbit(i)];
	for(i=1;i<1<<M;i++){
		if(s[i]==0){
			for(j=i;j;j=(j-1)&i){
				if(s[j]==0)f[i]=max(f[i],f[i^j]+1);
			}
		}
	}
	printf("%d",n-(res+f[(1<<M)-1]));
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
bool solve(const vector<int> &A)
{
    Int N = A.size();
    Int sum = accumulate(begin(A), end(A), 0LL);
    Int one = N * (N+1) / 2;
    if (sum % one) return false;
    Int cnt = sum / one;
    vector<int> B(N);
    B[0] = A[0] - A[N-1];
    for (int i = 1; i < N; i++) B[i] = A[i] - A[i-1];
    Int t = 0;
    for (auto b : B) {
        b -= cnt;
        if (b % -N) return false;
        if (b / -N < 0) return false;
        t += b / -N;
    }
    return t == cnt;
}
int main()
{
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    cout << (solve(A) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 1024
using namespace std;
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define w(x) int x;cin>>x;while(x--)

#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define ll long long

void abc()
{
	FIO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mod = 1000000007;
map<int, vector<int>> adjlist;
vector<int> dp;


int go(int i) {
	if (dp[i] != -1) return dp[i];
	dp[i] = 0;
	for (auto j : adjlist[i]) {
		dp[i] = max(dp[i], go(j) + 1);
	}

	return dp[i];
}



int main()
{
	abc();
	int n, e;
	cin >> n >> e;
	dp.resize(n + 1, -1);
	while (e--) {
		int x, y;
		cin >> x >> y;
		adjlist[x].push_back(y);
	}

	int answer = 0;

	for (int i = 0; i <= n; i++) {
		answer = max(answer, go(i));
	}

	cout << answer;


}

Measured memory_bytes: 17828
const fs = require('fs')
const chars = 'abcdefghijklmnopqrstuvwxyz'
 
function changeBase(value) {
    let result = ''
    while (value > 0) {
      	const remand = value % 26
    	const c = chars[(remand + 25) % 26]
        result = c + result
        if (remand === 0) {
        	value = Math.floor(value / 26) - 1
        } else {
        	value = Math.floor(value / 26)
        }
    }
	return result
}
 
const inputValue = parseInt(fs.readFileSync('/dev/stdin', 'utf8'))
console.log(changeBase(inputValue))

Measured memory_bytes: 29600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll to_i(string&s, int i1) {
  ll ret = 0;
  ret += (s[i1]-'0')*10;
  ret += (s[i1+1]-'0');
  return ret;
}

ll to_time(string& s) {
  ll hr = to_i(s,0);
  ll mn = to_i(s,3);
  ll sc = to_i(s,6);
  return hr*3600 + mn*60 + sc;
}

void solve(ll n) {
  vector<pair<string,string>> a(n); // pair of <start, end>
  rep(i,n) {
    cin >> a[i].first >> a[i].second;
  }
  vector<pair<ll,ll>> b(n); // pair of <end, start>
  rep(i,n) {
    b[i] = pair<ll,ll>(to_time(a[i].second), -to_time(a[i].first));
  }
  sort(all(b));

  map<ll,ll> mp; // collection of end time
  for (auto& p : b) {
    if (mp.empty()) {
      ++mp[p.first];
      continue;
    }
    // Here, mp is not empty

    auto it = mp.upper_bound(-p.second);
    // Here, prev(it) is insertion point.
    if (it == mp.begin()) { // Here, we can not use same train. Add new train.
      ++mp[p.first];
    } else { // Here, we can use prev(it) as same train.
      auto pit = prev(it);
      --(pit->second);
      if (pit->second == 0) { // count is 0
        mp.erase(pit);
      }
      ++mp[p.first];
    }
  }

  ll ans = 0;
  for (auto& p : mp) {
    ans += p.second;
  }
  cout << ans << endl;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  while (true) {
    ll n;
    cin >> n;
    if (n == 0) { break; }
    solve(n);
  }
}



Measured memory_bytes: 4464
n = int(input())
nl = []
for i in range(n):
    a = int(input())
    b = list(str(a))
    c1 = list(sorted(b))
    c2 = list(reversed(c1))
    cc1 = ''
    cc2 = ''
    for i in range(len(c1)):
        cc1 = cc1 + c1[i]
        cc2 = cc2 + c2[i]
    c1n = int(cc1)
    c2n = int(cc2)
    nl.append(abs(c1n-c2n))
    
for i in range(len(nl)):
    print(nl[i])


Measured memory_bytes: 5592
#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>;

int main()
{
    ll h, w;
    cin >> h >> w;
    cout << h * w << " " << (h + w) * 2 << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main(){
    while(1){
        int x,y;
        cin >> x >> y;
        if(x==0&&y==0)break;
        if(x>y){
            int tes;
            tes=x;
            x=y;
            y=tes;

        }
        cout << x << " " << y << endl;
    }

    return 0;
}

Measured memory_bytes: 3088
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

A,B,C = iln()
odd_num = []
if A%2 == 1: odd_num.append(A) 
if B%2 == 1: odd_num.append(B) 
if C%2 == 1: odd_num.append(C)

if len(odd_num) == 3:
    print(min(odd_num[0] * odd_num[1], odd_num[1] * odd_num[2], odd_num[0]*odd_num[2]))
else:
    print(0)



Measured memory_bytes: 5300
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(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; }


const int MAX = 42;




int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int res = K;

  while(A >= B){
    if(res == 0){
      break;
    }
    B *= 2;
    res--;
  }

  while(B >= C){
    if(res == 0){
      break;
    }
    C *= 2;
    res--;
  }

  if (A < B && B < C){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }



  // cout << setprecision(8) << ans << endl;  // For double
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int rec(int val, vector<int>& D, int N)
{
  int n = D.size();
  if (val >= N) { return val; }
  int ret = INF;
  for (int i = 0; i < n; ++i) {
    ret = min(ret, rec(val * 10 + D[i], D, N));
  }
  return ret;
}

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  int d;
  vector<int> usable(10, 1);
  for (int i = 0; i < K; ++i) {
    scanf("%d", &d);
    usable[d] = 0;
  }
  vector<int> D;
  for (int i = 0; i < 10; ++i) {
    if (usable[i]) { D.push_back(i); }
  }

  int ans = INF, n = D.size();
  for (int i = 0; i < n; ++i) {
    if (D[i] == 0) { continue; }
    ans = min(ans, rec(D[i], D, N));
  }
  printf("%d\n", ans);
  return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

// 4文字削除でシミュレーション？？
void solve() {
    int H,W;
    cin >> H >> W;
    int sm = H*W;
    map<char,int> mp;
    REP(i,H) {
        string s;
        cin >> s;
        for(const auto &it: s) {
            if (!mp.count(it)) mp[it] = 0;
            mp[it]++;
        }
    }
    if (H > 1) {
        // 4文字削除を行う回数
        int del = (W/2)*(H/2);
        REP(i,26) {
            if(del == 0) break;
            if(mp.count((char)'a'+i) && mp[(char)'a'+i] >= 4) {
                int d = mp[(char)'a'+i]/4;
                del = max(del-d,0);
                if (del - d < 0) mp[(char)'a'+i] = (d-del)*4 + mp[(char)'a'+i]%4;
            }
        }
        if (del != 0) {
            cout << "No" << endl;
            return;
        }
    }
    bool ok_once = sm%2;
    for(const auto &it: mp) {
        auto [c,v] = it;
        if(v%2) {
            if(!ok_once) {
                cout << "No" << endl;
                return;
            } else ok_once = false;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3644
//============================================================================
// Name        : AOJ_Test.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
	unsigned long long int N;
	vector<unsigned long long int> Ai;
	cin >> N;
	Ai.resize(N);
	for (unsigned int i = 0; i < N; i++) {
	    cin >> Ai[i];
	}

    unsigned long long int answer = 0;
    unsigned long long int mulans = 0;
    unsigned long long int mulbase = 0;

	for (unsigned int i = 0; i < N - 1; i++) {
		mulbase = (mulbase + Ai[N-1-i]) % 1000000007;
	    mulans = (mulbase * Ai[N-2-i]) % 1000000007;
	    answer = (answer + mulans) % 1000000007;
	}

    cout << answer << endl;
	// cout << tlen - max << endl;
	return 0;
}


Measured memory_bytes: 4440
#include<stdio.h>
int main(void)
{
	int n,x,a[100],i,k;
	scanf("%d",&n);
	for(i=0;i<n+2;i++)	a[i]=0;
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	k=1;	x=0;
	for(i=0;i<n+2;i++){
		if(a[i]==1){
			k++;
		}
		if(a[i]==0){
//printf("%d%d ",i,a[i]);
			if(x<=k)	x=k;
			k=1;
		}
	}
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2732
//M Candy

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define INTMAX 1000000000
#define MOD 1000000007
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VVI vector<VI>
#define alf "abcdefghijklmnopqrstuvwxyz"

int N,K,a[100002];
LL dp[102][100002] = {};
LL sum[102][100002] = {};

int main(){
	cin >> N >> K;
	for(int i=1; i<=N; i++) cin >> a[i]; 
	sum[0][K] = 1;

	for(int i = 1; i <= N; i++){//i番目
		for(int j = 0; j <= K; j++){//分けた後残りj枚
			dp[i][j] += sum[i-1][min(K,j+a[i])] - (j ? sum[i-1][j-1] : 0) + MOD;
			dp[i][j] %= MOD;
		}
		for(int j=0; j<=K; j++)	{
			sum[i][j] += dp[i][j] + (j ? sum[i][j-1] : 0) + MOD;
			sum[i][j] %= MOD;
		}
		/*
			for(int k = 0; k <= a[i]; k++){//i番目にk枚分けた
				if(j + k <= K){
					dp[i][j] += dp[i-1][j+k];
				}
				*/
		//dp[i-1][j]からdp[i-1][min(K,j+a[i])]までを足す
		//->sum[102][100002]で二重
	}
	cout << dp[N][0] << endl;
	return 0;
}


Measured memory_bytes: 159232
#include <algorithm>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

constexpr int inf = 1e9+7;
int main() {
    int x, k; scanf("%d%d", &x, &k);
    vector<int> r(k); repeat (i, k) scanf("%d", &r[i]);
    if (r[0]) r.insert(r.begin(), 0);
    r.push_back(inf);
    vector<int> hi(k + 1, x);
    vector<int> ub(k + 1, x);
    vector<int> lb(k + 1);
    vector<int> lo(k + 1);
    repeat (i, k) {
        ll dt = r[i + 1] - r[i];
        if (i % 2 == 0) {
            hi[i + 1] = hi[i] - dt;
            ub[i + 1] = ub[i];
            lo[i + 1] = lo[i] - dt;
            lb[i + 1] = lb[i] + max<ll>(0, - lo[i + 1]);
        } else {
            hi[i + 1] = hi[i] + dt;
            lb[i + 1] = lb[i];
            lo[i + 1] = lo[i] + dt;
            ub[i + 1] = ub[i] - max(0, hi[i + 1] - x);
        }
        setmax(hi[i + 1], 0); setmin(hi[i + 1], x);
        setmax(ub[i + 1], 0); setmin(ub[i + 1], x);
        setmax(lb[i + 1], 0); setmin(lb[i + 1], x);
        setmax(lo[i + 1], 0); setmin(lo[i + 1], x);
    }
    int q; scanf("%d", &q);
    while (q --) {
        int t, a; scanf("%d%d", &t, &a);
        auto j = (upper_bound(whole(r), t) - r.begin()) - 1;
        if (a <= lb[j]) {
            a = lo[j];
        } else if (ub[j] <= a) {
            a = hi[j];
        } else {
            a = (a - lb[j]) + lo[j];
        }
        int dt = t - r[j];
        a = j & 1 ? min(x, a + dt) : max(0, a - dt);
        printf("%d\n", a);
    }
    return 0;
}


Measured memory_bytes: 3192