akhauriyash/Code-Regression huggingface dataset:
// tokiomarine2020_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    REP(k, K){

        vector<int> imos(N+1);
        vector<int> B(N);
        REP(i, N){
            int l = max(0, i - A[i]);
            int r = min(N, i + A[i] + 1);
            imos[l]++;
            imos[r]--;
        }
        int cumsum = 0;
        REP(i, N){
            cumsum += imos[i];
            B[i] = cumsum;
        }
        A = B;

        bool end = true;
        REP(i, N){
            if (A[i] != N) end = false;
        }
        if (end) break;
    }
    print_line(A, N);

    return 0;
}


Measured memory_bytes: 5528
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}


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

  ll N ;cin >> N;
  vector<ll> a;
  rep(i,N){
    ll inp; cin >> inp;
    a.pb(inp);
  }
  rmsame(a);
  cout << a.size() << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

__int128 lmodpower(__int128 a, __int128 r, __int128 mod){ //a^r
    __int128 x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

__int128 lmodinv(__int128 a, __int128 mod){
    return lmodpower(a, mod-2, mod);
}

vector<__int128> eval(vector<__int128> &A, __int128 x, int depth, int K, int c, __int128 mod) {
    if (depth == K) {
        if (c < (int)A.size()) return {A[c]};
        else return {0};
    }
    __int128 xx = x*x%mod;
    vector<__int128> even = eval(A, xx, depth+1, K, c, mod);
    vector<__int128> odd = eval(A, xx, depth+1, K, c + (1<<depth), mod);
    vector<__int128> res(1<<(K-depth));
    __int128 y = 1;
    for (int i = 0; i < (1<<(K-depth-1)); i++) {
        __int128 f1 = even[i], f2 = y*odd[i]%mod;
        res[i] = f1+f2;
        if (res[i] >= mod) res[i] -= mod;
        int im = i+(1<<(K-depth-1));
        res[im] = f1-f2;
        if (res[im] < mod) res[im] += mod;
        y = y*x%mod;
    }
    return res;
}


vector<ll> FFT(vector<__int128> &A, vector<__int128> &B) {
    int d = A.size()+B.size()-1;
    int K = 1;
    while ((1<<K) < d) K++;
    __int128 lmod = 59785854321;
    lmod <<= 24;
    lmod += 1; // lmod = 1003040191687950337 (prime)
    __int128 proot = lmodpower(7, (lmod-1)>>K, lmod);
    __int128 m = lmodinv(1<<K, lmod);
    
    vector<__int128> eval_a = eval(A, proot, 0, K, 0, lmod);
    vector<__int128> eval_b = eval(B, proot, 0, K, 0, lmod);
    vector<__int128> mul(1<<K, 0);
    for (int i = 0; i < (1<<K); i++) {
        mul[i] = eval_a[i]*eval_b[i]%lmod;
    }

    vector<__int128> lres = eval(mul, lmodinv(proot, lmod), 0, K, 0, lmod);
    for (int i = 0; i < (1<<K); i++) {
        lres[i] = lres[i] * m % lmod;
    }
    
    vector<ll> res(1<<K);
    ll mask = (1LL<<62)-1;
    for (int i = 0; i < (1<<K); i++) res[i] = (ll)(lres[i]&mask);
    return res;
}

int main() {
    int N;
    cin >> N;
    ll mod = 200003;
    vector<int> A(N, 0), B(mod, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    
    ll g = 1;
    vector<__int128> cnt(mod, 0);
    for (int i = 0; i < mod-1; i++) {
        cnt[i] = B[g];
        g *= 2;
        g %= mod;
    }
    
    vector<ll> fft = FFT(cnt, cnt);
    g = 1;
    ll ans = 0;
    for (int i = 0; i < N; i++) ans -= ((ll)A[i]*A[i])%mod;
    for (int i = 0; i < (int)fft.size(); i++) {
        ans += fft[i]*g;
        g *= 2;
        g %= mod;
    }
    ans /= 2;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 57080
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

T = input()
if T[:-1] == S:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 9976
a,b,c,d=map(int, input().split())
count = 0
num=b-a+1
import fractions
lcm= int(c*d / fractions.gcd(c,d))
ac=(a-1)//c
ad=(a-1)//d
acd=(a-1)//lcm

bc=b//c
bd=b//d
bcd=b//lcm

print(num-((bc+bd-bcd)-(ac+ad-acd)))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


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

    int N; cin >> N;
    vector<pair<int, int>> A(N);
    rep(i,N){
        int a; cin >> a;
        A[i].fs = a; A[i].sc = i+1;
    }
    sort(all(A));
    rep(i,N) {
        cout << A[i].sc << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
 
 
int main()
{
	char i;
	scanf("%c", &i);
	if (i == 'S') {
		printf("Cloudy\n");
	}
	if (i == 'C') {
		printf("Rainy\n");
	}
	if (i == 'R') {
		printf("Sunny\n");
	}
    return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hmk = readln.split.to!(int[]);
    auto h1 = hmk[0];
    auto m1 = hmk[1];
    auto h2 = hmk[2];
    auto m2 = hmk[3];
    auto K = hmk[4];

    auto s = h1 * 60 + m1;
    auto e = h2 * 60 + m2;
    auto r = e - K - s;
    writeln(r);
}

Measured memory_bytes: 2672
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n,h; cin>>n>>h;
    vector<ll>a(n);
    vector<ll>b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    ll A=a[0];
    ll cnt=0;
    ll ans=0;
    rep(i,n){
        if(A<b[i]){
            cnt++;
            ans+=b[i];
            if(ans>=h){
                cout<<cnt<<endl;
                return 0;
            }
    }
    else break;
}
ll remain=h-ans;
cnt+=(h-ans+A-1)/A;
cout<<cnt<<endl;
}



















































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

#define ll long long
#define pb push_back
#define eb emplace_back
#define REP(i, n) for(int i=0;i<(n);++i)
#define caset int ___T; cin >> ___T; while(___T--)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define fast_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

void solve() {
	int n;
	cin >> n;

	vector <int> v(n);
	REP(i, n) cin >> v[i];

	sort(all(v));

	multiset <vector <int>> st;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			for (int k = j+1; k < n; ++k) {
				if (v[i] == v[j] || v[j] == v[k] || v[i] == v[k]) {
					continue;
				} else {
					if (v[i] + v[j] > v[k]) {
						vector <int> temp = {v[i], v[j], v[k]};
						st.insert(temp);
					}
				}
			}
		}
	}

	cout << st.size() << endl;
}

int main() {
	fast_IO;

	solve();

	cout << flush;
}


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

int main() {
  int s;
  cin >> s;
  vector<long> a(1000000);
  a.at(0) = s;
  for(long i = 1; i < 1000000;i++){
    if(a.at(i-1) %2 == 0){
      a.at(i) = a.at(i-1) /2;
    }else{
      a.at(i) = a.at(i-1) *3 +1;
    }
  }
  int ans = 0;
  for(long i = 0;i < 1000000;i++){
    for(long j = i+1;j < 1000000;j++){
      if(a.at(i) == a.at(j)){
        ans = j + 1;
        cout << ans << endl;
        break;
      }
    }
    if(ans > 0){
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int[] aji = new int[N];
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			aji[i] = L + i;
			sum += aji[i];
		}
		
		int[] ans = new int[N];
		int sa = 1000000000;
		int x = 0;
		
		for(int i = 0; i < N; i++) {
			ans[i] = sum - aji[i];
			if(sa > Math.abs(sum - ans[i])) {
				sa = Math.abs(sum - ans[i]);
				x = i;
			}
		}
		
		System.out.println(ans[x]);
	}
}


Measured memory_bytes: 21332
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n, r;
		int p, c;
		int[] deck;
		int[] ptemp, ctemp;
		while (true) {
			n = sc.nextInt();
			r = sc.nextInt();
			if (n == 0 && r == 0) break;
			deck = new int[n];
			ptemp = new int[n];
			ctemp = new int[n];
			for (int i = 0; i < n; i++)
				deck[i] = n-i;
			for (int i = 0; i < r; i++) {
				p = sc.nextInt();
				c = sc.nextInt();
				for (int j = 0; j < p-1; j++)
					ptemp[j] = deck[j];
				for (int j = 0; j < c; j++)
					ctemp[j] = deck[p-1+j];
				
				for (int j = 0; j < c; j++)
					deck[j] = ctemp[j];
				for (int j = 0; j < p-1; j++)
					deck[c+j] = ptemp[j];
			}
			out.println(deck[0]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 31052
#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 { return mint(-x);}
  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;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = f(n);
  ans -= 1;
  ans -= choose(n,a);
  ans -= choose(n,b);
  cout << ans.x << endl;
  return 0;
}


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

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  int answer = 0, temp;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (i == j || j == k || k == i) continue;
        temp = v[i] * 10 + v[j] + v[k];
        answer = max(temp, answer);
      }
    }
  }
  cout << answer;
  return 0;
}

Measured memory_bytes: 256
/*
             ██████  ██████
             ██   ██ ██   ██
 Author ->   ██████  ██   ██
             ██      ██   ██
             ██      ██████
 
    nik is love.
    nik is motivation.
    Use modulus operator very carefully.
    Watch for integer overflows.
*/
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                   1000000007
#define eps                   0.000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> val(300010,1),vis(300010,0),dis(300010,-1),mini(300010,inf);
vector<pair<int,int>> adj[110];
int seg[5010][5010];
int myrandom (int i) { return std::rand()%i;}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int a,b,c;
    cin>>a>>b>>c;
    set<int> st={a,b,c};
    if((int)st.size()==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
ll dp[1000001];
ll h[2000001];
ll dpp(ll n){
  if(dp[n]!=-1) return dp[n];
  dp[n]=min(abs(h[n]-h[n-1])+dpp(n-1),abs(h[n]-h[n-2])+dpp(n-2));
  return dp[n];
}
int main(){
  ll t;
  cin>>t;
  fop(i,0,t) cin>>h[i];
  fop(i,0,1000000) dp[i]=-1;
  dp[1]=abs(h[1]-h[0]);
  dp[2]=abs(h[2]-h[0]);
  cout<<dpp(t-1)<<endl;
}


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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    string result1,result2;
    int a,b;
    cin>>a>>b;
   
        for(int i=0;i<b;i++)
        {
            result1+=to_string(a);
        }    
    
    
        for(int i=0;i<a;i++)
        {
            result2+=to_string(b);
        }    
    if(result1<result2)
    cout<<result1<<endl;
    else
    {
        cout<<result2<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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 ll INF = 1e18+1;


int main() {
   ll N;
   cin >> N;
    
   ll res = INF;
   for (ll i = 1; i * i <= N; i++) {
       if (N % i == 0) {
           ll j = N / i;
           chmin(res, i - 1 + j - 1);
       }
   }
   cout << res << endl;


    
}

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

int main() {
  string str;
  while(getline(cin,str)){
    for(int i = 0;i < 26;i++){
      for(int i = 0;i <str.size();i++){
        if(isalpha(str[i]))
          str[i] = (str[i]=='z')? 'a' : str[i] + 1;
      }
      if(str.find("the") !=string::npos||str.find("that") !=string::npos||
         str.find("this") !=string::npos){
        cout <<str<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1180
#include<cstdio>
#include<cmath>

using namespace std;

int main(void){
	double x,h;
	while(scanf("%lf%lf", &x, &h) && x != 0 && h != 0 ){
		double y = sqrt( (x/2)*(x/2) + h*h );
		printf("%lf\n",2*y*x+x*x);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int dist(int x1, int y1, int x2, int y2)
{
	int x = x1 - x2;
	int y = y1 - y2;
	return x * x + y * y;
}
int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int N, X, Y, x[1024], y[1024];
		scanf("%d%d%d", &N, &X, &Y);
		for (int i = 0; i <= N; ++i)
			scanf("%d%d", x + i, y + i);


		vector<int> edge[1024];
		for (int i = 1; i <= N; ++i)
			if (dist(x[0], y[0], x[i], y[i]) <= 100)
				edge[0].push_back(i);

		for (int i = 1; i <= N; ++i)
			for (int j = i + 1; j <= N; ++j)
				if (dist(x[i], y[i], x[j], y[j]) <= 2500)
					edge[i].push_back(j), edge[j].push_back(i);

		int dis[1024];
		fill_n(dis, N + 1, -1);
		queue<int> q;
		q.push(0);
		dis[0] = 0;
		while (!q.empty())
		{
			int v = q.front(); q.pop();
			for (int i = 0; i < edge[v].size(); ++i)
			{
				int to = edge[v][i];
				if (dis[to] < 0)
				{
					q.push(to);
					dis[to] = dis[v] + 1;
				}
			}
		}
		int m = *max_element(dis, dis + (N + 1));
		if (m > 1 && X > Y)
			puts("You're always welcome!");
		else
			printf("%d\n", X * m);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X, Y;
  cin >> X >> Y;

  string ans;
  if (abs(X-Y) >= 2) {
    ans = "Alice";
  } else {
    ans = "Brown";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
int n, k;
int dp[200][50000][2];
signed main() {
	cin >> k >> n;
	int ans = 0;
	int res = 0;
	for (int i = 1; i * i <= k; i++) {
		dp[0][i][0] = i;
		dp[0][i][1] = k / i;
		res++;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j * j <= k; j++) {
			dp[i][j][0] = dp[i - 1][j][1];
			if (j == res) {
				dp[i][j][1] = ((k / j) - j) * dp[i - 1][j][0] % mod;
			}
			else {
				dp[i][j][1] = ((k / j) - (k / (j + 1))) * dp[i - 1][j][0] % mod;
			}
		}
		for (int j = 1; j * j <= k; j++) {
			(dp[i][j][0] += dp[i][j - 1][0]) % mod;
		}
		(dp[i][res][1] += dp[i][res][0]) %= mod;
		for (int j = res - 1; j >= 1; j--) {
			(dp[i][j][1] += dp[i][j + 1][1]) %= mod;
		}
	}
	cout << dp[n - 1][1][1] << endl;
}

Measured memory_bytes: 81536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, a, b, c;
  cin >> A;

  a = A / 100;
  b = (A - 100 * a) /10;
  c = (A - 100 * a - 10 * b);
  cout << a + b + c << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>
#define N 100


int main()
{
  int i,j,a[N],n,v,c = 0,min,flag = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<=n-1;i++){
    min = i;
    flag = 0;
    for(j=i;j<n;j++){
      if(a[j]<a[min]){
	min = j;
	flag = 1;
      }/* 最小値の変更 */
    }
    if(flag == 1){
      v = a[i];
      a[i] = a[min];
      a[min] = v;	
      c++;
    }/* 最小値が変った場合、値を交換 */
  }
  
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}




Measured memory_bytes: 2136
n, m = list(map(int, input().split()))
if m > 0:
  a = set([int(input()) for i in range(m)])
else:
  a = set([])

if n == 1:
  pat = 1
else:
  pt = [1]
  if (1 in a):
    pt.append(0)
  else:
    pt.append(1)

  for i in range(2, n + 1):
    if (i in a):
      pt.append(0)
    else:
      if (i-1 in a):
        pt.append(pt[i-2])
      else:
        pt.append(pt[i-1] + pt[i-2])

  pat = (pt[-1] % 1000000007)
print(pat)


Measured memory_bytes: 460020
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

bool calc(vector<int> &a, vector<int> &b) {
    int d = a.size();
    int c = 0;
    for (int i = 0; i < d; ++i) {
        c += (a[i] - b[i]) * (a[i] - b[i]);
    }
    for (int i = 0; i < 1000; ++i) {
        if (c == i*i) return true;
    }
    return false;
}

int main() {
    int n, d;
    cin >> n >> d;
    vector<vector<int>> a(n, vector<int>(d));
    for (auto &e: a) for (auto &ee: e) cin >> ee;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (calc(a[i], a[j])) ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod (lint)1000000007
#pragma endregion

int n;
vector<int> d;
void input() {
	cin >> n;
	d.resize(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	return;
}

int main(void) {
	input();
	int cnt = 0;
	for (int i = 0; i < n; i++) cnt += d[i];
	if (cnt % 10 != 0) cout << cnt << endl;
	else {
		int c = mod;
		for (int i = 0; i < n; i++) {
			if (d[i] % 10 != 0) 
				c = min(c, d[i]);
		}
		if (c == mod) cout << 0 << endl;
		else cout << cnt - c << endl;
	}

	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

typedef long long ll;

int main(void)
{
	ll n, i, ans = 0;

	scanf("%lld", &n);

	for (i = 1; i <= n; i++)
		ans += (n / i + 1) * (n / i) / 2 * i;

	printf("%lld", ans);
	return 0;
}

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

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

  if(b % a == 0) {
    cout << a + b << '\n';
  } else {
    cout << b - a << '\n';
  }
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
vector<int> color;
using ll = long long;
// white 0, black 1

bool dfs(int cn, int cn_color){
    color[cn] = cn_color;
    for (auto next: G[cn]){
        if (color[next] != -1) {
            if (color[next] == cn_color) return false;
            continue;
        }
        if (!dfs(next, 1 - cn_color)) return false;
    }
    return true;
    // bool ok = true;
    // for (auto next: G[cn]){
    //     if (color[next] == -1) {
    //         color[next] = 1 - cn_color;
    //         ok = dfs(next, color[next]);
    //         continue;
    //     }
    //     if (cn_color == color[next]) return false;
    //     else continue;
    // }
    // return ok;
}

int main() {
    ll N, M;
    cin >> N >> M;
    G.resize(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    color.assign(N, -1);
    bool is_bipartite = dfs(0, 0);
    ll ans = 0;
    ll B = 0;
    if (is_bipartite) {
        B = count(color.begin(), color.end(), 1);
        ans = B * (N - B) - M;
    }
    else ans = (N - 1) * N / 2 - M;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

vector <vector <int>> g;
vector <vector <ll>> ans;

void dfs(int u, int p=-1)
{
    ans[u][0] = 1;
    ans[u][1] = 1;
    for (auto v:g[u])
    {
        if (v==p)
            continue;
        dfs(v, u);
        ans[u][0] *= (ans[v][0] + ans[v][1]);
        ans[u][1] *= ans[v][0];
        ans[u][1] %= MOD;
        ans[u][0] %= MOD;
    }
}

int main()
{
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n, vector <ll> (2, 0));
    for (int i=0; i<n-1; ++i)
    {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0);

    cout << (ans[0][0] + ans[0][1]) % MOD;
    return 0;
}

Measured memory_bytes: 18176
def solve():
    H, W = list(map(int, input().split(" ")))
    field = []
    for _ in range(H):
        field.append(list(input()))
    answer = [[None] * W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if field[i][j] == ".":
                cnt = 0
                for x in [-1, 0, 1]:
                    for y in [-1, 0, 1]:
                        dx = i + x
                        dy = j + y
                        if dx >= 0 and dx < H and dy >=0 and dy < W and field[dx][dy] == "#":
                            cnt += 1
                    answer[i][j] = cnt
            else:
                answer[i][j] = "#"


    for i, col in enumerate(answer):
        answer[i] = [str(x) for x in col]

    for col in answer:
        print("".join(col))
        
        
solve()

Measured memory_bytes: 3188
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    int ptr=0;
    int cnt=0;
    while(ptr<n){
            cnt++;
        while(s[ptr+1]==s[ptr]){
            ptr++;
        }
    ptr++;
    }
cout<<cnt;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        if(!mp.count(s)){
            mp[s] = 1;
        }
    }
    cout << mp.size() << endl;
}


Measured memory_bytes: 19064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	ll s;
	scanf("%lld",&s);
	ll m=sqrt(s);
	if(m*m<s)m++;
	while(1){
		ll r=m*m-s;
		rep(i,1,1000)if(r%i==0&&r/i<1e9){
			printf("0 0 %lld %lld %lld %lld",m,i,r/i,m);
			return 0;
		}
		m++;
	}
}

Measured memory_bytes: 128
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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;
}




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int INF = 1100100100;
    int N;cin >> N;
    VI H(N);
    REP(i,N) {
        int tmp;
        cin >> tmp;
        H[N-1-i] = tmp;//backword;
    }
    REP(i,N) cerr << H[i]<<endl;
    int res = INF;
    REP(i,N){
        cerr << "i= " << i << endl;
        cerr << res<< endl;
        if(H[i] > res+1){
            cout << "No" << endl;
            return;
        }
        chmin(res,H[i]);
    }
    cout << "Yes" << endl;
    return;
}



// ----------------------------------------------
int main(){

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 1e5+5,mod=1e9+7;
int dp[N][2];
vi adj[N];
int add(ll a,ll b){
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
int mul(ll a,ll b){
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
int solve(int u,int p,bool color){
    int &ret = dp[u][color];
    if(~ret)
        return ret;
    ret=1;
    For(v,adj[u]){
        if(v==p)
            continue;
        ll now = solve(v,u,0);
        if(!color)now=add(now,solve(v,u,1));
        ret=mul(ret,now);
    }
    return ret;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> v >> u;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    clr(dp, -1);
    cout << add(solve(1, -1, 0), solve(1, -1, 1));
}

Measured memory_bytes: 18044
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  
  int d = a-b ;
  
  if ((a-b) > c) cout << 0 ;
  int res = c - ( a - b );
  if ((a-b) <= c) cout << res;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
 
    int x, y, q, r;
    long long int a,b,z;
 
    while(scanf("%lld %lld", &a, &b)!=EOF){
 
    x = a;
    y = b;
 
    if(x < 0) x = -x;
    if(y < 0) y = -y;
    for(;;){
        q = x/y;
        r = x - q*y;
        if(r == 0) break;
        x = y;
        y = r;
    }
    z=a*b/y;
    printf("%d %lld\n",y,z);
    }
    return 0;
}


Measured memory_bytes: 2044
--[[------------------------------------------------------------------------]]--
local function floor_sum(elm_num, div_num, mul_num, add_num, result)
	local ans = 0
	if mul_num >= div_num then
		ans = ans + (elm_num - 1) * elm_num * (mul_num // div_num) // 2
		mul_num = mul_num % div_num
	end
	if add_num >= div_num then
		ans = ans + elm_num * (add_num // div_num)
		add_num = add_num % div_num
	end

	local y_max = (mul_num * elm_num + add_num) // div_num
	local x_max = (y_max * div_num - add_num)
	if y_max <= 0 then
		return ans + (result or 0)
	else
		ans = ans + (elm_num - (x_max + mul_num - 1) // mul_num) * y_max
		return floor_sum(
			y_max, mul_num, div_num,
			(mul_num - x_max % mul_num) % mul_num, ans + (result or 0)
		)
	end
end
--[[------------------------------------------------------------------------]]--

local read = io.read
local t = read("n")

local out_t = {}
for i = 1, t do
	out_t[i] = floor_sum(read("n", "n", "n", "n"))
end
print(table.concat(out_t, "\n"))


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

int main() {
    long long K;
    cin >> K;
    long long M = 7 % K;
    vector<bool> done(K, false);
    int c = 1;
    while (true) {
        if (M % K == 0) {
            cout << c << endl;
            return 0;
        } else if (done[M]) {
            cout << -1 << endl;
            return 0;
        } else {
            done[M] = true;
            c++;
            M = (M * 10 + 7) % K;
        }
    }
}


Measured memory_bytes: 3732
#include<stdio.h>
int main(void){
    int N,i,j,gen,ans=0,Tall=0,Isok=0;
    int ban[510][510]={0};
    int Tkei[510]={0};
    int Ykei[510]={0};
    char c;
    char mozi[510];
    scanf("%d",&N);
    for(i=1;i<=N;i++){
        scanf("%s",mozi);
        for(j=1;j<=N;j++){
            c=mozi[j-1];
            if(c==0x2e){ban[i][j]=0;}
            if(c==0x23){ban[i][j]=1;Ykei[i]++;Tkei[j]++;Isok=1;}
        }
        
    }
    if(Isok==0){printf("-1\n");return 0;}
    for(j=1;j<=N;j++){
        if(Tkei[j]==N){Tall++;}
    }
    gen=0;
    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            if(ban[i][j]==1){//Ykeiの最大値を求める
                if(Ykei[j]>gen){gen=Ykei[j];}
            }
        }
        if(Ykei[i]-1>gen){gen=Ykei[i]-1;}
    }
    ans=(N-Tall)+(N-gen);
    printf("%d\n",ans);
    return 0;
}
    

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

using namespace std;
#define ll long long int

int main()
{
    ll n,m;
    cin >> n >> m;
    if(n%2==1){
        for(int i=1;i<=m;i++){
            cout << i << " " << (n-i) << endl;
        }
    }
    else{
        int k = (m+1)/2;
        for(int i=1;i<=k;i++){
            cout << i << " " << (n-i+1) << endl;
        }
        for(int i=k+1;i<=m;i++){
            cout << i << " " << (n-i) << endl;
        }
    }
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n,m;
  cin>>n>>m;

  int ans = (n * (n - 1) / 2) + (m * (m - 1) / 2);
  ANS(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
   int a , b , c , y;
   
   cin >> a >> b >> c;
   
   if(a > b){
      y = a;
      a = b;
      b = y;
      
   }
   
   if(b > c){
      y = b;
      b = c;
      c = y;

   }
   
   if(a > b){
      y = a;
      a = b;
      b = y;
      
   }
   
   cout << a << " " << b << " " << c << endl;
   
   return 0;
} 

Measured memory_bytes: 0
n = int(input())
A = list(map(int, input().split()))
q = int(input())
nums = list(map(int, input().split()))

sum_set = set()
for i in range(1, 2 ** n):
    total = 0
    for j in range(n):
        if i >> j & 1:
            total += A[j]
    sum_set.add(total)

for num in nums:
    print('yes' if num in sum_set else 'no')



Measured memory_bytes: 5648
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll n;
ll mpow(ll x, ll y) {
  ll sum = 1;
  REP(i, y) {
    sum = (sum * x) % mod;
  }
  return sum;
}

ll solve() {
  if(n == 1) return 0;

  ll ans = (mpow(10, n) - ((mpow(9, n) * 2) % mod) + mpow(8, n)) % mod;
  if(ans < 0) ans += mod;
  return ans;
}

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

  cin >> n;
  ll ans = solve();
  cout << ans << endl;
}


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

int main()
{
	int h[100000];
	int dp[100000];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);

	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))



ll n,k;
ll a[100010];
int main(){
	scanf("%lld%lld",&n,&k);
	rep(i,0,n){
		ll p,q;
		scanf("%lld%lld",&p,&q);
		a[p]+=q;
	}
	ll cnt=0;
	rep(i,1,100010){
		cnt+=a[i];
		if(cnt>=k){
			printf("%lld\n",i);
			return 0;
		}
	}
}

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

using namespace std ;
int n , m ;
string s ;
const int N = 1e5 + 10 ;
int a[N] , q[N] , pre[N] , f[N] ;
int ans[N] ;
signed main() {
  ios :: sync_with_stdio(false) ;
  cin.tie(nullptr) ; cout.tie(nullptr) ;
  cin >> n >> m ;
  cin >> s ;
  int h , t ; q[h = t = 0] = 0 ;
  for(int i = 0 ; i <= n ; i ++) a[i] = s[i] & 15 ;
  for(int i = 0 ; i <= n ; i ++) {
    if(a[i]) continue ;
    while(h <= t && q[h] + m < i) ++ h ;
    if(h > t) { cout << -1 << '\n' ; return 0 ; }
    pre[i] = q[h] ; f[i] = f[q[h]] + 1 ;
    while(h <= t && f[q[t]] > f[i]) t -- ;
    q[++ t] = i ;
  }
  int now = n ;
  int top = 0 ;
  ans[++ top] = n ;
  while(now) { ans[++ top] = pre[now] ; now = pre[now] ; }
  top -- ;
  int last = 0 ;
  while(top) {
    cout << ans[top] - last << ' ' ;
    last = ans[top --] ;
  }
  return 0 ;
}

Measured memory_bytes: 2640