akhauriyash/Code-Regression huggingface dataset:
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int x;
    cin>>x;

    bool ok = true;

    while(ok){
        int cnt = 0;
        for(int i =2; i*i<=x; i++){
            if(x%i==0){cnt++;break;}
        }
        if(cnt==0){
            ok=false;
            cout<<x<<endl;
            return 0;
        }
        x++;
    }
}

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

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

    int n, c, k;
    cin >> n >> c >> k;

    vector<int> ts(n);
    for (int i = 0; i < n; i++) cin >> ts[i];
    sort(ts.begin(), ts.end());

    int ans = 1;
    int nax = ts[0] + k;
    int cur = 1;
    for (int i = 1; i < n; i++) {
        if (ts[i] <= nax && cur < c) {
            cur++;
            continue;
        }
        ans++;
        cur = 1;
        nax = ts[i] + k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;


ll gcd(ll a, ll b){


    if(a < b) return gcd(b,a);

    if(a % b == 0){
        return b;
    }else{
        return gcd(b, a - b);
    }
}


int main(){

    ll a,b;
    cin >> a >> b;

    ll commondiv = gcd(a,b);

    vector<int> prime(1000001, 1);

    prime[0] = 0;
    prime[1] = 0;

    cerr << prime.size() << endl;

    for(int i = 2; i * i <= 1000000; i++){
        if(prime[i] == 1){
            for(int j = i * i; j <= 1000000; j = j + i){
                prime[j] = 0;
            }
        }
    }

    int ans = 1;
    vector<int> primeans(1000000);

    while(commondiv != 1){
        bool found = false;

        for(int i = 2; i <= 1000000; i++){
            if(prime[i] == 1 && commondiv % i == 0){
                commondiv /= i;
                primeans[i]++;
                found = true;
                break;
            }
        }

        if(!found){
            if(commondiv > 1000000){
                ans++;
            }
            break;
        }
    }

    for(int i = 2; i <= 1000000; i++){
        if(prime[i] == 1 && primeans[i] > 0) ans++;
    }

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


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

int main() {
    long long N,K,R,S,P;
    cin>>N>>K>>R>>S>>P;
    string T;
    cin>>T;
    int A[100010]={};
   long long sum=0;
    
    for(long long i=0; i<K; i++){
        if(T[i]=='r') {A[i]=1; sum+=P;}
        if(T[i]=='s') {A[i]=1; sum+=R;}
        if(T[i]=='p') {A[i]=1; sum+=S;}
    }
        
     for(long long j=K; j<N; j++){
         if((T[j]=='r' && T[j-K]!='r')||(T[j]=='r' && T[j-K]=='r' && A[j-K]==0)){A[j]=1; sum+=P;} 
        else if((T[j]=='s' && T[j-K]!='s')||(T[j]=='s' && T[j-K]=='s' && A[j-K]==0)){A[j]=1; sum+=R;}
         else if((T[j]=='p' && T[j-K]!='p')||(T[j]=='p' && T[j-K]=='p' && A[j-K]==0)){A[j]=1; sum+=S;}
     }
 
    
    
    
    cout<<sum<<endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int a;
    cin >> a;
    cout << a+ a*a + a*a*a << endl;
}


Measured memory_bytes: 3628
n=int(input())
ans=1
a=[]
for i in range(n):
  a.append(int(input()))
x=a[0]
if x==2:
  print(ans)
  exit()
for i in range(n):
  x=a[x-1]
  if x==2:
    print(ans+1)
    exit()
  else:
    ans+=1
print(-1)

Measured memory_bytes: 7084
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long money = 100;
        long ans = 0;
        while (money < x) {
            ans++;
            money += money * 0.01;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35696
N, K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

a = 0
b = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            a += 1

A.extend(A)

for i in range(N):
    for j in range(N, 2 * N):
        if A[i] > A[j]:
            b += 1

print(((K * (K - 1) // 2) * b + K * a) % (10**9 + 7))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<P> key;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    int tmp = 0;
    for (int i = 0; i < b; i++) {
      int c;
      cin >> c;
      c--;
      tmp |= (1 << c);
    }
    key.emplace_back(make_pair(tmp, a));
  }

  vector<int> dp(1<<n, INF);

  dp[0] = 0;

  for (int i = 0; i < m; i++) {
    for (int bit = 0; bit < (1 << n); bit++) {
      dp[bit | key[i].first] = min(dp[bit | key[i].first], dp[bit] + key[i].second);

    }
  }
  if (dp[(1 << n) - 1] == INF) cout << -1 << endl;
  else cout << dp[(1 << n) - 1] << endl;

  return 0;  
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int changeValue;
        changeValue = x;
        x = y;
        y = changeValue;
        changeValue = x;
        x = z;
        z = changeValue;
        System.out.printf("%d %d %d",x,y,z);
    }
}

Measured memory_bytes: 23636
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    static String T = "";

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> array = new ArrayList();
        int n = sc.nextInt();
        array.add(n);
        while(true){
            n = function(n);
            if(array.indexOf(n) == -1){
                array.add(n);
            }else{
                System.out.println(array.size() + 1);
                return;
            }
        }
    }

    public static int function(int n){
        if(n % 2 == 0){
            return n / 2;
        }else{
            return 3*n + 1;
        }
    }
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  ll s = 0;
  for (int i = 0; i + 1 < n / 2; ++i) {
    s += 2 * (a[n - i - 1] - a[i]);
  }
  int l = n/2 - 1, r = n - n/2;
  s += a[r] - a[l];
  if (n % 2) {
    s += max(a[r] - a[n/2], a[n/2] - a[l]);
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 640
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, k, ans = 0; cin >> n >> k;

    for(long long i = 0; i < n; i++) {
        long long x; cin >> x;
        ans += min(x, k - x) * 2;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main (void){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
  	

  	printf("%d %d %lf\n",d,r,f );

return 0;	
}

Measured memory_bytes: 1844
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
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;};

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

  Int n,m;
  cin>>n>>m;
  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  vector<Int> ind(n,0);
  for(Int i=0;i<m;i++){
    Int a,b,c;
    cin>>a>>b>>c;
    G[a].emplace_back(b,c);
    ind[b]++;
  }
  
  vector<Int> dp(n,0);
  queue<Int> que;
  que.emplace(0);
  while(!que.empty()){
    Int v=que.front();que.pop();
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      chmax(dp[u],dp[v]+c);
      ind[u]--;
      if(ind[u]==0) que.emplace(u);
    }
  }

  cout<<dp.back()<<endl;
  return 0;
}



Measured memory_bytes: 3228
package main

import "fmt"

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

func factorization(n int) (r map[int]int) {
	r = make(map[int]int, 0)
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			n /= i
			r[i]++
		}
	}
	if n > 1 {
		r[n]++
	}
	return r
}

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	fmt.Println(len(factorization(gcd(A, B))) + 1)
}


Measured memory_bytes: 512
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
Min = 100000
ans = 0
for i, h in enumerate(H,start=1):
    if abs(A - (T - h * 0.006)) < Min:
        ans = i
        Min = abs(A - (T - h * 0.006))
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int binarySearch(int *, int, int);

main() {

	int n, q;
	int *s, *t;
	int c=0;
	
	int i, j, k;


	scanf("%d", &n);
	s = (int *)malloc( sizeof(int) *n );
	for( i=0; i<n; i++) {
		scanf("%d", &s[i]);
	}
	
	
	scanf("%d", &q);
	t = (int *)malloc( sizeof(int) *q );
		for( i=0; i<q; i++) {
		scanf("%d", &t[i]);
	}
	
	for( i=0; i<q; i++) {
		c += binarySearch( s, n, t[i]);
	}
	
	printf("%d\n", c);
	
	return 0;
}


int binarySearch(int *array, int length, int key) {
	
	int left = 0;
	int right = length;
	int mid = (int)length/2;
	
	while(left < right) {
		mid = (left + right)/2;
		if(key==array[mid]) {
			return 1;
		}
		if(key>array[mid]){
			left=mid+1;
		}
		else if(key<array[mid]) {
			right = mid;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N, M = map(int, input().split())
A = [] * N
B = [] * N
C = [] * M
D = [] * M

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for i in range(M):
    c, d = map(int, input().split())
    C.append(c)
    D.append(d)

def get_dists(a, b):
    ret = []
    for i in range(M):
#        print(ret, a, b, C[i], D[i])
        ret.append(abs(a-C[i])+abs(b-D[i]))

    return ret

def nearest_idx(dists):
    near = float('inf')
    idx = -1
    for i in range(M):
        if near > dists[i]:
            near = dists[i]
            idx = i+1

    return idx


for i in range(N):
    dists = get_dists(A[i], B[i])
    print(nearest_idx(dists))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int h,w;
int t[101][101];
char s[101][101];
int main() {
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++) scanf("%s",s[i]);
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
            if(i==0 && j==0) {
                if(s[i][j]=='#') t[i][j]=1;
                else t[i][j]=0;
            }
            else {
                if(i==0) {
                    if(s[i][j]=='#') {
                        if(s[i][j-1]=='#') t[i][j]=t[i][j-1];
                        else t[i][j]=t[i][j-1]+1;
                    }
                    else t[i][j]=t[i][j-1];
                }
                else {
                    if(j==0) {
                        if(s[i][j]=='#') {
                            if(s[i-1][j]=='#') t[i][j]=t[i-1][j];
                            else t[i][j]=t[i-1][j]+1;
                        }
                        else t[i][j]=t[i-1][j];
                    }
                    else {
                        if(s[i][j]=='#') {
                            int t1,t2;
                            if(s[i][j-1]=='#') t1=t[i][j-1];
                            else t1=t[i][j-1]+1;
                            if(s[i-1][j]=='#') t2=t[i-1][j];
                            else t2=t[i-1][j]+1;
                            t[i][j]=min(t1,t2);
                        }
                        else t[i][j]=min(t[i][j-1],t[i-1][j]);
                    }
                }
            }
        }
    }
    printf("%d",t[h-1][w-1]);
    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B;
  C = A * B;
  if (C % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  bs <- map read . words <$> getLine :: IO [Int]
  print $ solve n as bs

solve :: Int -> [Int] -> [Int] -> Int
solve n as bs = x + min y (last as)
  where
    (x, y) = foldl' f (0, 0) $ zip as bs
    f :: (Int, Int) -> (Int, Int) -> (Int, Int)
    f !(!count, !left) !(!a, !b) =
      (
        count + min a (b + left),
        max 0 $ b - max 0 (a - left)
      )



Measured memory_bytes: 101628
#include<stdio.h>

int l0[7], l[7], l1[7], s=1;

void dice(int num){
    l[0] = l[1];
    l[1] = l[num];
    l[num] = l[6];
    l[6] = l[7-num];
    l[7-num] = l[0];
}

int same(void){
    s = (l0[1]==l[1]&&l0[3]==l[3]&&l0[4]==l[4]&&l0[5]==l[5]&&l0[6]==l[6])?0:1;
    return s;
}

void reset(void){
    for(int i=0; i<6; i++) l[i+1] = l1[i+1];
}

int main(void){
    int c=0;
    for(int i=0; i<6; i++) scanf("%d", &l0[i+1]);
    for(int i=0; i<6; i++) scanf("%d", &l[i+1]);
    for(int i=0; i<6; i++) l1[i+1] = l[i+1];
    if(s){
        dice(5);
        if(l0[2]==l[2]) while(same() && c++<4) dice(4);
    } // 1
    if(s){
        reset();
        if(l0[2]==l[2]) while(same() && c++<4) dice(4);
    } // 2
    if(s){
        reset();
        dice(3);
        dice(5);
        if(l0[2]==l[2]) while(same() && c++<4) dice(4);
    } // 3
    if(s){
        reset();
        dice(4);
        dice(5);
        if(l0[2]==l[2]) while(same() && c++<4) dice(4);
    } // 4
    if(s){
        reset();
        dice(5);
        dice(5);
        if(l0[2]==l[2]) while(same() && c++<4) dice(4);
    } // 5
    if(s){
        reset();
        dice(2);
        if(l0[2]==l[2]) while(same() && c++<4) dice(4);
    } // 6
    if(s) printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2080
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

const int INF = 1000000000;
const int MAX_N = 100000 + 10;
int dp[MAX_N];
int h[MAX_N];

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

  int N, K;
  cin >> N >> K;

  for (int i = 0; i < N; i++) cin >> h[i];
  
  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    int jp = INF;
    for (int k = 1; k <= K; k++) {
      if (i - k >= 0) jp = min(jp, dp[i-k] + abs(h[i] - h[i-k]));
    }
    dp[i] = jp;
  }

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



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

//Cards
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] c = new int[n][2];
		for(int i=0;i<n;i++)for(int j=0;j<2;j++)c[i][j]=sc.nextInt();
		int[][] dp = new int[n][n];
		for(int i=0;i<n;i++)Arrays.fill(dp[i], Integer.MAX_VALUE);
		for(int i=0;i<n;i++)dp[i][i]=0;
		for(int w=1;w<n;w++){
			for(int i=0;i+w<n;i++){
				int j = i+w;
				for(int k=i;k<j;k++){
					dp[i][j] = Math.min(dp[i][j], dp[i][k]+dp[k+1][j]+c[i][0]*c[k][1]*c[k+1][0]*c[j][1]);
				}
			}
		}
		System.out.println(dp[0][n-1]);
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <algorithm>
#include <functional>

using namespace std;

int main (void){
    int N;
    vector<bool> A;
    vector<int> NUM;
    vector<bool> TAMA;
    int temp;
    int num = 0;
    A.push_back(0);
    TAMA.push_back(0);

    cin >> N;
    for(int i=0; i < N ; i++){
        cin >> temp;
        A.push_back(temp);
        TAMA.push_back(0);
    }
    if(N==1){
        if(A[1] == 0){
            cout << "0" ;
        }
        else if(A[1] == 1){
            cout << "1" << endl;
            cout << "1" ;
        }
        return 0;
    }

    int k = N/2;
    if(N%2 != 0) k++;

    for(int i = N; i > k; i--){
        TAMA[i] = A[i];
        if(A[i] == 1) num++;
    }

    for(int i = k;i > 0 ; i--){
        int j = i+i;
        bool amari = 0;
        while(1){
            if(j >= N+1) break;
            else if(TAMA[j] == 1){
                if(amari == 1) amari = 0;
                else            amari = 1;
            }
            j += i;
            //cout<< i << " " << j << " "<< amari << endl; 
        }
        if(A[i] == 0 && amari == 1){
            TAMA[i] = 1;
            num++;
        }
        else if(A[i] == 1 && amari == 0){
            TAMA[i] = 1;
            num++;
        }
        else TAMA[i] = 0;
    }
    if(num == 0){
        cout << "0";
        return 0;
    }
    cout << num << endl;
    for(int i = 1; i < N+1 ;i++){
        if(TAMA[i] == 1){
            cout << i <<" ";
        }   
    }
    return 0; 
}

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

//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;
const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
void transpose(int xl,int xr,int yl,int yr){

}
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
      int a,b,c,d;
      cin>>a>>b>>c>>d;
      int win=0;
      while(a>0 && c>0){
         c-=b;
         if(c<=0){
          win=1;
          break;
         }
         a-=d;
         if(a<=0){
          win=2;
          break;
         }
      }
      if(win==1)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }

  }












Measured memory_bytes: 3628
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#define ll long long
using namespace std;
const int MOD = 1000000007;
inline int add(int x, int y) { int r = x + y; if(r >= MOD) r -= MOD; return r; }
inline int mul(int x, int y) { return (ll)x * (ll)y % MOD; }

const int MAXN = 100010;
const int MAXM = 200010;

vector<int> G[MAXN], GW[MAXN], T[MAXN], TR[MAXN], TD[MAXN];
int N, M, PS, PT;

namespace dij {
    struct item {
        int u; ll d;
        inline bool operator<(item rhs) const { return d > rhs.d; }
    } A[MAXN];
    priority_queue<item> Q;
    ll dist[MAXN];
    bool done[MAXN];
    inline void work() {
        int i, u, v;
        memset(dist, 0x3f, sizeof(dist));
        dist[PS] = 0, Q.push( (item){ PS, 0 } );
        while(!Q.empty()) {
            u = Q.top().u; Q.pop();

            if(done[u]) continue;
            done[u] = 1;

            for(i = 0; i < G[u].size(); i++) {
                v = G[u][i];
                if(dist[u] + GW[u][i] < dist[v]) {
                    dist[v] = dist[u] + GW[u][i];
                    Q.push( (item){v, dist[v]} );
                }
            }
        }

        for(u = 1; u <= N; u++) for(i = 0; i < G[u].size(); i++) {
            v = G[u][i];
            if(dist[u] + GW[u][i] == dist[v]) {
                T[u].push_back(v), TD[u].push_back( GW[u][i] );
                TR[v].push_back(u);
            }
        }
    }
}

int fromS[MAXN], toT[MAXN];
void getFrom(int u) {
    int i, v;
    fromS[u] = 0;
    for(i = 0; i < TR[u].size(); i++) {
        v = TR[u][i];
        if(fromS[v] == -1) getFrom(v);
        fromS[u] = add(fromS[u], fromS[v]);
    }
}
void getTo(int u) {
    int i, v;
    toT[u] = 0;
    for(i = 0; i < T[u].size(); i++) {
        v = T[u][i];
        if(toT[v] == -1) getTo(v);
        toT[u] = add(toT[u], toT[v]);
    }
}

int main() {
    int i, u, v, d;
    scanf("%d%d%d%d", &N, &M, &PS, &PT);
    for(i = 1; i <= M; i++) {
        scanf("%d%d%d", &u, &v, &d);
        G[u].push_back(v), GW[u].push_back(d);
        G[v].push_back(u), GW[v].push_back(d);
    }

    dij::work();

    memset(fromS, -1, sizeof(fromS)), memset(toT, -1, sizeof(toT));
    fromS[PS] = 1, toT[PT] = 1;
    for(u = 1; u <= N; u++) {
        if(fromS[u] == -1) getFrom(u);
        if(toT[u] == -1) getTo(u);
    }

    int Ans = mul(fromS[PT], fromS[PT]);
    ll totd = dij::dist[PT];
    //dec points
    for(u = 1; u <= N; u++) if(dij::dist[u] == totd - dij::dist[u]) {
        Ans = add(Ans, MOD - mul( mul(fromS[u], toT[u]) , mul(fromS[u], toT[u]) ));
    }
    //dec sides
    for(u = 1; u <= N; u++) for(i = 0; i < T[u].size(); i++) {
        v = T[u][i];

        ll T1 = dij::dist[u], T2 = totd - dij::dist[v], x = T2 - T1 + TD[u][i];
        if(x > 0 && x < 2 * TD[u][i]) Ans = add(Ans, MOD - mul( mul(fromS[u], toT[v]), mul(fromS[u], toT[v]) ) );
    }

    printf("%d", Ans);
}


Measured memory_bytes: 34684
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
long long a, b;
int main()
{
	scanf("%lld%lld", &a, &b);
	if(abs(a - b) <= 1)printf("Brown\n");
	else printf("Alice\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include <string.h>
#include<math.h>

int main(){
	char s[21];
	int i=0;
	scanf("%s",s);
	
	while(s[i]!=0){
		i++;
	}
	i--;
	while(i>=0){
		printf("%c",s[i]);
		i--;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = input()
    sn = sum(int(i) for i in N)
    if int(N)%sn == 0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
R=[]
max_ = 0
for i in range(N):
    max_ = max(max_, A[i])
    R.append(max_)
L=[]
max_ = 0
for i in reversed(list(range(N))):
    max_ = max(max_, A[i])
    L.append(max_)
L = list(reversed(L))
print(L[1])
for i in range(1, N-1):
    print(max(R[i-1], L[i+1]))
print(R[N-2])

Measured memory_bytes: 22060
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        mut a: [[i32;w];h],
    }
    let mut r = vec![];
    for (i, a) in a.iter_mut().enumerate() {
        for j in 1..w {
            if a[j - 1] & 1 != 0 {
                a[j - 1] -= 1;
                a[j] += 1;
                r.push([i + 1, j, i + 1, j + 1]);
            }
        }
    }
    for i in 1..h {
        if a[i - 1][w - 1] & 1 != 0 {
            a[i - 1][w - 1] -= 1;
            a[i][w - 1] += 1;
            r.push([i, w, i + 1, w]);
        }
    }
    println!("{}", r.len());
    for r in r {
        println!("{}", itertools::join(&r, " "));
    }
}


Measured memory_bytes: 7816
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll power(ll x, ll y) {
	if (y==0) return 1;
	else if (y==1) return x%MOD;
	else if (y%2==0){
		ll pow = power(x, y / 2);
		return (pow*pow)%MOD;
	} 
	else{
		ll pow = power(x, y / 2);
		return ((pow*pow)%MOD)*x%MOD;
	}
}
ll divid(ll x, ll y) {
	return ((x%MOD)*power(y,MOD-2))%MOD;
}
ll com(ll x, ll y){
	ll a=1;
	REP(i,y)a=(a*(x-i))%MOD;
	REP(i,y)a=divid(a,i+1);
	return a;
}
int main() {
	ll n, a, b; cin >> n >> a >> b;
	cout << (power(2,n)-com(n,a)-com(n,b)-1+(3*MOD))%MOD << endl;
	return 0;
}

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

int main()
{
	int r, g, b;
	cin >> r >> g >> b;

	int a;
	a = (100 * r) + (10 * g) + b;

	if( a % 4 == 0){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)

	val m = scala.collection.mutable.Map[String, Int]()
	
	(1 to sc.nextInt).foreach { _ =>
		val s = sc.next
		m(s) = if (m.contains(s)) m(s)+1 else 1
	}
	
	val ranking = m.toSeq.sortWith(_._2 > _._2)
	val top = ranking.head._2
	
	ranking.collect{case r if r._2 == top => r._1}.sorted.foreach(pw.println(_))
	pw.flush()
}

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<20)

ll N, X;
vector<ll> a(55,0), p(55,0);

ll f(ll N, ll X) {
	if(N==0) return 1;
	if(X==1) return 0;
	if(1<X && X<=1+a[N-1]) return f(N-1,X-1);
	if(X==2+a[N-1]) return p[N-1]+1;
	if(2+a[N-1]<X && X<=2+2*a[N-1]) return p[N-1]+1+f(N-1,X-2-a[N-1]);
	if(X==3+2*a[N-1]) return 2*p[N-1]+1;
}

int main() {
	cin >> N >> X;

	a[0] = p[0] = 1;
	for (ll i = 1; i < N; i++) {
		a[i] = 2*a[i-1]+3;
		p[i] = 2*p[i-1]+1;
	}

	cout << f(N,X) << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if (N%2 == 0) {
			int N_ = N/2;
			if (N_%2 == 0) {
				for (int i=0;i<N_/2;i++) {
					System.out.println((i+1)+" "+(N_-i));
					M--;
					if (M==0) return;
				}
				for (int i=0;i<N_/2-1;i++) {
					System.out.println((i+N_+1)+" "+(N-1-i));
					M--;
					if (M==0) return;
				}
			} else { // N_%2 == 1
				for (int i=0;i<N_/2;i++) {
					System.out.println((i+1)+" "+(N_-1-i));
					M--;
					if (M==0) return;
				}
				for (int i=0;i<N_/2;i++) {
					System.out.println((i+N_)+" "+(N-1-i));
					M--;
					if (M==0) return;
				}
			}
		} else { // N%2 == 1
			for (int i=0;i<M;i++) {
				System.out.println((i+1)+" "+(N-1-i));
			}
		}
	}
}

Measured memory_bytes: 53896
import sys
input = sys.stdin.readline

n,k = (int(x) for x in input().split())
r,s,p = (int(x) for x in input().split())
#つまりs,p,rを出されたときに得る点数
mydict = {"s":r, "p":s, "r":p}
t = input()

ans = 0

for i in range(n):
	if i<k:
		ans += mydict[t[i]]
	elif t[i-k]!=t[i]:
		ans += mydict[t[i]]
	elif t[i-k]==t[i]:
		t = t[:i] + 'z' + t[i+1:]

print(ans)

Measured memory_bytes: 3508
n = int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
a.append(0)

def weight(i,j):
    global a
    return abs(a[i]-a[j])


nomiss = 0

for i in range(len(a)-1):
    nomiss+=weight(i,i+1)

def course(miss):
    skipDist = weight(miss-1,miss+1)
    curDist = weight(miss,miss+1)+weight(miss,miss-1)
    return (nomiss-curDist)+skipDist

for i in range(1,len(a)-1):
    print(course(i))


Measured memory_bytes: 14048
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const double EPS = 1e-12;
#define EQ(a,b) (abs((a)-(b)) < EPS)

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}


int intersectSC(const L &s, const C &c) {
  int ins = 0;
  for(int i = 0; i < 2; i++ ) {
    if (abs(s[i]-c.p)<c.r) ins++;
    else if (EQ(abs(s[i]-c.p), c.r)) return 0;
  }
  if (ins == 2) return -1;
  if (ins == 1) return 1;
  double d = distanceLP(s, c.p);
  if (d-c.r > EPS) return -1;
  P nor=(s[0]-s[1]) * P(0, 1);
  if (ccw(c.p, c.p+nor, s[0]) * ccw(c.p, c.p+nor, s[1]) < 0) return 2;
  return -1;
}

int main() {
  int N;
  while(cin >>N && N){
    vector<int> x(N), y(N), r(N);
    REP(i, N) cin >>x[i] >>y[i] >>r[i];
    int M; cin >>M;
    REP(m, M){
      int tx, ty, sx, sy; cin >>tx >>ty >>sx >>sy;
      L l = L(P(tx, ty), P(sx, sy));
      bool f = true;
      REP(n, N) if(intersectSC(l, C(P(x[n], y[n]), r[n])) >= 0) f = false;
      cout <<(f ? "Danger" : "Safe") <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int e = sc.nextInt();
			if (e == 0)
				break;
			System.out.println(calc(e));
		}
		sc.close();
	}

	private static int calc(int e) {
		int min = e;
		int val = 0;
		int x = 0;

		for (int y = 0; y * y <= e; y++) {
			for (int z = 0; z * z * z <= e; z++) {
				val = y * y + z * z * z;
				x = e - (y * y + z * z * z);
				if (x < 0)
					break;
				if (min > x + y + z)
					min = x + y + z;
			}
		}
		return min;
	}
}

Measured memory_bytes: 26160
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            long k = long.Parse(ReadLine());
            
            int one = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '1')
                {
                    one++;
                }
                else break;
            }

            int ans = 1;
            for (int i = 0; i < s.Length; i++)
            {
                if (one>=k)
                {
                    break;
                }
                else if (ans != int.Parse(s[i].ToString()))
                {
                    ans = int.Parse(s[i].ToString());
                    break;
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ri register int
const int N=3e3+5;
char s[N<<1];
struct node{
	string s;
	vector<int> v;
	inline bool operator <(const node &rhs)const{
		return s<rhs.s; 
	} 
}suf[N],f[N];
inline node merge(node a,node b){
	ri n=a.v.size(),m=b.v.size(),i,j;
	node ans;
	i=j=0;
	while(i<n&&j<m){
		if(a.v[i]<b.v[j])
			ans.v.push_back(a.v[i]),
			ans.s+=a.s[i],
			++i;
		else
			ans.v.push_back(b.v[j]),
			ans.s+=b.s[j],
			++j;
	}
	while(i<n)
		ans.v.push_back(a.v[i]),
		ans.s+=a.s[i],
		++i;
	while(j<m)
		ans.v.push_back(b.v[j]),
		ans.s+=b.s[j],
		++j;
	return ans;
}
int posa[N],posb[N];
int main(){
	ri n,len,i,j,k,cnta,cntb;
	scanf("%d%s",&n,s+1);
	cnta=cntb=0;
	len=n<<1;
	for(i=1;i<=len;++i)
		if(s[i]=='a')
			posa[++cnta]=i;
		else
			posb[++cntb]=i;
	for(i=n;i;--i){
		if(posa[i]<posb[i]){
			for(j=i+1;j<=n&&posa[j]<posb[i];++j);
			f[i].s=string("a")+string("b");
			f[i].v.push_back(posa[i]);
			f[i].v.push_back(posb[i]);	
			f[i]=merge(f[i],suf[j]);
		}
		else{
			j=i+1;	
			for(j=i+1;j<=n&&posb[j]<posa[i];++j);
			for(k=i;k^j;++k) f[i].s+='b',f[i].v.push_back(posb[k]);
			for(k=i;k^j;++k) f[i].s+='a',f[i].v.push_back(posa[k]);
			if(posb[j]<posa[j]&&posb[j]<f[i].v.back())
				f[i]=merge(f[i],f[j]);
			else
				f[i]=merge(f[i],suf[j]);
		}
		suf[i]=max(suf[i+1],f[i]);
	}
	cout<<suf[1].s<<endl;
    return 0;
}

Measured memory_bytes: 90112
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;

//template <typename T>
//using TABLE = vector<vector<T>>;

//using LONG = long long;
//using LVEC = vector<long long>;

//long long PRIME = 1e9 + 7;
//long long PRIME2 = 998244353;


int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<bool>> passed(H, vector<bool>(W, false));
    vector<string> S(H);

    for(int i = 0; i < H; ++i){
        cin >> S[i];
    }

    long long sum = 0;

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

    for(int y = 0; y < H; ++y){
        for(int x = 0; x < W; ++x){
            if(passed[y][x]){
                continue;
            }

            queue<pair<int, int>> pos_q;
            pos_q.push(pair<int, int>(y, x));
            passed[y][x] = true;

            long long black_num = 0;
            long long white_num = 0;

            while(pos_q.size()){
                auto p = pos_q.front();
                pos_q.pop();

                if(S[p.first][p.second] == '#'){
                    ++black_num;
                }
                else{
                    ++white_num;
                }

                for(int d = 0; d < 4; ++d){
                    int ny = p.first + dy[d];
                    int nx = p.second + dx[d];

                    if(nx < 0 || W <= nx)continue;
                    if(ny < 0 || H <= ny)continue;
                    if(passed[ny][nx])continue;
                    if(S[ny][nx] == S[p.first][p.second])continue;

                    passed[ny][nx] = true;
                    pos_q.push(pair<int, int>(ny, nx));
                }
            }

            sum += white_num * black_num;
        }
    }


    cout << sum;
}



Measured memory_bytes: 512
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int cn;

  for ( cn = 1; ; ++cn )
  {
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    printf ( "Case %d:\n", cn );
    switch ( n )
    {
      case 1:
        puts ( "  1" );
        break ;
      case 2:
        puts ( "  1  2" );
        puts ( "  3  4" );
        break ;
      case 3:
        puts ( "  1  2  6" );
        puts ( "  3  5  7" );
        puts ( "  4  8  9" );
        break ;
      case 4:
        puts ( "  1  2  6  7" );
        puts ( "  3  5  8 13" );
        puts ( "  4  9 12 14" );
        puts ( " 10 11 15 16" );
        break;
      case 5:
        puts ( "  1  2  6  7 15" );
        puts ( "  3  5  8 14 16" );
        puts ( "  4  9 13 17 22" );
        puts ( " 10 12 18 21 23" );
        puts ( " 11 19 20 24 25" );
        break;
      case 6:
        puts ( "  1  2  6  7 15 16" );
        puts ( "  3  5  8 14 17 26" );
        puts ( "  4  9 13 18 25 27" );
        puts ( " 10 12 19 24 28 33" );
        puts ( " 11 20 23 29 32 34" );
        puts ( " 21 22 30 31 35 36" );
        break;
      case 7:
        puts ( "  1  2  6  7 15 16 28" );
        puts ( "  3  5  8 14 17 27 29" );
        puts ( "  4  9 13 18 26 30 39" );
        puts ( " 10 12 19 25 31 38 40" );
        puts ( " 11 20 24 32 37 41 46" );
        puts ( " 21 23 33 36 42 45 47" );
        puts ( " 22 34 35 43 44 48 49" );
        break;
      case 8:
        puts ( "  1  2  6  7 15 16 28 29" );
        puts ( "  3  5  8 14 17 27 30 43" );
        puts ( "  4  9 13 18 26 31 42 44" );
        puts ( " 10 12 19 25 32 41 45 54" );
        puts ( " 11 20 24 33 40 46 53 55" );
        puts ( " 21 23 34 39 47 52 56 61" );
        puts ( " 22 35 38 48 51 57 60 62" );
        puts ( " 36 37 49 50 58 59 63 64" );
        break;
      case 9:
        puts ( "  1  2  6  7 15 16 28 29 45" );
        puts ( "  3  5  8 14 17 27 30 44 46" );
        puts ( "  4  9 13 18 26 31 43 47 60" );
        puts ( " 10 12 19 25 32 42 48 59 61" );
        puts ( " 11 20 24 33 41 49 58 62 71" );
        puts ( " 21 23 34 40 50 57 63 70 72" );
        puts ( " 22 35 39 51 56 64 69 73 78" );
        puts ( " 36 38 52 55 65 68 74 77 79" );
        puts ( " 37 53 54 66 67 75 76 80 81" );
        break;
    }
  }

  return ( 0 );
}

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

int main(){
  long long a,b,c,d;
  cin >> a >> b >> c >> d ;
  long long ac,ad,bc,bd;
  
  ac=a*c;
  ad=a*d;
  bc=b*c;
  bd=b*d;
  
  long long biggest;
  biggest = max(ac,max(ad,max(bc,bd)));
  
  cout << biggest;
}

Measured memory_bytes: 3460
k=0
a=[0,0,0]

while k<27 :
    a[0],a[1],a[2]=input().split()
    x=int(a[1])+int(a[2])
    y=200*int(a[1])+300*int(a[2])
    print(a[0],x,y)
    k=k+3


Measured memory_bytes: 5600
type SortDataType=Longint;
function SortCmp(const a,b:SortDataType):Boolean;forward;
procedure SortImpl(var A:Array of SortDataType;L,R:Longint);
var
	tmp:SortDataType;
	mid,il,ir:Longint;
begin
	if R-L<20 then begin
		for ir:=R-1 downto L+1 do for il:=L to ir-1 do if SortCmp(A[il+1],A[il])then begin
			tmp:=A[il];
			A[il]:=A[il+1];
			A[il+1]:=tmp;
		end;
	end else begin
		mid:=(L+R)div 2;
		if SortCmp(A[mid],A[L])then begin
			tmp:=A[mid];
			A[mid]:=A[L];
			A[L]:=tmp;
		end;
		if SortCmp(A[R-1],A[mid])then begin
			tmp:=A[R-1];
			A[R-1]:=A[mid];
			A[mid]:=tmp;
			if SortCmp(A[mid],A[L])then begin
				tmp:=A[mid];
				A[mid]:=A[L];
				A[L]:=tmp;
			end;
		end;
		il:=L;
		ir:=R-1;
		while il<=ir do begin
			while SortCmp(A[il],A[mid])do inc(il);
			while SortCmp(A[mid],A[ir])do dec(ir);
			if il<ir then begin
				tmp:=A[il];
				A[il]:=A[ir];
				A[ir]:=tmp;
				if mid=il then mid:=ir else if mid=ir then mid:=il;
				inc(il);
				dec(ir);
			end else if il=ir then begin
				inc(il);
				dec(ir);
			end;
		end;
		SortImpl(A,L,il);
		SortImpl(A,il,R);
	end;
end;
procedure Sort(var A:Array of SortDataType;size:Longint);
begin
	SortImpl(A,0,size);
end;
function SortCmp(const a,b:SortDataType):Boolean;
begin
	SortCmp:=a<b;
end;
var
	N,i:Longint;
	H:Array[1..200000]of Longint;
	ans:int64;
begin
	read(N);
	for i:=1 to N do read(H[i]);
	Sort(H,N);
	for i:=2 to N do if H[i-1]=H[i]then begin
		writeln('NO');
		exit;
	end;
	writeln('YES');
end.


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// chctxdy
set <ll> occ[26];
int main(){
	for (ll i = 0; i<26; i++) occ[i].clear();
	for (ll i = 0; i<26; i++) occ[i].insert(0);
	ll n; string s; cin >> n >> s;
	for (ll i = 0; i<n; i++) occ[s[i] - 'a'].insert(i + 1);
	ll q; cin >> q;
	while (q--){
		ll t; cin >> t;
		if (t == 1){
			// update
			ll i; char c; cin >> i >> c;
			occ[s[i - 1] - 'a'].erase(i);
			occ[c - 'a'].insert(i);
			s[i - 1] = c;
		}
		else{
			// query
			ll l, r; cin >> l >> r;
			ll ans = 0;
			for (ll a = 0; a < 26; a++){
				set <ll>::iterator bl = occ[a].lower_bound(r + 1); bl--; 
				ll x = *bl;
				if (x >= l) ans++;
			}
			cout << ans << endl;
		}
	}
	
}

Measured memory_bytes: 24196
S = input()

S_list = list(S)
S_1 = int(S_list[0]+S_list[1])
S_2 = int(S_list[2]+S_list[3])

if S_1==0 or (13<=S_1<=99):
    if 1<=S_2<=12:
        ans = 'YYMM'
    else:
        ans = 'NA'
else:
    if S_2==0 or (13<=S_2<=99):
        ans = 'MMYY'
    else:
        ans = 'AMBIGUOUS'
        
print(ans)

Measured memory_bytes: 3064
import math
n=int(input())
mod=10**9+7

def eratosthenes(n):
  primes=[True for i in range(n+1)]
  p=2
  while(p*p<=n):
    if primes[p]==True:
      for i in range(p*2,n+1,p):
        primes[i]=False
    p+=1
  ls=[]
  for i in range(2,n+1):
    if primes[i]:
      ls.append(i)
  return ls

ls=[]
primes=eratosthenes(n)
for prime in primes:
  power=prime
  exp=0
  while n >= power:
    exp+=n//power
    # print("prime",prime,"power",power,"n",n,"n//power",n//power)
    power*=prime
  ls.append(exp)
# print(ls)
mul=1
for i in ls:
  mul*=(i+1)
print(mul%mod)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

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

    bool ok = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]){
            ok = false;
            break;
        }
    }

    if (ok){
        cout << "Yes"
             << "\n";
    }
    else{
        cout << "No"
             << "\n";
    }

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <stack>

using namespace std;

typedef struct{
	int color;
	int num;
} Stone;

int opcolor(int color){
	return 1 - color;
}

stack<Stone> st;
int n;

int main(){
	while(scanf("%d",&n), n != 0){
		//init
		st = stack<Stone>();
		Stone init_stone = {0,0};
		st.push(init_stone);

		// put
		for(int i = 1; i <= n; i++){
			int c;
			scanf("%d",&c);
			if( i % 2 == 0){
				Stone bef = st.top();st.pop();
				if(c == bef.color){
					bef.num++;
					st.push(bef);
				}
				else{
					if(!st.empty()){
						Stone befbef = st.top();st.pop();
						befbef.num += bef.num + 1;
						st.push(befbef);
					}
					else{
						bef.color = c;
						bef.num++;
						st.push(bef);
					}
				}
			}
			else{
				Stone bef = st.top();st.pop();
				if(c == bef.color){
					bef.num++;
					st.push(bef);
				}
				else{
					st.push(bef);
					Stone ns = {c,1};
					st.push(ns);
				}
			}
		}
		//count white(0) 
		int ans = 0;
		while(!st.empty()){
			Stone s = st.top();st.pop();
			if(s.color == 0){
				ans += s.num;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 2584
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
int main(){
	iostream::sync_with_stdio(false);
	int h, w,n;
	cin >> h >> w >> n;
	vector<pair<int, int>> gogo;
	REP(i, n) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		gogo.push_back(make_pair(b,a - b));//y,x
	}
	sort(gogo.begin(), gogo.end());
	int ans = h;
	if (n == 0) {
		cout << ans << endl;
		return 0;
	}
	int top = -1;
	int bot = 1;
	int done = 0;
	for (int i = 0; i < gogo.size(); ++i) {
		swap(gogo[i].first, gogo[i].second);
		if (i == 0) {
			if (gogo[i].second != 0) {
				done = 1;
			}
		}
		if (i != 0) {
			if (gogo[i].second - gogo[i - 1].second > 1) {
				top = 300000;
				done = 1;
			}
		}
		if (top == -1) {
			if (gogo[i].first >= 1) {
				top = gogo[i].first;
			}
		}
		if (bot <= gogo[i].first&&gogo[i].first <= top) {
			ans = min(ans, gogo[i].first + gogo[i].second);
		}
		if (bot - 1 == gogo[i].first) {
			bot++;
		}
		if (done == 0&&top == gogo[i].first) {
			top++;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int primes[100500] = {1,1};
int ok[100500];

void findPrimes() {
	for(int i = 2; i < 100500; i++) {
		if(primes[i] == 1)
			continue;
		for(int j = i * 2; j < 100500; j+=i)
			primes[j] = 1;
	}
}



int main() {
	findPrimes();

	for(int i = 2; i < 100500; i++) {
		int other = 2*i-1;
		if(other >= 100500)
			break;
		if(!primes[i] && !primes[other])
			ok[other] = 1;
	}
	for(int i = 1; i < 100500; i++)
		ok[i] += ok[i-1];
	int q;
	cin >> q;
	
	for(int i = 0; i < q; i++) {
		int l,r;
		cin >> l >> r;
		cout << ok[r] - ok[l-1] << endl;
	}
}

Measured memory_bytes: 1408