akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n) {
		rep(j, i) {
			rep(k, j) {
				if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) {
					int ma = max({ a[i],a[j],a[k] });
					if (ma < a[i] + a[j] + a[k] - ma) ans++;
				}
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3608
from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

for idx, perm in enumerate(permutations(range(1, n+1))):
    # perm は intからなるタプル
    res = True
    for ip in range(n):
        if p[ip] != perm[ip]:
            res = False
    if res:
        idx_p = idx
    res = True
    for iq in range(n):
        if q[iq] != perm[iq]:
            res = False
    if res:
        idx_q = idx

print(abs(idx_p - idx_q))


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'

int main(){
    string n;
    cin >> n;
    int k = n.length();
    int ans = 9*(k-1)+int(n[0]-'0');
    if(n.substr(1) == string(n.length()-1, '9'))
        cout << ans;
    else
        cout << ans-1;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007;
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<int> g(a),r(b),nc(c);
	priority_queue<int> green,red,noc;
	for(int i=0;i<a;i++){ cin>>g[i]; green.push(g[i]); }
	for(int i=0;i<b;i++){ cin>>r[i]; red.push(r[i]); }
	for(int i=0;i<c;i++){ cin>>nc[i]; noc.push(nc[i]); }
	int ans = 0;
	int gc = 0, rc = 0, nct = 0;
	while( gc + rc + nct < x + y ){
		int gt = 0;
		int rt = 0;
		int nt = 0;
		if( gc < x ) gt = green.top();
		if( rc < y ) rt = red.top();
		if( !noc.empty() ) nt = noc.top();
		int ma = max( gt, max( rt, nt ) );
		if( nt == ma ){
			noc.pop();
			ans += nt;
			nct++;
		}
		else if( gt == ma ){
			green.pop();
			ans += gt;
			gc++;
		}
		else{
			red.pop();
			ans += rt;
			rc++;
		}
	}
	cout<<ans<<Endl;
	return 0;
}

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll n; cin >> n;
  	while(n){
    	if(n % 10 == 7){
        	cout << "Yes\n";
          	return 0;
        }
      
      	n /= 10;
    }
  
  	cout << "No\n";
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

#define rep(i, n) for(int i = 0; i < n; i++)
#define in_arr(type, a, n) for(int i = 0; i < n; i++) scanf(type, &((a)[i]));

int main(){
    int ret = 100, n, a;
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a);
        int count = 0;
        while(a % 2 == 0){
            ++count;
            a /= 2;
        }
        if(ret > count){
            ret = count;
        }
    }
    printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
typedef long long ll;

using namespace std;

int main(){
	
	int X(0);
    cin >> X;

    int ans(0);
    if(X<=2){
        ans = 2;
    }else{
        while(ans == 0){
            for(int i(2);i<sqrt(X);i++){
                if(X%i == 0){
                    X++;
                    break;
                }
                if(i==int(sqrt(X)))ans=X;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int main() {

	int s, w;
	cin >> s >> w;

	string ans = "safe";
	if (s <= w) ans = "unsafe";

	cout << ans << endl;
}

//printf("%ld\n", ans);

Measured memory_bytes: 3612
from math import *
PI = 3.1415926535898
res = [0,31,29,31,30,31,30,31,31,30,31,30,31]
wk = ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"]
pas = [0]
for i in range(1, len(res)):
	pas.append(pas[i-1] + res[i])
while True:
	try:
		m, d = map(int, raw_input().strip().split(' '))
		if m == 0 and d == 0:
			break
		print wk[(pas[m-1]+d)%7]
	except EOFError:
		break

Measured memory_bytes: 6400
implicit none

integer :: h,w
character(2000) :: s
logical,allocatable :: map(:,:)
integer,allocatable :: n(:,:)
integer :: i,j,k

read *,h,w
allocate(map(h,w))
map(:,:) = .false.
do i = 1, h
   read *,s
   do j = 1, w
      if (s(j:j) == '#') then
         map(i,j) = .true.
      endif
   enddo
enddo

allocate(n(h,w))
n(:,:) = 0

do i = 1, h
   j = 1
   k = 0
   do while (j <= w)
      if (map(i,j)) then
         if (k > 0) then
            n(i,k:j-1) = j-k
         endif
         k = 0
      else
         if (k == 0) then
            k = j
         endif
      endif
      j = j + 1
   enddo
   if (k > 0) then
      n(i,k:w) = w - k + 1
   endif
enddo

do j = 1, w
   i = 1
   k = 0
   do while (i <= h)
      if (map(i,j)) then
         if (k > 0) then
            n(k:i-1,j) = n(k:i-1,j) + i-k
         endif
         k = 0
      else
         if (k == 0) then
            k = i
         endif
      endif
      i = i + 1
   enddo
   if (k > 0) then
      n(k:h,j) = n(k:h,j) + h - k + 1
   endif
enddo

n(:,:) = n(:,:) - 1

print '(i0)',maxval(n)

stop
end

Measured memory_bytes: 31488
# import n as integer
n = int(input())
# obtain list
l = list(map(int, input().split()))

sum = 0
# if even, say no
for i in range (0, n):
	if l[i]%2 == 0:
		if l[i]%3 != 0 and l[i]%5 != 0:
			sum+=1

if sum ==0:
	print('APPROVED')
else:
	print('DENIED')

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
	int x, y, z;
	while (true){
		scanf("%d %d", &x, &y);
		if (x > y){
			z = x;
			x = y;
			y = z;
		}
		if (x == 0 && y == 0)break;
		printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)100000000000000

int main() {
  int H,W;
  cin>>H>>W;
  int A[H][W];
  int B[H][W];
  bool dp[H][W][15000];
  rep(i,H){
    rep(j,W){
      cin>>A[i][j];
    }
  }
  rep(i,H){
    rep(j,W){
      int b;
      cin>>b;
      B[i][j]=abs(b-A[i][j]);
    }
  }
  rep(i,H){
    rep(j,W){
      rep(k,15000){
        dp[i][j][k]=false;
      }
    }
  }
  dp[0][0][B[0][0]]=true;
  rep(i,H-1){
    rep(j,15000){
      if(dp[i][0][j]){
        dp[i+1][0][j+B[i+1][0]]=true;
        dp[i+1][0][abs(j-B[i+1][0])]=true;
      }
    }
  }
  rep(i,W-1){
    rep(j,15000){
      if(dp[0][i][j]){
        dp[0][i+1][j+B[0][i+1]]=true;
        dp[0][i+1][abs(j-B[0][i+1])]=true;
      }
    }
  }
  rep(i,H-1){
    rep(j,W-1){
      rep(k,15000){
        if(dp[i][j+1][k]){
          dp[i+1][j+1][k+B[i+1][j+1]]=true;
          dp[i+1][j+1][abs(k-B[i+1][j+1])]=true;
        }
        if(dp[i+1][j][k]){
          dp[i+1][j+1][k+B[i+1][j+1]]=true;
          dp[i+1][j+1][abs(k-B[i+1][j+1])]=true;
        }
      }
    }
  }
  rep(i,15000){
    if(dp[H-1][W-1][i]){cout<<i;break;}
  }
}


Measured memory_bytes: 97400
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>

using namespace std;

int main() {
    int n, l, r, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2424

#include <iostream>
#include <string>
#include <climits>
using namespace std;

int check(string num, int cnt){
  if(stoi(num)<10) return cnt;
  int max = -1;
  for(int i=1;i<=num.size()-1;i++){
    string sub1, sub2;
    sub1 = num.substr(0,i);
    sub2 = num.substr(i, num.size()-i);
    int num1 = stoi(sub1, nullptr, 10);
    int num2 = stoi(sub2, nullptr, 10);
    if(max<num1*num2) max=num1*num2;
  }

  cnt = check(to_string(max), cnt+1);

  return cnt;
}

int main(){
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    string num;
    cin >> num;
    int cnt=0;
    cnt = check(num, cnt);
    if(cnt==INT_MAX) cout << -1 << endl;
    else cout << cnt << endl;
  }

  return 0;
}

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

using namespace std;

int dp[20]={};
string S;

int main(){
  cin >> S;
  dp[0]=(S[0]=='A' || S[0]=='C' || S[0]=='G' || S[0]=='T')?1:0;
  for(int i=1;i<S.length();i++){
    dp[i]=(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T')?1:0;
    dp[i]=dp[i]!=0?dp[i]+dp[i-1]:0;
  }
  int res=0;
  for(int i=0;i<S.length();i++){
    res=max(res,dp[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++)
    {
        if(((4*i)+(2*(x-i)))==y)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

int main(void){

    int n;
    cin >> n;
    vector<pair<int,int>> datas;
    for(int i=0; i<n; i++) {
        pair<int,int> temp;
        int a;
        cin >> a;
        temp.second = i+1;
        temp.first = a;
        datas.push_back(temp);
    }
    
    sort(datas.begin(), datas.end());
    
    for(int i=0; i<datas.size(); i++) {
        if(i != datas.size()-1)cout << datas[i].second << " ";
        else cout << datas[i].second << endl;
    }

    return 0;
}


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

using namespace std;

const int MAXN=200111;

int unCode(char c){
	return c=='W';
}

string input;
int N;
int A[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	
	cin >> input;
	N=input.length();
	
	for(int i=1;i<=N;++i)	A[i]=unCode(input[i-1]);
	
	long long Ans=0LL;
	
	for(int i=N, c=0;i>=1;--i){
		c+=A[i];
		if(!A[i])	Ans+=c;
	}
	
	cout << Ans << endl;
	
	return 0;
}

Measured memory_bytes: 1300
def call(n)
  i = 1

  (1..n).each do |i| 
    x = i

    if x % 3 == 0
      print " #{i}"
    else
      while x != 0 do
        if x % 10 == 3
          print " #{i}"
          break
        end
        x /= 10
      end
    end
  end
  puts
end

call(gets.to_i)



Measured memory_bytes: 6852
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int N=100005;
int dp[N];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    int pos=-1;
    for(int i=n-1;i>=max(0,n-m);i--){
        if(s[i]=='0'){
            pos=i;
        }
    }
    if(pos==-1){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=n;i>=0;i--){
        if(i==n){
            dp[i]=pos;
            continue;
        }
        int x=dp[i+1];
        int ind=max(0,i-m);
        if(s[ind]=='0')x=min(x,ind);
        if(x<i || x==0){
            dp[i]=x;
            if(x==0)break;
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    int ind=n;
    vector<ll>res;
    while(ind>0){
        int x=dp[ind];
        res.push_back(ind-x);
        ind=dp[ind];
    }
    reverse(res.begin(),res.end());
    for(auto i:res){
        cout<<i<<" ";
    }
    cout<<endl;
    return 0;
    }


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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (i * 4 + j * 7 == n) {
                printf("Yes");
                return 0;
            }
        }
    }

    printf("No");
    return 0;
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint f2(int x, int y) {
    combination c(x+y-1);
    return c(x+y-1, y-1);
}

mint f(int x, int y) {
    return f2(x-y, y);
}

int main() {
    int n, k;
    cin >> n >> k;
    combination c(n-k+1);
    for (int i = 1; i <= k; i++) {
        mint red = c(n-k+1, i);
        mint blue = f(k, i);
        mint ans = red*blue;
        cout << ans.x << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define N 100005
#define inf 999999999
#define ll long long
#define lson l,mid,o<<1
#define rson mid+1,r,o<<1|1
#define Ls(o) t[o].ls
#define Rs(o) t[o].rs
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define mcpy(x,y) memcpy(x,y,sizeof(x))
#define mset(x,y) memset(x,y,sizeof(x))
using namespace std;
bool vis[N],wj;
int head[N],a[N],cnt,l[N],r[N];
struct ed{ int v,nxt; }e[N<<1];
void add(int u,int v){
	e[++cnt]=(ed){v,head[u]},head[u]=cnt;
	e[++cnt]=(ed){u,head[v]},head[v]=cnt;
}
void dfs(int x,int fa){
	Edge(x){
		if(wj) return;
		int to=e[i].v;
		if(fa!=to){
			dfs(to,x);
			if(!vis[x]){
				l[x]=max(l[x],l[to]-1);
				r[x]=min(r[x],r[to]+1);
			}
			if(vis[x]&&vis[to]) if(abs(a[x]-a[to])!=1){ wj=1;return; } 			
		}
	}
	if(l[x]>r[x]){ wj=1;return; }
}
void dfs3(int x,int fa){
	Edge(x){
		if(wj) return;
		int to=e[i].v;
		if(fa!=to){
			if(to!=fa){
				if(!vis[to]){
					l[to]=max(l[x]-1,l[to]);
					r[to]=min(r[x]+1,r[to]);
				}
				if(l[to]>r[to]){ wj=1;return; }
				dfs3(to,x);
			}		
		}
	}	
}
void dfs2(int x,int fa){
	Edge(x){
		int to=e[i].v;
		if(fa!=to){
			if(a[x]-1>=l[to] && a[x]-1<=r[to]) a[to]=a[x]-1;
			else if(a[x]+1>=l[to] && a[x]+1<=r[to]) a[to]=a[x]+1;
			dfs2(to,x); 
		}
	}
}
int main(){
	int n,u,v,m;
	scanf("%d",&n);
	For(i,1,n-1) scanf("%d%d",&u,&v),add(u,v);
	For(i,1,n) a[i]=inf,l[i]=-inf,r[i]=inf;
	scanf("%d",&m);
	For(i,1,m) scanf("%d%d",&u,&v),a[u]=v,l[u]=r[u]=v,vis[u]=1;
	dfs(1,0),dfs3(1,0);
	if(wj) return puts("No"),0;
	else{
		a[1]=l[1];
		puts("Yes");
		dfs2(1,0); 
		For(i,1,n) printf("%d\n",a[i]);
	}
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
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; }
const int INF=100100100100100;
const int MAXR=500010;

signed main(){
  int n,m,x;cin>>n>>m>>x;
  int ans=0;
  rep(i,n){
    int po;cin>>po;
    if(po<x)ans++;
  }
  chmin(ans,m-ans);
  cout<<ans<<endl;
  return 0;
}

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

int N, M;
#define MAX_N 3000
long long D[2][MAX_N - 1 + 1][2];
#define MOD 1000000007LL
long long R;

int main() {
  cin >> N >> M;
  D[0][0][1] = 2;
  for(int k = 1; k <= N - 1; ++k) D[0][k][0] = 2;
  for(int i = 0; i < M - 1; ++i) {
    int prev = i % 2, cur = (i + 1) % 2;
    D[cur][0][1] = 2 * D[prev][0][1] % MOD;
    if(N - 1 > 0) (D[cur][0][1] += D[prev][1][0] + D[prev][1][1]) %= MOD;
    for(int k = 1; k <= N - 1; ++k) for(int c = 0; c < 2; ++c) {
      D[cur][k][c] = 2 * D[prev][k][c] % MOD;
      if(k > 0) (D[cur][k][c] += D[prev][k - 1][c]) %= MOD;
      if(k < N - 1) (D[cur][k][c] += D[prev][k + 1][c]) %= MOD;
    }
  }
  for(int k = 0; k <= N - 1; ++k) {
    (R += D[(M - 1) % 2][k][1]) %= MOD;
  }
  cout << R * 2 % MOD << endl;
  return 0;
}


Measured memory_bytes: 384
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll x;
    cin>>x;
    ll doub=x/500;
    ll ans=0;
    ans+=(2*doub*500);
    x-=(doub*500);
    ll sing=x/5;
    ans+=(sing*5);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
from itertools import combinations_with_replacement
N, M, Q = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(Q)]
max = 0
for A in combinations_with_replacement(range(1, M + 1), N):
    A = (1, ) + A + (M, )
    score = 0
    for i in range(Q):
        if A[a[i][1]] - A[a[i][0]] == a[i][2]:
            score += a[i][3]
    if score > max:
        max = score
print(max)

Measured memory_bytes: 68072
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

const int MAX_N=100;
int N,A[2][MAX_N];

int main(){
	cin>>N;
	REP(i,2){
		REP(j,N)
			cin>>A[i][j];
	}
	int ans=0;
	REP(i,N){
		int tem=0;
		REP(j,N){
			if (i<=j){
				tem+=A[1][j];
			}
			if (j<=i){
				tem+=A[0][j];
			}
		}
		ans=max(ans,tem);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>=1&&b>=1&&c>=1&&a<=100&&b<=100&&c<=100)
    {
        if(a+b==c||a+c==b||c+b==a)
            printf("Yes");
        else
            printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <map>
#define SIZE 105
#define MX 20005
#define INF 1000000000

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct MaxFlow
{
	struct edge
	{
		int to,cap,rev;
		edge(int to=0,int cap=0,int rev=0):to(to),cap(cap),rev(rev){}
	};
	vector <edge> vec[MX];
	int level[MX];
	int iter[MX];
	
	void add(int s,int t,int c)
	{
		int S=vec[s].size(),T=vec[t].size();
		vec[s].push_back(edge(t,c,T));
		vec[t].push_back(edge(s,0,S));
	}
	void bfs(int s)
	{
		memset(level,-1,sizeof(level));
		queue <int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty())
		{
			int v = que.front();que.pop();
			for(int i=0;i<vec[v].size();i++)
			{
				edge&e=vec[v][i];
				if (e.cap>0&&level[e.to]<0)
				{
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	int flow_dfs(int v,int t,int f)
	{
		if (v==t) return f;
		for(int &i=iter[v];i<vec[v].size();i++)
		{
			edge &e=vec[v][i];
			if (e.cap>0&&level[v]<level[e.to])
			{
				int d=flow_dfs(e.to,t,min(f,e.cap));
				if (d>0)
				{
					e.cap-=d;
					vec[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s,int t)
	{
		int flow = 0;
		while(1)
		{
			bfs(s);
			if (level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			while (1)
			{
				int f=flow_dfs(s,t,INF);
				if(f==0) break;
				flow += f;
			}
		}
	}
};
MaxFlow M;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char mp[SIZE][SIZE];
bool use[SIZE][SIZE];
bool vis[SIZE][SIZE];
int h,w;

int in_id(int x,int y)
{
	return (x*w+y)*2;
}
int out_id(int x,int y)
{
	return (x*w+y)*2+1;
}
int main()
{
	scanf("%d %d",&h,&w);
	for(int i=0;i<h;i++) scanf("%s",&mp[i]);
	int S=h*w*2,T=S+1;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(mp[i][j]=='X')
			{
				M.add(out_id(i,j),T,INF);
				M.add(in_id(i,j),out_id(i,j),INF);
				if(i==0||i==h-1||j==0||j==w-1)
				{
					puts("-1");
					return 0;
				}
			}
			else
			{
				M.add(in_id(i,j),out_id(i,j),1);
			}
			for(int k=0;k<4;k++)
			{
				int nx=i+dx[k],ny=j+dy[k];
				if(0<=nx&&nx<h&&0<=ny&&ny<w)
				{
					M.add(out_id(i,j),in_id(nx,ny),INF);
				}
				else
				{
					M.add(S,in_id(i,j),INF);
				}
			}
		}
	}
	int ret=M.max_flow(S,T);
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 2944
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll h, w, k;

int main() {
    cin >> h >> w >> k;

    VVl dp(h+1, Vl(w, 0));
    dp[0][0] = 1;
    REP2(i, 1, h+1) {
        REP(bit, 1 << (w-1)) {
            bool f = false;
            REP(j, w-2) {
                if ((bit & (3 << j)) == (3 << j)) f = true;
            }
            if (f) continue;

            REP(j, w) {
                if (j != 0 && (bit & (1 << (j-1)))) {
                    dp[i][j-1] += dp[i-1][j];
                    dp[i][j-1] %= MOD;
                } else if (j != w-1 && (bit & (1 << j))) {
                    dp[i][j+1] += dp[i-1][j];
                    dp[i][j+1] %= MOD;
                } else {
                    dp[i][j] += dp[i-1][j];
                    dp[i][j] %= MOD;
                }
            }
        }
    }
    cout << dp[h][k-1] << '\n';

    return 0;
}


Measured memory_bytes: 256
package main

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

var (
	m = make(map[int]int)
	n int
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()

	x := 0
	for sc.Scan() {
		x, _ = strconv.Atoi(sc.Text())
		m[x]++
	}

	max := 0
	tmp := 0
	for k := range m {
		tmp = m[k-1] + m[k] + m[k+1]
		if max < tmp {
			max = tmp
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    long long K;
    cin >> S >> K;
    
    bool judge = true;
    for (long long i = 0; i < K; ++i) {
        if (i >= S.size()) break;
        if (S[i] != '1') judge = false;
    }
    if (judge) {
        cout << 1 << endl;
        return 0;
    }
    rep(i, 100) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import Foundation

func readDoubles() -> [Double] {
   return readLine()!.split(separator: " ").map { Double($0)! }
}


func main(){
    let ab = readLine()!.split(separator: " ").map { String($0) }
    
    let a = NSDecimalNumber(string: ab[0])
    let b = NSDecimalNumber(string: ab[1])
    let x = a.multiplying(by: b)
    print(x.intValue)
}

main()



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

int main(){
  string s;cin>>s;
  bool f=0;
  if(s.at(2)==s.at(3)){
    if(s.at(4)==s.at(5)) f=1;
  }

  cout<<(f?"Yes":"No");
}

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

const int N = 100000;
int for_erat[N];
set<int> prime;

void erat(){
    for(int i = 0; i < N; i++){
        for_erat[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(for_erat[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                for_erat[i *(j + 2)] = 0;
            }
        }
    }

    for(int i = 2; i < N; i++){
        if(for_erat[i]){
            prime.insert(i);
        }
    }
}


int main(){
    erat();
    int q;
    cin >> q;

    vector<int> v(100010);
    for(int i=1; i<100010; i++){
        if(i%2 == 1 && prime.find(i) != prime.end() && prime.find((i+1)/2) != prime.end()){
            v[i+1]++;
        }
    }

    for(int i=0; i<100010; i++) v[i+1] += v[i];
    cout << endl;
    for(int i=0; i<q; i++){
        int l, r;
        cin >> l >> r;
        cout << v[r+1] - v[l] << endl;
    }
}

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

int main() {
	int N;
	cin >> N;
	vector<int> vec1(N);
	vector<int> vec2(N);
	vector<int> vec3(N);

	for (int i = 0; i < N; i++) {
		cin >> vec1.at(i);
	}

	int count = 0;
	for (int i = 1; i < N; i++) {
		if (vec1.at(i) < vec1.at(i - 1)) {
			count++;
			vec2.at(count - 1) = i;
		}
	}

	vec3 = vec1;
	sort(vec3.begin(), vec3.end());

	int n = vec2.at(0) - 1;
	int m = vec2.at(1);

	if (count > 2)
		cout << "NO" << endl;
	else if (count == 0)
		cout << "YES" << endl;
	else {
		swap(vec1.at(n), vec1.at(m));
		if (vec1 == vec3)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]

dic = {}

for word in s:
	if word not in dic:
		dic[word] = 1
	else:
		dic[word] += 1

# 書かれた回数の最大値
value_max = max(dic.values())
# print(value_max)


ans = [k for k, v in dic.items() if v==value_max]
ans = sorted(ans)

for a in ans:
	print(a)

Measured memory_bytes: 35216
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
string s;
string t;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>s;
    cin>>t;
    int ans=0;
    for (int i=0; i<s.length(); i++){
        if (s[i]!=t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    string t;
    for(char c : s) {
        if(t.empty() or c != t.back()) {
            t += c;
        }
    }
    cout << t.size() << endl;
    return 0;
}


Measured memory_bytes: 592
def unitmat(n):
    return [[int(i==j) for i in range(n)] for j in range(n)]
def matadd(A,B):
    h=len(A); w=len(A[0])
    C=[[A[i][j]+B[i][j] for j in range(w)] for i in range(h)]
    return C
def matmul(A,B):
    h=len(A)
    w=len(B[0])
    l=len(B)
    C=[[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            for k in range(l):
                C[i][j]+=A[i][k]*B[k][j]
    for i in range(h):
        for j in range(w):
            C[i][j]%=mod
    return C
def matpow(A,k):
    n=len(A)
    B=unitmat(n)
    while k:
        if k&1:
            B=matmul(B,A)
        A=matmul(A,A)
        k>>=1
    return B

l,a,b,mod=map(int,input().split())
X=[[0],[a],[1]]
maxdigit=18
Idx=[0]*(maxdigit+1)
for i in range(maxdigit+1):
    if 10**i-1<a:
        continue
    Idx[i]=min((10**i-1-a)//b+1,l)
for i in range(1,maxdigit+1):
    f=[[10**i,1,0],[0,1,b],[0,0,1]]
    X=matmul(matpow(f,Idx[i]-Idx[i-1]),X)
print(X[0][0])

Measured memory_bytes: 42736
#include<iostream>
#include<string>
using namespace std;
int main() {
	int m=0,f=0,r=0;
	char s;
	while(1){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1)break;
		if((m==-1||f==-1)||((m+f)<30)){
			s='F';
		}
		else if(80<=(m+f)){
			s='A';
		}
		else if(65<=(m+f)){
			s='B';
		}
		else if(50<=(m+f)){
			s='C';
		}
		else if(30<=(m+f)){
			s='D';
			if(50<=r){
				s='C';
			}
		}
		else if((m==-1||f==-1)||((m+f)<30)){
			s='F';
		}
		cout<<s<<endl;
		
	}
}



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

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  
  if (a + b > c) {
    cout << "No" << endl;
  }
  else if (4*a*b < (c-a-b)*(c-a-b)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
ans1 = 0
sign = True
total = 0
for i in range(len(A)):
    if sign:
        if total + A[i] >= 0:
            ans1 += total + A[i] + 1
            total = -1
        else:
            total += A[i]
    else:
        if total + A[i] <= 0:
            ans1 += 1 - (total + A[i])
            total = 1
        else:
            total += A[i]
    sign = total > 0
ans2 = 0
sign = False
total = 0
for i in range(len(A)):
    if sign:
        if total + A[i] >= 0:
            ans2 += total + A[i] + 1
            total = -1
        else:
            total += A[i]
    else:
        if total + A[i] <= 0:
            ans2 += 1 - (total + A[i])
            total = 1
        else:
            total += A[i]
    sign = total > 0
print(min(ans1, ans2))


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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] x = new int[N * 3];
        for (int i = 0; i < x.length; ) {
            x[i++] = in.i();
            x[i++] = in.i();
            x[i++] = in.i();
        }

        int x0 = 0;
        int y0 = 0;
        int h0 = 0;
        for (int i = 0; i < x.length; ) {
            x0 = x[i++];
            y0 = x[i++];
            h0 = x[i++];
            if (0 < h0) {
                break;
            }
        }

        for (int Cx = 0; Cx <= 100; Cx++) {
            loop: for (int Cy = 0; Cy <= 100; Cy++) {
                int H = h0 + Math.abs(Cx - x0) + Math.abs(Cy - y0);
                for (int i = 0; i < x.length; ) {
                    int h = Math.max(H - Math.abs(Cx - x[i++]) - Math.abs(Cy - x[i++]), 0);
                    if (h != x[i++]) {
                        continue loop;
                    }
                }
                System.out.printf("%d %d %d\n", Cx, Cy, H);
                return;
            }
        }
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 34320
T=!!0
F=!T
[T,F].map{|c|
class<<c
alias:%:==
def!=x
!self|x
end
end
}
until(s=gets.tr"-=>*+","!%=&|")=~/#/
puts (0..2047).all?{|x|
eval s.tr'abcdefghijk',("%011b"%x).tr("01","TF")
}?'YES':'NO'
end

Measured memory_bytes: 13104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String b = scanner.next();
		if ("A".equals(b) || "T".equals(b)) {
			System.out.println("A".equals(b) ? "T" : "A");
		}
		if ("C".equals(b) || "G".equals(b)) {
			System.out.println("C".equals(b) ? "G" : "C");
		}
		scanner.close();
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define   vpll   vector<pll >
#define   all(x) x.begin(),x.end()
#define   present(c,x)    ((c).find(x) != (c).end())
#define   dbg(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){
  std::cerr << name << " = " << arg1 << "\n";
}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
#define   sz(a)  a.size()
#define   vll vector<int>
#define   pll pair<int,int>
#define   ff  first
#define   ss  second
#define   br  cout<<"\n";
#define   ld  long double
#define   int  long long int
const int  INF = 1e18+7;
const int  MAX = 1234567;
const int  MOD = 1000000007;



void solve(){
	int n , m ;
	cin >> n >> m ;
	int tmp = n * ( n - 1 ) ;
	tmp /= 2 ;
	int ans = max ( 0ll , tmp )  ;
	tmp = m * ( m - 1 ) ;
	tmp /=2 ;
	ans += max ( 0ll , tmp )  ;
	cout << ans ;
}
int32_t main(){
    int t;
    t=1;
    // #ifndef ONLINE_JUDGE
    //     freopen ("input.txt","r",stdin);
    //     freopen ("output.txt","w",stdout);  
    // #endif
    cin.sync_with_stdio(0), cin.tie(0);
    //cin>>t;
    while(t--){
        solve();
        br;
    }
    return 0;
}
 
 
 
 
 
 

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        a: i64,
        b: i64,
        x: i64,
    };
    let x_a = if a == 0 { -1 } else { (a - 1) / x };
    let x_b = b / x;
    let ans = x_b - x_a;
    println!("{}", ans);
}


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

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		char c;
		cin >> c;
		if (c == 'Y')
		{
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 3548
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m =MAP()
graph = defaultdict(set)
for _ in range(m):
    temp1, temp2 = MAP()

    graph[temp1].add(temp2)
    graph[temp2].add(temp1)

visited = [0]*(n+1)

q = deque()

q.append(1)
visited[1] = -1
while(q):
    popped = q.popleft()

    for child in graph[popped]:
        if(visited[child]==0):
            q.append(child)
            visited[child] = popped
visited = visited[2:]

if(0 in visited):
    print("No")
else:
    print("Yes")
    for el in visited:
        print(el)

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

using namespace std;

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

const int N = int(6e5) + 5;
const int inf = (int)1e9 + 7;

int binpow(int n, int k){
  if(k == 0){
    return 1 % inf;
  }
  int z = binpow(n, k / 2);
  z = z * 1ll * z % inf;
  if(k & 1){
    z = z * 1ll * n % inf;
  }
  return z;
}

int n;
int a[N], u[N], p1, p2;
int f[N], rf[N];

int cnk(int n, int k){
  if(n < k){
    return 0;
  }
  return (f[n] * 1ll * rf[k] % inf) * 1ll * rf[n - k] % inf;
}

int main(){
  scanf("%d", &n);
  f[0] = 1;
  rf[0] = 1;
  for(int i = 1; i <= n * 2 + 3; ++i){
    f[i] = f[i - 1] * 1ll * i % inf;
    rf[i] = (binpow(i, inf - 2) * 1LL * rf[i - 1]) % inf; 
  }
  for(int i = 1; i <= n + 1; ++i){
    scanf("%d", a + i);
    if(u[a[i]]){
      p2 = i;
      p1 = u[a[i]];
    }
    u[a[i]] = i;
  }
  printf("%d\n", n);
  // sum cnk(a, x) * cnk(b, len - x)
  for(int len = 2; len <= n + 1; ++len){
    int ans = cnk(n + 1, len);
    int tot = p1 - 1 + (n + 1) - p2;
    ans -= cnk(tot, len - 1);
    if(ans < 0){
      ans += inf;
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 8192
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> v = new ArrayList<>();
        for (int i=0;i<n;i++){
            v.add(scanner.nextInt());
        }
        Collections.sort(v);
        double ans = (((double)v.get(0)) + ((double)v.get(1)))/2;
        for (int i=2;i<n;i++){
            ans = (ans + ((double)v.get(i)))/2;
        }
        System.out.println(ans);

    }

}

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

using namespace std;
	
int a[30];

int main()
{
	int a,d=0,ans1=0,ans=0;
	cin >> a;
	string s,b;
	cin >> s >> b;
	for(int i=a-1;i>=0;i--)
	{	
		d=i;
		for(int j=0;j<a;j++)
		{
			if(s[d] == b[j])
			{
				ans++;
				d++;
			}
			else 
			{
				break;
			}
			if(d>(a-1))
				break;
		}
		ans1=max(ans,ans1);
		ans=0;
	}
	cout <<(2*a)-ans1;
}

 



Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(string &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll a,b,k ;
	cin >> a >> b >> k ;
	for(int i=0;i<k;i++){
		if(i&1){
			b -= (b&1) ;
			a += b/2 ;
			b /= 2 ;
		}else{
			a -= (a&1) ;
			b += a/2 ;
			a /= 2 ;
		}
	}
	cout << a << " " << b << endl ;
}


Measured memory_bytes: 256
N, K = map(int, input().split())  #数字
A = [list(map(int, input().split())) for i in range(K*2)]  #数字、複数行複数列

cou = []
for i in range(len(A)):
    if (i+1) % 2 == 0:
#        print(i)
        for j in A[i]:
#            print(j)
            cou.append(j)   

#print(cou)
print(N - len(set(cou)))

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, K;
	cin >> H >> W >> K;

	vector<string> S(H);
	for (int i = 0; i < H; ++i) {
		cin >> S[i];
	}

	vector<vector<int>> acc(H, vector<int>(W, 0));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (S[i][j] == '1') {
				acc[i][j] += 1;
			}
			if (i > 0) {
				acc[i][j] += acc[i - 1][j];
			}
			if (j > 0) {
				acc[i][j] += acc[i][j - 1];
			}
			if (i > 0 && j > 0) {
				acc[i][j] -= acc[i - 1][j - 1];
			}
		}
	}

	auto cnt = [&](int r1, int c1, int r2, int c2) {
		int ans = acc[r2][c2];
		if (r1 > 0) {
			ans -= acc[r1 - 1][c2];
		}
		if (c1 > 0) {
			ans -= acc[r2][c1 - 1];
		}
		if (r1 > 0 && c1 > 0) {
			ans += acc[r1 - 1][c1 - 1];
		}
		return ans;
	};

	int ans = H * W;
	for (int h_mask = 0; h_mask < (1 << (H - 1)); ++h_mask) {
		int result = 0;
		vector<int> a;
		a.push_back(0);
		for (int i = 0; i < H - 1; ++i) {
			if (h_mask & (1 << i)) {
				a.push_back(i + 1);
			}
		}
		a.push_back(H);
		const int M = a.size();

		result = a.size() - 2;

		bool possible = true;
		for (int j = 0; j < W; ) {
			int x;
			for (x = 0; j + x + 1 <= W; ++x) {
				int width = x + 1;
				bool ok = true;
				for (int k = 0; k + 1 < M; ++k) {
					int num = cnt(a[k], j, a[k + 1] - 1, j + width - 1);
					if (num > K) {
						ok = false;
						break;
					}
				}
				if (!ok) {
					break;
				}
			}
			if (x == 0) {
				possible = false;
				break;
			}
			j += x;
			if (j < W) {
				++result;
			}
		}

		if (possible) {
			ans = min(ans, result);
		}
	}
	cout << ans << endl;
}


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

int main(void)
{
    string S;
    cin >> S;
    set<char> characters;
    for (int i = 0; i < S.length(); i++) {
        characters.insert(S[i]);
    }
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < 26; i++) {
        auto search = characters.find(alphabet[i]);
        if (search == characters.end()) {
            cout << alphabet[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 3664