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

int main() {
	int n, m, Q; cin >> n >> m >> Q;
	vector<vector<int>> train(509);
	for (int i = 0; i < m; ++i) {
		int l, r; cin >> l >> r;
		for(int j=1;j<l+1;++j) train[j].push_back(r);
	}
	for (int i = 0; i < 509; ++i) {
		sort(train[i].begin(), train[i].end());
	}

	for (int i = 0; i < Q; ++i) {
		int p, q; cin >> p >> q;
		int ans = 0;
		auto iter = lower_bound(train[p].begin(), train[p].end(), q+1);
		//　初めてqを超えたものの一つ前まで	
		cout << iter-train[p].begin()-1+1 << endl;
	}
}

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

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    long long ans = 0;
    for(long long i = 1; i < N; i++) ans += A[N - 1 - i / 2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
const int MOD=1000000007;
const int INF=1000000000;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int n,m;
double l[25],a[25],b[25];
double dis[25][25];
double ans=0.0;
double tmp=0.0;
int main(int argc,char const* argv[])
{
  cin >> n >> m;
  for(int i=0;i<n;i++)
    {
      cin >> l[i] >> a[i] >> b[i];
    }
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
	{
	  dis[i][j]=pow(l[i]-l[j],2)+pow(a[i]-a[j],2)+pow(b[i]-b[j],2);
	}
    }
  for(int i=0;i<(1<<n);i++)
    {
      bitset<20> bs(i);
      if(bs.count()!=m) continue;
      tmp=0.0;
      int j=0;
      int k;
      //cout << bs << endl;
      while(j<=20)
	{
	  if(bs[j]==1)
	    {
	      //cout << j << endl;;
	      k=j+1;
	      while(k<=20)
		{
		  if(bs[k]==1)
		    {
		      //cout << k << endl;
		      tmp+=dis[j][k];
		    }
		  k++;
		}     
	    }
	  j++;
	}
      //cout << tmp << endl;
      ans=max(ans,tmp);
    }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}



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

#define int long long

#define inf 1000000007LL
#define mod 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

vector<int> v[334334];

int dfs(int p, int o) {
  int now = 0;
  for(auto i : v[p]) {
    if(i != o) {
      now ^= dfs(i, p) + 1;
    }
  }
  return now;
}

signed main() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  if(dfs(0, -1) == 0) {
    cout << "Bob" << endl;
  }
  else {
    cout << "Alice" << endl;
  }
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
ll modpow(ll a,ll n) {
	ll r=1,b=a;
	while(n>0) {
		if(n&1) r=r*b%mod;
		b=b*b%mod;
		n>>=1;
	}
	return r;
}

struct modint {
	ll x;
	modint(){x=0;}
	modint(ll v){x=v%mod;}
	modint operator+(modint t)const{return modint(x+t.x);}
	modint operator-(modint t)const{return modint(x-t.x+mod);}
	modint operator*(modint t)const{return modint(x*t.x%mod);}
	modint operator/(modint t)const{return modint(x*modpow(t.x,mod-2)%mod);}
};
int n;
int sub[200010];
vector<int> adj[200010];
modint ans;
modint half=modint(1)/modint(2);
modint Pow(modint a,ll n) {
	modint r(1), b=a;
	while(n>0) {
		if(n&1) r=r*b;
		b=b*b;
		n>>=1;
	}
	return r;
}
void prepare(int p,int u) {
	sub[u]=1;
	for(auto& it:adj[u])
		if(it!=p) {
			prepare(u,it);
			sub[u]+=sub[it];
		}
}
void solve(int p,int u,int e) {
	for(auto& it:adj[u]) {
		if(it==p)continue;
		solve(u,it,e+sub[u]-sub[it]);
	}
	vector<modint> pws;
	modint prod(1);
	pws.push_back(Pow(half,e));
	prod=prod*pws.back();
	for(auto& it:adj[u]) {
		if(it==p)continue;
		pws.push_back(Pow(half,sub[it]));
		prod=prod*pws.back();
	}
	modint sum=prod;
	for(auto& it:pws) {
		sum=sum+prod/it*(modint(1)-it);
	}
	ans=ans+half*(modint(1)-sum);
}
int main() {
	scanf("%d",&n);
	for(int i=0;i<n-1;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	prepare(1,1);
	solve(1,1,0);
	printf("%lld",ans.x);
	return 0;
}

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

int main () 
{
    int High, Width;
    
    while (1)
    {
        std::cin >> High >> Width;
        
        if (High == 0 && Width == 0) break;
        
        for (int i = 0; i < High; i++) 
        {
            for (int j = 0; j < Width; j++) 
            {
                std::cout <<  "#";
            }
        
        std::cout << std::endl;
        }
        
        std::cout << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	ll a, b, n;
	cin >> a >> b >> n;
	ll x = min(n, b-1);
	cout << (a*x/b-a*(x/b));

	return 0;
}


Measured memory_bytes: 3628
from operator import itemgetter, attrgetter
NK = list(map(int,input().split()))
AB = sorted([tuple(map(int, input().split())) for _ in range(NK[0])],key = itemgetter(0))
for i,j in AB:
    NK[1] = NK[1] - j
    if NK[1]<=0:
        print(i)
        break

Measured memory_bytes: 19048
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	char a[h][w];
	int g[h], r[w];
	REP(i,h) g[i] = 0;
	REP(i,w) r[i] = 0;
	REP(i,h){
		REP(j,w){
			cin >> a[i][j];
			if(a[i][j] == '.'){
				g[i]++;
				r[j]++;
			}
		}
	}

	REP(i,h){
		REP(j,w){
			if(g[i] != w && r[j] != h){
				cout << a[i][j];
			}
		}
		if(i == h) cout << endl;
		else if(g[i] != w) cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
}


int main(){
  int n;cin>>n;
  vector<int> w(n);for(int i=0;i<n;i++)cin>>w[i];
  vector<int> accum(n);accum[0]=w[0];
  for(int i=1;i<n;i++)accum[i]=accum[i-1]+w[i];
  int sum=accum[n-1];
  int ans=1000000;
  for(int i=0;i<n-1;i++){
    ans=min(ans, std::abs(sum-accum[i]-accum[i]));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int N;
int A[101];
 
void print() {
  for(int i = 1; i <= N; ++i)
    cout << (i!=1?" ":"") << A[i];
  cout << endl;
}
 
int main() {
  cin >> N;
  for(int i = 1; i <= N; ++i) cin >> A[i];
 
  print();
  for(int j = 2; j <= N; ++j) {
    int key = A[j];
    /* insert A[j] into the sorted sequence A[1,....,j-1] */
    int i = j - 1;
    while(i > 0 && A[i] > key) {
      A[i+1] = A[i];
      i = i - 1;
    }
    A[i+1] = key;
    print();
  }
  return 0;
}


Measured memory_bytes: 3092
N = int(raw_input())
s = sorted([int(raw_input()) for _ in range(N)])

t = sum(s)
if t % 10 != 0:
    print t
else:
    m = [v for v in s if v % 10]
    if len(m):
        print t - m[0]
    else:
        print 0

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, a = 0, b = 0, both = 0, ans = 0;
    cin >> len;
    for(int i = 0; i < len; i++) {
        string s;
        cin >> s;
        int l = s.length();
        for(int j = 0; j < l - 1; j++) {
            if(s[j] == 'A' && s[j + 1] == 'B')
                ans++;
        }
        if(s[l - 1] == 'A' && s[0] == 'B')
            both++;
        else if(s[l - 1] == 'A')
            a++;
        else if(s[0] == 'B')
            b++;
    }
    if(both == 0) {
        cout << ans + min(a, b);
    } else {
        if(a + b == 0)
            cout << ans + both - 1;
        else
            cout << ans + both + min(a, b);
    }
}

Measured memory_bytes: 3644
from collections import deque

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

edges = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

def dfs(start, end):
    minDist = [-1 for _ in range(N)]
    minDist[start] = 0

    que = deque([])
    que.append((start, 0))

    while que:
        now, dist = que.popleft()

        minDist[now] = dist
        if now == end:
            return dist

        for to in edges[now]:
            if minDist[to] >= 0:
                continue
            que.append((to, dist + 1))

    return float('inf')

if dfs(0, N - 1) <= 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 46812
#include <stdio.h>

int main(void){

  int a1, a2, a3;
  scanf("%d %d %d", &a1, &a2, &a3);
  int score = a1+a2+a3;

  if (score >= 22) {
    printf("bust\n");
  } else {
    printf("win\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int main(void)
{
    string s,t;
    cin >>s >>t;
    int a,b;
    cin >>a >>b;
    map<string, int> mp;
    mp[s] = a;
    mp[t] = b;

    string u;
    cin >>u;
    mp[u]--;

    printf("%d %d\n", mp[s], mp[t]);

}

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

int main () {
    
    int n = 0, a = 0, flag = 0;

    scanf ("%d", &n);

    while (n > 1) {
        a = n%10;
        if (a == 9) {
            flag = 1;
            printf ("Yes\n");
            break;
        }
        n /= 10;
    }

    if (!flag) printf ("No\n");
    return 0;
}

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

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  bool ans = false;
  
  if((A == 1 && B == 2) || (A == N-1 && B == N))
    ans = true;
  else if(A % 2 != B % 2)
    ans = true;
  
  if(ans) cout << "Borys" << endl;
  else cout << "Alice" << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int c[8],n[8]={1,2,1,2,1,4,1,4},m,p,r[8]={1,5,2,6,4,8,3,7};

int main(){
	while(cin>>c[0]>>c[1]>>c[2]>>c[3]>>c[4]>>c[5]>>c[6]>>c[7]){
		int m=99999999;
		for(int i=0;i<8;i++){
			int sum=0;
			for(int j=0;j<8;j++)sum+=max(0,c[j]-n[(i+j)%8]);
			//cout<<sum<<" ";
			if(sum<m||sum==m&&r[i]<r[p]){m=sum;p=i;}
		}
		//cout<<"p"<<p<<" ";
		for(int i=0;i<8;i++){
			cout<<n[(i+p)%8];
			if(i<7)cout<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 0
N,M = map(int, input().split())
As = list(map(int, input().split()))

Bs = [a//2 for a in As]

b = Bs[0]
beki2 = 0
while b % 2 == 0:
    b //= 2
    beki2 += 1

for b in Bs[1:]:
    n = 0
    while b % 2 == 0:
        b //= 2
        n += 1
    if beki2 != n : 
        print(0)
        exit()

def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

lcd = 1
for b in Bs:
    lcd = (lcd * b) // gcd(lcd, b)

ans = M / (2*lcd) + 1/2
print(int(ans))




Measured memory_bytes: 14400
n=int(input())
A = list(map(int,input().split()))
B = {}
s = 0
for a in A:
  B[a] = B.get(a,0)+1
  s += a
q=int(input())
for _ in range(q):
  b,c=map(int,input().split())
  s = s - b*B.get(b,0) + c*B.get(b,0)
  B[c] = B.get(c,0)+B.get(b,0)
  B[b] = 0
  print(s)


Measured memory_bytes: 23608
<?php
	while(fscanf(STDIN, "%d", $n)) {
		$ans = 0;
		for($a = 0; $a < 10; $a++) {
			for($b = 0; $b < 10; $b++) {
				for($c = 0; $c < 10; $c++) {
					for($d = 0; $d < 10; $d++) {
						if($a + $b + $c + $d == $n) $ans++;
					}
				}
			}
		}
		print $ans . "\n";
	}
?>

Measured memory_bytes: 6548
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(){
  int h,m,s;
  while(1){
    cin >> h >> m >> s;
    if(h == -1 && m == -1 && s == -1)break;
    int hms = 7200-(h*3600+m*60+s);
    h = hms/3600;
    hms-=3600*h;
    m = hms/60;
    hms-=60*m;
    s = hms;
    printf("%02d:%02d:%02d\n",h,m,s);
    hms = 3*(h*3600+m*60+s);
    h = hms/3600;
    hms-=3600*h;
    m = hms/60;
    hms-=60*m;
    s = hms;
    printf("%02d:%02d:%02d\n",h,m,s);
  }
}

Measured memory_bytes: 1160
import java.util.*;

class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int n = sc.nextInt();
    int ans = 0;
    
    for(int i = 0; i <= n; i++){
	  for(int j = 0; j <= n; j++){
        if(r * i + g * j > n) continue;
        if((n - r * i - g * j) % b == 0) ans++;
      }
    }
    
    System.out.println(ans);
    
  }
  
}


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

int main() {
    long long n, m;
    cin >> n >> m;
    
    if (n == 1 && m == 1) cout << 1 << endl;
    else if (n == 1) cout << m - 2 << endl;
    else if (m == 1) cout << n - 2 << endl;
    else cout << (n - 2) * (m - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
from math import ceil

def zalgo(S):
    L = len(S)
    Z = [0]*L
    l = 0
    for i in range(1, L):
        if i + Z[i-l] < l + Z[l]:
            Z[i] = Z[i-l]
        else:
            cnt = max(0, l+Z[l]-i)
            while i + cnt < L and S[i+cnt] == S[cnt]:
                cnt += 1
            Z[i] = cnt
            l = i
    Z[0] = L
    return Z

def topological_sort(E, D):
    D = D[:]
    n = len(E)
    Q = [i for i in range(n) if D[i] == 0]
    L = []
    while Q:
        p = Q.pop()
        L.append(p)
        for vf in E[p]:
            D[vf] -= 1
            if not D[vf]:
                Q.append(vf)
    
    if len(L) != n:
        return False
    return L


S = [ord(s) - 97 for s in input().strip()]
T = [ord(t) - 97 for t in input().strip()]

ls = len(S)
lt = len(T)
S = S * ceil(lt/ls)
ls = len(S)


Z = zalgo(T+[-1]+S+S)[lt+1:]

Edge = [[] for _ in range(ls)]
Dim = [0]*ls

for i in range(ls):
    if Z[i] == lt:
        Edge[i] = [(i+lt)%ls]
        Dim[(i+lt)%ls] += 1

TS = topological_sort(Edge, Dim)

if TS == False:
    print(-1)
else:
    dp = [0]*ls
    for ts in TS:
        if Edge[ts]:
            dp[Edge[ts][0]] = 1 + dp[ts]
    print(max(dp))


Measured memory_bytes: 185448
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int count = 0;
  vector<int> h(n);

  for(int i=0;i<n;i++){
  	cin >> h.at(i);
  }
  for(int i=0;i<n;i++){
  	for(int j=0;j<=i;j++){
  		if(i == j){
  			count++;
  			break;
  		}
  		else if(h.at(j) <= h.at(i))
  			continue;
  		else
  			break;
  	}
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger

getInt = readInt <$> BS.getLine

rev :: Int -> Int -> Int
rev n n' | n'' < n' = rev (n+1) n'
         | n'' == n' = n
         | otherwise = -1
  where 
    n'' = n * 108 `div` 100 

main = do
  n <- getInt
  let n' = n * 100
  let d = n' `div` 108
  let m = n' `mod` 108
  if m == 0 then
    print d
  else do
    let x = rev d n
    if x == -1 then
      putStrLn ":("
    else
      print x

Measured memory_bytes: 380
def main():
  import sys
  input = sys.stdin.readline
  ans = []
  ans_append = ans.append
  s = input()
  t = input()
  a = len(s)
  b = len(t)
  dp = [[0]*(b+1) for _ in range(a+1)]
  prev_w = [[None]*(b+1) for _ in range(a+1)]
  for i in range(a):
    for j in range(b):
      if s[i]==t[j]:
        if dp[i][j]+1>dp[i+1][j+1]:
          dp[i+1][j+1] = dp[i][j]+1
          prev_w[i+1][j+1] = (i,j)
      else:
        if dp[i+1][j]>dp[i][j+1]:
          dp[i+1][j+1]=dp[i+1][j]
          prev_w[i+1][j+1] = (i+1,j)
        else:
          dp[i+1][j+1]=dp[i][j+1]
          prev_w[i+1][j+1] = (i,j+1)
  while a!=0 and b !=0:
    l = dp[a][b]
    a,b=prev_w[a][b]
    if l>dp[a][b]:
      ans_append(s[a])
  ans ="".join(ans)
  ans =ans[::-1]
  print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 376712
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a;
    cin>>a;
    bool flag=false;
    for(long long i=-1000;i<=1000;i++){
        if(flag){
            break;
        }
        for(long long j=-1000;j<=1000;j++){
            if(i*i*i*i*i-(j*j*j*j*j)==a){
                cout<<i<<" "<<j<<endl;
                flag=true;
                if(flag) break;
            }
        }
    }
}



Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{ 
        public static void main(String[] args){
            int i=0,j,k,count=0;
            int a[];
            int b[];
            a = new int[100000];
            b = new int[100000];
                Scanner n = new Scanner(System.in);
                while(true){
                     a[i] = n.nextInt();
                     b[i] = n.nextInt();
                     if(a[i]==0 && b[i]==0){
                         break;
                     }
                     count++;
                     i++;
                }
                i=0;
                while(count>i){
                        for(k=0;k<a[i];k++){
                            if(k==0 || k==(a[i]-1)){
                                for(j=0;j<b[i];j++){
                                    System.out.print("#");
                                }
                                System.out.printf("\n");
                            }else{
                            for(j=0;j<b[i];j++){
                                if(j==0 || j==b[i]-1){
                                System.out.print("#");
                                }else{
                                    System.out.print(".");
                                }
                            }
                            System.out.printf("\n");
                        }
                    }
                     i++;
                     System.out.printf("\n");
                }
        }
    }


Measured memory_bytes: 38056
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    // input
    static int a;
    static int b;

    /**
     * input
     */
    static void input(){
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        sc.close();
    }
 
    /**
     * solver
     */
    static void solve(){
        int ans;

        if (a>b){
            ans = 2*a-1;
        } else if (a==b) {
            ans = a + b;
        } else {
            ans = 2*b-1;
        }
        
        System.out.println(ans);
    }

    public static void main(String args[]) {

        input();

        solve();
    }
}


Measured memory_bytes: 23124
import sys
readline = sys.stdin.readline

A, V = map(int, readline().split())
B, W = map(int, readline().split())
T = int(readline())
if A > B:
    A, B = B, A

ans = 'NO'
if A+T*V >= B+T*W:
    ans = 'YES'
print(ans)

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

int main() {
	int N, ans;
	static int W[300010], E[300010];
	string S;
	cin >> N >> S;
	ans = N;
	for (int i = 1; i <= N; i++) {
		W[i] = W[i - 1];
		if (S[i - 1] == 'W') W[i]++;
	}
	for (int i = N; i >= 1; i--) {
		E[i] = E[i + 1];
		if (S[i - 1] == 'E') E[i]++;
	}
	for (int i = 1; i <= N; i++) {
		ans = min(ans, W[i] + E[i]);
	}
	cout << ans - 1;
}

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

using namespace std;

const int N = 2e5 + 9;

int n, a[N], b[N];

inline int nxt(int x) {
	return x == n ? 1 : x + 1;
}

inline int lxt(int x) {
	return x == 1 ? n : x - 1;
}

typedef pair<int, int> P;

priority_queue<P> que;

void solve() {
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		que.push(make_pair(b[i], i));
	}
	while (!que.empty()) {
		P top = que.top(); que.pop();
		int x = top.second;
		if (a[x] == b[x]) continue;
		int p = b[lxt(x)] + b[nxt(x)];
		if (b[x] - p < a[x]) {
			puts("-1");
			return ;
		} else {
			int d = (b[x] - a[x]) / p;
			ans += d;
			b[x] -= d * p;
			que.push(make_pair(b[x], x));
		}
	}
	printf("%lld\n", ans);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 	
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &b[i]);
	solve();
	return 0;
}

Measured memory_bytes: 3956
#include <cstdio>

const int N = 200000;
int n, k, a[N];

int main() 
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) scanf("%d", a + i);
	for (int i = k; i < n; ++i) {
		if (a[i] > a[i - k]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2440
#include<bits/stdc++.h>
#define fint register int
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n>=400&&n<=599)
	cout<<8;
	else
	if(n>=600&&n<=799)
	cout<<7;
	else
	if(n>=800&&n<=999)
	cout<<6;
	else
	if(n>=1000&&n<=1199)
	cout<<5;
	else
	if(n>=1200&&n<=1399)
	cout<<4;
	else
	if(n>=1400&&n<=1599)
	cout<<3;
	else
	if(n>=1600&&n<=1799)
	cout<<2;
	else
	if(n>=1800&&n<=1999)
	cout<<1;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
LL gcd(LL a, LL b) { return b > 0 ? gcd(b, a % b) : a; }
LL ksm(LL a, LL b)
{
    LL ans = 1;
    while (b)
    {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}
int a[N];
int b[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int cnt = 0;
    int flag = 0;
    for (int k = 1; k <= n - 1; k++)
    {
        if (a[k] >= a[k + 1])
            flag = 1;
    }
    if (!flag)
    {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++)
    {
        //memcpy(b, a, sizeof a);
        // for (int j = 1; j <= n;j++)
        //     cout << b[j] << ' ';
        // cout << endl;
        for (int j = i + 1; j <= n; j++)
        {
            memcpy(b, a, sizeof a);
            int flag = 0;
            swap(b[i], b[j]);
            //     for (int j = 1; j <= n;j++)
            //     cout << b[j] << ' ';
            // cout << endl;
            for (int k = 1; k <= n - 1; k++)
            {
                if (b[k] >= b[k + 1])
                    flag = 1;
            }
            if (!flag)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

ll n;
double l;
double t[3009];

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

    cin >> n >> l;
    rep(i, n) cin >> t[i];

    double res_x = 0, res_y = 0;

    rep(i, n) rep(j, i) {
        double r = PI * (t[i] + t[j]) / l;
        res_x += cos(r) * (n + j - i - 1);
        res_y += sin(r) * (n + j - i - 1);

        r += PI;
        res_x += cos(r) * (i - j - 1);
        res_y += sin(r) * (i - j - 1);
    }

    ll r = n * (n - 1) * (n - 2) / 6;

    cout << fixed << setprecision(10);
    cout << res_x / r << " " << res_y / r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    long long  b;
    bool flag = false;
    for (int i = 0; i < n; i++) {
        cin >> b;
        if (b % 2)
            flag = true;
    }
    if (flag)
        cout << "first" << endl;
    else 
        cout << "second" << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int graf[10][10];
int dfs(int v, int n, bool vst[10]) {
	bool flg = true;
	for (int i = 0; i < n; i++) {
		if (!vst[i])flg = false;
	}
	if (flg)return 1;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!graf[v][i])continue;
		if (vst[i])continue;
		vst[i] = true;
		ans += dfs(i, n, vst);
		vst[i] = false;
	}
	return ans;
}
int main() {
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graf[a - 1][b - 1] = graf[b - 1][a - 1] = true;
	}

	bool vst[10];
	for (int i = 0; i < 10; i++)vst[i] = false;
	vst[0] = true;
	cout << dfs(0, n, vst) << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 2e5 + 20;
LL sum[maxn];
int c[maxn];
int n, k;
int lowbit(int x) {
    return x & (-x);
}
void upDate(int pos, int val) {
    while (pos <= n) {
        c[pos] += val;
        pos += lowbit(pos);
    }
}
int ask(int pos) {
    int ans = 0;
    while (pos) {
        ans += c[pos];
        pos -= lowbit(pos);
    }
    return ans;
}
LL vc[maxn], lenvc;
void work() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) {
        int val;
        scanf("%d", &val);
        sum[i] = sum[i - 1] + val;
    }
    for (int i = 1; i <= n; ++i) {
        sum[i] -= 1LL * i * k;
        vc[++lenvc] = sum[i];
//        cout << sum[i] << " ";
    }
//    cout << endl;
    sort(vc + 1, vc + 1 + lenvc);
    LL ans = 0;
    for (int i = 1; i <= n; ++i) {
        int pos = lower_bound(vc + 1, vc + 1 + lenvc, sum[i]) - vc;
        if (sum[i] >= 0) {
            ans++;
        }
        ans += ask(pos);
        upDate(pos, 1);
    }
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 4096
from math import sqrt as q
f=lambda x,y:max(len(str(x)),len(str(y)))
a=int(input())
l=[f(int(a/i),i) for i in range(2,int(q(a))+2) if not a%i]
if l:
  print(min(l))
else:
  print(len(str(a)))

Measured memory_bytes: 3060
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//grobal変数


int main() {
	int n;
	cin >> n;
	VI a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
 
flag = False
for i in range(0, N+1):
  for j in range(0, N+1-i):
    k = N - i - j
    if 10000*i + 5000*j + 1000*k == Y:
      flag = True
      break
  if flag: break

if flag: print(i, j, k)
else: print(-1, -1, -1)

Measured memory_bytes: 8996
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	while (true) {
		int n, m; std::cin >> n >> m; if (n == 0) break;
		std::vector<std::vector<int>> town(n);
		for (auto i = 0; i < m; ++i) {
			int u, v; std::cin >> u >> v;
			town[u - 1].push_back(v - 1);
			town[v - 1].push_back(u - 1);
		}
		std::vector<int> parity(n, -1);
		std::stack<int> stack;
		parity[0] = 0; stack.push(0);
		bool is_bipartite{ true };
		while (!stack.empty()) {
			auto top = stack.top(); stack.pop();
			for (const auto next : town[top]) {
				if (parity[next] == -1) {
					parity[next] = (parity[top] + 1) % 2;
					stack.push(next);
				}
				else if (parity[next] != (parity[top] + 1) % 2) {
					is_bipartite = false;
				}
			}
			if (!is_bipartite) break;
		}
		if (is_bipartite) {
			std::vector<int> result{ static_cast<int>(std::count(parity.begin(), parity.end(), 0)), static_cast<int>(std::count(parity.begin(), parity.end(), 1)) };
			result.erase(std::remove_if(result.begin(), result.end(), [](const int p) {return p % 2 != 0; }), result.end());
			std::sort(result.begin(), result.end());
			result.erase(std::unique(result.begin(), result.end()), result.end());
			std::cout << result.size() << '\n';
			for (const auto r : result) std::cout << r / 2 << '\n';
		}
		else {
			std::cout << "0\n";
		}
	}
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#define         inf         100000000000000
using namespace std;

int main(){


    int n,tmp,cnt,c;

    cin>>n;

    cnt = 0;

    for(int i=1;i<=n;i++){
        tmp = i;
        c=0;
        while(tmp>0){
            tmp/=10;
            c++;
        }
        if(c%2!=0){
            cnt++;
        }
    }

    cout<<cnt<<endl;



    return 0;
}


Measured memory_bytes: 256
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/

void solve() {
	string s, t; cin >> s >> t;
	if (t.length() == 1 + s.length() && t.substr(0, s.length()) == s) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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 (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}



int main(){
    int n;cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);

    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}



Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    int ans;
    cin>> a>>b>>c>>d;
    ans = min(b,d) - max(a,c);
    if(ans<0) ans = 0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int x, y, z;
  cin >> x >> y >> z;
  if ((x * 100 + y * 10 + z) % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,D;
    cin >> N >> D;
    int X[N][D];
    for(int i=0; i<N; i++){
        for(int j=0; j<D; j++){
            cin >> X[i][j];
        }
    }
    int count = 0;
    int distance_2=0;
    
    //高々200の2乗まで考えればよい
    //比較対象1
    for(int i=0; i<N; i++){
        
        //比較対象2
        for(int j=i+1; j<N; j++){
            distance_2 = 0;
            //距離計算
            if (i != j){
                for(int k=0; k<D; k++){
                    distance_2 += (abs(X[i][k]-X[j][k])*abs(X[i][k]-X[j][k])); 
                }
                //整数チェック
                for(int num=0; num<200; num++){
                    if(distance_2 == num*num){ count++; cerr << i << " " << j << endl;} 
                }
            }

        }
    }



    cout << count << endl;
    return 0;
}


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

int main() {
  int city[55] = {0};
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; ++i)
  {
    int city1, city2;
    cin >> city1 >> city2;
    city[city1]++;
    city[city2]++;
  }
  for(int i = 1; i <= n; ++i)
  {
    cout << city[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  
  int q;
  cin>>q;
  while(q--){
    int k;
    cin>>k;
    int ans = lower_bound(A.begin(),A.end(), k) - A.begin();
    cout<<ans<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3336
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  
  int vec[n];
  
  rep(i,n) cin >> vec[i];
  
  for(int k=0;k<n;k++){
    if(k>0) cout << " ";
    cout << vec[k];
  }
  cout << endl;
  
  for(int i=1;i<n;i++){
    int v = vec[i];
    int j=i-1;
    while(j>=0 && vec[j]>v){
      vec[j+1]=vec[j];
      j--;
    }
    vec[j+1]=v;
    
    for(int k=0;k<n;k++){
      if(k>0) cout << " ";
      cout << vec[k];
    }
    cout << endl;
  }
      
  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
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 X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b;
    cin >> n >> a >> b;
    int x=n/(a+b);
    int y=n%(a+b);
    int res=a*x + min(a,y);
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	string s;
	cin >> s;
	ll dp[13];
	forn(i,13) dp[i]=0;
	dp[0]=1;
	ll fact = 1;
	rforn(i,(ll)s.size()-1){
		ll temp[13];
		forn(i,13) temp[i]=0;
		if(s[i]=='?'){
			forn(l,10){
				ll d = (l*fact)%13;
				forn(i,13){
					temp[(i+d)%13]+=dp[i];
				}
			}
		}
		else{
			ll d = ((s[i]-'0')*fact)%13;
			forn(i,13){
				temp[(i+d)%13]+=dp[i];
			}
		}
		fact *= 10;
		fact %= 13;
		forn(i,13) dp[i]=temp[i]%MOD;
	}
	cout << dp[5] << ln;
}

int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 512
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

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



int main(){
  int n;cin>>n;
  double z = 0.0;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    z += (double)1/t;
  }
  cout << fixed << setprecision(10) << 1/z << endl;
}


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

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>a>>b>>c;
    if(b>=a*c)
        cout<<c;
    else
    {
        cout<<b/a;
    }
    
	
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int h, n, sum;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
  }
  cout << (sum >= h ? "Yes" : "No") << endl;
  return 0;
}

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



int main(){
	
	int A,B,C,X;
	cin>>A>>B>>C>>X;
	
	int ans = 0;
	
	for(int i=0;i<=A;i++){
		for(int j=0;j<=B;j++){
			for(int k=0;k<=C;k++){
				if(500*i+100*j+50*k==X)ans++;
			}
		}
	}
	
	cout<<ans<<endl;
		
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N,a,b,c,d;
  cin>>N;
  a=N/1000%10;
  b=N/100%10;
  c=N/10%10;
  d=N%10;
  if(a==b && b==c)cout<<"Yes";
  else if(b==c && c==d)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256