akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
	char a, b;
	cin >> a >> b;

	if(a=='H' && b=='H')		cout << 'H' << endl;
	else if(a=='D' && b=='H')	cout << 'D' << endl;
	else if(a=='D' && b=='D')	cout << 'H' << endl;
	else if(a=='H' && b=='D')	cout << 'D' << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iterator>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  cin.get();

  string line;
  getline(cin, line);
  istringstream iss {line};
  vector<double> x {istream_iterator<double> {iss},
    istream_iterator<double> {}};

  getline(cin, line);
  istringstream issy {line};
  vector<double> y {istream_iterator<double> {issy},
    istream_iterator<double> {}};

  cout << fixed;

  // 1-norm, 2-norm, 3-norm
  for (double p =1; p <= 3; ++p) {
    double serr {0};
    auto xit = x.begin();
    auto yit = y.begin();
    for (; xit != x.end(); ++xit, ++yit) {
      serr += pow(abs(*xit - *yit), p);
    }
    cout << pow(serr, 1/p) << endl;
  }

  // inf-norm
  vector<double> diffs;
  auto xit = x.begin();
  auto yit = y.begin();
  for (; xit != x.end(); ++xit, ++yit)
    diffs.push_back(abs(*xit - *yit));
  double max {0};
  for (double c : diffs)
    if (c > max) max = c;
  cout << max << endl;  // print inf-norm
}


Measured memory_bytes: 3408
#include<stdio.h>

typedef long long ll;
const int N=500005,P=998244353;

int fexp(int a,int b)
{
	ll x=1,o=a;
	for(;b;b>>=1,o=o*o%P)
		if(b&1)x=x*o%P;
	return x;
}

int n,m,ans,fac[N],ifac[N];

int C(int n,int m){return 1ll*fac[n]*ifac[n-m]%P*ifac[m]%P;}

int main()
{
	scanf("%d%d",&n,&m);
	if(n<m){
		int t=n;
		n=m;
		m=t;
	}
	fac[0]=1;
	for(int i=1; i<=n; i++)fac[i]=1ll*fac[i-1]*i%P;
	ifac[n]=fexp(fac[n],P-2);
	for(int i=n-1; ~i; i--)ifac[i]=1ll*ifac[i+1]*(i+1)%P;
	for(int k=0; k<=m; k++){
		int f=1ll*C(n,k)*C(m,k)%P*fac[k]%P*fexp(m+1,n-k)%P*fexp(n+1,m-k)%P;
		if(k&1)ans=(ans+P-f)%P;else ans=(ans+f)%P;
	}
	printf("%d",ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[15];
    char b[15];
    cin >> a >> b;
    int f=1;
    for(int i=0;i<strlen(a);i++){
        if(a[i]!=b[i]){
            f=0;
        break;}
    }
    if(f==0)
        cout<< "No";
    else
        cout << "Yes";
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<int> A(N);
	long long totS = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		totS += A[i];
	}
	long long ans = 4e18;
	long long curS = 0;
	for (int i = 0; i+1 < N; i++) {
		curS += A[i];
		ans = min(ans, abs(curS - (totS - curS)));
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1024
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

const MODULO: usize = 1_000_000_007;

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let mut f: Vec<usize> = vec![0; n + 1];
    f[0] = 1;
    for i in 1..n + 1 {
        f[i] = i * f[i - 1] % MODULO;
    }
    let g: Vec<usize> = f.iter().map(|&x| inverse(x)).collect();
    let binom = |x, y| {
        if x < y {
            0
        } else {
            f[x] * g[y] % MODULO * g[x - y] % MODULO
        }
    };
    for i in 1..k + 1 {
        println!("{}", binom(k - 1, i - 1) * binom(n - k + 1, i) % MODULO);
    }
}

fn power(mut b: usize, mut e: usize) -> usize {
    let mut a = 1;
    while e != 0 {
        if e & 1 != 0 {
            a = a * b % MODULO;
        }
        b = b * b % MODULO;
        e >>= 1;
    }
    a
}

fn inverse(x: usize) -> usize {
    power(x, MODULO - 2)
}


Measured memory_bytes: 4352
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807

signed main(){
int x=0,y=0,z=0,w=0;
std::cin >> x>>y;
if(x+y==0)std::cout << 0 << '\n';
else if(x+y<0)std::cout << -1 << '\n';
else std::cout << 1 << '\n';
}



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

using namespace std;

int main(void)
{
  int n; cin >> n; vector<int> vec(2* n, 0); for(int i = 0; i < 2* n; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  long long ret = 0;
  
  for(int i = 0; i < 2*n; i++)
    if(i%2 == 0)
      ret += vec[i];
  
  cout << ret << endl;
  
  
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> b(N);
    REP(i, N) cin >> b[i];
    vector<ll> res;

    REP(i, N){
    	ll idx = -1;
    	REP(j, N-i){
    		if(j+1 == b[j]){
    			idx = j;
    		}
    	}
    	if(idx == -1){
    		cout << -1 << endl;
    		return 0;
    	}
    	res.push_back(idx+1);
    	b.erase(b.begin()+idx, b.begin()+idx+1);
    }
    REP(i, N) cout << res[N-1-i] << endl;
    return 0;
}

Measured memory_bytes: 256
line = gets
word = Hash.new
hoge = line.split("")
ans = "yes"
hoge.each{|var|
	if word[var] == nil
		word[var] = 1
		#p(word[var])
	else
		word[var] += 1
		#p(word[var])
	end
#print("#{var}\s")
}

word.each_value do |value|
	if value == 1
		ans = "yes"
		#p(value)
	else
		ans = "no"
		#p(value)
		break
	end
end

puts(ans)

Measured memory_bytes: 1788
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    inf=10**9
    n,ma,mb=MI()
    vv=[]
    cc=[]
    for _ in range(n):
        a,b,c=MI()
        vv.append(a*mb-b*ma)
        cc.append(c)
    dp=[[inf]*8005 for _ in range(n+1)]
    for i in range(n):
        v,c=vv[i],cc[i]
        dp[i + 1][4000+v] = min(dp[i + 1][4000+v], c)
        for j in range(8005):
            pre=dp[i][j]
            if pre==inf:continue
            dp[i + 1][j] = min(dp[i + 1][j], pre)
            dp[i + 1][j + v] = min(dp[i + 1][j + v], pre + c)
    ans=dp[-1][4000]
    if ans==inf:print(-1)
    else:print(ans)

main()


Measured memory_bytes: 6256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>

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

using namespace std;

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

int main() {
	int n, i, j;
	cin >> n;
	int a[n];
	double ansReciprocal = 0, ans = 0;
	roop(i, n) {
		cin >> a[i];
		ansReciprocal += (1 / (double)a[i]);
	}
	ans = 1 / ansReciprocal;
	cout << ans << endl;
	return 0;
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 3e5 + 1e3;

int n, a[N];

ll pre[N], suf[N];

priority_queue<int> Max;
priority_queue<int, vector<int>, greater<int>> Min;

int main () {

	File();

	n = read();
	For (i, 1, n * 3) a[i] = read();

	For (i, 1, n)
		Min.push(a[i]), pre[i] = pre[i - 1] + a[i];

	For (i, n + 1, 2 * n) {
		pre[i] = pre[i - 1];
		if (a[i] > Min.top())
			pre[i] += a[i] - Min.top(), Min.pop(), Min.push(a[i]);
	}

	Fordown (i, n * 3, n * 2 + 1)
		Max.push(a[i]), suf[i] = suf[i + 1] + a[i];

	Fordown (i, n * 2, n + 1) {
		suf[i] = suf[i + 1];
		if (a[i] < Max.top()) 
			suf[i] += a[i] - Max.top(), Max.pop(), Max.push(a[i]);
	}

	ll ans = pre[n] - suf[n + 1];
	For (i, n, 2 * n)
		chkmax(ans, pre[i] - suf[i + 1]);
	printf ("%lld\n", ans);

    return 0;

}

Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
int main(){
  long int n,m;
  cin>>n>>m;
  if(n*2>=m)
    cout<<m/2<<endl;
  else
    cout<<n+((m-n*2)/4)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
#include <complex>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<ii>
#define point complex<double>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 1e5 + 5;
const double pi = acos(-1);
using namespace std;

ll fact[N], inv[N];
ll fp(ll b, ll p)
{
	if (p == 0)
		return 1;
	ll ans = fp(b, p / 2);
	ans = (ans * ans) % MOD;

	if (p % 2 != 0)
		ans = (ans *(b % MOD)) % MOD;
	return ans;
}

void calc(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % MOD;
		inv[i] = fp(fact[i], MOD - 2);
	}
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % MOD * inv[n - r]) % MOD;
}

int main()
{
	assem99;
	calc(N - 1);
	ll n, k; cin >> n >> k;
	rep(i, 1, k + 1)
	{
		if (n - k + 1 >= i)
		{
			ll ans = ncr(n - k + 1, i) % MOD;
			ans *= (ncr(k - 1, i - 1) % MOD) ;
			ans %= MOD;
			cout << ans << endl;
		}
		else cout << "0" << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
n = int(input())
a = n%10
if a == 0:
    print("pon")
elif a == 1:
    print("pon")
elif a == 2:
    print("hon")
elif a == 3:
    print("bon")
elif a == 4:
    print("hon")
elif a == 5:
    print("hon")
elif a == 6:
    print("pon")
elif a == 7:
    print("hon")
elif a == 8:
    print("pon")
elif a == 9:
    print("hon")

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll k,x;
	cin>>k>>x;

	k=k*500;
	if(k>=x){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int X,N,p[104];
	set<int> cnt;
	scan(X>>N);
	rep(i,N){
		scan(p[i]);
		cnt.insert(p[i]);
	}
	rep(i,101){
		if(cnt.count(X-i)==0){
			prin(X-i); return 0;
		}
		if(cnt.count(X+i)==0){
			prin(X+i); return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
n,m=map(int,input().split())
a=0
b=0
c=0
ans=0
for i in range(n+1):
  AA=10000*i
  for j in range(n-i+1):
    BB=5000*j
    CC=1000*(n-i-j)
    if(AA+BB+CC==m and ans==0):
      print(i,j,n-i-j)
      ans+=1

if(ans==0):
  print(-1,-1,-1)

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
vector<int> vertexs[200000];
long long timing[200000] = {};
int bad = 0;
long long solve(int now, int back) {
	if (vertexs[now].size() == 1&&back != -1) return timing[now];
	vector<long long> gogo;
	REP(i, vertexs[now].size()) {
		if (vertexs[now][i] != back) {
			long long geko = solve(vertexs[now][i], now);
			gogo.push_back(geko);
			if (geko < 0) bad = 1;
		}
	}
	long long required_loop = 0;
	REP(i, gogo.size()) {
		required_loop += gogo[i];
	}
	required_loop -= timing[now];
	if (required_loop < 0) bad = 1;
	long long backe = 0;
	sort(gogo.begin(), gogo.end());
	REP(i, gogo.size()-1) {
		backe += gogo[i];
	}
	if (required_loop > backe) bad = 1;
	if (bad == 1) {
		return 11000000000000000LL;
	}
	else {
		return timing[now] - required_loop;
	}
}
int main() {
#define int long long
	int n;
	cin >> n;
	REP(i, n) {
		cin >> timing[i];
	}
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	REP(i, n) {
		if (vertexs[i].size() == 1) {
			if (solve(i, -1) == timing[i]&&bad == 0) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}
			return 0;
		}
	}
}

Measured memory_bytes: 20480
# 解説

def main():
    N = int(input())
    s = input()

    dp = [[0] * (N + 1) for _ in range(N + 1)]
    ans = 0
    for i in reversed(range(N)):
        for j in reversed(range(i, N)):
            if s[i] == s[j]:
                dp[i][j] = min(dp[i + 1][j + 1] + 1, j - i)
                ans = max(ans, dp[i][j])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 229768
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
lli dp[MAX][2];
int n;
vector<int>adj[MAX];
lli solve(int v, int c, int p){
  if(dp[v][c]!=-1)
    return dp[v][c];
  lli t=1;
  for(auto it=adj[v].begin();it!=adj[v].end();it++){
      if(*it==p) continue;
    if(c==0)
    t=t*(solve(*it,0,v)+solve(*it,1,v))%MOD;
    else t=t*(solve(*it,0,v))%MOD;
  }
  return dp[v][c]=t;
}
int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n;
  for(int i=1;i<n;i++){
    int u,v;
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  lli ans=(solve(1,0,-1)+solve(1,1,-1))%MOD;
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 17404
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

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

int main() {
    long long A,B,C;cin >> A >> B >> C;
    long long ans = min(A+B,C);
    ans += B;
    if(A+B < C) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
n,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7



def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 #出力の制限
N = 10**5+5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
L=[]
for i in range(n):
    L.append(cmb(n-1-i,K-1,mod))
#print(L)
Small=0
for i in range(n):
    Small+=A[i]*L[i]
    Small%mod
    
Big=0
RA=A[::-1]
for i in range(n):
    Big+=RA[i]*L[i]
    Big%=mod
print((Big-Small)%mod)


Measured memory_bytes: 77480
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

const K: usize = 100_000;

fn dfs(i: usize, edge: &Vec<Vec<usize>>, used: &mut Vec<bool>, count: &mut [i64; 2]) -> i64 {
  used[i] = true;
  count[i / K] += 1;
  for &j in &edge[i] {
    if ! used[j] {
      dfs(j, edge, used, count);
    }
  }
  count[0] * count[1]
}

fn main() {
  input! {
    n: usize,
    p: [(usize1, usize1); n],
  }
  let mut edge = vec![vec![]; 2 * K];
  for &(x, y) in &p {
    let y = y + K;
    edge[x].push(y);
    edge[y].push(x);
  }
  let mut used = vec![false; 2 * K];
  let mut ans = 0;
  for i in 0 .. 2 * K {
    ans += dfs(i, &edge, &mut used, &mut [0, 0]);
  }

  println!("{}", ans - n as i64);
}


Measured memory_bytes: 19580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int k;
  cin >> k;
  queue<ll> q;
  for (int i = 1; i <= 9; i++) q.push(i);
  ll ans;
  for (int i = 0; i < k; i++) {
    ans = q.front();
    q.pop();
    int next1 = ans % 10;
    ll next = ans * 10 + next1;
    if (next1 != 0) q.push(next - 1);
    q.push(next);
    if (next1 != 9) q.push(next + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n&1)cout<<"No";
    else{
          bool ok =true;

        for(int i=0;i<n/2;i++){
            if(s[i]!=s[n/2+i])ok=false;
        }
        if(!ok)cout<<"No";
        else cout<<"Yes";

    }


    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max = Math.max(a, Math.max(b, c));
		int min = Math.min(a, Math.min(b, c));
		int mid = a + b + c - max - min;
		int ans = 0;
		int tmp = (max - min) / 2;
		min += 2 * tmp;
		ans += tmp;
		tmp = (max - mid) / 2;
		mid += 2 * tmp;
		ans += tmp;
		if(max != min && max != mid) {
			ans++;
		} else if(!(max == min && max == mid)) {
			ans += 2;
		}
		System.out.println(ans);
	}

}


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

int main() {
    //
    int xNum, yNum, xMain, yMain;

    cin >> xNum >> yNum >> xMain >> yMain;

    vector<int> x(xNum);
    vector<int> y(yNum);

    for (int i = 0; i < xNum; i++) cin >> x.at(i);
    for (int i = 0; i < yNum; i++) cin >> y.at(i);
    sort(x.rbegin(), x.rend());
    sort(y.begin(), y.end());

    bool chk = false;
    for (int i = xMain + 1; i <= yMain; i++) {
        if (x.at(0) < i && i <=  y.at(0)) {
            chk = true;
            break;
        }
    }

    if (chk)
        cout << "No War";
    else
        cout << "War";

    //
}


Measured memory_bytes: 3588
import Control.Monad

main=do
    (h:w:_)<-map read.words<$>getLine::IO[Int]
    ss <- replicateM h $ words<$>getLine::IO[[String]]
    putStrLn $ (\(a,b)->b:show a) $ finds (1,'A') ss
--
finds (h,w) ([]:ss) = finds (h+1,'A') ss 
finds (h,w) (("snuke":ss):_) = (h,w)
finds (h,w) ((_:ss):sr) = finds (h,succ w) (ss:sr)

Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const long INF = 1000000007;
    private static long[] hp;
    private static long B, C;
    public static void Main()
    {
        long[] inp = LongLine();
        long N = inp[0], A = inp[1];
        B = inp[2];
        C = A - B;
        hp = new long[N];
        for (int i = 0; i < N; i++) hp[i] = LongRead();
        long min = 0, max = (long)Math.Pow(10, 9);
        while (min + 1 != max)
        {
            long x = (min + max) / 2;
            if (judge(x)) max = x;
            else min = x;
            //Console.WriteLine(min + " " + max);
        }
        Console.WriteLine(max);
    }

    private static bool judge(long x)
    {
        bool ret = false;
        long count = 0;
        foreach (int h in hp)
        {
            long box = h - x * B;
            if (box < 0) continue;
            else count += (box % C == 0 ? box / C : box / C + 1);
        }
        return (count <= x);
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 16208
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int n;
int C[50][26],A[26] = {0};
string S;

int main(){
	for(int i=0;i<50;i++){
		for(int j=0;j<26;j++){
			C[i][j] = 0;
		}
	}
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> S;
		for(int j=0;j<S.size();j++){
			C[i][S[j]-'a']++;
		}
	}
	for(int i=0;i<26;i++){
		int al = 1e9;
		for(int j=0;j<n;j++){
			al = min(al,C[j][i]);
		}
		A[i] = al;
	}
	char c = 'a';
	for(int i=0;i<26;i++){
		for(int j=0;j<A[i];j++){
			cout << c;
		}
		c++;
	}
	cout << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n ;
    cin >> n ;
    vl v;
    forn(i , 1 , n ) {
       ll x;
       cin >> x;
       v.pb(x) ;
    }
    vl one , two ,four ;
    for(auto &x : v){
        if(x % 2 == 1){
            one.pb(x);
        }
        if(x% 2 == 0){
            if(x % 4 != 0){
                two.pb(x);
            }
            else {
                four.pb(x);
            }
        }
    }
    ll b1 = ll(one.sz) ;
    ll b2 = ll(two.sz) ;
    ll b4 = ll(four.sz);
    if(b2 == 0){
        if(b1 <= b4+1){
            cout << "Yes\n";
            ro;
        }
        else {
            cout << "No\n" ;
            ro ;
        }
    }
    else if(b2 > 0 ){
        if(b1 <= b4){
            cout << "Yes\n" ;
            ro ;
        }
        else {
            cout << "No\n" ;
            ro ;
        }
    }
    ro ;

}


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

using namespace std;

struct Prob { bool ok;int ngcnt; int time; };
struct Team { int cnt; int time; };

struct Pred{
    bool operator()(const Team& a, const Team& b){
        if(a.cnt==b.cnt) return a.time < b.time;
        else return a.cnt > b.cnt;
    }
};


bool isEq(const Team& a, const Team& b){
    return a.cnt == b.cnt && a.time == b.time;
}

int main()
{
    int M, T, P, R;
    while(cin >> M >> T >> P >> R, M){
        vector<vector<Prob>> ps(T, vector<Prob>(P, {false, 0, 0}));
        
        for(int i=0;i<R;++i){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            t-=1;p-=1;
            auto& e = ps[t][p];
            if(!j){
                e.ok=true;
                e.time=m;
            }else{
                ++e.ngcnt;
            }
        }
        
        vector<int> tsInt(T, 0);
        vector<Team> ts(T, {0, 0});
        for(int i=0;i<T;++i){
            tsInt[i] = i;
            auto& t = ts[i];
            for(auto& p: ps[i]) if(p.ok){
                ++t.cnt;
                t.time += p.time + p.ngcnt*20;
            }
        }
        
        Pred pred;
        sort(tsInt.begin(), tsInt.end(), [&](int i, int j){ return pred(ts[i], ts[j]); });
        
        vector<vector<int>> merge{};
        int size = 0;
        for(auto& e: tsInt){
            if(merge.size() == 0){
                vector<int> vs(1); vs[0]=e; merge.push_back(vs);
                ++size;
            }
            else{
                if(isEq(ts[merge[size-1][0]], ts[e]))
                    merge[size-1].push_back(e);
                else{
                    vector<int> vs(1); vs[0]=e; merge.push_back(vs);
                    ++size;
                }
            }
        }
        
        for(int i=0;i<size;++i){
            sort(merge[i].begin(), merge[i].end(), greater<int>());
            int s = merge[i].size();
            for(int j=0;j<s;++j){
                cout << merge[i][j]+1;
                if(j==s-1) break;
                cout << "=";
            }
            if(i==size-1) break;
            cout << ",";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1232
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    int d,m;
    int date = 2;
    auto ds = ["Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday","Monday"];
    auto a = [31,29,31,30,31,30,31,31,30,31,30,31];
    while(true){
	date = 2;
	auto s = split(readln());
	d = to!int(s[0]);
	m = to!int(s[1]);
	if(d == 0 && m == 0) break;
	for(int i=0;i<d-1;i++){
	    date += a[i];
	}
	    date += m-1;
	date = date % 7;
	writeln(ds[date]);
    }
}

Measured memory_bytes: 2436
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

a, b, c, k = [int(i) for i in input().split()]

tmp = 0
res = 0

if k <= a:
    res = k
elif k <= a + b:
    res = a
else:
    res = 2 * a + b - k

print(res)


Measured memory_bytes: 31144
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
ll x;
cin >> x;

ll a = 100;
ll ans = 0;
while(a < x){
    a += (a/100);
    ans++;
}

 cout << ans << endl;
return 0;

}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
int main(){
	int n;
	cin>>n;
	DIJ dij(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		dij.add_edge(a,b,1);
		dij.add_edge(b,a,1);
	}
	dij.dij(0);
	vi d=dij.d;
	dij.dij(n-1);
	vi D=dij.d;
	int co=0;
	rep(i,n)if(d[i]<=D[i])co++;
	if(co*2<=n)cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
}








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

int main() {
    int N;

    cin >> N;
    int *A = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N - 1; i++) {
        cout << A[i] << " ";
    }
    cout << A[N - 1];
    cout << "\n";
    int key, j;
    for (int i = 1; i < N; i++) {
        key = A[i];
        j = i - 1;
        while ((j >= 0) && (A[j] > key)) {
            A[j + 1] = A[j];
            j--;
            A[j + 1] = key;
        }

        for (int k = 0; k < N - 1; k++) {
            cout << A[k] << " ";
        }
        cout << A[N - 1];
        cout << "\n";
    }

    delete [] A;
}

Measured memory_bytes: 3092
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc070/tasks/abc070_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int n = sc.nextInt();
		sc.close();
		
		boolean ans = n/100 == n%10;
		System.out.println(ans ? "Yes" : "No");

	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <map>
#include <cstring>

#define MAX_Q (400000)

using namespace std;

typedef long long lint;


int bit[MAX_Q + 1];
lint val[MAX_Q + 1];

void add(int pos, int val)
{
    while (pos <= MAX_Q){
        bit[pos] += val;
        pos += pos & -pos;
    }
}

int sum(int pos)
{
    int ret = 0;
     
    while (pos){
        ret += bit[pos];
        pos &= (pos - 1);
    }
     
    return (ret);
}

int valid(int x)
{
    int l = 0, r = MAX_Q;
     
    while (l != r){
        int center = (l + r) / 2;
         
        if (sum(center) < x){
            l = center + 1;
        }
        else {
            r = center;
        }
    }
     
    return (r);
}

int main()
{
    int q, lim;
     
    while (scanf("%d %d", &q, &lim), lim){
        memset(bit, 0, sizeof(bit));
        memset(val, 0, sizeof(val));
         
        map<lint, int> pos;
         
        int p = 1;
         
        while (q--){
            int qtype, x;
            scanf("%d %lld", &qtype, &x);
             
            if (qtype == 0){
                add(p, 1);
                pos[x] = p;
                val[p++] = x;
                if (sum(MAX_Q) > lim){
                    add(valid(1), -1);
                }
            }
            if (qtype == 1){
                add(valid(x), -1);
            }
            if (qtype == 2){
                printf("%d\n", val[valid(x)]);
            }
            if (qtype == 3){
                add(pos[x], -1);
            }
        }
         
        printf("end\n");
    }
     
    return (0);
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,m;
    string s; cin >> n >> m >> s;
    reverse(all(s));
    vl dp(n+1,L_INF);
    dp[0] = 0;
    rep(i,n){
        ll sub = (n+1)-i;
        bool check = false;
        for(int j=min(m,sub);j>0;j--){
            if(i+j <= n){
                if(s[i+j] != '1'){
                    chmin(dp[i+j],dp[i]+1);
                    check = true;
                    break;
                }
            }
        }
        if(check == false){
            out(-1);
            return 0;
        }
    }
    if(dp[n] == L_INF){
        out(-1);
        return 0;
    }
    vl res;
    //dpの後ろから歩数をとる
    ll pre = dp[n];
    ll dist = n;
    for(int i=n-1;i>=0;i--){
        if(pre - dp[i] == 1){
            pre = dp[i];
            res.push_back(dist - i);
            dist = i;
        }
    }
    rep(i,res.size())out(res[i]);
}


Measured memory_bytes: 2248
K=input()
A,B=input().split()
K=int(K)
A=int(A)
B=int(B)

i=0
while True:
    if A<=i*K:
        if B>=i*K:
            print('OK')
            break
        else:
            print('NG')
            break
    else:
        i+=1

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (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);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

class union_find{
public:
    vector<int> parent;
    union_find(int n) : parent(vector<int>(n, -1)) {} //Parent is -(size of set)
    int root(int a){ return (parent[a] < 0 ? a : parent[a] = root(parent[a])); }
    int size(int a){ return -parent[root(a)]; }
    bool same(int &a, int &b){ a=root(a);b=root(b); return (a==b); }
    bool connect(int a, int b){
        if(same(a,b)) return false;
        if(size(a)<size(b)) a^=b^=a^=b;
        parent[a] += parent[b]; parent[b]=a;
        return true;
    }
};

//v -> number of vertex,
//g -> cost_map (cost, (start, target))
ll kruskal(int v, vector<pair<ll, pii>> &g){
    union_find uf(v);
    SORT(g);
    ll ans = 0;
    for(ll i = 0; i < g.size(); i++){
        if(!uf.same(g[i].second.first, g[i].second.second)){
            ans += g[i].fi;
            uf.connect(g[i].second.first, g[i].second.second);
        }
    }
    return ans;
}

int main(void)
{
    int n;
    cin >> n;
    vector<pii> x(n), y(n);
    REP(i, n){
        int xi,yi;
        cin >> xi >> yi;
        x[i] = pii(xi, i);
        y[i] = pii(yi, i);
    }

    SORT(x);
    SORT(y);

    vector<pair<ll, pii>> g;
    REP(i, n-1){
        g.pb(pair<ll, pii>(x[i+1].fi - x[i].fi, pii(x[i].se, x[i+1].se))); 
        g.pb(pair<ll, pii>(y[i+1].fi - y[i].fi, pii(y[i].se, y[i+1].se))); 
    }
    pr(kruskal(n, g));
}

Measured memory_bytes: 7920
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    char a;
    cin>>a;
    ll a1 = long(a);
    if(a1>=97){
        cout<<"a";
    }
    else{
        cout<<"A";
    }


    return 0;
}

Measured memory_bytes: 3640
H, W = map(int,input().split())

A = []
for i in range(H):
	A.append(list(input()))

B = []
for a in A:
	if '#' in a:
		B.append(a)

C = []
for b in zip(*B):
	if '#' in b:
		C.append(b)

for c in zip(*C):
	print(''.join(c))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

int main(){

	string S;
	cin>>S;
	
	cout<<string(S.size(),'x')<<endl;
	
	return 0;
}

Measured memory_bytes: 256
let isqq n =
    let qqList =
        seq {for a in 1..9 do
             for b in 1..9 do
             yield a * b}
    qqList
    |> Seq.contains n
            

let n = stdin.ReadLine() |> int
let ans = if isqq n then "Yes" else "No"

printfn "%s" ans

Measured memory_bytes: 14044