akhauriyash/Code-Regression huggingface dataset:
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bpw(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}

ll ar[1<<17];

int main(){
	ll n; read(n);
	FER(i, 0, n-1) read(ar[i]);
	ll ans = 0;
	FER(i, 0, n-2){
		ans += min(ar[i], ar[i+1]);
	}
	// trace(ans);
	ans += ar[0] + ar[n-2];
	// trace(ar[0], ar[n-2];)
	// ans += max(ar[0], ar[n-2]);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    string s, t;
    cin>>s>>t;
    t.pop_back();
    puts(s == t? "Yes" : "No");
    
    return 0;
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(b<=c||d<=a) {cout<<0<<endl; return 0;}
  vector<int> x(4);
  x[0]=a;x[1]=b;x[2]=c;x[3]=d;
 sort(x.begin(),x.end());
  cout<<x[2]-x[1]<<endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    
    if (A > B) {
        if (A - 1 > B) {
            cout << A + A - 1;
        }
        else {
            cout << A + B;
        }
    }
    else if (A == B) {
        cout << A + B;
    }
    else {
        if (B - 1 > A) {
            cout << B + B - 1;
        }
        else {
            cout << A + B;
        }
    }
    
    cout << endl;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split())) 

ans = 10**19
num = []
arr = []

if not p:
    print(x)
    exit()

for i in range(min(p)-1, max(p)+2):
    if i in p:
        continue
    # if abs(x-i) >= ans:
    #     print(i)
    #     exit()
    # print(f'{i} {abs(x-i)}')
    num.append(i)
    arr.append([abs(x-i)])
    ans = abs(x-i)

mm = 10**10

for i in range(len(arr)-1):
    if arr[i] <= arr[i+1]:
        print(num[i])
        exit()

print(num[-1])
# for i in range(len(arr)-1):
#     print(arr[i][1])

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    bool odd[n] = {};

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        odd[a] ^= 1, odd[b] ^= 1;
    }

    bool can = true;
    rep(i, n) if (odd[i]) can = false;
    YES(can);
    return 0;
}



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

const int MAX = 210000;
const ll MOD = 1000000007;

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

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

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

    COMinit();
    int n, m, k;
    cin >> n >> m >> k;
    ll ans = COM(n * m - 2, k - 2);

    ll sub = 0;
    rep(i, n)
    {
        rep(j, m)
        {
            ll a = (ll)(i + j) * (ll)(n - i) * (ll)(m - j);
            if (j != 0 && i != 0)
                a *= 2LL;
            sub += a;
            sub %= MOD;
        }
    }
    ans *= sub;
    ans %= MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define endl '\n'
#define MAX 100002
#define pii pair<int, int>
#define pll pair<long long, long long>


typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vec;


int main(){
    int n;cin>>n;
    int x=n%10;
    if(x==2 or x==4 or x==5 or x==7 or x==9)
        cout<<"hon\n";
    else if(x==3)
        cout<<"bon\n";
    else
        cout<<"pon\n";

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    int i=0;
    while(A>0&&C>0){
        if(i%2==0){
            C=C-B;
        }
        if(i%2==1){
            A=A-D;
        }
        i++;
    }
    if(A<=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3624
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std::placeholders;

typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<bool, bool> pbb;
typedef std::pair<ld, ld> pdd;

const int inf = (int)1e9;
const ll linf = (ll) 1e18;
const ld eps = 1e-5;
const int mod = (int) 1e9 + 7;

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp std::make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

bool prime(int x)
{
	if (x == 1)
		return false;
	ld kek = sqrt(x);
	for (int i = 2; i <= kek; i++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}

int main()
{
	std::ios_base::sync_with_stdio(false);
	const int cap = (int)1e5;
	vi p(cap);
	for (int i = 1; i < cap; i++)
	{
		p[i] = p[i - 1];
		if (i % 2 == 1 && prime(i) && prime((i + 1) / 2))
			p[i]++;
	}
	int q;
	std::cin >> q;
	for (int i = 0; i < q; i++)
	{
		int l, r;
		std::cin >> l >> r;
		std::cout << p[r] - p[l - 1] << "\n";
	}
}



Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
  //
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << endl;
    ;
  } else if (s == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 760
#include<cstdio>
char s[10][10];
char a[10][10];

void copy(int n,int m){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++) a[i][j] = s[i][j];
    }
}

void doRow(int p,int m){
    for(int i = 1; i <= m; i++) a[p][i] = '.';
}

void doCol(int p,int n){
    for(int i = 1; i <= n; i++) a[i][p] = '.';
}

int getCnt(int n,int m){
    int res = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++) res += (a[i][j]=='#');
    }
    return res;
}

int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i = 1; i <= n; i++) scanf("%s",s[i]+1);
    int ans = 0;
    for(int i = 0; i < (1<<(n+m)); i++){
        copy(n,m);
        int mask = i;
        for(int j = 1; j <= n+m; j++){
            if(mask%2){
                if(j<=n) doRow(j,m);
                else doCol(j-n,n);
            }
            mask /= 2;
        }
        if(getCnt(n,m)==k) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;
typedef pair<int,int> P;

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    if(N % 2 == 1) {
        cout << "No" << endl;
    }
    else {
        bool cnt = true;
        for(int i = 0;i < N / 2;i++) {
            if(S.at(i) != S.at(N / 2 + i)) {
                cnt = false;
            } 
        }
        if(cnt == true) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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

int main(){
    string S;
    cin >> S;
    deque<char> dq;
    for(int i=0;i<S.size();i++)
        dq.push_back(S[i]);
    int Q;
    cin >> Q;

    bool inv = false;
    for(int i=0;i<Q;i++){
        int T;
        cin >> T;
        if(T == 1){     // 反転
            inv = !inv;
        }else{          // 追加
            int F;
            cin >> F;
            char C;
            cin >> C;
            if(F == 1){ // 先頭に追加
                if(inv)
                    dq.push_back(C);
                else
                    dq.push_front(C);
            }else{      // 末尾に追加
                if(inv)
                    dq.push_front(C);
                else
                    dq.push_back(C);
            }
        }
    }

    while(!dq.empty()){
        if(inv){
            cout << dq.back();
            dq.pop_back();
        }else{
            cout << dq.front();
            dq.pop_front();
        }
    }
    cout << endl;

}

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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int gcd3(int a, int b, int c)
{
  return(gcd(c,gcd(a,b)));
}

int main() {
  int n,s=0;

  cin >> n;

  rep1(i,n+1) rep1(j,n+1) rep1(k,n+1) s+=gcd3(i,j,k);
  cout << s << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define N 1000000
using namespace std;

bool prime[N+5]={0};
int a,d,n,cnt;

void sprime();

int main(){
  sprime();
  while(1){
    cin >> a >> d >> n;
    if(a+d+n==0)break;
    cnt=0;
    while(cnt<n){
      if(!prime[a])cnt++;
      a+=d;
    }
    cout << a-d << endl;
  }
  return 0;
}

void sprime(){
  int i,j;
  prime[0]=1;
  prime[1]=1;
  for(i=2;i<sqrt(N);i++)if(!prime[i])for(j=2;i*j<=N;j++)prime[i*j]=1;
}



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

int main()
{
   int n,a[101],v[101],sum=0;
   cin>>n;
   for(int i=1;i<=n-1;i++){ 
       cin>>a[i];
   } 
   v[1]=a[1];
   v[2]=a[1];
   for(int i=3;i<=n;i++){
       v[i]=a[i-1];
       if(v[i]>=v[i-1])continue;
       v[i-1]=v[i];
   } 
   for(int i=1;i<=n;i++)sum+=v[i];
   cout<<sum;
       
  
  
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N,P;
    ll odd = 0;
    cin >> N >> P;
    REP(i,N){
        int A;
        cin >> A;
        if(A%2 != 0) odd++;
    }
    ll ans;
    if(odd == 0){
        if(P==1) ans = 0;
        else ans = ((ll)1)<<N;
    }
    else ans = ((ll)1)<<(N-1);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int a, b, n;
    while( cin >> a >> b >> n ){
        int ans = 0;
        a = (a-a/b*b)*10;
        while( n-- > 0 ){
            ans += a/b;
            a = (a-a/b*b)*10;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int MAX=1e5+10;
vector<int> v(MAX, 1);

void soe() {
	v[0] = 0;
	v[1] = 0;
	for (int i=2; i<=sqrt(MAX); ++i) {
		if (v[i]) {
			for (int j=i*i; j<=MAX; j+=i) {
				v[j]=0;
			}
		}
	}	
}

int main() {
	int x; cin>>x;
	soe();
	while(!v[x]) {
		x++;
	}
	cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define ll long long
#define inf 999999999999
#define F first
#define S second
#define eb emplace_back
#define mp make_pair
#define P(x) cout<<__LINE__ <<": "<<#x<<' '<<(x)<<'\n'
#define dbg cout<<__LINE__ <<": 0manush\n"
#define read(x) freopen("input.txt","r",stdin)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 200009
#define mod 1000000007
using namespace std;
int main(){//read(x);
//fast;
ll a,b,d,g,h,i,l,j,k,n,t,x,y,z,e,p;
string s;
cin>>s;l=0;
for(i=0;i<s.size();i++){
    a=0;
    while(s[i]=='R'){
        a++;
        i++;
    }
    l=max(l,a);
}
cout<<l<<endl;
}


Measured memory_bytes: 3620
def solve():
    a, b, c, d = input()
    for bit in range(2 ** 3):
        o1, o2, o3 = ['+' if bit & (1 << i) == 0 else '-' for i in range(3)]
        stmt = ''.join([a,o1,b,o2,c,o3,d])
        if eval(stmt) == 7:
            return stmt + "=7"

print(solve())


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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    ll N,M,X;
    cin >> N >> M >> X;

    vector<pair<ll,vector<ll>>> books(N);
    for(int i=0;i<N;i++)
    {
        cin >> books[i].first;
        vector<ll> book(M);
        for(int j=0;j<M;j++) cin >> book[j];
        books[i].second = book;
    }

    ll minprice = 2000000001;

    for(unsigned int i=0;i<1<<N;i++)
    {
        vector<ll> test(M,0);
        ll price = 0;
        for(unsigned int j=0;j<N;j++)
        {
            unsigned int ij = i&(1<<j);
            if(ij==(1<<j))
            {
                for(unsigned int k=0;k<M;k++)
                {
                    test[k] += books[j].second[k];
                }
                price += books[j].first;
            }
        }
        bool TF = true;
        for(int i=0;i<M;i++)
        {
            if(test[i]<X) TF = false;
        }
        if(TF)
        {
            minprice = min(minprice,price);
        }
    }

    if(minprice==2000000001) cout << "-1" << endl;
    else cout << minprice << endl;

//    if(minprice == 2000000001) cout << "-1" << endl;
//    else cout << minprice << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#define int long long

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (const T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, m, s;
	cin >> n >> m >> s;
	s = min(s, 5000LL);
	vvi vis(n, vi(5001));
	vvi ans(n, vi(5001));
	vector<vector<pair<int, pii>>> M(n);
	rep(i,0,m)
	{
		int x, y, a, b;
		cin >> x >> y >> a >> b;
		x--, y--;
		M[x].push_back({y, {a, b}});
		M[y].push_back({x, {a, b}});
	}
	vi C(n), d(n);
	rep(i,0,n)
	{
		cin >> C[i] >> d[i];
		C[i] = min(C[i], 5000LL);
	}
	priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
	pq.push({0, {0, s}});
	while(!pq.empty())
	{
		int t = pq.top().F;
		int x = pq.top().S.F;
		int c = pq.top().S.S;
		pq.pop();
		if(vis[x][c])
			continue;
		ans[x][c] = t;
		vis[x][c] = true;
		for(auto z : M[x])
			if(z.S.F <= c)
				pq.push({t + z.S.S, {z.F, c - z.S.F}});
		pq.push({t + d[x], {x, min(c + C[x], 5000LL)}});
	}
	rep(i,1,n)
	{
		int m = LLONG_MAX;
		rep(j,0,5001)
			m = min(m, ans[i][j]);
		cout << m << '\n';
	}
}



Measured memory_bytes: 31696
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

void dfs(vector<vector<int>> &G, vector<int> &C, bool* seen, int n) {
    seen[n] = true;
    for (auto g : G[n]) {
        if (seen[g]) continue;
        C[g] += C[n];
        dfs(G, C, seen, g);
    }
}

int main() {
    int N, Q; cin >> N >> Q;
    vector<vector<int>> G(N);
    REP(i, 0, N - 1) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> counter(N);
    REP(i, 0, Q) {
        int p, q; cin >> p >> q;
        counter[--p] += q;
    }

    bool seen[N] = {};
    dfs(G, counter, seen, 0);

    REP(i, 0, N) cout << counter[i] << endl;

    return 0;
}

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

int main()
{
  int n, count=0;
  cin >> n;
  string s;
  char A='A', B='B', C='C';
  cin >> s;
  
  for(int i=2; i<=n; ++i)
  {
    if(s[i-2] == A && s[i-1] == B && s[i] == C)
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
# frozen_string_literal: true

$res = Array.new(1000,0)
def factrize(n)
  (2..Math.sqrt(n)).each do |i|
    while n % i == 0
      $res[i] += 1
      n /= i
    end
  end
  $res[n] += 1 if n != 1
end

n = gets.to_i

(2..n).each do |k|
  factrize(k)
end

sum = 1

$res.each do |ex|
  sum *= ex + 1
  sum %= 1e9 + 7
end
puts sum.to_i


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


int main(){
  string s;
  cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int limit = 10000;
	int x[limit];
	int count;
	for (count = 0; count < limit; count++) {
		scanf("%d", &x[count]);
		if (x[count] == 0) {
			break;
		}
	}
	for (int i = 0; i < count; i++) {
		printf("Case %d: %d\n", i + 1, x[i]);
	}
	return 0;
}


Measured memory_bytes: 2016
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000;
int R, C, N;
pii x[MAX_N], y[MAX_N];

int on_edge(int x, int y) {
  if (x == R) return y;
  if (y == C) return C+(R-x);
  if (x == 0) return C+R+(C-y);
  if (y == 0) return C+R+C+x;
  return -1;
}


int main() {
  cin >> R >> C >> N;
  rep(i,N) {
    cin >> x[i].fi >> y[i].fi;
    cin >> x[i].sc >> y[i].sc;
  }

  vector<pii> vp;
  for (int i = 0; i < N; ++i) {
    int a = on_edge(x[i].fi, y[i].fi), b = on_edge(x[i].sc, y[i].sc);
    if (a == -1 || b == -1) continue;
    vp.push_back(pii(a, i));
    vp.push_back(pii(b, i));
  }

  sort(all(vp));

  stack<int> stk;
  for (pii &p : vp) {
    if (stk.empty() || stk.top() != p.sc) {
      stk.push(p.sc);
    } else {
      stk.pop();
    }
  }

  if (stk.empty()) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}



Measured memory_bytes: 3956
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        vector<int> tapi(3);
        cin >> tapi[0] >> tapi[1] >> tapi[2];
        sort(all(tapi));
        cout << tapi[0] * tapi[1] / 2 << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b; 
	for (int h = 0; h < 7; h++) {
		cin >> a >> b;
		cout << abs(a - b) << endl;
	}
	cin >> n;
}



Measured memory_bytes: 3116
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  string s; cin >> s;
  int n=s.size();
  loop(i,0,n) {
    if (i%2==1) continue;
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n = 5;
    int k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a.at(i);
    cin >> k;
    if(a.at(4)-a.at(0) > k || a.at(3) - a.at(1) > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> H >> W >> N;
	vector< pii > A(N);
	rep(i, N) {
		cin >> A[i].first >> A[i].second;
		--A[i].first;
		--A[i].second;
	}
	sort(A.begin(), A.end());
	vector< vector< int > > B(W);
	vector< int > index(W, 0);
	rep(i, N) B[A[i].second].push_back(A[i].first);
	rep(i, W) B[i].push_back(H);
	set< pii > s;
	rep(i, N) s.insert(A[i]);
	int ans = LINF;
	int i = 0, j = 0;
	while (j < W) {
		while (B[j][index[j]] < i)
			index[j]++;
		chmin(ans, B[j][index[j]]);
		if (s.find(pii(i + 1, j)) != s.end())
			break;
		++i;
		while (s.find(pii(i, j + 1)) != s.end() && s.find(pii(i + 1, j)) == s.end())
			i++;
		if (i >= H)
			break;
		if (s.find(pii(i, j + 1)) != s.end())
			break;
		++j;
	}
	cout << ans << endl;
	return 0;
}

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


int main(){
	int n,k;
	cin>>n>>k;
	int arr[n+1];
	arr[0]=0;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}

	int dp[n+1];
	dp[0]=0;
	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i] = 2e9+10;
	}

	for(int i=2;i<=n;i++){
		if(i<=k){
			for(int j=1;j<i;j++){
				dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
			}
		}else{
			for(int j=i-k;j<i;j++){
				dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
			}
		}
	}

	cout<<dp[n];
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int A,B,C,X;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&X);
  int count=0;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        int Y=500*i+100*j+50*k;
        if(X==Y)
          count++;
      }
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
inline long long read();
using namespace std;

int main()
{
	long long n=read(),m=read();
	if(n*m==0)
	{
		cout<<0;return 0;
	}
	if(n==1)
	{
		if(m!=1)
		cout<<m-2;
		else cout<<1;
		return 0;
	}
	if(m==1)
	{
		cout<<n-2;return 0;
	}
	cout<<(m-2)*(n-2);
}
inline long long read()
{
    register long long x=0,k=1;
    char c;
    c=getchar();
    while(c<'0'||c>'9'){if(c=='-')k*=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*k;
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ');
  buildMaxHeap(arr);
  console.log(' ' + arr.join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && Number(arr[left]) > Number(arr[largest])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };
  for (let i = Math.floor(n / 2 - 1); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 88304
A,B,C=map(int,input().split())
kot=0
"""while C!=0:

    if B+A==0:
        kot+=1
        break
    else:
        C-=1
        kot+=1
        if B>0:
            B-=1
            kot+=1
        elif A>0:
            A-=1
if B>0:
    kot+=B

print(kot)"""
if C>=B:
    kot+=B*2
    C-=B
else:
    kot+=B+C
    print(kot)
    exit()
if C-1>A:
    kot+=A+1
else:
    kot+=C
print(kot)

Measured memory_bytes: 61844
#MLE注意！0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,m,q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]

    def dfs(l):
        res = 0
        if len(l)==n:
            for a,b,c,d in abcd:
                if l[b-1]-l[a-1]==c:
                    res += d
            return res
        else:
            a = l[-1]
            for i in range(a, m+1):
                temp = l + [i]
                res = max(res, dfs(temp))
            return res
    print(dfs([1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9488
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int ans=0;
	string S,T;
	cin>>S>>T;
	for(int i=0;i<S.length();i++){
		if(S[i]!=T[i])ans++;
	}
	cout<<ans;
	return 0;
}

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

int main(){
    long long n,q,s,t;
    long long nowtem=0;
    cin>>n>>q>>s>>t;
    long long mountain[200005],dmoun[200005];
    for(int i=0; i<=n; i++){
        cin>>mountain[i];
        if(i) dmoun[i]=mountain[i]-mountain[i-1];
    }
    dmoun[n+1]=0;
    for(int i=1; i<=n; i++){
        if(dmoun[i]>=0) nowtem-=s*dmoun[i];
        else nowtem+=t*abs(dmoun[i]);
    }
    for(int i=0; i<q; i++){
        long long l,r,x,newd=0,oldd=0;
        cin>>l>>r>>x;
        
        if(dmoun[l]>=0) oldd-=s*dmoun[l];
        else oldd+=abs(dmoun[l])*t;
        if(dmoun[r+1]>=0) oldd-=s*dmoun[r+1];
        else oldd+=abs(dmoun[r+1]*t);
        
        dmoun[l]+=x;
        if(r!=n) dmoun[r+1]-=x;
        
        if(dmoun[l]>=0) newd-=s*dmoun[l];
        else newd+=abs(dmoun[l])*t;
        if(dmoun[r+1]>=0) newd-=s*dmoun[r+1];
        else newd+=abs(dmoun[r+1]*t);
        long long d=newd-oldd;
        nowtem+=d;
        cout<<nowtem<<endl;
    }
    return 0;
}

Measured memory_bytes: 6216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n,d;cin>>n>>d;
    d*=d;int ans=0;
    for(int i=0;i<n;i++)
    {
        int x,y;cin>>x>>y;
        if(x*x+y*y<=d)
            ans++;
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    if (X < 0) X *= -1;

    // 何回で原点に行くか
    ll a = X / D;

    // a+1回目以降は0より大きい
    if (K <= a) {
        cout << X - K * D << endl;
        return 0;
    }

    if ((K-a) % 2 == 0) {
        cout << X % D << endl;
    } else {
        cout << (X % D - D) * (-1) << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

const int inf = 1e9+7;
int dp[47][407][407];

int main(){
	int n,ma,mb;
	int a[47],b[47],c[47];
	
	cin >> n >> ma >> mb;
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i = 0;i<=40;i++){
		for(int j = 0;j<=400;j++){
			for(int k = 0;k<=400;k++){
				dp[i][j][k] = inf;
			}
		}
	}
	dp[0][0][0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j<=400;j++){
			for(int k = 0;k<=400;k++){
				if(dp[i][j][k]==inf) continue;
				dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]);
				dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
			}
		}
	}
	int minx = inf;
	for(int i = 1;i<=400;i++){
		for(int j = 1;j<=400;j++){
			if(i*mb==j*ma) minx = min(minx,dp[n][i][j]);
		}
	}
	if(minx==inf) cout << -1;
	else cout << minx;
}

Measured memory_bytes: 26880
w, h, n = map(int, input().split())
sw = 0
sh = 0
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        sw = max(sw, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        sh = max(sh, y)
    elif a == 4:
        h = min(h, y)
if sw < w and sh < h:
    print((w-sw) * (h-sh))
else:
    print(0)


Measured memory_bytes: 9184
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

vector<int> prepNext(int K) {
  int sz = 1;
  for (int i = 0; i < K; ++i) sz *= 3;

  vector<int> ret(sz);
  for (int m12 = 0; m12 < (1 << K); ++m12) {
    for (int m1 = m12;; m1 = (m1 - 1) & m12) {
      int x = 0, y = 0, pw = 1;
      for (int i = 0; i < K; ++i, pw *= 3) {
        if (m12 & (1 << i)) {
          if (m1 & (1 << i))
            x += pw, y += 2 * pw;
          else
            x += 2 * pw, y += pw;
        }
      }
      ret[x] = y;
      if (m1 == 0) break;
    }
  }
  return ret;
}

int main() {
  std::ios_base::sync_with_stdio(false);
  int N;
  string T;
  cin >> N >> T;

  int K = (N + 1) / 2;
  vector<int> next = prepNext(K);
  int H = next.size();

  int M = 1;
  for (int i = 0; i < N; ++i) M *= 3;

  vector<int> Plo(H);
  for (int i = 0; i < H; ++i) Plo[i] = i;

  vector<int> Phi(M), Shi(M);
  for (int i = 0; i < M; ++i) {
    Phi[i] = i / H;
    Shi[i] = 0;
  }

  int swapsCnt = 0;
  for (char c : T) {
    if (c == 'S') {
      for (auto& x : Plo) x = next[x];
      swapsCnt++;
    } else {
      int x = -1;
      for (int i = 0; i < H; ++i) {
        Plo[i]++;
        if (Plo[i] == H) {
          Plo[i] = 0;
          assert(x == -1);
          x = i;
        }
      }
      assert(x != -1);

      for (int y = 0; y * H + x < M; ++y) {
        int v = y * H + x;
        if (Shi[v] % 2 != swapsCnt % 2) {
          Phi[v] = next[Phi[v]];
          Shi[v] = swapsCnt;
        }
        Phi[v]++;
        if (Phi[v] * H == M) Phi[v] = 0;
      }
    }
  }

  for (int i = 0; i < M; ++i) {
    if (Shi[i] % 2 != swapsCnt % 2) {
      Phi[i] = next[Phi[i]];
    }
    int ans = Phi[i] * H + Plo[i % H];
    cout << ans << ' ';
  }
  cout << '\n';
  return 0;
}


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

int main()
{
    int x,y;

    while(1)
    {
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        else{
            if (x>y){
                cout << y << " " << x << endl;
            }
            else{
                cout << x << " " << y << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long double ld;
using namespace std;
int main(void){
  int n; cin>>n;
  vector<pair<ld,ld>> ab(n);
  for(auto& i:ab) cin>>i.first>>i.second;
  ld res=0;
  for(int i=0; i<n; ++i) for(int j=i+1; j<n; ++j){
    ld x=ab[i].first-ab[j].first;
    ld y=ab[i].second-ab[j].second;
    res+=sqrtl(x*x+y*y)*2;
  }
  printf("%.10llf",res/n);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1),B(N);
  for(int i=0;i<N+1;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  long cnt=0;
  for(int i=0;i<N;i++){
    int left=min(A.at(i),B.at(i));
    cnt += left;
    A.at(i) -= left;
    B.at(i) -= left;

    int right=min(A.at(i+1),B.at(i));
    cnt += right;
    A.at(i+1) -= right;
    B.at(i) -= right;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[101],b=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0)b=0;
		}
	}
	if(b)cout<<"APPROVED";
	else cout<<"DENIED";
}


Measured memory_bytes: 3560
def gcd(m, n):
    if(n == 0):
        return m
    return gcd(n, m % n)


(a, b, c, d) = [int(i) for i in input().split()]
c_d_lcm = (c * d) // gcd(c, d)
able_c_div = b // c - (a - 1) // c
able_d_div = b // d - (a - 1) // d
able_c_d_div = b // c_d_lcm - (a - 1) // c_d_lcm
diff = b - (a - 1)
print(diff - (able_c_div + able_d_div - able_c_d_div))


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

using namespace std;

typedef long long llint;
typedef pair <int, int> pi;

llint n, sol;
llint br[60][60];

int f (llint val, int p) {
    int cnt = 0;
    while (val % p == 0) {
        val /= p;
        cnt++;
    }
    return cnt;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        long double x;
        cin >> x;
        x *= 1e9;
        llint val = round(x);
        int a = f(val, 2);
        int b = f(val, 5);
        br[a][b]++;
        if (a >= 9 && b >= 9) sol--;
    }
    for (int i = 0; i < 60; i++) {
        for (int j = 0; j < 60; j++) {
            for (int k = 0; k < 60; k++) {
                for (int h = 0; h < 60; h++) {
                    if (i + k >= 18 && j + h >= 18) sol += br[i][j] * br[k][h];
                }
            }
        }
    }
    cout << sol / 2;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int h, w, hcnt, wcnt;
ll ans;
P p[200010];

int main() {
	cin >> w >> h;
	wcnt = w + 1, hcnt = h + 1;
	for (int i = 0;i < w;i++) {
		cin >> p[i].fr;
		p[i].sc = 0;
	}
	for (int i = 0;i < h;i++) {
		cin >> p[i + w].fr;
		p[i + w].sc = 1;
	}
	sort(p, p + w + h);
	for (int i = 0;i < w + h;i++) {
		if (!p[i].sc) {
			wcnt--;
			ans += p[i].fr*hcnt;
		}
		else {
			hcnt--;
			ans += p[i].fr*wcnt;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int s[2020], t[2020];
LL dp[2020][2020];
const LL mod = 1e9 + 7;
int main(){
    cin >> n >> m;
    REP(i, n)cin >> s[i + 1];
    REP(j, m)cin >> t[j + 1];
    REP(i, 2020)dp[0][i] = dp[i][0] = 1;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            (dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod) %= mod;
            if(s[i] == t[j])(dp[i][j] += dp[i - 1][j - 1]) %= mod;
        }
    }
    cout << dp[n][m] << endl;    
}

Measured memory_bytes: 31872
N = int(input())
l = [int(x) for x in input().split()]
ans = 0
l.sort()

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (l[i]-l[j])*(l[k]-l[j]) != 0:
                if l[k]<(l[i]+l[j]):
                    ans += 1

print(ans)



Measured memory_bytes: 9180