akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    for(int i=0;i<s.length();++i) {
        if(i % 2) {
            if(s[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(s[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


////////////////////////////////////////////////////////////////////




int main() {
string s;
cin>>s;
int k;
cin>>k;

int n=s.size();
ll dp0[n+1][k+1];
ll dp1[n+1][k+1];
for(int i=0;i<=n;i++){
	for(int j=0;j<=k;j++){
dp0[i][j]=0;
dp1[i][j]=0;


	}
}

dp0[0][0]=0;
dp1[0][0]=1;

for(int i=1;i<=n;i++){
	for(int j=0;j<=k;j++){

char y=s[i-1];

ll r=y-'0';

if(j==0){
	dp0[i][j]=1;
	dp1[i][j]=0;
	continue;
}


if(r){
	dp0[i][j]=dp1[i-1][j]+dp1[i-1][j-1]*(r-1)+dp0[i-1][j]+dp0[i-1][j-1]*9;
dp1[i][j]=dp1[i-1][j-1];
}
if(r==0){
	dp0[i][j]=dp0[i-1][j-1]*9+dp0[i-1][j];
	dp1[i][j]=dp1[i-1][j];
}

	
	}
}



ll ans;
ans=dp0[n][k]+dp1[n][k];
cout<<ans<<endl;
return 0;



}

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

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

int main(){
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
            }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> div = divisor(m);

    ll ans = 1;

    for(auto v : div){
        ll k = m / v;
        if (k >= n) ans = max(ans, v);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<cmath>
double pi=acos(-1.0);
using namespace std;
int main(){
    int a,b,x;
    double tanp,ans;
    cin>>a>>b>>x;
    double v,temp;
    v=a*a*b*1.0;
    if(x>=v/2){
        temp=2.0*(v-x)/a/a;
        tanp=temp/a;
    }
    else if(x<v/2){
        temp=2.0*x/a/b;
        tanp=b/temp;
    }
    ans=atan(tanp);
    ans=ans*180.0/pi;
    printf("%.10f",ans);
    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 v   = vector<int>;
using vv  = vector<v>;
using P   = pair<ll,ll>;
using vp  = vector<P>;
using vvp = vector<vp>;

int main(){
    ll n,m;
    cin>>n>>m;
  
  vp ab(n);
  rep(i,n)cin>>ab[i].first>>ab[i].second;
  
  sort(ab.begin(), ab.end());
  
  ll count = 0;
  ll ans = 0;
  rep(i,n){
    if(ab[i].second>m){
      ans += m*ab[i].first;
      break;
    }
    else{
      ans += ab[i].second * ab[i].first;
      m -= ab[i].second;
    }
  }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a != c){
        cout << "1" << endl;
    }else{
        cout << 0 << endl;
    }

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Integer> train = new ArrayList<>();
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int num = sc.nextInt();
			if (num == 0) {
				System.out.println(train.get(train.size() - 1));
				train.remove(train.size() - 1);
			} else {
				train.add(num);
			}
		}
		sc.close();
	}
}



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

//コピペここから

// extended Euclidean Algorithm
// ax + by = gcd(a, b)
// return : gcd(a, b)
template<typename Integer = int_fast64_t>
constexpr Integer extgcd(Integer a, Integer b, Integer &x, Integer &y){
    Integer u = 0, v = 1, q = 0, tmp = 0;
    x = v = 1;
    y = u = 0;

    while(b){
        q = a / b;
        x ^= u ^= x ^= u;
        u = u - q * x;
        y ^= v ^= y ^= v;
        v = v - q * y;
        a ^= b ^= a ^= b;
        b = b - q * a;
    }

    return a;
}

// mod inverse(設計が変わるかもしれません)
// return : val^(-1) mod MOD
template<uint_fast64_t MOD, typename Integer = int_fast64_t>
constexpr Integer modinv(Integer val){
    int_fast64_t ret = 0, tmp = 0;

    extgcd<int_fast64_t>(static_cast<int_fast64_t>(val), static_cast<int_fast64_t>(MOD), ret, tmp);

    return static_cast<Integer>(ret > 0 ? ret % MOD : (MOD - (-ret % MOD)));
}

// const expression factorial mod MOD
template<std::size_t N, std::uint_fast64_t MOD>
struct Fact {
    std::uint_fast64_t val[N + 1];

    constexpr Fact() : val() {
        val[0] = 1;
        for (std::size_t i = 1; i <= N; ++i) val[i] = val[i - 1] * i % MOD;
    }
};

// const expression factorial inverse mod MOD
template<std::size_t N, std::uint_fast64_t MOD, std::uint_fast64_t F>
struct IFact {
    std::uint_fast64_t val[N + 1];

    constexpr IFact() : val() {
        val[N] = F;
        for (std::size_t i = N; i; --i) val[i - 1] = val[i] * i % MOD;
    }
};

constexpr std::uint_fast64_t MOD = 998244353, maxN = 300000;

constexpr auto fact = Fact<maxN, MOD>();
constexpr auto ifact = IFact<maxN, MOD, modinv<MOD>(fact.val[maxN])>();

// const expression binomial mod MOD
constexpr std::uint_fast64_t binommod(std::uint_fast64_t n, std::uint_fast64_t r){
    if(r < 0 || r > n)return 0;
    return fact.val[n] * (ifact.val[r] * ifact.val[n - r] % MOD) % MOD;
}

//コピペここまで(ある部分を使うためにはそれより上を全てコピーしてください)

//verified : AtCoder Grand Contest 025 B - RGB Coloring

long long int N, M, A, B, K, ans;

int main(){
    using namespace std;
    scanf("%lld%lld%lld%lld", &N, &A, &B, &K);
    M = min(N, K / A);
    for(int i = 0; i <= M; ++i){
        if((K - i * A) % B == 0){
            ans += binommod(N, i) * binommod(N, (K - i * A) / B);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  int n; cin>>n;
  vector<double> v(n);
  rep(i,n) cin>>v[i];
  sort(v.begin(),v.end());
  
  double ans=v[0];
  rep(i,n){
    ans=(ans+v[i+1])/2;
  }
  cout<<fixed<<setprecision(5)<<ans*2<<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n,w;
    cin>>n>>w;
    vector<vector<ll>> dp(2,vector<ll>(w+1));
    vector<pii> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i].ff>>v[i].ss;
    }
    dp[0][v[0].ff]=v[0].ss;
    ll answer=v[0].ss;
    for(int i=1; i<n; i++){
        for(int j=0; j<=w; j++){
            dp[i%2][j]=dp[1-(i%2)][j];
            if(j-v[i].ff<0) continue;
            dp[i%2][j]=max(dp[i%2][j],dp[1-(i%2)][j-v[i].ff]+v[i].ss);
            answer=max(answer,dp[i%2][j]);
        }
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 5584
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
mod_list = []
for i in l:
  mod_list.append((i-1)%10)
last = l.pop(mod_list.index(min(mod_list)))
s = 0
for i in l:
  s += ((i-1)//10 + 1) * 10
s += last
print(s)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  if((r*100 + g*10 + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int INF = 1e9;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/




int main(){
	FASTIO
	
	int n, m;
	cin >> n >> m;
	
	//for (int i = 0; i < n; ++i) {
		//for (int j = 1; j <= n; ++j) {
			//cout << (i + j) % (n) + ((i + j) % n == 0 ? n : 0)  << " ";
		//}
		//cout << endl;
	//}
	
	
	if (n & 1) {
		for (int i = 1; i <= m; ++i) {
			cout << i << " " << n - i << endl;
		}
	}
	else {
		int odd = (m + 1) / 2;
		for (int i = 1; i <= odd; ++i) {
			cout << i << " " << n - i + 1 << endl;
		}
		for (int i = odd + 1; i <= m; ++i) {
			cout << i << " " << n - i << endl;
		}
	}
    return 0;
}

/*

*/


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  int ans = 0;
  REP(i, N+1){
    if(i%5 == 0 || i%3 == 0){
    }else{
      ans += i;
    }
  }

  cout << ans << "\n";

  return 0;
}

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

using namespace std;

int main(){
	int n;	cin>>n;
	while(n--){
		int g[9],j[9];
		for(int i=0;i<9;i++)	cin>>g[i];
		for(int i=0;i<9;i++)	cin>>j[i];

		sort(j,j+9);

		int cnt=0;
		do{
			int sc=0;
			for(int i=0;i<9;i++)	if(g[i]>j[i])	sc+=g[i]+j[i];
			if(sc>=86)	cnt++;
		}while(next_permutation(j,j+9));

		cout<<cnt/362880.<<' '<<1-cnt/362880.<<endl;
	}

	return 0;
}

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


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   
    int num, res; 
    int n= 5;
    for(int i=0; i<5; ++i){
        cin >> num;
        if(num==0){
            cout << i+1 << endl;
            return 0;
        } else if (num==i+1){
           res = num;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3580
N, K, C = map(int, input().split())
S = input()[::-1]
Top = []
Bottom = []
yasumi = 0
ans = []
k = K
for i in range(N):
    if (yasumi == 0) and (S[i] == "o") and (k > 0):
        Bottom.append(N-i)
        yasumi += C
        k -= 1
    elif yasumi > 0:
        yasumi -= 1

S_ = S[::-1]
Bottom.sort()
j = -1
yasumi = 0
for i in range(N):
    if (yasumi == 0) and (S_[i] == "o") and (K > 0):
        j += 1
        yasumi += C
        K -= 1
        if j >= len(Bottom):
            break
        elif Bottom[j] == i+1:
            ans.append(i+1)
    elif yasumi > 0:
        yasumi -= 1

for i in ans:
    print(i)

Measured memory_bytes: 20960
#include<stdio.h>

#define N 100
#define INF 1000000

int x,A[N],B[N][N],C[N][N],D[N];

void funk(int,int);

int main() {
  int i,j,k;

  scanf("%d",&x);

  for(i = 0; i < x; i++) {
    scanf("%d",&k);
    scanf("%d",&A[k]);
    for(j = 0; j < A[k]; j++) {
      scanf("%d",&B[k][j]);
      scanf("%d",&C[k][j]);
    }
  }

  for(i = 0; i < x; i++) {
    D[i] = INF;
  }

  funk(0,0);

  for(i = 0; i < x; i++) {
    printf("%d %d\n",i,D[i]);
  }

  return 0;
}

void funk(int x,int y) {
  int i;
  D[x] = y;
  for(i = 0; i < A[x]; i++) {
    if(D[B[x][i]] > y + C[x][i]) {
      funk(B[x][i],y + C[x][i]);
    }
  }
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) break;
        a -= d;
        if (a <= 0) break;
    }

    cout << ((a <= 0)  ? "No" : "Yes") << endl;

    return 0;
}
 

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	cout << "ABC" << N << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  if(a>b)cout<<"Alice"<<endl;
  else if(a==b)cout<<"Draw"<<endl;
  else cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
function main(input){
  const lines = input.split('\n');
  const S = lines.shift().split('');
  const T = lines.shift().split('');

//  console.log(S);
//  console.log(T);

  dp = []
  for(var i=0;i<=S.length;i++){
    dp.push( Array(T.length+1).fill(0) );
  }

  for(var i=1;i<=S.length;i++){
    for(var j=1;j<=T.length;j++){
      if(S[i-1]==T[j-1]){
        dp[i][j]=Math.max(dp[i][j], dp[i-1][j-1]+1);
      }else{
        dp[i][j]=Math.max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }

  var i = S.length;
  var j = T.length;
  var result = [];
  while(i!=0 &&  j!=0){
//  console.log([i,j]);
//  console.log([S[i-1],T[j-1]]);
    if(S[i-1]==T[j-1]){
      result.unshift(S[i-1]);
      i--;
      j--;
    }else{
      if(dp[i-1][j] < dp[i][j-1]){
        j--;
      }else{
        i--;
      }
    }
  }

//  console.log(dp);
  console.log(result.join(''));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 101808
local function getgcd(x, y)
  while 0 < x do
    x, y = y % x, x
  end
  return y
end

local n, k = io.read("*n", "*n")
local gcd = io.read("*n")
local max = gcd
local mma = math.max
for i = 2, n do
  local t = io.read("*n")
  gcd = getgcd(gcd, t)
  max = mma(max, t)
end
local r = k % gcd == 0 and k <= max
print(r and "POSSIBLE" or "IMPOSSIBLE")


Measured memory_bytes: 760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int result = 0;

		if(n % 1000 == 0) {
			result = 0;
		}else {
			result = 1000 - (n % 1000);
		}

		System.out.println(result);

	}

}


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

using namespace std;

int main() {

	const string wheather[3] = { "Sunny", "Cloudy", "Rainy" };

	string in;
	cin >> in;

	if (in == wheather[0])		cout << wheather[1];
	else if (in == wheather[1])	cout << wheather[2];
	else if (in == wheather[2])	cout << wheather[0];


	return 0;
}


Measured memory_bytes: 256
N=int(input())
f=lambda c:sum([list(map(lambda z:z+y,f(c-1))) for y in '357'],[]) if c!=0 else ['']
print(sum([len(list(filter(lambda y:y==3,list(map(lambda x:len(set(sorted(x))),filter(lambda z:int(z)<=N,f(e+1))))))) for e in range(10)]))


Measured memory_bytes: 9424
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

bool ok(vector<int> &A) {
    rep(i, A.size()) {
        if(A[i] > 1) return false;
    }
    return true;
}

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<vector<int>> B(N + 1, vector<int>(20, 0));
    rep(i, N) {
        rep(j, 20) {
            B[i + 1][j] = (A[i] >> j) & 1;
        }
    }
    
    rep(i, 1, N + 1) {
        rep(j, 20) {
            B[i][j] += B[i - 1][j];
        }
    }
    
    ll ans = 0;
    rep(i, 1, N + 1) {
        int l = i, r = N + 1;
        while(r - l > 1) {
            int m = (l + r) / 2;
            vector<int> C(20);
            rep(j, 20) {
                C[j] = B[m][j] - B[i - 1][j];
            }
            if(ok(C)) {
                l = m;
            }
            else r = m;
        }
        ans += l - i + 1;
    }
    output(ans);
    
    
    
    
    return 0;
}


Measured memory_bytes: 24448
def rot(x,y):
    return -y, x

x1,y1,x2,y2 = map(int, input().split())
x3,y3 = rot(x2-x1, y2-y1)
x3+=x2
y3+=y2
x4,y4 = rot(x3-x2, y3-y2)
x4+=x3
y4+=y3
print(x3,y3,x4,y4)

Measured memory_bytes: 38256
fun main( args : Array<String> ) {
  val bs = readLine()!!
  for(i in (bs.length - 2 downTo 0) ) {
    val check = bs.slice(0..i)
    if( check.length % 2 == 1 ) continue
    if( check.slice(0..i/2) == check.slice(i/2+1..i) ) {
      println(check.length)
      break
    }
  }
}

Measured memory_bytes: 31880
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
int cmp(LL a,LL b,LL c,LL d)
{
	if (a==c)
	{
		return c-d;
	}
	else
	{
		return a-c;
	}
}
int main()
{
	LL i,j,k,a,b,c,ans;
	scanf("%lld%lld",&a,&b);
	ans=0;
	for (i=1;i<=12;i++)
	{
		if (cmp(i,i,a,b)<=0)
		{
			ans+=1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
ll mul(ll a, ll b){
    return ((a%mod) * (b%mod))%mod;
}
ll power(ll a, ll b){
    ll z = 1; ll x = a;
    while(b>0){
        if (b&1)z = mul(z, x);
        x = mul(x, x);
        b >>= 1;
    }
    return z;
}
int main()
{
    int n;
    cin>>n;
    map<string, int> m;
    m["AC"] = 0, m["WA"] = 0, m["TLE"] = 0, m["RE"] = 0;
    while(n--){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC "<<"x "<<m["AC"]<<endl;
    cout<<"WA "<<"x "<<m["WA"]<<endl;
    cout<<"TLE "<<"x "<<m["TLE"]<<endl;
    cout<<"RE "<<"x "<<m["RE"]<<endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------

/// problem's variable---------------



///--------------------------

int main()
{
    Phuong_;
    int a,b;
    cin >> a >> b;
    for(int i=1; i<=max(a,b); ++i) cout << min(a,b);
    return 0;
}



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

#define int long long
#define mod 1000000007

int f(int i, int j){
    return (abs(i) > abs(j));
}

signed main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n, f);
    // for(int i = 0; i < n; i++){
    //     cout << a[i] << ' ';
    // }
    int ans = 1;
    if((*max_element(a, a + n) <= 0 && (k&1)) || (k == n)){
        reverse(a, a + n);
        for(int i = 0; i < k; i++){
            ans *= a[i];
            ans %= mod;
        }
        cout << ((ans + mod) % mod) << '\n';
    }
    else{
        bool x = 0;
        for(int i = 0; i < k; i++){
            x ^= (a[i] < 0);
            if(a[i] == 0){
                cout << "0";
                return 0;
            }
            
        }
        int pos_pos = -1, pos_neg = -1;
        int rep_pos = -1, rep_neg = -1;
        for(int i = 0; i < k; i++){
            if(a[i] >= 0)
                pos_pos = i;
            else
                pos_neg = i;
        }
        for(int i = k; i < n; i++){
            if(a[i] >= 0){
                rep_pos = i;
                break;
            }
        }
        for(int i = k; i < n; i++){
            if(a[i] <= 0){
                rep_neg = i;
                break;
            }
        }
        // cout << pos_pos << ' ' << pos_neg << ' ' << rep_pos <<' ' << rep_neg << '\n';
        if(x){
            bool should_take_pos = 0;
            if(pos_pos == -1 || rep_neg == -1){
                should_take_pos = 0;
            }
            else{
                if(pos_neg == -1 || rep_pos == -1){
                    should_take_pos = 1;
                }
                else{
                    if(-(a[rep_neg] * a[pos_neg]) > -(a[rep_pos] * a[pos_pos])){
                        should_take_pos = 0;
                    }
                    else{
                        should_take_pos = 1;
                    }
                }
            }
            if(should_take_pos){
                swap(a[rep_neg], a[pos_pos]);
            }
            else{
                swap(a[rep_pos], a[pos_neg]);
            }
        }
        for(int i = 0; i < k; i++){
            ans *= a[i];
            ans %= mod;
        }
        cout << ((ans + mod) % mod) << '\n';
        
    }
    
}

Measured memory_bytes: 5192
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=jp
// Recursion / Divide and Conquer - Exhaustive Search

#define SUBMIT

#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
using i64 = long long;

int main() {
    int n, q;

    vector<int> A;
    vector<int> m;
    set<int> s;
#ifdef SUBMIT
    cin >> n;
    A.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    cin >> q;
    m.resize(q);
    for (int i = 0; i < q; ++i) {
        cin >> m[i];
    }
#else
    n = 5, q = 4;
    A = {1, 5, 7, 10, 21};
    m = {2, 4, 17, 8};
#endif

    for (int bit = 0; bit < (1 << n); ++bit) {
        auto sum = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) sum += A[i];
        }

        s.insert(sum);
    }

    for (const auto& m_i : m) {
        if (s.find(m_i) != s.end()) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
'use strict'
function main(inp) {
  inp = inp.trim().split(' ').map(x=> x*1);
  if(inp[0] > inp[1]){
  	console.log("safe");
  } else {
    console.log("unsafe");
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29628
#include <iostream>
#include <vector>

#define FOR(i,n) for(int i=0;i<n;i++)
#define FORI(i,z,n) for(int i=z;i<n;i++)
#define MAX(a,b,c) max(a,max(b,c))

using namespace std;

struct Obj {int weight; int value;};

int main () {
    int N, W;
    cin >> N >> W;

    vector<Obj> objects(N);
    FOR(i,N) {
        int v, w;
        cin >> v >> w;
        objects[i] = Obj{w, v};
    }

    vector<vector<int> > dyn(N+1, vector<int>(W+1, 0));

    FOR(i, N)
        FOR(w, W) {
            int x = i+1;
            int y = w+1;
            dyn[x][y] = MAX(
                    dyn[x-1][y],
                    dyn[x][y-1],
                    (objects[i].weight <= y ? dyn[x-1][y-objects[i].weight] + objects[i].value : 0)
                    );
        }

    cout << dyn[N][W] << endl;
}



Measured memory_bytes: 6808
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cassert>

using namespace std;
int N;

struct Disk {
  int x;
  int y;
  int r;
  int c;
  Disk(int x, int y, int r, int c) : x(x), y(y), r(r), c(c) {}
};

int tree[30];
char dp[1 << 24];

vector<Disk> disk_list;

double dist(int x1, int y1, int x2, int y2) {
  int dx = x1 - x2;
  int dy = y1 - y2;
  return dx * dx + dy * dy;
}

bool intersect(int i, int j) {
  double d = dist(disk_list[i].x, disk_list[i].y, disk_list[j].x, disk_list[j].y);
  double r2 = (disk_list[i].r + disk_list[j].r);
  return d < r2 * r2; 
}

void print_state(int state) {
  for (int i = 0; i < N; i++) {
    if (state & (1 << i)) {
      printf("%d ", i);
    }
  }
  printf("\n");
}

int _solve(int state) {
  int mx = 0;
  //print_state(state);
  
  for (int i = 0; i < N; i++) {
    if ((1 << i) & state) {
      for (int j = i + 1; j < N; j++) {
        if ((1 << j) & state) {
          if (disk_list[i].c == disk_list[j].c && 
              (tree[i] & state) == 0 &&
              (tree[j] & state) == 0) {
            //printf("i, j = %d, %d\n", i, j);
            int cur_state = state;
            cur_state &= ~(1 << i);
            cur_state &= ~(1 << j);
            if (dp[cur_state] > 0) {
              mx = max(dp[cur_state] + 2, mx);
            } else {
              int res = _solve(cur_state);
              dp[cur_state] = res;
              mx = max(res + 2, mx);
            }
          }
        }
      }
    }
  }
  //printf("end\n");
  return mx;
}

void solve() {
  int state = (1 << N) - 1;
  fill(dp, dp + sizeof(dp), -1);
  printf("%d\n", _solve(state));
}

void make_tree() {
  fill(tree, tree + 30, 0);
  for (int i = 0; i < N; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (intersect(i, j)) {
        tree[i] |= (1 << j);
      }
    }
  }
  /*
  for (int i = 0; i < N; i++) {
    printf("%d:", i);
    for (int j = 0; j < N; j++) {
      if (tree[i] & (1 << j)) {
        printf("%d ", j);
      }
    }
    printf("\n");
  }
  */
}

int main() {
  while (true) {
    scanf("%d ", &N);
    disk_list.clear();
    if (N == 0) {
      return 0;
    }
    for (int i = 0; i < N; i++) {
      int x, y, r, c;
      scanf("%d %d %d %d ", &x, &y, &r, &c);
      disk_list.push_back(Disk(x, y, r, c));
    }
    make_tree();
    solve();
  }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int H, W; cin >> H >> W;
  vstr S(H); cin >> S;
  vector<vi32> xsums(H + 2, vi32(W + 2));
  vector<vi32> ysums(H + 2, vi32(W + 2));
  reps(i, H) reps(j, W) {
    if (S[i - 1][j - 1] == '#') continue;
    xsums[i][j] = xsums[i][j - 1] + 1;
    ysums[i][j] = ysums[i - 1][j] + 1;
  }
  rreps(i, H) rreps(j, W) {
    if (xsums[i][j] > 0) amax(xsums[i][j], xsums[i][j + 1]);
    if (ysums[i][j] > 0) amax(ysums[i][j], ysums[i + 1][j]);
  }
  int ans = 1;
  reps(i, H) reps(j, W) {
    amax(ans, xsums[i][j] + ysums[i][j] - 1);
  }
  cout << ans << '\n';
}


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

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
  int a,b;
  cin>>a>>b;
  int x=a+b;
  int y=a-b;
  int z=a*b;
  int ans=max(max(x,y),z);
  cout<<ans<<endl;

}

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

int main()
{
	char str[1001];
	
	while (1) {
		scanf("%s",str,1001);
		int sum = 0;
		if (strcmp(str,"0")==0) {
			break;
		}
		else {
			for (int i = 0; i < strlen(str); i++) {
				sum += (str[i] - '0');
			}
		}
		printf("%d\n", sum);

	}
	return 0;
}

Measured memory_bytes: 3192
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, K;
int A[MAX_N + 1];

int main(void)
{
  cin >> N >> K;
  REP(i, N) cin >> A[i];
  int idx = 0;
  REP(i, N) if (A[i] == 1) idx = i;

  int L = idx, R = N - idx - 1;
  int ans = ceil((double)(R + L) / (K - 1));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import bisect
import numpy as np

n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

small = []
big = []

for x in b:
    small.append(bisect.bisect_left(a, x))
    big.append(n-bisect.bisect(c, x))

small = np.array(small)
big = np.array(big)

print(np.sum(small*big))


Measured memory_bytes: 34044
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

int N;
ll x[200000], y[200000];
ll X[200000], Y[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
        X[i] = x[i]+y[i];
        Y[i] = x[i]-y[i];
    }
    sort(X, X+N);
    sort(Y, Y+N);
    cout << max(X[N-1]-X[0], Y[N-1]-Y[0]) << endl;
}

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

vector<int>num(3);

int main() {
    cin >> num[0] >> num[1] >> num[2];
    sort(num.begin(), num.end());
    int res = 0;
    res += num[2] - num[1];
    num[0] += res; num[1] += res;
    int temp = num[1] - num[0];
    if (temp % 2) res += temp/2+2;
    else res += temp/2;
    cout << res << endl;
}

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

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n,k;
	cin>>n>>k;
	ll i;ll a;
	for(i=0;i<n;i++)cin>>a;
	cout<<(n-1+k-2)/(k-1);	
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
b=sum(a)/n
c=0
d=abs(a[0]-b)
for i in range(n):
 if(abs(a[i]-b)<d):
  c=i
  d=abs(a[i]-b)
 else:
  continue
print(c)


Measured memory_bytes: 3064
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn main() {
    input!{
        x: u64,
        y: u64,
        z: u64,
    }
    println!("{}", (x - z) / (y + z));
}


Measured memory_bytes: 4352
H,W,B,A = map(int, input().split())
for i in range(H):
    ans = ""
    for j in range(W):
        if i < A:
            if j < B:
                ans += '1'
            else:
                ans += '0'
        else:
            if j < B:
                ans += '0'
            else:
                ans += '1'
    print(ans)

      

Measured memory_bytes: 4084
# -*- coding: utf-8 -*-

N = int(input().strip())
a_list = [int(i) for i in input().rstrip().split()]
#-----

def gcd(a,b):
    x = max(a,b)
    y = min(a,b)

    while y != 0:
        r = x % y
        
        x = y
        y = r
    
    return x

ans = a_list[0]
for i in a_list[1:]:
    ans = gcd(ans, i)

print(ans)


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

  int main() {
    string S,T;
    cin >> S >> T;
    int N;
    N = S.size();
    int count=0;
    if(T.size()!=N+1){
      count++;
    }
    for(int i=0;i<N;i++){
      if(S.at(i)!=T.at(i)){
        count++;
      }
    }
    if(count>0){
      cout << "No";
    }
    else{
      cout << "Yes";
    }
  }




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

const int N = 1 << 20;

int debug = 0;

int nv = 2, temp, a[N], lst[N], p[N], root[N * 30];
struct node { int sl, sr, val; } t[N * 30];

void build(int v, int vl, int vr) {
    if (vr - vl == 1) { t[v] = {0, 0, 0}; return; }
    int vm = (vl + vr) >> 1;
    t[v] = {nv, nv + 1, 0};
    nv += 2;
    build(t[v].sl, vl, vm);
    build(t[v].sr, vm, vr);
}

void update(int pv, int v, int vl, int vr, int id, int nval) {
    if (vl > id || vr <= id) return;
    if (vr - vl == 1 && vl == id) { t[v] = {0, 0, nval}; return; }
    int vm = (vl + vr) >> 1;
    t[v] = t[pv];
    if (id < vm) { t[v].sl = nv++; update(t[pv].sl, t[v].sl, vl, vm, id, nval); }
    else         { t[v].sr = nv++; update(t[pv].sr, t[v].sr, vm, vr, id, nval); }
    t[v].val = t[t[v].sl].val + t[t[v].sr].val;
}

int get(int v, int vl, int vr, int l, int r) {
    if (l >= vr || vl >= r) return 0;
    if (l <= vl && vr <= r) return t[v].val;
    int vm = (vl + vr) >> 1;
    return get(t[v].sl, vl, vm, l, r) + get(t[v].sr, vm, vr, l, r);
}

int go(int v, int vl, int vr, int cnt) {
    if (vr - vl <= 1) return vl;
    int vm = (vl + vr) >> 1, cntl = t[t[v].sl].val;
    if (cntl >= cnt) return go(t[v].sl, vl, vm, cnt);
    return go(t[v].sr, vm, vr, cnt - cntl);
}

main() {
    int n, q, l, r;
    cin >> n >> q;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    fill(lst, lst + n + 2, -1);
    root[0] = nv++;
    build(root[0], 0, N);
    for (int i = 1; i <= n; ++i) {
        if (lst[a[i]] != -1) {
            p[lst[a[i]]] = 0;
            temp = nv++;
            update(root[i - 1], temp, 0, N, lst[a[i]], 0);
        } else {
            temp = root[i - 1];
        }
        p[i] = 1;
        lst[a[i]] = i;
        root[i] = nv++;
        update(temp, root[i], 0, N, i, 1);
    }
    vector <int> ans;
    while (q--) {
        cin >> l >> r;
        int res = get(root[r], 0, N, 0, r+1) - get(root[r], 0, N, 0, l);
        ans.push_back(res);
    }
    for (int i : ans)
        cout << i << '\n';
    return 0;
}

Measured memory_bytes: 283808
#include <cstdio>

int main()
{
	unsigned long N, K;
	scanf("%lu %lu", &N, &K);

	unsigned long mod = N % K;

	if(mod == 0) {
		printf("0");
	} else {
		unsigned long value = K - mod;
		if(mod < value) {
			printf("%lu", mod);
		} else {
			printf("%lu", value);
		}
	}

	return 0;
}

Measured memory_bytes: 128
n = int(input())
count = 1
total = 0
for i in range(1, n+1, 2):
    for j in range(1, i // 2+1):
        if i % j == 0:
            count += 1
    else:
        if count == 8:
            total += 1
        count = 1
print(total)


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

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}
int main() {
    INCANT;
    solve();
    return 0;
}




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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e9;


signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x;
    cin >> x;

    auto pw = [](int x){
      return x * x * x * x * x;
    };

    for (int i = -1000; i < 1000; i++){
      for (int j = -1000; j < 1000; j++){
        if (pw(i) - pw(j) == x){
          cout << i << ' ' << j << '\n';
          return 0;
        }
      }
    }

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    vector<int> V(5);
    for (int &i : V)
        cin >> i;
    for (int i = 0; i < 5; i++) {
        if (!V[i]) {
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}


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

int main() {
  string O, E;
  cin >> O >> E;

  string ans;
  for (int i = 0; i < O.length() + E.length(); i++) {
    if (i % 2 == 0) {
      ans.push_back(O.at(i / 2));
    } else {
      ans.push_back(E.at(i / 2));
    }
  }

  printf("%s", ans.c_str());
  return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
xy = []
N.times do |i|
  xy << gets.chomp.split(" ").map(&:to_i)
end


def dist(xy1, xy2)
  @dist ||= {}
  k = [xy1, xy2].sort
  @dist[k] ||= Math.sqrt((xy1[0] - xy2[0])**2 + (xy1[1] - xy2[1])**2)
end

sum_d = 0
n_pat = 0
(1..N).to_a.permutation(N).each do |pat|
  d = 0
  0.upto(pat.size - 2) do |x|
    i = pat[x]-1
    j = pat[x+1]-1
    d += dist(xy[i], xy[j])
  end
  sum_d += d
  n_pat += 1
end

puts sum_d / n_pat


Measured memory_bytes: 3836