akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String S = readLine()[0];
		print(S.replace("?","D"));
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static long[] readLineLong(){
		try{
			String[] s = readLine();
			long[] ints = new long[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Long.parseLong(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


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

struct DLList{
	
	int before,next,name,x;
	
};

void insertx(DLList *a,int &first,int &end,int &cou,int &x){
	if(first==end&&first==-1){
		a[cou].next=-1;
		a[cou].before=-1;
		first=cou;
		end=cou;
		a[cou].x=x;
	}else{
		a[first].before=cou;
		a[cou].next=first;
		a[cou].before=-1;
		first=cou;
		a[cou].x=x;
	}
}

void deletex(DLList *a,int &first,int &end,int &cou,int &x){
	
	int i=first;
	int b,n;
	while(i!=-1){
		if(a[i].x==x){
			b=a[i].before;
			n=a[i].next;
			if(i!=first&&i!=end){
				a[b].next=n;
				a[n].before=b;
			}else if(i==first){
				a[n].before=-1;
				first=n;
			}else{
				a[b].next=-1;
				end=b;
			}
			break;
		}else{
			i=a[i].next;
		}
	}
}

void deleteFirst(DLList *a,int &first,int &end){
	int n=a[first].next;
	if(first==end){
		int b=a[end].before;
		if(b>=0){
			a[b].next=-1;
		}
		if(n>=0){
			a[n].before=-1;
		}
		end=b;
	}else{
		if(n>=0){
			a[n].before=-1;
		}
	}
	first=n;
}

void deleteLast(DLList *a,int &first,int &end){
	int b=a[end].before;
	if(first==end){
		if(b>=0){
			a[b].next=-1;
		}
		int n=a[first].next;
		if(n>=0){
			a[n].before=-1;
		}
		first=n;
	}else{
		if(b>=0){
			a[b].next=-1;
		}
	}
	end=b;
}

int main(){
	
	int n;
	std::cin>>n;
	int first=-1,end=-1,cou=0,x;
	std::string str;
	DLList a[n];
	for(int i=0;i<n;i++){
		std::cin>>str;
		
		if(str=="insert"){
			std::cin>>x;
			insertx(a,first,end,cou,x);
			cou++;
		}
		if(str=="delete"){
			std::cin>>x;
			deletex(a,first,end,cou,x);
		}
		if(str=="deleteFirst"){
			deleteFirst(a,first,end);
		}
		if(str=="deleteLast"){
			deleteLast(a,first,end);
		}
		
//		std::cout<<first<<" "<<a[first].x<<" "<<end<<" "<<a[end].x<<"\n";
	}
	
	int now=first;
	if(now!=-1){
//	std::cout<<first<<end;
		while(now!=-1){
			if(a[now].next!=-1){
				std::cout<<a[now].x<<" ";
			}else{
				std::cout<<a[now].x<<"\n";
			}
			now=a[now].next;
		}
//		std::cout<<a[now].x<<"\n";
	}
	return 0;
}


Measured memory_bytes: 20332
N = int(input())

res = 0
status = 0
A = list(map(int, input().split()))
pre = A[0]
for i in range(1, N):
    if status == 0:
        if pre < A[i]:
            status = 1
            res += 1
        elif pre > A[i]:
            status = 2
            res += 1
    elif (status == 1 and pre > A[i]) or (status == 2 and pre < A[i]):
        status = 0
    pre = A[i]

if status == 0:
    res += 1

print (str(res))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,l,r,d,a[MAXN];
int main()
{
    scanf("%d%d%d",&l,&r,&d);
    printf("%d\n",r/d-(l-1)/d);
}

Measured memory_bytes: 3836
from collections import defaultdict


def to_cumsum(arr):
    arr.sort(reverse=True)
    cumsum = 0
    new = [0] * (len(arr) + 1)
    for i, e in enumerate(arr):
        cumsum += e
        new[i + 1] = cumsum
    return new


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

weights = defaultdict(int)
values = defaultdict(list)
for i in range(N):
    w, v = map(int, input().split())
    weights[w] += 1
    values[w].append(v)
for k, v in values.items():
    values[k] = to_cumsum(v)

w1 = min(weights.keys())
w2 = w1 + 1
w3 = w2 + 1
w4 = w3 + 1
for w in [w1, w2, w3, w4]:
    if len(values[w]) == 0:
        values[w] = [0]

ans = 0
for i1 in range(weights[w1] + 1):
    for i2 in range(weights[w2] + 1):
        for i3 in range(weights[w3] + 1):
            for i4 in range(weights[w4] + 1):
                if w1 * i1 + w2 * i2 + w3 * i3 + w4 * i4 > W:
                    continue
                ans = max(ans, values[w1][i1] + values[w2][i2] + values[w3][i3] + values[w4][i4])
print(ans)


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

int main() {
  int n,k,t,s,a;
  cin >>n >>k;
  t=1;
  a=0;
  while(t<=n){
    s = t*k;
    t = s;
    a++;
  }
  cout <<a <<endl;    
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    x = 0
    ans = 0
    for i in range(n):
        if s[i] == "I":
            x += 1
        elif s[i] == "D":
            x -= 1
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
ans = 0
for i in range(N):
    a = A[i]
    ans += B[A[i]-1]
    if i and A[i-1] == A[i]-1:
        ans += C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define ll long long
using namespace std;
//
const int inf=1e9+7;//0x3f
//
struct nCk{
	//
	ll pow(ll x,ll n,ll mod){
		ll res=1;
		if(n>0){
			res=pow(x,n/2,mod);
			if(n%2==0){
				(res=(res*res))%=mod;
			}else{
				(res=((res*res)%mod)*x)%=mod;
			}
		}
		return res;
	}
	//
	ll inv(ll n,ll mod){
		return pow(n,mod-2,mod);
	}
	//
	ll cul(ll n,ll k,ll mod){
		ll res=1;
		for(int i=n;i>n-k;i--){
			(res*=i)%=mod;
		}
		for(int i=k;i>=1;i--){
			(res*=inv(i,mod))%=mod;
		}
		return res;
	}
	//
};
int main(){
	nCk nck;
	long long N,M;
	cin>>N>>M;
	long long ans=1;
	long long cnt=0;
	while(M%2==0){
		M/=2;
		cnt++;
	}
	if(cnt){
		(ans*=nck.cul((cnt+N-1),cnt,inf))%=inf;
	}
	long long now=3;
	while(M>1){
		cnt=0;
		while(M%now==0){
			M/=now;
			cnt++;
		}
		if(cnt){
			(ans*=nck.cul((cnt+N-1),cnt,inf))%=inf;
		}
		now+=2;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int A,B; cin >> A >> B;
  int sum=0;
  if(A>B){
    sum+=A;
    A--;
  }else{
    sum+=B;
    B--;
  }
  if(A>B) cout << sum+A << endl;
  else cout << sum+B << endl;
}

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

const double PI=3.141592653589793;

int main()
{

  //今回はdoubleじゃだめらしい
  //A*(B*100)/100にすることで、小数のBを整数にすることで楽にする
  ll A;
  double B;
  cin>>A>>B;
  ll ib = B * 100 + 0.5;  //doubleからllへのキャスト（切り捨て）なので、微妙な誤差が生じるらしい->0.1とか0.5とか足すと狙った整数になるらしい

  A *= ib;
  A /= 100;
  cout << A << endl;

  return 0;
}


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

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

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    u-=1;v-=1
    g[u].append([v,w])
    g[v].append([u,w])
ans = [-1]*n
def dfs(x,y):
    for i,j in g[x]:
        if ans[i] == -1:
            ans[i] = (y+j)%2
            dfs(i,y+j)
dfs(0,0)
for i in ans:
    print(i)

Measured memory_bytes: 87204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    char a;
    cin >> a;
    if (a >= 'A' && a <= 'Z') cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    # n,m の bipartite graph
    E=[[] for _ in range(n+m)]
    for i in range(n):
        L=list(map(lambda x:int(x)-1,input().split()))[::-1]
        L.pop()
        for l in L:
            E[i].append(n+l)
            E[n+l].append(i)

    # 0,...,n-1 が連結かどうかを見る
    used=[0]*(n+m)
    used[0]=1
    Q=[0]
    while(Q):
        v=Q.pop()
        for nv in E[v]:
            if(used[nv]): continue
            used[nv]=1
            Q.append(nv)

    print("YES" if(min(used[:n])==1) else "NO")
resolve()

Measured memory_bytes: 69836
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <list>
#include <iterator>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	int card[100005] = {};
	int maxi = 0;
	for (int i = 0; i < m; ++i) {
		int l, r; cin >> l >> r;
		card[l]++; card[r + 1]--;
		maxi = max(maxi, r);
	}
	int cnt = 0;
	for (int i = 1; i <= maxi; ++i) {
		card[i] += card[i - 1];
		if (card[i] >= m) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	string s,t;
	cin>>s>>t;
	for (int i=0;i<sz(s);i++){
		if (s[i]!=t[i]){
			cout<<"No";
			re 0;
		}
	}
	cout<<"Yes";
	re 0;
}

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

int main(){


  int N;
  cin >> N;
  int o = 0;

  for(int i = 0 ; i < N ; i++){
    int x;
    cin >> x;
    o += x%2;
  }

  if(o % 2){
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

int h, w, k;
vector<string> table;
void solve()
{
    cin >> h >> w >> k;
    table.resize(h);
    for(int i = 0; i < h; i++)
    {
        cin >> table[i];
    }
    int ans = 0;
    for(int bit_h = 0; bit_h < (1<<h); bit_h++)
    {
        for(int bit_w = 0; bit_w < (1<<w); bit_w++)
        {
            vector<string> tmp = table;
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(bit_h & (1<<i) || bit_w & (1<<j))
                    {
                        tmp[i][j] = '.';
                    }
                }
            }
            int cnt = 0;
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(tmp[i][j] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,q,m,d;
    while (cin>>n>>q) {
        if (n==0&&q==0) {
            break;
        } else {
            std::deque<int> date(101,0);
            for (int i=0;i<n;i++) {
                cin>>m;
                for (int j=0;j<m;j++) {
                    cin>>d;
                    date[d]++;
                }
            }
            int now=0;
            int ans=0;
            for (int k=0;k<101;k++) {
                if (date[k]>=q) {
                    if (now<date[k]) {
                        now=date[k];
                        ans=k;
                    }
                }
            }
            cout<<ans<<endl;
        }
    }
}



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

struct LowLink{
  int n,pos;
  vector<int> ord,low,par,blg;
  vector<vector<int> > G,C,T;
  
  vector<int> ap;
  vector<pair<int, int> > bs;

  LowLink(int n):n(n),pos(0),ord(n,-1),low(n),par(n,-1),blg(n,-1),G(n){}

  void add_edge(int u,int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  bool is_bridge(int u,int v){
    if(ord[u]>ord[v]) swap(u,v);
    return ord[u]<low[v];
  }

  void dfs(int v){
    ord[v]=low[v]=pos++;
    for(int u:G[v]){
      if(u==par[v]) continue;
      if(~ord[u]){
	low[v]=min(low[v],ord[u]);
	continue;
      }
      par[u]=v;
      dfs(u);
      low[v]=min(low[v],low[u]);
      if(is_bridge(u,v)) bs.emplace_back(u,v);
    }
  }

  void fill_component(int v){
    C[blg[v]].emplace_back(v);
    for(int u:G[v]){
      if(~blg[u]) continue;
      blg[u]=blg[v];
      fill_component(u);
    }
  }

  void add_component(int v,int &k){
    if(~blg[v]) return;
    blg[v]=k++;
    C.emplace_back();
    fill_component(v);
  }
  
  void build(){
    for(int i=0;i<n;i++)
      if(ord[i]<0) dfs(i);
    
    vector<int> cnt(n,0);
    for(int i=0;i<n;i++){
      int p=par[i];
      if(p<0) continue;
      if(par[p]<0) cnt[p]++;
      else if(ord[p]<=low[i]) ap.emplace_back(p);
    }
    
    for(int i=0;i<n;i++)
      if(cnt[i]>1) ap.emplace_back(i);

    sort(ap.begin(),ap.end());
    ap.erase(unique(ap.begin(),ap.end()),ap.end());

    int k=0;    
    for(int i=0;i<n;i++) add_component(i,k);

    T.assign(C.size(),vector<int>());
    for(auto e:bs){
      int u=blg[e.first],v=blg[e.first];
      T[u].emplace_back(v);
      T[v].emplace_back(u);
    }      
  }
};


//problemId=GRL_3_B
signed main(){
  int n,m;
  scanf("%d %d",&n,&m);
  
  LowLink G(n);
  for(int i=0;i<m;i++){
    int u,v;
    scanf("%d %d",&u,&v);
    G.add_edge(u,v);
  }
  G.build();
  
  auto bs=G.bs;
  for(auto &e:bs)
    if(e.first>e.second) swap(e.first, e.second);
  
  sort(bs.begin(),bs.end());
  for(auto e:bs) printf("%d %d\n",e.first, e.second);
  
  return 0;
}



Measured memory_bytes: 4644
#include<stdio.h>
#include<string.h>
char srx[100001];
int main()
{
    gets(srx);
    int i,zjq=0;
    for(i=1;i<strlen(srx);i++)
    if(srx[i]!=srx[i-1])
    zjq++;
    printf("%d\n",zjq);
    return 0;
}

Measured memory_bytes: 256
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e6 + 1;

void solve(){
	ll x , n;
	cin >> x >> n;
	vll v;
	rep(i , n) {
		ll a;
		cin >> a;
		v.pb(a);
	}
	map<ll ,set<ll> > m;
	sort(all(v));
	ll mn = inf;
	ll ans =0 ;
	for(ll i = -2 ; i<= 102 ; i++){
		auto it = find(all(v) , i);
		if(it == v.end()){
			ll val = abs(x - i);
			mn = min(val , mn);
			m[mn].insert(i);
		}
	}
	cout << *m[mn].begin() << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

  auto solve_1_fn = [](const vector<int64>& xs, int n) -> int64 {
    int64 cur = 0;
    int64 cost = 0;
    for (int i = 0; i < n; i++) {
      cur += xs[i];
      if (i % 2 == 0 && cur <= 0) {
        int64 d = 1 - cur;
        cur += d;
        cost += d;
      } else if (i % 2 == 1 && cur >= 0) {
        int64 d = -(cur + 1);
        cur += d;
        cost += abs(d);
      }
    }
    return cost;
  };

  int64 v1 = solve_1_fn(xs, n);

  for (int i = 0; i < n; i++) {
    xs[i] *= -1;
  }
  int64 v2 = solve_1_fn(xs, n);

  cout << min(v1, v2) << endl;
} 

Measured memory_bytes: 1024
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let a: u32 = read(&mut stdin).unwrap();
    let b: u32 = read(&mut stdin).unwrap();
    let c: u32 = read(&mut stdin).unwrap();

    println!("{}", if a + b >= c { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();

        int H, W;
        string[] C;
        void solve() {
            H = cin.Int();
            W = cin.Int();
            C = new string[H];
            for (int i = 0; i < H; i++)
                C[i] = cin.String();


            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            for (int i = 0; i < H * 2; i++)
                Console.WriteLine(C[i / 2]);
            Console.Out.Flush();

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string String() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public char Char() { return char.Parse(String()); }
            public int Int() { return int.Parse(String()); }
            public long Long() { return long.Parse(String()); }
            public double Double() { return double.Parse(String()); }
        }

        class Mathf {
            public int mod = 1000000007;//10^9+7
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
            public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); }
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
int32_t main()
{
	fast;
	int a, b;
	cin>>a>>b;
	int n=1;
	int c=0;
	while(n<b)
	{
		c++;
		n--;
		n+=a;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(4e5)+10;
int n,q;
int head[maxn],nxt[maxn],tot;
int to[maxn];
ll w[maxn];
void add(int x,int y) {
	tot++; nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;	
}
void dfs(int u,int p) {
	for (int i=head[u],v;i;i=nxt[i]) {
		v=to[i]; if (v==p) continue;
		w[v]+=w[u]; dfs(v,u);
	}
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); int x,y; read(q);
	for (int i=1;i<n;i++) {
		read(x); read(y);
		add(x,y); add(y,x);
	}
	while (q--) {
		read(x); read(y); w[x]+=y;
	}
	dfs(1,0);
	for (int i=1;i<=n;i++)
		printf("%lld ",w[i]);
	printf("\n");
	return 0;
}

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

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	vector<long long int> b(n);

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

	for (long long int i = n-1; i >= 0; i--) {
		long long int k = (a[i]+c)%b[i];
		if (k == 0) {
		} else {
			c += b[i]-k;
		}
	}

	/*

	for (long long int i = 0; i < n; i++) {
		cout << a[i] << ' ' << a[i]+c << ' ' << b[i] << endl;
		long long int k = (a[i]+c)%b[i];
		if (k == 0) {
		} else {
			c += b[i]-k;
		}
	}*/
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    string s;
    cin >> s;
    int n = s.size();

    bool abc[26];
    rep(i, 26) {
        abc[i] = false;
    }
    rep(i, n) {
        abc[s[i] - 'a'] = true;
    }
    rep(i, 26) {
        if(!abc[i]) {
            char a = i + 'a';
            cout << a << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

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

int main()
{

   int n;
   cin>>n;
   long long int a[n];
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
   }
   sort(a,a+n);
    
   long long int ans=0;
   for(int i=0;i<n-2;i++)
   {
    
       for(int j=i+1;j<n-1;j++)
       {
           
           for(int k=j+1;k<n;k++)
           {
              if(a[i]+a[j]>a[k] and a[i]!=a[j] and a[j]!=a[k])
              {
                  ans+=1;
                 
              }
              
           }
           
         
       }
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int a, b, c, d, e, f, ans;

  if(scanf("%d %d %d %d", &a, &b, &c, &d) == 1);

  if(a < c) {
    e = c;
  } else {
    e = a;
  }

  if(b > d) {
    f = d;
  } else {
    f = b;
  }

  if(f < e) {
    ans = 0;
  } else{
    ans = f - e;
  }

  printf("%d", ans);

  return 0;
}


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

using namespace std;
const int MN = 1e5+7;

int dp[MN], n, h[MN];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 1; i < n; i++){
        dp[i] = 1e9+7;
        if(i > 1){
            dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
            continue;
        }
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
n, m = readline.split(' ').map(&:to_i)
c = Array.new(n)
cant = false
0.upto(m - 1) do |num|
  a, b = readline.split(' ').map(&:to_i)
  cant = true if !c[a - 1].nil? && c[a - 1] != b
  c[a - 1] = b
end
 
if cant
  puts '-1'
elsif n >= 2 && c[0] == 0
  puts '-1'
else
  c[0] = 1 if  n >= 2 && c[0].nil?
  puts c.map { |num| num.nil? ? 0:num }.join('')
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  deque<ll> ans;
  for (int i = 0; i < N; i++)
  {
    int idx = lower_bound(ans.begin(), ans.end(), A[i]) - ans.begin();
    if (idx == 0)
    {
      ans.push_front(A[i]);
    }
    else
    {
      idx--;
      ans[idx] = A[i];
    }
  }
  cout << ans.size() << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


int main(void)
{
    double a,b,x;
    cin >> a >> b >> x;
    
    double lb = 0, ub = 90;
    REP(i, 100){
        double mid = (lb + ub)/2.0;
        double c = a*a*b;
        double b_tmp = a*tan(mid/180.0*PI);
        double r;
        if(b_tmp <= b){
            r = a*a*b_tmp/2.0;
            if(x < (c-r)){
                lb = mid;
            }else{
                ub = mid;
            }
        }else{
            if(x < a*b*b*tan((90-mid)/180.0*PI)/2.0){
                lb = mid;
            }else{
                ub = mid;
            }
        }
    }
    printf("%.10lf\n", lb);
    
}

Measured memory_bytes: 256
#include <stdio.h>
#define S_MAX 10000
#define T_MAX 500

int main(){
  int ns,nt,i,j,count = 0;
  int s[S_MAX],t[T_MAX];

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

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

  for(i = 0; i < ns; i++){
    for(j = 0; j < nt; j++){
      if(s[i] == t[j]){
        count++;
        t[j] = -1;
        break;
      }
    }
  }

  printf("%d\n" ,count);

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

long long binary_search(long long ng, long long ok,
                        function<bool(long long)> f) {
  while (abs(ok - ng) > 1) {
    long long mid = (ng + ok) / 2;
    if (f(mid))
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}

int main() {
  long long n, A, B;
  cin >> n >> A >> B;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  auto f = [&](long long K) {
    long long x = 0;
    for (const auto& e : h) {
      long long rem = (long long)e - B * K;
      if (rem > 0) {
        x += (rem + A - B - 1) / (A - B);
      }
    }
    return x <= K;
  };
  cout << binary_search(0, 1e9 * 2, f) << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<20);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

set<int> stl,str;

int p[100100],i;

int main(void){
	int n,i,a,b,c,d,e;
	ll ans=0ll,tmp;
	cin >> n;
	stl.insert(1);
	stl.insert(INF);
	str.insert(n);
	str.insert(INF);
	for(i=0; i<n; ++i){
		cin >> a; --a;
		p[a] = i;
	}
	for(i=(n-1); i>=0; --i){
		c = p[i];
		b = *stl.upper_bound(-c);
		a = *stl.upper_bound(b);
		b *= -1; a *= -1;
		d = *str.upper_bound(c);
		e = *str.upper_bound(d);
		stl.insert(-c);
		str.insert(c);
		if(b<0 && d>=n){
			continue;
		}else if(b<0){
			tmp = (ll)(i+1)*(e-d)*(c-b);
		}else if(d>=n){
			tmp = (ll)(i+1)*(d-c)*(b-a);
		}else{
			tmp = (ll)(i+1)*(e-d)*(c-b);
			tmp += (ll)(i+1)*(d-c)*(b-a);
		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[100005][10];

int main()
{
    int k;
    cin >> k;
    queue<ll> q;
    for (ll i = 1; i < 10; i++)
    {
        q.push(i);
    }
    
    ll num;
    rep(i,k)
    {
        num = q.front();
        if (num%10!=0)
        {
            q.push(num * 10 + (num % 10 - 1));
        }
        q.push(num * 10 + (num % 10));
        if (num%10 != 9)
        {
            q.push(num * 10 + (num % 10 + 1));
        }
        q.pop();
        //cout << num << endl;
    }
    cout << num << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
#define LOG(x) cout << #x << " := " << (x) << endl
#define _LOG(x) cout << "Momentai " << x << endl
typedef long long ll;
typedef long double Lf;

const int max_N = 1e5+5;
const int max_M = 35;

int N, L, Q;
int ar[max_N], nxt[max_N][max_M];

int get_next(int i) {
    if (i == N) return N;

    int l = i+1, r = N;
    while (l < r) {
        int m = (l+r+1) / 2;
        if (ar[m]-ar[i] > L) r = m-1;
        else l = m;
    }

    return l;
}

void init() {
    for (int i = 0; i <= N; ++i) nxt[i][0] = get_next(i);
    
    for (int i = 1; i < max_M; ++i)
        for (int j = 0; j <= N; ++j) {
            nxt[j][i] = nxt[nxt[j][i-1]][i-1];
        }
}

int calc_distance(int a, int b) {
    int ans = 0;
    
    for (int k = max_M-1; k >= 0; --k)
        if (nxt[a][k] <= b) {
            ans += (1 << k);
            a = nxt[a][k];
        }
    if (a != b) ++ans;

    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N;
    for (int i = 0; i < N; ++i) cin >> ar[i];
    ar[N] = ar[N-1]+1;
    cin >> L >> Q;
    init();

    while (Q--) {
        int a, b; cin >> a >> b; --a; --b;
        if (a > b) swap(a, b);
        cout << calc_distance(a, b) << endl;
    }

    return 0;
}

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

int main() {
    int N; cin >> N;
    string W[N];
    bool heObeyRule = true;
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (W[i] == W[j]) {
                heObeyRule = false;
            }
        }
        if (W[i][W[i].size() - 1] != W[i + 1][0]) {
            heObeyRule = false;
        }
    }
    if (heObeyRule) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3608
def main():
    n = int(input())
    p = list(map(int, input().split()))

    cnt = 0
    for i in range(1,n-1):
        if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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


int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 0;
  if( (b-a)%2 == 0 ){
    cout << (b-a)/2 << endl;
  }else{
    if( a-1 <= n-b ){
      ans += a-1;
      b -= a-1;
      a = 1;
      ans += 1;
      b --;
      ans += (b-a)/2;
      cout << ans << endl;
    }else{
      ans += n-b;
      a += n-b;
      b = n;
      ans += 1;
      a ++;
      ans += (b-a)/2;
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    S = input().strip()

    S2 = S

    while S2.count("()"):
        S2 = S2.replace("()", "")

    x = S2.count("(")
    y = S2.count(")")

    print(y * "(" + S + x * ")")




if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}


vector<int>a, b;
int main() {
	int N, H; cin >> N >> H;
	vector<int>a(N), b(N);
	REP(i, N) {
		cin >> a[i] >> b[i];
	}
	VSORT(a); VREVERSE(a);
	VSORT(b); VREVERSE(b);
	int cnt = 0;
	int aMax = a[0];
	REP(i, N) {
		if (aMax < b[i]) {
			H -= b[i];
			cnt++;
			if (H <= 0) {
				print(cnt);
				return 0;
			}
		}
		else break;
	}
	cnt += (H+aMax-1) / aMax;
	print(cnt);
}

Measured memory_bytes: 1024
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n;
ll ans=0;
int32_t main(){
cin>>n;
for(ll i=2;i<=sqrt(n);i++)
{
    if(n%i==0){
        ll val=n;
        while(val%i==0){
            val=val/i;
        }
        if(val%i==1){
            ans++;
        }
        if(n/i!=i){
            val=n;
            ll x=n/i;
            while(val%x==0){
                val=val/x;
            }
            if(val%x==1){
                ans++;
            }
        }
    }
}
n--;
if(n!=1){
    ans++;
}
ans++;
for(ll i=2;i<=sqrt(n);i++)
if(n%i==0){
    ans++;
    if(i!=n/i){
        ans++;
    }
}
cout<<ans<<endl;
}


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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    int bcnt = 0;
    int ret = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'B')
        {
            bcnt++;
            ret += s.length() - bcnt - i;
        }
    }
    cout << ret << endl;
}

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

int main() {
  
  int N; cin >> N; int tmp = 0; int count = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  for (int i = 0; i < N; i++) {
    
    count++;
    
    tmp = vec.at(tmp);
    
    if (tmp == 2) {
      cout << count << endl;
      return 0;
    }
    
    tmp--;
    
  }
  
  cout << -1 << endl;
  
}

Measured memory_bytes: 640
import itertools as it
n,m,k=list(map(int,input().split()))
S=[list(str(input())) for h in range(n)]
ans=0
for i in it.product([0,1],repeat=n):
  for j in it.product(range(2),repeat=m):
    count=0
    for h in range(n):
      for c in range(m):
        if S[h][c]=="#" and i[h]+j[c]==0:
          count+=1
    if count==k:
      ans+=1
print(ans)

Measured memory_bytes: 73728
s = input()
a, b = int(s[:2]), int(s[2:])
ch = 0
if 0 < a < 13:
    ch += 1
if 0 < b < 13:
    ch += 2
if ch == 0:
    print("NA")
elif ch == 1:
    print('MMYY')
elif ch == 2:
    print('YYMM')
elif ch == 3:
    print('AMBIGUOUS')


Measured memory_bytes: 3060
n,k,c=map(int,input().split()) ; c+=1
s=input()
A=[i+1 for i in range(n) if s[i]=="o"] #働ける日付
L=[1 for i in range(k)] #働く日数[l] はL[l]以降
R=[n for i in range(k)] #L[l]以前

import bisect
for i in range(1,k):
  L[i]= A[bisect.bisect_left(A,L[i-1]+c)]
  R[-i-1]= A[bisect.bisect_right(A,R[-i]-c)-1]

  
for i in range(k):
  if L[i]==R[i]: 
    print(L[i])

Measured memory_bytes: 15832
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
ll n,m,q,A[N],B[N],C[N],fa[N],res,vis[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void merge(int x, int y){
	x=find(x);y=find(y);fa[x]=y;
}
int main() {
	read(n);read(m);read(q);
	rep(i,1,q)read(A[i]),read(B[i]),read(C[i]),A[i]++,B[i]++;
	rep(i,1,n)fa[i]=i;
	rep(i,1,q)if(C[i]==0)merge(A[i],B[i]);
	rep(i,1,q)if(C[i]==1){
		int x=find(A[i]),y=find(B[i]);
		if(x==y){puts("No");return 0;}
		vis[x]=vis[y]=1;
	}
	ll cnt=0,tot=0;
	res=n;rep(i,1,n)if(find(i)==i)res--,cnt+=vis[i],tot++;
	if(tot==2&&cnt)puts("No");
	else if(m>=n-1+(cnt>0)&&m<=res+tot*(tot-1)/2)
		puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 9216
/** MIT License Copyright (c) 2018-2019 Vasilev Daniil **/
#include <bits/stdc++.h>
using namespace std;
template<typename T> using v = vector<T>;
#define int long long
typedef double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
const long double EPS = 1e-11;
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin >>
#define put fout <<
#else
#define get cin >>
#define put cout <<
#endif
#define eol put endl
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
int getInt(){int a; get a; return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//code starts here

void run() {
	int n;
	get n;
	int a[n];
	rep(i, 0, n)
		get a[i];
	int s = 0;
	rep(i, 0, n)
		s += a[i];

	s /= 2;
	for (int i = 1; i < n; i += 2)
		s -= a[i];
	print(s * 2);
	int pr = s;
	rep(i, 1, n) {
		pr = a[i - 1] - pr;
		print(pr * 2);
	}

	/*
	x1 + x2 = a[1]
	x2 + x3 = a[2]
	x3 + x4 = a[3]
	...
	xn + x1 = a[n]
	*/
}
signed main() {srand(time(0)); ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run();}


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

int main(){
	const int size = 100000;
	int N, C;
	cin >> N >> C;
	vector<int> s(N);
	vector<int> t(N);
	vector<int> c(N);
	for (int i = 0; i < N; i++){
		cin >> s[i] >> t[i] >> c[i];
	}

	array<int, size*2+10> d;
	d.fill(0);
	array<int, size*2+10> dx;
	dx.fill(0);
	for (int i = 1; i <= C; i++){
		dx.fill(0);

		for (int j = 0; j < N; j++){
			if (c[j] != i) continue;

			dx[s[j]*2]++;
			dx[t[j]*2]--;
		}

		for (int j = 1; j <= size*2; j++){
			if (dx[j] == 1) d[j-1]++;
			else if (dx[j] == -1) d[j]--;
		}
	}

	int res = 0;
	for (int i = 1; i <= size*2; i++){
		d[i] += d[i-1];
		res = max(res, d[i]);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>

int main(){
  int x,y;
  int i,j;
  int a[3000],b[3000];
  for(i=0;i<3000;i++){
    scanf("%d %d",&x,&y);
    if(x==0&&y==0){
      break;
    }
    if(x>y){
      a[i] = y;
      b[i] = x;
    }
    else{
      a[i] = x;
      b[i] = y;
    }
  }
  for(j=0;j<i;j++){
    printf("%d %d\n",a[j],b[j]);
  }
  return 0;
}

Measured memory_bytes: 2652
#include <stdio.h>
int main(){
    int i,m,m1,m2,m3;
    for(i=0;i<10;i++){
        scanf("%d",&m);
        if(i==0){
            m1=m;
        }
        else if(i==1){
            if(m>m1){
                m2=m1;
                m1=m;
            }
            else{
                m2=m;
            }
        }
        else if(i==2){
            if(m>m2){
                if(m>m1){
                    m3=m2;
                    m2=m1;
                    m1=m;
                }
                else{
                    m3=m2;
                    m2=m;
                }
            }
            else{
                m3=m;
            }
        }
        else{
            if(m>m3){
                if(m>m2){
                    if(m>m1){
                        m3=m2;
                        m2=m1;
                        m1=m;
                    }
                    else{
                        m3=m2;
                        m2=m;
                    }
                }
                else{
                    m3=m;
                }
            }
        }
    }
    printf("%d\n%d\n%d\n",m1,m2,m3);
    return 0;
}

Measured memory_bytes: 600