akhauriyash/Code-Regression huggingface dataset:
from math import ceil


def solve(string):
    n, h, *ab = map(int, string.split())
    max_a = max(ab[::2])
    b = sorted([b for b in ab[1::2] if b > max_a], reverse=True)
    if sum(b) < h:
        cnt = len(b) + ceil((h - sum(b)) / max_a)
    else:
        for i, _b in enumerate(b):
            cnt = i + 1
            h -= _b
            if h <= 0:
                break
    return str(cnt)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 27268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)

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

  int n;
  cin >> n;
  int dic[50][26] = {};
  rep(i, n) {
    string s;
    cin >> s;
    for (auto&& j : s) {
      dic[i][j-'a']++;
    }
  }

  vector<char> ans;
  rep(i, 26) {
    int cnt = 10000;
    rep(j, n) {
      cnt = min(cnt, dic[j][i]);
    }
    rep(k, cnt) {
      ans.push_back((char)'a'+i);
    }
  }

  for (auto&& i : ans) {
    cout << i;
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

    public static void main(String[] args){

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int count = 0;
	try{
	    String N = br.readLine();
	    int n = Integer.parseInt(N);
	    String ox = br.readLine();
	    //System.out.println(ox);
	    String[] o_x = ox.split("");
	    for(int i=0;i<ox.length();i++){
		if(i==n-1){
		    //System.out.println("a");
		    continue;
		}
		if(ox.charAt(i) != ox.charAt(i+1)){
		    //System.out.println("b");
		    count++;
		    i++;
		}else{
		    //System.out.println("c");
		  
		}
	
	    }
	    System.out.println(count);
	}catch(Exception e){

	}	
	
    }
   
   
}




Measured memory_bytes: 34156
import java.io.*;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        BigInteger power = new BigInteger("1");
        BigInteger check = new BigInteger("1000000007");
        power.remainder(check);
        for(int i=1; i<=n;i++)power =
                power.multiply(BigInteger.valueOf(i)).remainder(check);
        System.out.println(power);
    }
}


Measured memory_bytes: 41368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
const ll INF = 1001001001;

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;

    rep2(i, 1, n)
    {

        ans += n / i;
        if (n % i == 0)
        {
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int deg[N+2],bln[N+2];
set<int>adj[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,m;cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int u,v;cin>>u>>v;
    adj[u].insert(v);deg[u]++;
    adj[v].insert(u);deg[v]++;
  }
  set<pair<int,int> >st;
  for(int i=1;i<=n;i++)
    st.insert({deg[i],i});
  vector<pair<int,int> >ed;
  while(st.size())
  {
    pair<int,int>p=*st.begin();
    int u=p.second,v;
    if(bln[u])
    {
      v=*adj[u].begin();
      ed.push_back({u,v});bln[u]^=1;
      adj[u].erase(v);adj[v].erase(u);
      st.erase({deg[u],u});
      st.erase({deg[v],v});
      deg[u]--;deg[v]--;
      if(deg[u])st.insert({deg[u],u});
      if(deg[v])st.insert({deg[v],v});
    }
    else
    {
      v=*adj[u].begin();
      ed.push_back({v,u});bln[v]^=1;
      adj[u].erase(v);adj[v].erase(u);
      st.erase({deg[u],u});
      st.erase({deg[v],v});
      deg[u]--;deg[v]--;
      if(deg[u])st.insert({deg[u],u});
      if(deg[v])st.insert({deg[v],v});
    }
  }
  for(int i=1;i<=n;i++)
    if(bln[i])cout<<-1<<endl,exit(0);
  for(auto x:ed)
    cout<<x.first<<" "<<x.second<<"\n";
  return 0;
}

Measured memory_bytes: 67576
#include <stdio.h>
#include <string.h>

int mirror(int num) {
  return num*100+(num/10)%10*10+(num/100);
}

int main(void) {
  int a, b;
  char line[15];
  FILE* fp = stdin;
  if(!fgets(line, 15, fp)) return 0;
  sscanf(line, "%d %d", &a, &b);
  int a_100 = a/100;
  int b_100 = b/100;
  int res = 0;
  // printf("%d %d\n", mirror(a_100), mirror(b_100));
  if(b_100 == a_100) {
    int check = mirror(a_100);
    if( a <= check && check <= b) { res = 1; }
  } else {
    res = b_100 - a_100 + 1;
    if(mirror(a_100) < a) res--;
    if(mirror(b_100) > b) res--;
  }

  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int ans = 0;
    rep(i, n) {
        if(a[i] == b[i] && b[i] == c[i]) {
            continue;
        }
        else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            ans++;
        }
        else {
            ans += 2;
        }
    }

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

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

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    double M=gd();
	    double[] A=new double[N];
	    double s=0;
	    for (int i=0; i<N;i++) {
	    	A[i]=gd();
	    	s+=A[i];
	    }
	    Arrays.parallelSort(A);
	    double mm=s/(4*M);
	    boolean f=true;
	    for (int i=0; i<M;i++) {
	    	double a=A[A.length-i-1];
	    	if(a<mm) {
	    		f=false;
	    		break;
	    	}
	    }
	    //System.out.print(a*1000+b*5);
        if (f) {
    	    System.out.print("Yes");
        }else {
        	System.out.print("No");
        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35468
#include<stdio.h>

#define N 20
#define Q 200

int solve(int,int);

int n,A[N];

int main(void){
  int q,m[Q];
  int i;

  scanf(" %d",&n);
  for(i = 0; i < n; i++){
    scanf(" %d",&A[i]);
  }
  scanf(" %d",&q);
  for(i = 0; i < q; i++){
    scanf(" %d",&m[i]);
  }

  for(i = 0; i < q; i++){
    if(solve(0,m[i]) == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i, int m){
  int res;
  
  if(m == 0) return 1;
  if(i >= n) return 0;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}



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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, a[100001], sum1 = 0, sum2 = 0, ans1 = 0, ans2 = 0;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    sum1 += a[i];
    sum2 += a[i];
    if (i % 2 == 1) {
      ans1 += max((ll)1 - sum1, (ll)0);
      sum1 = max((ll)1, sum1);
      ans2 += max((ll)1 + sum2, (ll)0);
      sum2 = min((ll)-1, sum2);
    } else {
      ans1 += max((ll)1 + sum1, (ll)0);
      sum1 = min((ll)-1, sum1);
      ans2 += max((ll)1 - sum2, (ll)0);
      sum2 = max((ll)1, sum2);
    }
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (abs(c-a) <= d) {
    puts("Yes");
  } else if (abs(c-b) <= d && abs(b-a) <= d) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

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

void maxHeapify(int *, int);
void buildMaxHeap(int *);

int h;

int main(){
  int i;
  int *node;

  scanf("%d", &h);

  node = malloc(sizeof(int)*h + 1);
 
  for(i = 1; i <= h; i++) scanf("%d", &node[i]);

  buildMaxHeap(node);

  for(i = 1; i <= h; i++) printf(" %d", node[i]);

  printf("\n");

  return 0;
}


void maxHeapify(int *A, int i){
  int largest;
  int temp;
  int r, l;

  l = i*2;
  r = i*2+1;

  if(l <= h && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= h && A[r] > A[largest]) largest = r;
  
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;

    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  int i;

  for(i = h/2; i > 0; i--) maxHeapify(A, i);
}



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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct UnionFind{
	vi data;
	UnionFind(int size):data(size,-1){}
	int Find(int n){
		return data[n]<0?n:(data[n]=Find(data[n]));
	}
	void Unite(int a,int b){
		int ra=Find(a),rb=Find(b);
		if(ra!=rb){
			if(-data[ra]<-data[rb])
				swap(ra,rb);
			data[ra]+=data[rb];
			data[rb]=ra;
		}
	}
	int Size(int n){
		return -data[Find(n)];
	}
};

int main()
{
	for(int n,w,h;cin>>n>>w>>h && n|w|h;){
		vi xs(n),ys(n);
		rep(i,n) cin>>xs[i]>>ys[i];
		
		vi is(n); iota(all(is),0);
		UnionFind uf(n);
		sort(all(is),[&](int i,int j){return xs[i]<xs[j];});
		rep(i,n-1) if(xs[is[i]]==xs[is[i+1]]) uf.Unite(is[i],is[i+1]);
		sort(all(is),[&](int i,int j){return ys[i]<ys[j];});
		rep(i,n-1) if(ys[is[i]]==ys[is[i+1]]) uf.Unite(is[i],is[i+1]);
		
		int cnt=count_if(all(uf.data),[](int x){return x<0;});
		int res=n-cnt;
		if(cnt>1){
			res+=2*cnt-1;
			rep(i,n) if(xs[i]==1 || xs[i]==w || ys[i]==1 || ys[i]==h){
				res--;
				break;
			}
		}
		cout<<res<<endl;
	}
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  string ans;
  if (a==b&&b==c) ans="Yes";
  else ans="No";
		 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

enum MOD = 1000000007;

ulong _p(ulong n, ulong k) {
  if(k == 0) return 1;
  return (n * p(n-1, k-1)) % MOD;
}

alias p = memoize!_p;

void main() {
  auto input = readln.split.to!(int[]);
  int N = input[0], K = input[1];

  int[][] tree = new int[][N];
  foreach(i; 0..(N-1)) {
    input = readln.split.to!(int[]);
    int a = input[0], b = input[1];
    tree[a-1] ~= b-1;
    tree[b-1] ~= a-1;
  }

  bool[] seen = new bool[N];
  ulong dfs(ulong n, ulong k) {
    seen[n] = true;
    int[] children = tree[n].filter!(c => !seen[c]).array;
    ulong ck = K - tree[n].length;
    ulong ptns = 1;
    foreach(c; children) {
      ptns = (ptns * dfs(c, ck)) % MOD; 
    }
    ulong one = (ptns * p(children.length + (ck - 1), children.length)) % MOD;
    return one;
  }

  writeln((dfs(0, K) * K) % MOD);
}


Measured memory_bytes: 25468
import sys
N = int(input())
a = list(map(int, input().split()))
num, cut = 0, 0

if N == 1:
    print(1)
    sys.exit()

for i in range(N-1):
    if a[i] == a[i+1]:
        continue
    if a[i] < a[i+1] and num == 0:
        num  = 1
        cut += 1
    elif a[i] > a[i+1] and num == 0:
        num = -1
        cut += 1
    elif num == 1 and a[i] > a[i+1]:
        if i == N-2:
            cut += 1
        num = 0
    elif num == -1 and a[i] < a[i+1]:
        if i == N-2:
            cut += 1
        num = 0
print(cut)
        


Measured memory_bytes: 20428
#include <iostream>
#include <stdlib.h>

using namespace std;

int sort(const void *a, const void *b)
{
    if (*(int*)a < *(int*)b) {
        return -1;
    } else if (*(int*)a == *(int*)b) {
        return 0;
    } else {
        return 1;
    }
} 

int check(int X, int N, int p[])
{
    int i;

    int num = -1;
    for (i = 0; i < N; i++) {
        if (p[i] == X) {
            num = i;
            break;
        }
    }

    if (num == -1) {
        return X;
    } else if (num == N - 1) {
        if (p[num - 1] != X - 1) return X - 1;
        else return X + 1;
    } else if (num == 0) {
        if (p[num + 1] != X + 1) return X + 1;
        else return X - 1;
    } else {
        i = 1;
        while (1) {
            if (p[num - i] != X - i) {
                return X - i;
            }
            if (p[num + i] != X + i) {
                return X + i;
            }
            i++;
        }
    }
}

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

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

    qsort((void*)p, N, sizeof(p[0]), sort);

    cout << check(X, N, p);

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

long long  n;

int main(){
  cin >> n;
  long long sum = 0;
  for(long long  i = 1; i <= sqrt(n) + 100; i++){
    if(n % i == 0){
      long long num = n / i - 1;
      if(num <= i) break;
      sum += num;
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(20) << x << endl
const int MOD = 1e9 + 7;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  out(a + a * a + a * a * a);

  return 0;
}


Measured memory_bytes: 3560
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1<<32 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

N = int(input())
A = list(map(int,input().split()))
g = 0
for a in A:
    g = gcd(g, a)
if g > 1:
    print("not coprime")
    exit()

X = [0] * 1001001
for a in A:
    for p in primeFactor(a):
        if X[p]:
            print("setwise coprime")
            exit()
        X[p] = 1

print("pairwise coprime")


Measured memory_bytes: 181044
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int n, m;
vector<vector<int>> G;

void bfs() {
    vector<int> dist(n, -1);
    vector<int> pre(n, -1);
    queue<int> que;
    que.push(0);
    dist[0] = 0;
    
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto nv : G[v]) {
            if (dist[nv] == -1) {
                dist[nv] = dist[v] + 1;
                pre[nv] = v;
                que.push(nv);
            }
        }
    }
    
    for(int i = 1; i < n; i++) {
        cout << pre[i] + 1 << endl;
        
    }
}




int main() {

    cin >> n >> m;
    G.assign(n, vector<int>());

    REP(i, m) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    cout << "Yes" << endl;
    
    bfs();

return 0;
}

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

using namespace std;

const int INF = 1e9;

int main(void) {
  int n, s;
  cin >> n >> s;

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int l = 0, r = 0;
  int sum = 0;
  int ans = INF;
  while (l < n) {
    while (r < n && sum < s) {
      sum += a[r++];
    }
    if (r == n && sum < s) break;
    ans = min(ans, r - l);
    sum -= a[l++];
  }

  cout << ((ans == INF) ? 0 : ans) << endl;

  return 0;
}


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

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

struct Counter {
  int count;
  int max;
  Counter() : count(0), max(0) {}
  void inc() {
    count++;
    chmax(max, count);
  }
  void reset() { count = 0; }
};

int main() {
  int N, A, B, C, D;
  string S;

  cin >> N >> A >> B >> C >> D;
  cin >> S;
  S = '#' + S + '#';

  Counter bc1;
  for(int i = A; i <= C; ++i) {
    if(S[i] == '#') {
      bc1.inc();
    } else {
      bc1.reset();
    }
  }
  Counter bc2;
  for(int i = B; i <= D; ++i) {
    if(S[i] == '#') {
      bc2.inc();
    } else {
      bc2.reset();
    }
  }

  if(bc1.max >= 2 || bc2.max >= 2) {
    cout << "No" << endl;
    return 0;
  }

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

  Counter wc;
  for(int i = B - 1; i <= D + 1; ++i) {
    if(S[i] == '.') {
      wc.inc();
    } else {
      wc.reset();
    }
  }
  if(wc.max >= 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 772
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * treeMinimum(Node *x)
{
    while(x->left != NIL) x = x->left;
    return x;
}

Node * find(Node *u, int k)
{
    while(u != NIL && k != u->key)
    {
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

Node * treeSuccessor(Node *x)
{
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right)
    {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z)
{
    Node *y;
    Node *x;

    if(z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);
    if(y->left != NIL) x = y->left;
    else x = y->right;
    if(x != NIL) x->parent = y->parent;
    if(y->parent == NIL) root = x;
    else 
    {
        if(y == y->parent->left) y->parent->left = x;
        else y->parent->right = x;
    }
    if(y != z) z->key = y->key;
    free(y);
}

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL)
    {
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if(y == NIL) root = z;
    else
    {
        if(z->key < y->key) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u)
{
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if(u == NIL) return ;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, x;
    string com;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
    {
        cin >> com;
        if(com[0] == 'f')
        {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }
        else if(com == "insert")
        {
            scanf("%d", &x);
            insert(x);
        }
        else if(com == "print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com == "delete")
        {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }
    return 0;
}



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

const int N = 1e5 + 7;
int n , h[N] , f[N];

int main()
{
    cin >> n;
    for(int i = 1 ; i <= n; ++i)
    {
        cin >> h[i];
    }
    f[1] = 0;
    f[0] = 99999;
    h[0] = 99999;
    for(int i = 2 ; i <= n; ++i)
    {
        f[i] = min(f[i-1] + abs(h[i-1] - h[i]), f[i-2] + abs(h[i-2] - h[i]));
    }
    cout << f[n] << endl;
    return 0;
}


Measured memory_bytes: 4288
#include<stdio.h>
int main(void){
	
	int X;
	X<=9;
	X>=1;
	
	scanf("%d",&X);
	
	
	if(X==3||X==5||X==7){
		printf("YES\n");
	}
	
	else{
	printf("NO\n");
		}
	
	return 0;
	}

Measured memory_bytes: 128
from collections import defaultdict


def fraction(a, b):
    """a/b を既約分数 numer/denom として求める
    denom は必ず非負整数
    numer = denom = 0 のときは numer/denom = 0/0
    numer = 0 のときは numer/denom = 0/1
    denom = 0 のときは numer/denom = 1/0
    """
    numer, denom = a, b
    if numer == denom == 0:
        return 0, 0
    elif numer == 0:
        return 0, 1
    elif denom == 0:
        return 1, 0

    # GCD(a, b) を計算して約分する
    while b:
        a, b = b, a % b
    gcd_ab = a
    numer = numer // gcd_ab
    denom = denom // gcd_ab

    if denom < 0:  # denom は必ず非負整数
       numer, denom = -numer, -denom
    return numer, denom
  

n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
MOD = 10 ** 9 + 7

memo = defaultdict(int)
for i in range(n):
    a, b = info[i]
    memo[fraction(a, b)] += 1

cnt_00 = 0
cnt_n0 = 0 
cnt_d0 = 0
ans = 1
used = set()
for frac in memo:
    numer, denom = frac
    if numer == 0 and denom == 0:
        cnt_00 += memo[frac]
        continue
    if frac in used:
        continue
    if numer == 0 or denom == 0:
        cnt1, cnt2 = 0, 0
        if (0, 1) in memo:
            cnt1 = memo[(0, 1)]
        if (1, 0) in memo:
            cnt2 = memo[(1, 0)]
        tmp = pow(2, cnt1, MOD) + pow(2, cnt2, MOD) - 1
        ans *= tmp
        used.add((0, 1))
        used.add((1, 0))
        continue

    rev_num, rev_den = -denom, numer
    if rev_den < 0:
        rev_num, rev_den = -rev_num, -rev_den

    cnt1 = memo[frac]
    cnt2 = 0
    if (rev_num, rev_den) in memo:
        cnt2 = memo[(rev_num, rev_den)]
    tmp = pow(2, cnt1, MOD) + pow(2, cnt2, MOD) - 1
    ans *= tmp
    ans %= MOD
    used.add((rev_num, rev_den))

ans = ans + cnt_00
print((ans - 1) % MOD)

Measured memory_bytes: 171320
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]

lr = []
for i in range(n):
    l = max(xl[i][0] - xl[i][1], 0)
    r = max(xl[i][0] + xl[i][1], 0)
    lr.append([r, l])

lr = sorted(lr)
keep = [False] * n
# print(lr)

cur = 0
for i in range(n):
    if cur <= lr[i][1]:
        keep[i] = True
        cur = lr[i][0]
'''
for j in range(n - 1):
    if keep[j]:
        if lr[j][0] == lr[j + 1][0]:
            keep[j + 1] = False
        elif lr[j][0] < lr[j + 1][0]:# < lr[j][1]:
            keep[j + 1] = False
'''
#print(keep)
ans = sum(1 for x in range(n) if keep[x])
print(ans)


Measured memory_bytes: 42208
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(void){
	int d,sum;
	while( cin >> d ){
		sum = 0;
		for(int i=0;i < 600;i+=d){
			sum += i*i;
		}
		cout << sum*d << "\n";
	}
	return 0;
}

Measured memory_bytes: 1160
from scipy.misc import comb
MOD = 10**9+7
n, k = map(int, input().split())

def comb_mod(a, b):
    return int(comb(a, b, exact=True)) % MOD

for i in range(1, k+1):
    blue = comb_mod(k-1, i-1)
    red = comb_mod(n-k+1, i)
    print((red*blue)%MOD)

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

using namespace std;

int  main(){
    string s,t;
    cin >> s >> t;
    bool ans = true;
    for (int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) ans = false;
    }
    if (s.length() + 1 != t.length()) ans = false;
    if (ans) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
string s;
char num;
long long pos=23456;
long long k;
int main() {
	cin>>s;
	scanf("%I64d",&k);
	for(int i=0; i<s.size(); i++) {
		if(s[i]!='1') {
			num=s[i];
			pos=i;
			break;
			}
		}
	if((k-1)<pos)cout<<1;
	else cout<<num;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 10001
#define INF 10000000000
using namespace std;

typedef long long ll;

int main()
{
    vector<int> v;
    vector<int> res;

    int n;
    cin >> n;
    int m = 0;
    int k = n / 2;
    if (n % 2 == 0)
    {
        cout << 2*k*(k-1) << "\n";
        FOR(i, 1, k+1)
        {
            FOR(j, i+1,2*k-i+1)
            {
                cout << i << " " << j << "\n";
                cout << j << " " << (2*k-i+1) << "\n";
                m += 2;
            }
        }
    }
    else
    {
        cout << 2*k*k << "\n";
        FOR(i,1,n)
            cout << i << " " << n << "\n";
        m += (n-1);
        FOR(i, 1, k+1)
        {
            FOR(j, i+1,2*k-i+1)
            {
                cout << i << " " << j << "\n";
                cout << j << " " << (2*k-i+1) << "\n";
                m += 2;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll N,P;
map<ll,ll> cnt;

ll pow(ll a,ll b){if(b==0)return 1;if(b&1)return a*pow(a,b-1);return pow(a*a,b/2);}

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

    for(int i=2;i<=1000000;i++){
        while(P%i==0){
            P/=i;
            cnt[i]++;
        }
    }
    cnt[P]++;

    ll ans=1;
    repr(e,cnt){
        ans*=max(pow(e.first,(e.second/N)),1LL);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int L = stdIn.nextInt();
			if(L == 0) {
				break;
			}
			boolean alr = false;
			int m = 0;
			for(int i = 0; i < 12; i++) {
				L -= stdIn.nextInt();
				L += stdIn.nextInt();
				if(L <= 0) {
					if(!alr) {
						alr = true;
						m = i+1;
					}
				}
				
				
				
			}
			
			if(!alr) {
				System.out.println("NA");
			}
			else {
				System.out.println(m);
			}
		}
	}
	

}

Measured memory_bytes: 34620
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>
using namespace std;

int main()
{
	vector<int> x(3);
	cin >> x[0] >> x[1] >> x[2];
	sort(x.begin(), x.end());
  	cout << x[0] + x[1] << endl;
	return(0);
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> A(N), num(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}

	for (int i = 0; i < N; i++){
		num[A[i]]++;
	}

	sort(num.begin(), num.end(), greater<int>());

	int x = 0;
	for (int i = 0; i < K; i++){
		x += num[i];
	}

	cout << N - x << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=50;

    char str[N][N];
    ll f[N][N][N];
    void main()
    {
        int n=qread(),m=n+n;fo(i,1,m) scanf("%s",str[i]+1);
        if(n==1){write(str[1][2]-'0');return;}
        fo(i,1,m) f[i][i][i]=1;
        for(int ln=3;ln<=m;ln+=2) fo(l,1,m-ln+1)
        {
            int r=l+ln-1;
            fo(k,l+1,r-1) fo(x,l,k-1) fo(y,k+1,r) if(str[x][y]=='1')
                fo(a,x,k-1) fo(b,k+1,y) f[l][r][k]+=f[l][a][x]*f[a+1][b-1][k]*f[b][r][y];
        }
        ll ans=0;fo(k,3,m-1) if(str[1][k]=='1') ans+=f[2][m][k];write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PP pop_back()
#define set(x,y) memset(x,y,sizeof(x))
#define MIN3(x,y,z) min(min(x,y),z)
#define MAX3(x,y,z) max(max(x,y),z)
#define ALL(x) x.begin(),x.end()
#define sz(x) (int) x.size()
#define sag(x) 2*x+1
#define sol(x) 2*x
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define ROF(i,j,k) for(int i=j;i>=k;i--)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pii pair<int,int>
#define st first
#define nd second
#define ll long long
#define llu long long unsigned
#define lf double
#define orta (bas+son)/2
#define MOD 1000000007
#define inf 1000000000
#define N 200005
using namespace std;
int len,ans;
char s[N];
int main() {
    scanf("%s",s+1);
    len=strlen(s+1);
    int hak=0;
    FOR(i,1,len) {
        if(hak) ans+=(s[i]=='g'),hak=0;
        else ans-=(s[i]=='p'),hak=1;
    }
    printf("%d",ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<bitset>
using namespace std;
#define M 1000000007
#define rep(i, a, b) for(int i=a; i<b; i++)

typedef long long ll;
typedef unsigned long long int llt;
const int N = 2e5 + 10;


int main()
{
    llt ans = 0;
    int n;
    cin>>n;
    int arr[n];
    rep(i, 0, n)
        cin>>arr[i];
    rep(i, 0, n)
    {
        rep(j, i+1, n)
        {
            int m = arr[i] * arr[j];
            ans += m;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def solve():
      input = sys.stdin.readline
      N, X, M = map(int, input().split())
      D = [False] * M
      roopStart = -1
      now = X
      for i in range(M+1): #ループ検出
            ne = now * now % M
            if D[ne]:
                  roopStart = ne
                  break
            else: 
                  D[ne] = True
                  now = ne
      
      roopL, roopS = 1, 0
      now = roopStart
      for i in range(M+1):
            ne = now * now % M
            roopS += now
            if ne == roopStart: break
            else: 
                  roopL += 1
                  now = ne

      #初期和
      ans = 0
      initialL = 0
      now = X
      for i in range(M+1):
            if i == N: break
            if now != roopStart:
                  ans += now
                  initialL += 1
                  now = now * now % M
            else: break
      if initialL <= N:
            N -= initialL
            roopTimes = N // roopL
            roopRem = N % roopL
            ans += (roopTimes * roopS) 
            now = roopStart
            for j in range(roopRem):
                  ans += now
                  now = now * now % M
            
      print(ans)
      return 0

if __name__ == "__main__":
      solve() 

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

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

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5;
int n,a[MAXN],aa[MAXN],s[MAXN];
struct BIT{
	ll c[MAXN];
	inline int lb(int x){return x&(-x);}
	void add(int p,ll v){for(;p<=n;p+=lb(p))c[p]+=v;}
	ll ask(int p){ll r=0;for(;p;p-=lb(p))r+=c[p];return r;}
	void clr(){memset(c,0,sizeof(c));}
	BIT(){}
}T;
bool check(int mid){
	for(int i=1;i<=n;++i)s[i]=(a[i]>mid?1:-1);
	vector<int>vec;vec.pb(0);
	for(int i=1;i<=n;++i)s[i]+=s[i-1],vec.pb(s[i]);
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	T.clr();
	ll cnt=0;
	for(int i=0;i<=n;++i){
		int p=lob(vec.begin(),vec.end(),s[i])-vec.begin()+1;
		cnt+=T.ask(p);
		T.add(p,1);
	}//cnt:中位数>mid的区间数量
	return cnt<=((ll)n*(n+1)/2-1)/2;
}
int main() {
	n=read();
	for(int i=1;i<=n;++i)a[i]=read(),aa[i]=a[i];
	sort(aa+1,aa+n+1);
	check(8);
	int l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(aa[mid]))r=mid;
		else l=mid+1;
	}
	cout<<aa[l]<<endl;
	return 0;
}

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

int main(void)
{
  int K, N; cin >> K; cin >> N;
  long long  A[N];
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  long long D[N];
  for (int i=0; i<N-1; i++) {
    D[i] = A[i+1] - A[i];
  }
  D[N-1] = K - A[N-1] + A[0];
  sort(D, D+N);

  long long sum = 0;
  for (int i=0; i<N-1; i++) {
    sum += D[i];
  }

  cout << sum << endl;

}

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

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

    int min = 10000;
    int res=0;
    string dis = "";
    for(int i=0; i<s.length()-2; i++){
        dis = "";
        dis = s.substr(i, 3); // 部分文字列の取得
        res = abs(atoi(dis.c_str())-753);
        if(res < min) 
            min = res;
    }

    cout << min << endl;
    return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

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

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

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

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

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

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

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

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

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

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

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

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

const int inf=LLONG_MAX/3;

int Ask(int i){
	print(i);
	fflush(stdout);
	string s=readString();
	if(s[0]=='V'){
		exit(0);
	}
	if(s[0]=='M'){
		return 0;
	}
	if(s[0]=='F'){
		return 1;
	}
	assert(false);
	return -1;
}

void rec(int l,int r,int p,int q){
	int m=(l+r)/2;
	int w=Ask(m);
	if((p==w)^((m-l+1)%2==1))
		rec(l,m,p,w);
	else
		rec(m,r,w,q);
}

signed main(){
	int n=read();
	int p=Ask(0),q=Ask(n-1);
	rec(0,n-1,p,q);
}

Measured memory_bytes: 2900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    
    ll t = 1;
    while(t < n) t *= 2;
    if(t == n) {
        cout << "No\n";
        return 0;
    }

    vector<PII> edges;
    for(ll i=2; i+1<=n; i+=2) {
        edges.push_back({i, i+1});
        edges.push_back({i+1, 1});
        edges.push_back({1, n+i});
        edges.push_back({n+i, n+i+1});
    }
    edges.push_back({n+3, n+1});

    if(n%2==0) {
        ll t = 1;
        while(t < n) t *= 2;
        t /= 2;
        edges.push_back({t+n, 2*n});
        edges.push_back({n-t+1, n});
    }

    auto check = [&] {
        vector<vector<ll>> g(2*n+1);
        for(auto e: edges) {
            g[e.first].push_back(e.second);
            g[e.second].push_back(e.first);
        }

        bool ok;
        auto dfs = [&](auto &&self, ll v, ll p, ll st, ll w) -> void {
            // if(st == 1) dump(v, st, w);
            if(v == st+n) ok = st==w;
            for(auto to: g[v]) if(to!=p) {
                self(self, to, v, st, w^(to<=n ? to : to-n));
            }
        };
        vector<ll> err;
        FOR(i, 1, n+1) {
            dfs(dfs, i, -1, i, i);
            if(!ok) err.push_back(i);
        }
        if(err.size()) {
            dump(g);
            dump(err);
        }
    };
    // check();

    cout << "Yes\n";
    for(auto e: edges) cout << e.first << " " << e.second << "\n";

    return 0;
}

Measured memory_bytes: 6512
#include<iostream>
using namespace std;
#include<vector>
#include<set>
#include<cmath>
#include<iomanip>
#include<algorithm>
#define int long long int
#define mod 1000000007
int memo[101][101];
void function()
{
	int i=0,j=0;
	for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			if(j>i)
			{
				memo[i][j]=0;
			}
		}
	}
	memo[1][1]=1;
	for(i=2;i<=100;i++)
	{
		memo[i][1]=i;
	}
	for(i=2;i<=100;i++)
	{
		for(j=2;j<=100;j++)
		{
			memo[i][j]=(memo[i-1][j]+memo[i-1][j-1]);
		}
	}
}
int ncr(int n,int r)
{
	if(r>n)
	   return 0;
	return memo[n][r];
}
int32_t main()
{
	int n,m;
	cin>>n>>m;
	int arr1[n+1];
	int arr2[m+1];
	int j;
	for(j=1;j<=n;j++)
	{
		cin>>arr1[j];
	}
	for(j=1;j<=m;j++)
	{
		cin>>arr2[j];
	}
	int suffix2[m+1]={0};
	int sum=arr2[m];
	for(j=m-1;j>=1;j--)
	{
		int total=(m-j);
		suffix2[j]=(sum-total*arr2[j]);
		sum+=arr2[j];
	}
	int suffix1[n+1]={0};
	sum=arr1[n];
	for(j=n-1;j>=1;j--)
	{
		int total=(n-j);
		suffix1[j]=(sum-total*arr1[j]);
		sum+=arr1[j];
	}
	for(j=m-1;j>=1;j--)
	{
		suffix2[j]+=suffix2[j+1];
	}
	int answer=0;
	for(j=1;j<n;j++)
	{
		int here=suffix1[j]%mod;
		int val2=suffix2[1]%mod;
		here*=val2;
		here%=mod;
		answer+=here;
		answer%=mod;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S;
    cin >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < N; ++i) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  
  bool can = true;
  for (int i = 0; i < N; ++i) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007


void solve(void)
{

  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  cout<<max((N-K),(int)0)*Y + min(N,K)*X<<endl;
  
  return;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
import math

S = int(input())

first_half = math.floor(S / 100)
second_half = S - first_half * 100

if 1 <= second_half <= 12 and 1 <= first_half <= 12 :
  print("AMBIGUOUS")
elif 1 <= second_half <= 12 :
   		print("YYMM")
elif 0 == first_half or 12 < first_half :
    	print("NA")
else: 
        print("MMYY")

Measured memory_bytes: 3060
#include <stdio.h>
int main() {
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if (w >= x + r && 0 <= x - r && h >= y + r && 0 <= y - r) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k)cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 double  N,M;cin>>N>>M;
  double tot=0;
  cout<<pow(2,M)*(1900*M+(N-M)*100)<<endl;
}







Measured memory_bytes: 256
n = int(input())
maxCnt = 0
ans = 1

for i in range(1,n+1,1):
    tmpCnt = 0
    j = i
    while j%2 == 0:
        j = j/2
        tmpCnt += 1
    if maxCnt < tmpCnt:
        maxCnt = tmpCnt
        ans = i

print(ans)

Measured memory_bytes: 9060