akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "\n[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "\n[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]\n";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    int n;
    scanf("%d", &n);
    
    int want = 1;
    for (int i = 0; i < n; ++i) {
        int val;
        scanf("%d", &val);

        if (val == want) want += 1;
    }

    want = want == 1 ? n + 2: want;

    cout << n - want + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047


void solve(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	int x3, y3, x4, y4;
    int dx = x2-x1;
    int dy = y2-y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x3 - dx;
    y4 = y3 - dy;
    
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	solve();
	
	return 0;
}


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

//Coding below.
//未完
int main (){
    int n;
    int ans = 0;
    cin >> n;
    for(int i=0;i<=n;i++){
        if(to_string(i).length() % 2 == 1 && i != 0){
            ans++;
        }
    }
    cout << ans;
}

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

int main() {
  int n;cin>>n;
  int ans=0;
  for(int i=1;i<=n;i+=2){
    int cnt=0;
    for(int j=1;j<=n;j+=2){
      if(i%j==0)cnt++;
    }
    if(cnt==8)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3568
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val a = LongArray(n) { scanner.nextLong() }

    val s = a.map { 1.0 / it }.sum()
    val ret = 1.0 / s
    println(ret)
}

Measured memory_bytes: 31524
#include<iostream>
#include <vector>
using namespace std;
int counter =0;
bool visited[100001] ={false};
long int height[10000001] = {0};



int main(){
    int N; int M;
    cin >> N; cin >> M;
    vector <int> temp;
    vector <int> adj[N+1];
    for(int ii  = 0; ii < N ;ii++){
        int temp;
        cin>> temp;
        height[ii+1] = temp;
    }
    for(int ii  = 0; ii < M ;ii++){
        int n1, n2;
        cin >> n1 >> n2;
        adj[n1].push_back(n2);
        adj[n2].push_back(n1);
    }
    for(int ii  = 1; ii < N+1 ;ii++){
        if(adj[ii].size()==0)
        counter++;
        for(int jj  = 0; jj < adj[ii].size() ; jj++){
        if(height[ii] > height[(adj[ii][jj])]){
            ;
            if(jj == adj[ii].size()-1)
            counter++;
        }
        else{
            break;
            cout << ii <<  " " << adj[ii][jj] << endl;
        }
        }
    }
    cout << counter;
    
}

Measured memory_bytes: 9088
#include <stdio.h>

int main(){
    int n,a,b,i;
    int score[3];
  	for(i=0;i<3;i++) score[i] = 0;
    scanf("%d",&n);
    int p;
    scanf("%d %d",&a,&b);
    for(i=0;i<n;i++){
        scanf("%d",&p);
        if(p<=a){
            score[0]++;
        }else if(p<=b){
            score[1]++;
        }else{
            score[2]++;
        }
    }
    int min;
    if(score[0]<=score[1]) min = score[0];
    else min = score[1];
    if(score[2]<min) min = score[2];
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(b<10) a*=10;
  else if(b<100) a*=100;
  else a*=1000;
  for(int i=1;i<=316;i++){
    if(i*i==a+b){
      cout<<"Yes"<<'\n';
      return 0;
    }
  }
  cout<<"No"<<'\n';
  return 0;
}

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

const int N = 1010;
const int moder = 1e9 + 7;

int fac[N], inv[N], dp[N][N], n, a, b, c, d;

int power_mod(int a, int index){
	int ret = 1;
	while (index){
		if (index & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
		index >>= 1;
	}
	return ret;
}

int main(){
	fac[0] = inv[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
		inv[i] = power_mod(fac[i], moder - 2);
	}
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	dp[a][0] = 1;
	for (int i = a; i <= b; ++ i){
		for (int j = 0; j <= n; ++ j){
			dp[i + 1][j] = dp[i][j];
		}
		for (int j = c; j <= d; ++ j){
			for (int k = 0; k <= n; ++ k){
				int x = i * j + k;
				if (x > n){
					break;
				}
				dp[i + 1][x] = (dp[i + 1][x] + 1ll * fac[x] * inv[k] % moder * power_mod(inv[i], j) % moder * inv[j] % moder * dp[i][k]) % moder;
			}
		}
	}
	printf("%d\n", dp[b + 1][n]);
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, m; cin >> n >> m;
    vector<int> ans(n, 0);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        ans[a]++; ans[b]++;
    }

    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main()
{
	double r, area, around;

	cin >> r;

	area = r * r * M_PI;
	around = r * 2 * M_PI;

	cout << fixed << area << ' ' << fixed << around << '\n';

	return 0;
}


Measured memory_bytes: 3288
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
	char a[10];
	int i,j;
	scanf("%s",&a);
	if(a[2]==a[3]&&a[4]==a[5])
	printf("Yes");
	else
	printf("No");
return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	cnt := 0
	for i := 1; i <= n; i += 2 {
		if numDivSlow(i) == 8 {
			cnt++
		}

	}

	fmt.Println(cnt)

}

// 約数の数をカウントする(愚直)
func numDivSlow(a int) int {
	cnt := 1
	for i := 1; i <= a/2; i++ {
		if a%i == 0 {
			cnt++
		}
	}
	return cnt
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n , m; cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

int cal(int s){
  int c = 2*s;
  int root = 1 + (4 * c);
  //dg(root);
  int sq = sqrt(root);
  return ( -1 + sq)/2;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  
  int N;
  cin >> N;
  int ans = 0;
  for(int i=2;i<=N;i++){
    if(i * i > N) i = N;
    int cnt = 0;
    while(N % i==0){
      cnt++;
      N /= i;
    }
    ans += cal(cnt);
  }
  cout << ans << '\n';

}

Measured memory_bytes: 3196
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
su = 0
n1 = len(a)
for i in a:
    su += b[i-1]

for i in range(n1-1):
    if a[i] == a[i+1] -1:
        su += c[a[i]-1]

print(su)

Measured memory_bytes: 9072
#include <iostream>
#include <algorithm>
#include <vector>
#include <memory.h>
using namespace std;

const int MAXN = 100005;
const long long INF = (1LL << 60) - 1;
vector<pair<int ,int> > seg[MAXN];
long long zkw[MAXN * 5];
int N ,M ,leaf;

inline long long query(int l ,int r) {
    long long ans = INF;
    for(l += leaf ,r += leaf + 1;l ^ r ^ 1;l >>= 1, r >>= 1) {
        if(l % 2 == 0) ans = min(ans ,zkw[l ^ 1]);
        if(r % 2 == 1) ans = min(ans ,zkw[r ^ 1]);
    }
    return ans;
}

void update(int pos ,long long value) {
    pos += leaf + 1;
    zkw[pos] = value;
    for(pos >>= 1;pos != 1;pos >>= 1) zkw[pos] = min(zkw[pos * 2] ,zkw[pos * 2 + 1]);
}

int main() {
    int i ,l ,r ,c;
    long long tmp;
    while(cin >> N >> M) {
        for(i = 0;i < MAXN;i++) seg[i] = vector<pair<int ,int> >();
        for(i = 0;i < MAXN * 5;i++) zkw[i] = INF;
        for(leaf = 1;leaf < N + 2;leaf <<= 1) ;
        update(0 ,0);
        while(M--) {
            cin >> l >> r >> c;
            seg[r].push_back(pair<int ,int>(l ,c));
        }
        for(i = 1;i <= N;i++) for(auto item : seg[i]) {
            l = item.first - 1 ,r = i ,c = item.second;
            tmp = query(l ,r);
            if(tmp + c < query(r - 1 ,r)) update(r - 1 ,tmp + c);
        }
        tmp = query(N - 1 ,N);
        cout << (tmp == INF ? -1 : tmp) << endl;
    }
}


Measured memory_bytes: 9600
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <chrono>

using namespace std;

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

const ll INF = 1e15;


int main() {
	string s;
	cin >> s;
	vector<ll> v(3);
	for (int i = 0;i < s.size();i++) {
		v[s[i] - 'a']++;
	}
	sort(v.begin(), v.end());
	if (v.back() - v.front() <= 1)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> H(n + 1);
    rrep(i, n) cin >> H[i];
    vector<P> B(m + 1);
    rep(i, m) {
        cin >> B[i].first >> B[i].second;
    }
    vector<bool> ans(n + 1, true);
    rep(i, m) {
       if(H[B[i].first] < H[B[i].second]) {
           ans[B[i].first] = false;
       } else if(H[B[i].first] == H[B[i].second]){
           ans[B[i].first] = false;
           ans[B[i].second] = false;
       } else {
           ans[B[i].second] = false;
       }
    }
    int cnt = 0;
    rrep(i, n) {
        if(ans[i]) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> d(N + 1, 0);
	for (int i = 0; i < M; ++i) {
		int l, r;
		cin >> l >> r;
		d[l - 1] += 1;
		d[r] -= 1;
	}

	for (int i = 1; i <= N; ++i) {
		d[i] += d[i - 1];
	}

	int res = 0;
	for (int i = 0; i < N; ++i) {
		if (d[i] == M) { ++res; }
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1024
using System;

 class Program
 {
     static void Main(string[] args)
     {
         double data1, data2, data3,data4,data5,temp;
         double[] result = new double[3];
         String nyuryoku;



         while (true)
         {
             nyuryoku = Console.ReadLine();
             string[] data = nyuryoku.Split(' ');
             data1 = Double.Parse(data[0]);
             data2 = Double.Parse(data[1]);
             if ( data1 == 0 && data2 == 0)
                 return;
             if (data1 < data2)
                 Console.WriteLine("{0} {1}", data1, data2);
             else
                 Console.WriteLine("{0} {1}", data2, data1);
         }
      }
 }



Measured memory_bytes: 13760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main() {
  ll N,M; cin>>N>>M;
  vvi G(N);
  REP(i,M) {
    ll a,b; cin>>a>>b; a-=1; b-=1;
    G[a].PB(b); G[b].PB(a);
  }
  vi v(N,-1);
  v[0]=0;
  queue<ll> q; q.push(0);
  bool flag=false;
  while(q.size()) {
    ll from=q.front(); q.pop();
    for(ll to:G[from]) {
      if(v[to]==-1){
        v[to]=1-v[from];
        q.push(to);
      }else{
        if(v[to]==v[from]) {
          flag=true;
        }
      }
    }
  }
  if(flag==true){
    cout<<N*(N-1)/2-M<<endl;
  } else {
    ll cnt=0;
    REP(i,N) if(v[i]) cnt++;
    cout<<cnt*(N-cnt)-M<<endl;
  }

}


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

int main(void) {
	int h,w,i,j;
	char str[6];
	
	scanf("%d %d",&h,&w);
	
	for (i = 0;i < h;i++) {
		for (j = 0;j < w;j++) {
			scanf("%s",str);
			if (!strcmp(str,"snuke")) {
				printf("%c%d\n",'A'+j,i+1);
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
"""AtCoder Beginner Contest 086: C - Traveling
https://atcoder.jp/contests/abc086/tasks/arc089_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    N = int(input())
    current = {'t': 0, 'x': 0, 'y': 0}

    answer = 'Yes'
    for _ in range(N):
        t, x, y = map(int, input().split())
        length = abs(x-current['x']) + abs(y-current['y'])
        t_d = t - current['t']
        # t=1: odd, t=2: even, t=3: odd, t=4: even, ...
        if length <= t_d and length % 2 == t_d % 2:
            current = {'t': t, 'x': x, 'y': y}
        else:
            answer = 'No'
            break

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
   int n; cin>>n;
   string ans="No";
   for(int i=1;i<10;i++){
       for(int j=1;j<10;j++){
           if(i*j==n){
                ans="Yes";
                break;
           }
       }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=2e4+10;
const int Inf=0x3f3f3f3f;
 
int head[maxm],tot,X[maxm],Y[maxm],N,K,Deep[maxm];
bool Visit[maxm];
 
struct edge{
	int To;
	int Next;
	# define To(i) Edge[i].To
	# define Next(i) Edge[i].Next
}Edge[maxm<<1];

inline void Add_Edge(int From,int To){Edge[++tot]=(edge){To,head[From]},head[From]=tot;}
inline void Insert_Edge(int x,int y){Add_Edge(x,y),Add_Edge(y,x);return;}

void Dfs(int now,int Father){
	Deep[now]=Deep[Father]+1;
	if(Deep[now]>(K>>1)) tot++;
	for(int i=head[now];i;i=Next(i)){
		if(To(i)==Father || Visit[To(i)]) continue;
		Dfs(To(i),now); 
	}
	return; 
} 

int Subtask1(){
	register int i,Ans=Inf;
	for(i=1;i<N;i++){
		tot=0;
		Visit[X[i]]=Visit[Y[i]]=1;
		Dfs(X[i],0);Dfs(Y[i],0); 
		Ans=min(Ans,tot);
		Visit[X[i]]=Visit[Y[i]]=0; 
	}
	return Ans; 
} 

int Subtask2(){
	register int i,Ans=Inf; 
	for(i=1;i<=N;i++){
		tot=0;
		Dfs(i,0);
		Ans=min(Ans,tot); 
	}
	return Ans; 
} 

int main(){
	register int i,j; 
	scanf("%d%d",&N,&K);
	for(i=1;i<N;i++){
		scanf("%d%d",&X[i],&Y[i]);
		Insert_Edge(X[i],Y[i]);
	}
	Deep[0]=-1; 
	if(K&1){
		cout<<Subtask1(); 
	}else{
		cout<<Subtask2();
	}
	return 0; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<int> to[1000010], from[1000010];
int dp[1000010];
int taio[1000010];

void solve() {
    int N; cin>>N;
    vector<int> a(N),place(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
        place[a[i]-1] = i;
    }

    int longest=0;
    int left=0;
    for (int right = 1; right < N; ++right) {
        if(place[right]<place[right-1]){
            longest = max(longest,right-left);
            left=right;
        }
    }
    longest=max(longest,N-left);
    cout<<N-longest<<endl;
}


#define SINGLE
int main() {
#ifdef SINGLE
    solve();
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 51788
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}
ll A, B, C, D;
ll solve(ll num){ //num以下
  ll x = num/C;
  ll y = num/D;
  ll L = (C*D)/gcd(C, D);
  ll z = num/L;
  x = x + y - z;
  return num - x;
}
int main(int argc, char const *argv[]) {
  std::cin >> A >> B >> C >> D;
  std::cout << solve(B) - solve(A-1) << '\n';
  return 0;
}


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

int cmp(const void *n1, const void *n2)
{
    return *(double *)n2 - *(double *)n1;
}

int main(void)
{
    int flag = 1;
    double inputN, inputM, borderLine, *inputA;
    double voteCount = 0;
    scanf("%lf%lf", &inputN, &inputM);
    inputA = (double *)malloc(sizeof(double) * inputN);
    for (int count = 0; count < inputN; count++)
    {
        scanf("%lf", &inputA[count]);
        voteCount += inputA[count];
    }
    borderLine = voteCount / (4 * inputM);
    qsort(inputA, inputN, sizeof(double), cmp);
    for (int count = 0; count < inputM; count++)
    {
        if (inputA[count] < borderLine)
        {
            flag = 0;
        }
    }
    if (flag)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    free(inputA);

    return 0;
}

Measured memory_bytes: 256
def main(str)
  x = str.to_i
  money = 100
  n = 0
  loop do
    return n if x <= money
    n += 1
    money += money / 100
    money = money.to_i
  end
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(3, main("103"))
    assert_equal(3760, main("1000000000000000000"))
    assert_equal(3760, main("999999999999999999"))
    assert_equal(1, main("101"))
    assert_equal(2, main("102"))
    assert_equal(1706, main("1333333333"))
  end
end




Measured memory_bytes: 14324
#include<iostream>
using namespace std;
int main() {
	string S;
	int N = 0, z = 0, b = 0;
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] + N > 90) {
			S[i] = S[i] + N - 26;
		}
		else {
			S[i] = S[i] + N;
		}
	}
	cout << S << endl;

}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5;
int h[N];

void solve()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    sort(h, h + n);
    int moves = 0;
    for (int i = 0; i < n - k; i++)
        moves += h[i];
    cout << moves << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int samecount(string S){
    int A = 0;
    for(int i = 0;i < S.size();i++){
        int QA = 1;
        for(int j = i ;j < S.size() - 1;j++){
           if(S.at(j) == S.at(j + 1)){
               QA++ ;
           }
           if(S.at(j) != S.at(j + 1)){
               break;
           }
           
        }
        A = max(QA,A);
    }
    return A;
}

int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    int N;
    cin >>N;
    int ans = 0;
    for(int i = 0;i < 10;i++){
        if(pow(2,i) <= N) ans = pow(2,i);
        else break;
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			cout << i << "x" << j << "=" << i * j << "\n";
		}
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  int n,ans=0;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      ans+=a[i]*a[j];
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3576
import sys
import re
import queue
import collections
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N = i_input()
	sum = 0
	for i in range(1,N):
		sum += (N-1) // i

	print(sum)

	return

if __name__ == '__main__':
	main()

Measured memory_bytes: 10708
N = int(input())
S_x = input().split()
S = []
for i in range(N):
    S.append(S_x[i])
ans_p = 0
ans_y = 0
ans_w = 0
ans_g = 0
for char in S:
    if char == "P":
        ans_p = 1
    elif char == "Y":
        ans_y = 1
    elif char == "W":
        ans_w = 1
    elif char == "G":
        ans_g = 1
ans = ans_p + ans_y + ans_g + ans_w

if ans == 3:
    print("Three")
elif ans == 4:
    print("Four")

Measured memory_bytes: 3064
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
long long a[N],l[N],r[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	long long d,ret=0;
	cin>>n>>d;
	for(register int i=1;i<=n;i++)
	{
		cin>>a[i];
		ret+=a[i];
	}
	ret+=(n-1)*d;
	r[1]=a[1];
	for(register int i=2;i<=n;i++)
		r[i]=min(a[i],r[i-1]+d);
	l[n]=a[n];
	for(register int i=n-1;i>=1;i--)
		l[i]=min(a[i],l[i+1]+d);
	for(register int i=2;i<n;i++)
		ret+=min(l[i],r[i]);
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#define N 100000
#define Q 50000

int main(){
  int S[N];
  int T[Q];
  int left,right,midlle;
  int i,j,count=0,n,q;
   
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&S[i]);
   
  scanf("%d",&q);
  for(i=0; i<q; i++) scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    left=0;
    right=n;

    while(left<right){
      midlle=(left+right)/2;
      if(T[i]==S[midlle]){
	count++;
	break;
      }
      if(T[i]<S[midlle]) right=midlle;
      else if(T[i]>S[midlle]) left=midlle+1;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int M = NextInt();
        List<Tuple<int, int>> ab = Enumerable.Range(0, M).Select(v => new Tuple<int, int>(NextInt(), NextInt())).OrderByDescending(v => v.Item2).ToList();
        //後ろから内包を考える
        int st = ab[0].Item1;
        int end = ab[0].Item2;
        int ans = 1;
        for (int i = 1; i < M; i++)
        {
            int nxst = ab[i].Item1;
            int nxend = ab[i].Item2;
            if (nxend <= st)
            {
                //区間が変わる
                ans++;
                end = nxend;
                st = nxst;
            }
            else
            {
                st = Math.Max(st, nxst);
                end = Math.Min(end, nxend);
            }
            //Console.WriteLine(st+" " +end);
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}

public class Input
{
    public const long MOD = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 26308
from collections import deque
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
DE = [0] * N
e = 1
o = 0
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            DE[a] = DE[i] ^ 1
            if DE[a]:
                o += 1
            else:
                e += 1
            X[a].remove(i)
            deque.append(Q, a)

A = [i for i in range(1, N+1) if i % 3 == 1]
B = [i for i in range(1, N+1) if i % 3 == 2]
C = [i for i in range(1, N+1) if i % 3 == 0]

ANS = [-1] * N
if e <= len(C):
    for i in range(N):
        if DE[i] == 0:
            ANS[i] = C.pop()
    for i in range(N):
        if ANS[i] < 0:
            ANS[i] = A.pop() if len(A) else B.pop() if len(B) else C.pop()
elif o <= len(C):
    for i in range(N):
        if DE[i] == 1:
            ANS[i] = C.pop()
    for i in range(N):
        if ANS[i] < 0:
            ANS[i] = A.pop() if len(A) else B.pop() if len(B) else C.pop()
else:
    for i in range(N):
        if DE[i] == 0:
            ANS[i] = A.pop()
            if len(A) == 0: break
    for i in range(N):
        if DE[i] == 1:
            ANS[i] = B.pop()
            if len(B) == 0: break
    for i in range(N):
        if ANS[i] < 0:
            ANS[i] = A.pop() if len(A) else B.pop() if len(B) else C.pop()
    
print(*ANS)

Measured memory_bytes: 107852
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)
#define ll long long
#define P pair<int,int>
#define pb push_back

int n,m,h[200],r[200],d[200][200];

int main(){
	while(cin>>n&&n){
		rep(i,n)cin>>h[i]>>r[i];
		cin>>m;
		rep(i,m)cin>>h[i+n]>>r[i+n];
		n+=m;
		rep(i,n)fill(d[i],d[i]+n,INF);
		rep(i,n)rep(j,n){
			if(i==j)d[i][j]=0;
			if(h[i]>h[j]&&r[i]>r[j])d[i][j]=-1;
		}
		rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int ans=0;
		rep(i,n)rep(j,n)ans=max(ans,-d[i][j]+1);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 50000001
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;
ll n, k, r, s, p;
string t;

ll winScore(char c) {
	if (c == 'r') {
		return p;
	}
	else if (c == 's') {
		return r;
	}
	else if (c == 'p') {
		return s;
	}
}

int main() {
	cin >> n >> k >> r >> s >> p;
	cin >> t;

	repk(i,1, n) { // i=1スタート
		if (i <= k) {
			ans += winScore(t[i - 1]);
		}
		else {
			if (t[i - 1] == t[i - 1 - k]) {
				t[i - 1] = 'x';
			}
			else {
				ans += winScore(t[i - 1]);
			}
		}
	}

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

Measured memory_bytes: 512
n = int(input())
city = []
l = []
for i in range(n):
  s,p = input().split()
  if s not in city: city.append(s)
  l.append((s, int(p), i+1))
  
city = sorted(set(city))
l = sorted(l, key=lambda x: x[1], reverse=True)
for i in city:
  for j in l:
    if i == j[0]: print(j[2])

Measured memory_bytes: 9112
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        int N = S.length();
        for(int i = 1 ; i <= N ; i++){
            System.out.print("x");
        }
        scanner.close();
    }
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
template<class Abel> struct UnionFind {
    const Abel UNITY_SUM = 0;      // to be set
    vector<int> par;
    vector<Abel> diff_weight;

    UnionFind(int n) : par(n, -1), diff_weight(n, UNITY_SUM) {}
    void init(int n) { par.assign(n, -1), diff_weight.assign(n, UNITY_SUM); }

    int root(int x) {
        if (par[x] < 0) return x;
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel calc_weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w = 0) {
        w += calc_weight(x); w -= calc_weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y), w = -w; // merge technique
        par[x] += par[y];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return calc_weight(y) - calc_weight(x);
    }

    int size(int x) {
        return -par[root(x)];
    }
};
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, M; cin >> N >> M;
    UnionFind<int> uf(N);
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (uf.issame(l, r)) {
            int diff = uf.diff(l, r);
            if (diff != d) {
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            uf.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 1152
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()
i = 0
while K > 0:
    # if A % 2 == 0:
        # A = A-1
    if i % 2 == 0:
        A = A // 2
        B += A
        K -= 1
    else:
        B = B//2
        A += B
        K -= 1
    i += 1
print(A, B)



Measured memory_bytes: 5192
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int a[3] = {0};

  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[0] == 5 && a[1] == 5 && a[2] == 7)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}


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

using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> ws(n);
    set<string> origin;
    for(int i = 0; i < n; ++i) {
        cin >> ws[i];
        origin.insert(ws[i]);
    }
    auto rws = ws;
    for(auto& s : rws) reverse(begin(s), end(s));
    sort(begin(ws), end(ws));
    sort(begin(rws), end(rws));

    while(m--) {
        string ss;
        cin >> ss;
        bool left = ss[0] == '*', right = ss.back() == '*';
        string s;
        for(auto c : ss) {
            if(c != '*') s += c;
        }

        ll ans = 0;
        auto get_cnt = [](vector<string> const& ws, string& s) {
            auto l = lower_bound(begin(ws), end(ws), s);
            s.back() += 1;
            auto r = lower_bound(begin(ws), end(ws), s);
            s.back() -= 1;
            return r - l;
        };
        if(left) {
            reverse(begin(s), end(s));
            ans += get_cnt(rws, s);
        } else if(right) {
            ans += get_cnt(ws, s);
        } else {
            ans += origin.count(s);
        }

        for(int i = 0; i < (int)s.size(); ++i) {
            if(s[i] == '?') {
                for(char c = 'a'; c <= 'z'; ++c) {
                    s[i] = c;
                    if(left) {
                        ans += get_cnt(rws, s);
                    } else if(right) {
                        ans += get_cnt(ws, s);
                    } else {
                        ans += origin.count(s);
                    }
                }
                break;
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 13720
#include<algorithm>
#include<iostream>
            #include<deque>
            using namespace std;
            int main(){
              int n,x; cin >> n >> x;
              deque<int> q(n);
              for(int&a:q)cin >> a;
              sort(q.begin(), q.end());
              int pt = 0;
              while(x - *q.begin() >= 0){
                x -= *q.begin();
                q.pop_front();
                pt++;
                if(q.empty())break;
              }
              if(q.empty() && x > 0)pt--;
              cout << pt << endl;
              return 0;
            }

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

int main(void)
{
    int a, b, c, n = 0;
    cin >> a >> b >> c;
    for (int i = a; i < b + 1; ++i)
        if (c%i == 0)
            ++n;
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define MAXN 500
#define pii pair<int,int>
#define MP(a,b) nake_pair(a,b)
#define lowbit(x) ((x)&(-(x)))

using namespace std;
void get(int &v)
{
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return ;
}
int get()
{
    int v;
	char c;
	while((c=getchar())!=EOF&&isdigit(c)==0);
	v=c-'0';
	while((c=getchar())!=EOF&&isdigit(c))
		v=(v<<1)+(v<<3)+c-'0';
	return v;
}
int main()
{
	long long Q,H,S,D,n;
	cin>>Q>>H>>S>>D>>n;
	if(H>(Q<<1))
		H=(Q<<1);
	if(S>(H<<1))
		S=(H<<1);
	if(D>(S<<1))
		D=(S<<1);
	cout<<n/2*D+(n&1)*S;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main() {
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if( x - r  < 0 || y - r < 0 || y + r > H || x + r > W) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
}

Measured memory_bytes: 992
#include <iostream>
using namespace std;
int n,m,a;
int h;
int i,**data;
int main(){
	while(cin>>n>>m>>a){
		if(n==0 && m==0 && a==0){break;}
		data=new int*[m];
		data[0]=new int[m*3];
		for(i=0;i<m;i++){
			data[i]=data[0]+3*i;
			cin>>data[i][0]>>data[i][1]>>data[i][2];
		}
		for(h=1000;h>=1;h--){
			for(i=0;i<m;i++){
				if(data[i][0]==h){
					if(data[i][1]==a){
						a=data[i][2];
					}else if(data[i][2]==a){
						a=data[i][1];
					}
				}
			}
		}
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1968
package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)

func main() {
	var n, h, w, count int
	fmt.Fscanf(in, "%d %d %d\n", &n, &h, &w)
	for i := 0; i < n; i++ {
		var height, weight int
		fmt.Fscanf(in, "%d %d\n", &height, &weight)
		if height >= h && weight >= w {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;


public class Main {
    public static void main (String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Integer> queue = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            queue.add(a);
        }

        int cnt = 0;
        while (cnt < m) {
            queue.add(queue.poll() / 2);
            cnt++;
        }

        long ans = 0;
        for (int i : queue) {
            ans += i;
        }

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 43996
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int a, b, c;
	cin >> a >> b >> c;
	int ans = a * b;
	if (ans > c) ans = c;

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	v := make([]int, n)
	var a int
	for i := 1; i < n; i++ {
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		v[a-1]++
	}
	w := bufio.NewWriter(os.Stdout)
	for _, e := range v {
		fmt.Fprintln(w, e)
	}
	w.Flush()
}

Measured memory_bytes: 5924
# ABC161c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n, k = map(int, input().split())
    print(min(n % k, abs(n % k-k)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
	                                         
    	
	Scanner scanner = new Scanner(System.in);
    	int a = scanner.nextInt();
    	int b = scanner.nextInt();
    	int c = scanner.nextInt();
    	int y =0;
    	for (int z=a;z<=b;z++){
    		if ( c % z == 0){
    			y++;
    		}
    		//System.out.println(y);
    	}
    	System.out.println(y);
	}
}

Measured memory_bytes: 26148
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;

int a[105][105];

int main(){
	int n,sum = 0,cnt = 0;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[1][i];
	for(int i = 1;i <= n;i++) cin >> a[2][i];
	for(int i = 1;i <= n;i++){
		cnt = 0;
		for(int j = 1;j <= i;j++) cnt += a[1][j];
		for(int j = i;j <= n;j++) cnt += a[2][j];
		sum = max(cnt,sum);
	}
	cout << sum << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(i,k,h) for(int i = k; i <= h; ++i)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    ll h;
    cin >> h;
    ll count = 0;
    ll ans= 0;
    for(int i = 0; i < 1e12; i++) {
        h/=2;
        ans += pow(2,i);
        count++;
        if(h < 1) {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
while ( ! feof(STDIN) ) {
  $line[] = trim(fgets(STDIN));
}
$x = (int)$line[0];

$count = 0;
for($i=1;$i<=$x;$i++){
 if(strlen($i)%2 != 0){
 	$count++;
 }
}
echo $count;

Measured memory_bytes: 4604