akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int main() {
	int N, P;
	cin >> N >> P;
	int cnt0 = 0, cnt1 = 0;
	int x;
	FOR (i, N) {
		cin >> x;
		if (x % 2)
			cnt1++;
		else
			cnt0++;
	}
	LL ret = 1LL;
	FOR (i, cnt0)
		ret *= 2LL;
	FOR (i, cnt1 - 1)
		ret *= 2LL;
	if (P == 1 && cnt1 == 0)
		ret = 0LL;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define TLong long long 

int main(void){
	TLong x,y;
	TLong temp;
	scanf("%lld%lld",&x,&y);
	if(x % y == 0)	printf("-1\n");
	else printf("%lld\n", x);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int l[n],r[n];
    l[0] = 0;
    r[n-1] = 0;
    FOR(i,1,n){
        if(s[i-1] == 'W')
            l[i] = l[i-1]+1;
        else
            l[i] = l[i-1];
    }
    FORR(i,n-2,0){
        if(s[i+1] == 'E')
            r[i] = r[i+1]+1;
        else
            r[i] = r[i+1];
    }
    int answer = 300000;
    REP(i,n){
        answer = min(answer,l[i]+r[i]);
        //cout << l[i] << "\t" << r[i] << endl;
    }
    cout << answer << endl;
    return 0;
}

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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double PI=3.1415926535897932;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll MOD = 1e9+7;

int main(){
    ll n,k; cin >> n >> k;
    int sum=0,ans=0;
    for(ll i=k; i<=n+1; i++){
        ll min_sum=(i-1)*i/2;
        ll max_sum=(2*n-i+1)*i/2;
        sum=(max_sum-min_sum+1)%MOD;
        ans=(ans+sum)%MOD;
    }
    COUT(ans);
    

}

Measured memory_bytes: 3636
a, b, c, x, y = map(int, input().split())
ans = 0
mi = min(x, y)

if a+b > c*2:
    ans = min(c*max(x, y)*2, c*mi*2 + a*(x-mi) + b*(y-mi))
else:
    ans = a*x + b*y

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}




int m,d,ans;


signed main(){
	read(m);read(d);
	for(int i=1;i<=m;i++)
		for(int j=1;j<=d;j++) if(i==(j%10)*(j/10)&&(j%10)>=2&&j/10>=2)
			ans++;//,printf("%d-%d\n",i,j);
	write(ans);
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    string s;
    cin>>s;
    ll cnt=1;
    ll n=s.length();
    ll i=1; 
    string t;
    t.pb(s[0]);
    string temp;
    while(i<n){
        temp.pb(s[i]);
        if(temp != t){
            cnt++;
            t = temp;
            temp.clear();
            i++;
        }
        else if(temp == t){
            i++;
        }
    }
    print(cnt);
}

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

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 155, task c, 2020/08/13
//ms,
/*
*/

int main(void){
  map<string, int> cddt;
  int N;
  int max_vote;

  cin >>N;
  for(int i=0;i<N;i++){
    string tmp;
    cin >>tmp;

    if(cddt.count(tmp)) cddt[tmp]++;
    else cddt[tmp]=1;
  }

  max_vote=0;
  for(pair<string, int> p:cddt){
    string key = p.first;
    int value = p.second;

    max_vote = max(max_vote, value);
  }

  for(pair<string, int> p:cddt){
    string key = p.first;
    int value = p.second;

    if(value==max_vote) cout <<key<<endl;
  }

  return 0;
}
/*
mapを使おうとしたけどもしかしてsetの方がよかった？
*/


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

const int maxn = 4e5 + 10;
bool ans[maxn], mat0[maxn], mat1[maxn];
int n, A[maxn], B[maxn], dataA[maxn], dataB[maxn];

void kmp(int *A, int *B, bool *mat) {
  static int nxt[maxn];
  for (int i = 2, j = 0; i <= n; i++) {
    while (j && B[i] != B[j + 1]) j = nxt[j];
    j += B[i] == B[j + 1], nxt[i] = j;
  }
  for (int i = 1, j = 0; i <= n * 2; i++) {
    while (j && A[i] != B[j + 1]) j = nxt[j];
    j += A[i] == B[j + 1], mat[i] = 0;
    if (j == n) {
      mat[i - n + 1] = 1, j = nxt[j];
    }
  }
}

int main() {
  n = read();
  rep(i, 1, n) A[i] = read();
  rep(i, 1, n) B[i] = read();
  rep(bit, 0, 29) {
    rep(i, 1, n) dataA[i] = A[i] >> bit & 1;
    rep(i, 1, n) dataA[n + i] = dataA[i];
    rep(i, 1, n) dataB[i] = B[i] >> bit & 1;
    kmp(dataA, dataB, mat0);
    rep(i, 1, n) dataB[i] ^= 1;
    kmp(dataA, dataB, mat1);
    rep(i, 1, n) {
      ans[i] |= !mat0[i] && !mat1[i];
    }
  }
  rep(i, 1, n) if (!ans[i]) {
    printf("%d %d\n", i - 1, A[i] ^ B[1]);
  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i, M){
    cin >> A.at(i);
  }
  int sum = 0;
  rep(i, M){
    sum = sum + A.at(i);
  }
  int rest;
  rest =  N - sum;
  if(rest > -1){
    cout << N - sum << endl;
  }
  else{
    cout << -1 << endl;
  }
}  
  


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

int main(){

    while(1){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }

        vector<pair<int, int>> okList;

        for(int i = 0; i < n; i++){
            int f;
            cin >> f;
            int a;
            for(int j = 0; j < f; j++){
                cin >> a;
                okList.push_back(make_pair(a, i));
            }
        }

        sort(okList.begin(), okList.end());

        long long all = (1LL << n) - 1;
        vector<long long> have(n);
        for(int i = 0; i < n; i++){
            have[i] = (1LL << i);
        }

        int day = -1;
        int ans = -1;
        long long com = 0;
        vector<int> index;
        for(int i = 0; i < (int)okList.size(); i++){
            auto temp = okList[i];
            if(day == temp.first){
                com = (com | have[temp.second]);
                index.push_back(temp.second);
            }
            else{
                if(com == all){
                    break;
                }

                for(int j : index){
                    have[j] = com;
                }
                index.clear();

                day = temp.first;
                index.push_back(temp.second);
                com = have[temp.second];
            }
        }

        if(com == all){
            ans = day;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <inttypes.h>

int main(int argc, char* aragv[])
{
    uint64_t n = 0;
    uint64_t traffic[6] = {0};

    for(int i = 0 ; i < 1 ; i++){
        if(scanf("%"SCNu64, &n) != 1){
            return -1;
        }
    }

    for(int i = 0 ; i < 5 ; i++){
        if(scanf("%"SCNu64, &traffic[i]) != 1){
            return -1;
        }
    }

    uint64_t min_traffic = UINT64_MAX;
    for(int i = 0 ; i < 5 ; i++){
        if(traffic[i] < min_traffic){
            min_traffic = traffic[i];
        }
    }

    uint64_t arrival = (uint64_t)ceil((double)n / min_traffic) + 4;

    printf("%"PRIu64"\n", arrival);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back

int main()
{
	ios;
	ll n,x;
	cin>>n;
	map<ll,ll> mp;
	for(ll i=1;i<=n;i++)
	{
		mp[i]=0;
	}
	for(ll i=2;i<=n;i++)
	{
		cin>>x;
		mp[x]++;
	}
	for(auto i:mp)
	{
		cout<<i.second<<'\n';
	}
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

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

    ll n,h;
    cin >> h >> n;
    vector<ll> a(n);
    REP(i,n)cin >> a[i];

    string ans = "No";

    int sum = h;

    REP(i,n){
        sum -= a[i];
        if(sum <= 0){
            ans = "Yes";
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main(){
    int N , M;
    cin >> N >> M;
    vector<ll> A(N);
    for(int i = 0; i< N; i++) cin >> A[i];
    vector<pll> CB(M);
    for(int i = 0; i < M; i++) {
        cin >> CB[i].second >> CB[i].first;
    }    

    sort(A.begin(), A.end());
    sort(CB.begin(), CB.end(), greater<pll>());

    int cur = 0;
    bool flag = false;
    for(int i = 0; i < M; i++) {
        while(CB[i].second--) {
            if(A[cur] < CB[i].first) {
                A[cur] = CB[i].first;
                cur++;
            } else {
                flag = true;
                break;
            }
        }
        if(flag) break;
    }

    ll sum = 0;
    for(int i = 0; i < N; i++) {
        sum += A[i];
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
    string a;
    cin >> a;
    if(a=="A" || a=="B" || a=="C" || a=="D" || a=="E" || a=="F" || a=="G" || a=="H" || a=="I" || a=="J" || a=="K" || a=="L" || a=="M" || a=="N" || a=="O" || a=="P" || a=="Q" || a=="R" || a=="S" || a=="T" || a=="U" || a=="V" || a=="W" || a=="X" || a=="Y" || a=="Z"){
        cout << "A" << endl;
    }
    else cout << "a" << endl;
    return 0;
}

Measured memory_bytes: 3608
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        a: u64,
        mut b: String,
    }
    b.retain(|c| c != '.');
    println!("{}", a * b.parse::<u64>().unwrap() / 100);
}


Measured memory_bytes: 2168
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 10000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
string str;int kd;
int n;
map<int,map<int,int>> mp;
map<int,map<int,bool>> done;
int f(int ix, int k)
{
	if(done[ix][k]){return mp[ix][k];}
	//cout<<ix<<" "<<k<<"\n";
	if(k<0){return 0;}
	if(ix==n-1)
	{
		int num=str[ix]-'0';
		if(k==1){
			if(num>0){return num;}
			else{return 0;}
		}
		if(k>1){return 0;}
		if(k==0)
		{
			return num==0;
		}
	}
	done[ix][k]=1;
	int num=str[ix]-'0';
	int tot=0;
	if(num>0){
		int rem=n-ix-1;
		//ix =0
		int numerator=1,den=1,p=1;
		for(int i=0;i<k;++i)
		{
			p*=9;
			numerator*=rem-i;
			den*=i+1;
		}
		tot+=((numerator/den)*p);
		//ix<maxi
		if(k-1>=0)
		{
			numerator=1;den=1;p=1;
			for(int i=0;i<k-1;++i)
			{
				p*=9;
				numerator*=rem-i;
				den*=i+1;
			}
			tot+=(num-1)*((numerator/den)*p);
		}
		
		//ix=maxi
		tot+=f(ix+1,k-1);
	}
	else
	{
		tot+=f(ix+1,k);
	}
	//cout<<ix<<' '<<k<<' '<<tot<<"\n";
	mp[ix][k]=tot;
	return tot;


}
signed main()
{
	speed
	cin>>str>>kd;
	n=str.length();
	cout<<f(0,kd);

}

Measured memory_bytes: 256
def main():
    n, k, c = map(int, input().split())
    s = list(input())
    right = [False]*n
    left = [False]*n
    nl = [None]*n
    nr = [None]*n
    rp = [-c]*n
    lp = [n+c]*n
    i = 0
    while i < n:
        if s[i] == "o":
            left[i] = True
            i += c+1
        else:
            i += 1
    i = n - 1
    while i >= 0:
        if s[i] == "o":
            right[n-i-1] = True
            i -= c+1
        else:
            i -= 1
    cntl, cntr = 0, 0
    pl, pr = -c, n+c
    for i, (l, r) in enumerate(zip(left, right)):
        nl[i], nr[i]  = cntl, cntr
        lp[i] = pl
        rp[i] = pr
        if l:
            pl = i+1
        if r:
            pr = n-i
        cntl += l
        cntr += r
    for i in range(n):
        if s[i] == "o":
            num = nl[i]+nr[n-i-1]
            if rp[n-i-1]-lp[i] <= c:
                num -= 1
            if num < k:
                print(i+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 71112
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long X = lread();
    long ans;
    foreach (b; 1 .. 500)
        foreach (p; 2 .. 500)
            if (b ^^ p <= X)
            {
                ans = ans.max(b ^^ p);
            }
    writeln(ans);
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll X, Y, Z, K;
vector<ll> A,B,C;
vector<ll> BC;

// A[first]+BC[second]
class Comp {
public:
	bool operator() ( const pii &l, const pii &r ){
		return A[l.first]+BC[l.second] < A[r.first]+BC[r.second];
	};
};


int main(){
	cin >> X >> Y >> Z >> K;
	A.resize(X);
	B.resize(Y);
	C.resize(Z);
	BC.resize(Y*Z);
	
	for ( int i = 0; i < X; i++ )
		cin >> A[i];
	for ( int i = 0; i < Y; i++ )
		cin >> B[i];
	for ( int i = 0; i < Z; i++ )
		cin >> C[i];
	
	sort(A.begin(),A.end());
	
	for ( int i = 0; i < Y; i++ ){
		for ( int j = 0; j < Z; j++ ){
			BC[i*Z+j] = B[i]+C[j];
		}
	}
	sort(BC.begin(),BC.end());
	
	priority_queue<pii,vector<pii>,Comp> p;
	
	for ( int i = 0; i < X; i++ ){
		p.push({i,Y*Z-1});
	}
	
	for ( int i = 0; i < K; i++ ){
		pii t = p.top();
		p.pop();
		cout << A[t.first] + BC[t.second] << "\n";
		if ( t.second != 0 ){
			t.second--;
			p.push(t);
		}
	}
	
	return 0;
}



Measured memory_bytes: 8192
import sys

A, B, C = raw_input().split()
A = int(A)
B = int(B)
C = int(C)

if C <= A:
    print "%ld %ld" % (A-C,B)
elif C <= A + B:
    print "%ld %ld" % (0, A + B - C)
else:
    print "0 0"

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

int main(void)
{
    string S;
    cin >> S;

    bool flg = true;
    for (int i = 0; i < S.length(); i++) {
        if ((i + 1) % 2 == 1) {
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
                flg = false;
                break;
            }
        }
        else {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
                flg = false;
                break;
            }
        }
    }
    if (flg) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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;

int main() {
    int N, P; string S; cin >> N >> P >> S;

    ll ans = 0;
    if (P == 2 || P == 5) {
        REP(i, 0, N) if ((S[N - i - 1] - '0') % P == 0) ans += N - i;
    } else {
        vector<ll> mods(P, 0);

        ll cur = 0, coef = 1;
        mods[cur]++;
        REP(i, 0, N) {
            cur = (cur + coef * (S[N - i - 1] - '0') % P) % P;
            coef = coef * 10 % P;
            mods[cur]++;
        }

        REP(i, 0, P) {
            ans += mods[i] * (mods[i] - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    return a==b?cout<<"Yes":cout<<"No",0;
}

Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split()))
L = [0]*N
L[1]=abs(H[1]-H[0])
for i in range(2, N):
  L[i] = min(L[i-1]+abs(H[i]-H[i-1]), L[i-2]+abs(H[i]-H[i-2]))
print(L[-1])

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

int main(){
	string W, T;
	long i = 0;
	cin >> W;
	//W = "Hello,";
	transform(W.begin(), W.end(), W.begin(), ::tolower);
	while (cin >> T){
		//T = "Hello, Hello, World.";
		if (T == "END_OF_TEXT") break;
		transform(T.begin(), T.end(), T.begin(), ::tolower);
		if (T == W) i++;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 1192
import java.io.IOException;
import java.util.NoSuchElementException;

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x==0&&y==0){
				return;
			}
			System.out.println(Math.min(x,y) + " " + Math.max(x, y));
		}
	}
}









class FastScanner {
    private final java.io.InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





Measured memory_bytes: 25988
import itertools
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(H):
    data.append(list(input()))

right = 0
down  = 0
for i in data:
    for j in range(0,W-1):
        if i[j] == "#" and i[j+1] == "#":
            right += 1

data_t = []
for i in range(W):
    row = []
    for vector in data:
        row.append(vector[i])
    data_t.append(row)

for i in data_t:
    for j in range(0,H-1):
        if i[j] == "#" and i[j+1] == "#":
            down += 1

if down == H-1 and right == W-1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
using MAP = array<array<short,4>,4>;

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


struct waterdrop{
    int y, x, dir;
};

void add_wd(vector<waterdrop> &vp, int y, int x){
    rep(k,4){
        int ddy = y+dy[k];
        int ddx = x+dx[k];
        if(ddx<0 || ddy<0 || ddx>=4 || ddy>=4)continue;
        vp.pb( waterdrop{ddy, ddx, (int)k} );
    }
}

MAP eval(MAP v, int y, int x){
    vector<waterdrop> vp;
    v[y][x]++;
    if(v[y][x]>4){
        add_wd(vp, y, x);
    }

    while(vp.size()){
        vector<waterdrop> nvp;
        for(const auto &wd: vp){
            if(v[wd.y][wd.x]!=0){
                v[wd.y][wd.x]++;
            }
        }

        for(const auto &wd: vp){
            if(v[wd.y][wd.x]>4){
                add_wd(nvp, wd.y, wd.x);
                v[wd.y][wd.x] = -1;
            }else if(v[wd.y][wd.x]==0){
                int ddy = wd.y+dy[wd.dir];
                int ddx = wd.x+dx[wd.dir];
                if(ddx<0 || ddy<0 || ddx>=4 || ddy>=4)continue;
                nvp.pb( waterdrop{ddy, ddx, wd.dir} );
            }
        }
        rep(i,4){
            rep(j,4){
                if(v[i][j]>4 || v[i][j]<0)v[i][j] = 0;
            }
        }
        
        vp = nvp;
    }
    return v;
}

int dfs(MAP v, int t){
    if(t>5)return INF;
    bool all_zero = true;
    rep(i,4){
        rep(j,4){
            if(v[i][j]!=0){
                all_zero = false;
                j=100, i=100;
            }
        }
    }
    if(all_zero)return 0;
    
    int ret = INF;
    rep(i,4){
        rep(j,4){
            if(v[i][j]==0)continue;
            ret = min(ret, dfs(eval(v, i, j), t+1)+1);
        }
    }
    if(ret>5)return INF;
    else return ret;
}

int main(){
    MAP inp;
    rep(i,4)rep(j,4)cin>>inp[i][j];
    
    int ret = dfs(inp, 0);
    if(ret>=INF)cout<<-1<<endl;
    else cout<<ret<<endl;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAX = 510000;
const int MOD = 1e9+7;

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(){
    int n,b;
    cin>>n>>b;
    COMinit();
    int r=n-b;
    ll mod=1e9+7;
    for(int i=1; i<=b; i++){
        ll ans=COM(r+1,i)*COM(b-1,i-1);
        cout<<ans%mod<<endl;
    }
}

Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<functional>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define N_MAX 300010
#define M_MAX 1000000001
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

struct mono{
  li ma;
  mono(li a=0){ma=a;};
};

mono e(){
  return mono();
}

mono op(mono m,mono n){
  return {max(m.ma,n.ma)};
}
// pair 型
std::ostream& operator<<(std::ostream& os, const mono& p){
  cout << p.ma ;
  return os;
}


int main(){
  int n,k; cin >>n >>k;
  atcoder::segtree<mono,op,e> sgt(k+N_MAX);
  rep(i,n){
    li x; cin >>x;
    li a=x-k,b=x+k+1;
    maximize(a,0); minimize(b,k+N_MAX);
    li m=sgt.prod(a,b).ma;
    if(df)print(a,b,m);
    sgt.set(x,m+1);
  }
  print(sgt.prod(0,N_MAX));
}


Measured memory_bytes: 24232
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define NUM 100
 
int main()
{
   static long i,j,k,l;
   int mid;
   int end;
   int re;
   char grade[NUM];
   for(i=0;;i++) {
      cin >> mid >> end >> re;
      if(mid == -1 && end == -1 && re == -1)
         break;
      int sum = mid + end;
      if(mid == -1 || end == -1)
         grade[i] = 'F';
      else if(sum >= 80)
         grade[i] = 'A';
      else if(sum >= 65)
         grade[i] = 'B';
      else if(sum >= 50)
         grade[i] = 'C';
      else if(sum >= 30 && re >= 50)
         grade[i] = 'C';
      else if(sum >= 30)
         grade[i] = 'D';
      else
         grade[i] = 'F';
   }
   for(j=0;j<i;j++)
      cout << grade[j] << endl;
 
   return 0;
}

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


int h,w,n,paint,times,area=0,ans=0;

int main(){
  cin >> h >> w >> n;
  paint = max(h,w);
  times = min(h,w);
  
  rep(i, times){
  if (area < n) {
    area += paint;
    ans++;
  }
    else break;
  }
  
  cout << ans << endl;


}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a[1024];
	int m;
	int b[1024];
	int i;
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	if (scanf("%d", &m) != 1) return 1;
	for (i = 0; i < m; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	for (i = 0; i < n && i < m; i++) {
		if (a[i] > b[i]) {
			puts("0");
			return 0;
		}
		if (a[i] < b[i]) {
			puts("1");
			return 0;
		}
	}
	puts(n < m ? "1" : "0");
	return 0;
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int32_t main()
{
	fastio();
	int p,q,r;
	cin>>p>>q>>r;
	int mn=min(p+q,r+q);
	cout<<min(mn,r+p);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    vector<ll>v;
    ll x,i,j,k;
    for(i=1;i<=5;i++)
    {
        cin>>x;
        if(x==0)
            j=i;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String arggs[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        int arr[]=new int[n];
        String str[]=br.readLine().split(" ");
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        int cntr=0;
        for(int i=0;i<n;i++)
        {
            if(i%2==0&&arr[i]%2!=0)
            cntr++;
        }
        pw.println(cntr);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32772
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		int c=stdIn.nextInt();
		int[] array={a,b,c};
		for(int i=0;i<2;i++){
			for(int j=2;j>i;j--){
				if(array[j-1]>array[j]){
					int tmp=array[j];
					array[j]=array[j-1];
					array[j-1]=tmp;
				}
			}
		}
		System.out.println(array[0]+" "+array[1]+" "+array[2]);
	}
}

Measured memory_bytes: 26236
#include<stdio.h>
 
int main(){
  int i, j, cal, min = 2018;
  
  int L, R;
  scanf("%d %d", &L, &R);
  
  if(R-L >= 2019){
    
    min = 0;
    
  }else{
    
    for(i = L; i < R; i++){
      for(j = i+1; j <= R; j++){
        cal = (i % 2019) * (j % 2019) % 2019;
        if(cal < min){
          min = cal;
        }
      }
    }
    
  }
  
  printf("%d", min);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long

int solve(int N){
	if(N == 0){
		return 0;
	}
	else{
		return N / 5 + solve(N / 5);
	}
}

signed main(){
	int N;
	scanf("%lld", &N);
	if(N % 2 == 1){
		printf("0\n");
	}
	else{
		printf("%lld\n", N / 10 + solve(N / 10));
	}
	return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


X = [int(input()) for _ in range(4)]

ans = 0
for a in range(X[0] + 1):
    for b in range(X[1] + 1):
        tmp = X[3] - 500 * a - 100 * b
        q, mod = divmod(tmp, 50)
        if mod != 0 or tmp < 0:
            continue
        if q <= X[2]:
            ans += 1

print(ans)


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        m: usize,
        sc: [(usize1, i32); m],
    }
    for i in 0..1000 {
        let mut v = i;
        let mut seq = vec![];
        while v > 0 {
            seq.push(v % 10);
            v /= 10;
        }
        if seq.is_empty() {
            seq.push(0);
        }
        seq.reverse();
        let ok = seq.len() == n && sc.iter().all(|&(s, c)| seq[s] == c);
        if ok {
            puts!("{}\n", i);
            return;
        }
    }
    puts!("-1\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
def d():
    N  = int(input())
    S1 = input()
    S2 = input()
    from collections import deque
    s = deque(S1)
    S = ''
    for _ in range(N):
        if len(s) >= 2:
            if s[0] == s[1]:
                S += 'Z'
                s.popleft()
                s.popleft()
            else:
                S += 'I'
                s.popleft()
        elif len(s) == 1:
            S += 'I'
            s.popleft()
        else:
            break
    res = 6 if S[0] == 'Z' else 3
    for i in range(len(S)-1):
        if S[i:i+2] == 'II':
            res *= 2
        if S[i:i+2] == 'IZ':
            res *= 2
        if S[i:i+2] == 'ZI':
            res *= 1
        if S[i:i+2] == 'ZZ':
            res *= 3
    print(res % 1000000007)

d()

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

#define amen exit(0)

#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 100007;
const ll Inf = 1000000007;

ll sum_dig(ll x)
{
    ll res = 0;
    while (x > 0)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}

ll a[D];

int main() 
{
    ll n, k;
    cin >> n >> k;
    for (ll i = 1; i <= n; i++)
        cin >> a[i];
    ll res = 1;
    n -= k;
    k--;
    res += n / k;
    cout << res + (n % k > 0) << endl;
    amen;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());

        int[] x = new int[N];

        for(int i =0; N > i; i++){
            x[i] = Integer.parseInt(sc.next());  
        }
        int tmp = 0;
        int a =  0;
        for(int j = 0; N  > j; j++){  
            int b = Math.abs(X - x[j]);
            if(a == 0){
                a = b;
            }else{
                while ((tmp = b % a) != 0) {
                    b = a;
                    a = tmp;
                }
            }
        }
        System.out.println(a);
    }

}

Measured memory_bytes: 45956
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[100001];
	int maxx=0;
	long long minn=0x7fffffff;
    	int ans;
    	int n,i;
    	scanf("%d",&n);
    	for(i=0;i<n;i++)
    	{
    		scanf("%d",&a[i]);
    		maxx=max(maxx,a[i]);
    	}
	sort(a,a+n);
    	for(i=0;i<n-1;i++)
    	{
    		if(abs(a[n-1]/2-a[i])<=minn)
    		{
    			minn=abs(a[n-1]/2-a[i]);
    			ans=a[i];
    		}
    	}
    	printf("%d %d",maxx,ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
void gg(int a[],int b[],int c[])
{
    int x=0;
    //memset(c,0,sizeof(c));
    c[0]=max(a[0],b[0]);
    for(int i=1;i<=c[0];++i)
    {
        c[i]=a[i]+b[i]+x;
        x=c[i]/10;
        c[i]%=10;
    }
    if(x>0) c[++c[0]]=x;
}
int main()
{
    int t;
cin>>t;
while(t--){
    char a[1000],b[1000];
    int a2[1000],b2[1000],c2[1000];
    scanf("%s%s",a,b);
    a2[0]=strlen(a);
    b2[0]=strlen(b);
    for(int i=1;i<=a2[0];i++) a2[i]=int(a[a2[0]-i]-'0');
    for(int i=1;i<=b2[0];i++) b2[i]=int(b[b2[0]-i]-'0');
    gg(a2,b2,c2);
    if(c2[0]<=80) for(int i=c2[0];i>=1;i--) printf("%d",c2[i]);
    else printf("overflow");
    cout<<endl;
}
    return 0;
}


Measured memory_bytes: 3240
#include <iostream>

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)
#define per(i, a, b) for(int i = a; i > (b); --i)
#define ll long long
#define INF 1000000007

int main(){
  ll d, g;
  scanf("%lld%lld", &d, &g);

  ll p[100], c[100];
  rep(i, 0, d) scanf("%lld%lld", &p[i], &c[i]);

  ll ans = INF;
  rep(bit, 0, 1 << d) {
    ll point = 0, cnt = 0;
    rep(j, 0, d) {
      if ((bit >> j) & 1) {
        point += p[j] * 100 * (j+1) + c[j];
        cnt += p[j];
      }
    }
    per(j, d-1, -1) {
      if ((bit >> j) & 1) continue;
      ll tmp = 0;
      while (tmp + 1 < p[j] && point < g) {
        point += (j + 1) * 100;
        ++cnt;
        ++tmp;
      }
    }
    if (point >= g) {
      ans = min(ans, cnt);
    }
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 256
N = gets.to_i
Ps = (0...N).map{ gets.split.map(&:to_i) }
ps = Ps.sort_by{|x,y| [-y,x] }

cp = ps[0]
convex = [cp]
carg = Math.atan2(-1e-18,-1)
while true
  # cp
  #p carg
  cx,cy = *cp
  nr = ps.map{ |x,y|
    next nil if cx == x && cy == y
    arg = Math.atan2(y-cy, x-cx)
    #p [x,y,arg]
    next nil if carg > arg
    [arg, (cx-x)**2 + (cy-y)**2, [x,y]]
  }.compact.min
  #p nr
  break if !nr
  np = nr[-1]
  break if convex.include? np
  convex << np
  carg = nr[0]
  cp = np
end

#p convex

def distance(x0,y0,x1,y1)
  Math.sqrt(((x0-x1)**2+(y0-y1)**2).to_f)
end

M = convex.size
probs = {}
(0...M).each{ |i|
  j = (i-1+M)%M; k = (i+1+M)%M
  pi,pj,pk = [i,j,k].map{ |i| convex[i] }
  d = distance(*pi,*pj)*distance(*pi,*pk)
  probs[pi] = (Math::PI - Math.acos(((pj[1]-pi[1])*(pk[1]-pi[1]) + (pj[0]-pi[0])*(pk[0]-pi[0]))/d))/Math::PI/2
}

Ps.each{ |pt| p probs[pt] || 0 }



Measured memory_bytes: 3836
def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res
p=10**9+7
n=int(input())
print((power_func(10,n,p)-power_func(9,n,p)-power_func(9,n,p)+power_func(8,n,p))%p)

Measured memory_bytes: 61788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    forn(n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll ans = v[0];
    ll maxi = 1e18;
    for (int i = 1; i < n; ++i) {
        ll t = v[i];
        if (((ans * t) < ans) or ((ans * t) > maxi)) {
            cout << -1 << '\n';
            return;
        }
        ans *= t;
    }
    cout << ans << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 3992
from scipy.sparse.csgraph import floyd_warshall as fw
n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]

mapm = [[0] * (n) for _ in range(n)]
for i in abc:
    mapm[i[0] - 1][i[1] - 1] = i[2]
    mapm[i[1] - 1][i[0] - 1] = i[2]

f = fw(mapm)
count = 0
for i in abc:
    if f[i[0]-1][i[1]-1] != i[2]:
        count += 1

print(count)

Measured memory_bytes: 19756
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};

void score(int D,vector<int> c,vector<vector<int>> s,vector<int> t){
    vector<int> last(26,0);  
    int ans = 0;
    rep(i,D){
        last[t[i]-1] = i+1;
        ans += s[i][t[i]-1];
        int tmp =  0;
        rep(j,26){
            tmp += c[j] * (i+1-last[j]);
        }
        ans -= tmp;
        cout << ans << endl;   
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int> (26,0));
    vector<int> smax(D,0);
    vector<int> tt(D);
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
            int old = smax[i];
            smax[i] = max(smax[i],s[i][j]);
            if(old != smax[i]){
                tt[i] = j+1;
            }
        }
    }
    vector<int> t(D);
    vector<int> mis(26,0);
    int mismax = 0;
    int misi = 0;
    mis = c;
    rep(j,26){
        int t = mismax;
        mismax = max(mismax,mis[j]);
        if(t != mismax){
            misi = j;
        }
    }
    rep(i,D) {
        int sum = 0;
        rep(j,26){
            sum += mis[j];
        }
        if(smax[i] > sum){
            t[i] = tt[i];
        }else{
            t[i] = misi+1;
        }
        rep(j,26){
            int t = mismax;
            mis[j] += c[j];
            mismax = max(mismax,mis[j]);
            if(t != mismax){
                misi = j;
            }
        }
    }    
    rep(i,D){
        cout << t[i] << endl;
    }
    
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N,D[2],c=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>D[0]>>D[1];
        if(D[0]==D[1])c++;
        else c=0;
        if(c>=3){
            cout<<"Yes\n";
            break;
        }
        else if(i==N-1)cout<<"No\n";
    }
}

Measured memory_bytes: 3616
#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 EPS 1e-9
//#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 1LL << 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(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	M = (N - 1) * (N - 2) / 2;
	if (M < K) {
		cout << -1 << endl;
		return 0;
	}
	vector< pii > G;
	rep(i, N - 1) {
		G.emplace_back(i + 1, N);
	}
	int i = 0, j = 1;
	while (K < M) {
		K++;
		G.emplace_back(i + 1, j + 1);
		if (j < N - 2) {
			j++;
		} else {
			i++;
			j = i + 1;
		}
	}
	cout << G.size() << endl;
	rep(i, G.size()) {
		cout << G[i].first << " " << G[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#define ll long long
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,w[100005];
vector <int> v[100005];
bool odw[100005];
queue <int> q;
int main()
{
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;++i)
	{
		scanf("%d%d", &a, &b);
		v[a].pb(b);
		v[b].pb(a);
	}
	q.push(1);
	odw[1]=1;
	while(!q.empty())
	{
		a=q.front();
		//  printf("%d\n", a);
		q.pop();
		for(int i=0;i<v[a].size();++i)
		{
			if(odw[v[a][i]]==0)
			{
				w[v[a][i]]=a;
				odw[v[a][i]]=1;
				q.push(v[a][i]);
			}
		}
	}
	printf("Yes\n");
	for(int i=2;i<=n;++i) printf("%d\n", w[i]);
	return 0;
}


Measured memory_bytes: 10704