akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */




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

    int n; cin >> n;
    vector<int> a(n+1);
    rep(i, n) cin >> a[i];
    a[n] = 1e9+1;

    int ans = 0;
    vector<int> dp(n+1, 0);
    reprev(i, n){
        if(a[i] >= a[i+1]) dp[i] = dp[i+1] + 1;
        else dp[i] = 0;
        chmax(ans, dp[i]);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    //  vector<int> A(N);

    map<int, int> An;
    for (int i = 0; i < N; i++)
    {
        int B;
        cin >> B;
        An[B]++;
    }

    for (auto x : An)
    {
        if (x.second != 1)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

using namespace std;

const int inf = 1e9;

struct Edge {
	int to, cost, time, company;
};
struct Node {
	int v, cost, time;
};
struct Passport {
	int target, cost;
};
bool operator>(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

int dijkstra(vector< vector<Edge> >& G, int s, int t, int H, int pp) {
	int N = G.size();
	vector< vector<int> > dist(N, vector<int>(H+1, inf));
	priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push({s, 0, 0});
	while ( !Q.empty() ) {
		Node node = Q.top(); Q.pop();
		int v = node.v, cost = node.cost, time = node.time;
		if (cost > dist[v][time]) continue;
		for ( Edge& e : G[v] ) {
			int nv = e.to;
			int nc = ((1 << e.company) & pp) ? cost : cost + e.cost;
			int nt = time + e.time;
			if (nt <= H && nc < dist[nv][nt]) {
				dist[nv][nt] = nc;
				Q.push({nv, nc, nt});
			}
		}
	}
	int res = inf;
	for (int i = 0; i <= H; ++i) {
		res = min(res, dist[t][i]);
	}
	return res;
}

int main() {
	int N, M, H, K;
	while ( cin >> N >> M >> H >> K, N || M || H || K ) {
		vector< vector<Edge> > G(N);
		for (int i = 0; i < M; ++i) {
			int a, b, c, h, r; cin >> a >> b >> c >> h >> r; --a, --b, --r;
			G[a].push_back({b, c, h, r});
			G[b].push_back({a, c, h, r});
		}
		int S, T; cin >> S >> T; --S, --T;
		int P; cin >> P;
		vector<Passport> pp(P);
		for (int i = 0; i < P; ++i) {
			int l, d; cin >> l >> d;
			int f = 0;
			for (int j = 0; j < l; ++j) {
				int r; cin >> r; --r;
				f |= (1 << r);
			}
			pp[i] = {f, d};
		}
		vector<int> dp((1 << K), inf);
		dp[0] = 0;
		for (int i = 0; i < P; ++i) {
			for (int j = 0; j < (1 << K); ++j) {
				int nj = (j | pp[i].target);
				dp[nj] = min(dp[nj], dp[j]+pp[i].cost);
			}
		}
		int ans = inf;
		for (int i = 0; i < dp.size(); ++i) {
			ans = min(ans, dijkstra(G, S, T, H, i)+dp[i]);
		}
		if (ans == inf) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}

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

using namespace std;

using ll = long long;

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

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

class Magic
{
    public:
    ll A,B;
};

void Sort_Magics(vector<Magic>& Magics)
{
    sort(ALL(Magics),
    [](Magic& A, Magic& B)
    {
        return (A.A==B.A) ? (A.B < B.B) : (A.A > B.A);
    });
}

void ALLIN_MAGICS(ll N, vector<Magic>& Magics)
{
    vector<Magic> magics(N);
    for(ll i=0;i<N;i++)
    {
        cin >> magics[i].A >> magics[i].B;
    }
    
    map<ll,ll> magics_map;
    for(auto x : magics)
    {
        if(magics_map[x.A]==0)
        {
            magics_map[x.A] = x.B;
        }
        else
        {
            magics_map[x.A] = min(magics_map[x.A],x.B);
        }
    }

    for(auto x : magics_map)
    {
        Magics.push_back({x.first,x.second});
    }
}

void ALLOUT_MAGICS(vector<Magic> Magics)
{
    for(auto x : Magics)
    {
        cout << x.A << ' ' << x.B << endl;
    }
}

ll DP(ll H, vector<Magic> Magics)
{
    vector<ll> dp(H+1,1e9);
    dp[0] = 0;
    for(ll i=0;i<H;i++)
    {
        if(dp[i]!=1e9)
        {
            for(auto x : Magics)
            {
                dp[min(H,i+x.A)] = min(dp[min(H,i+x.A)],dp[i]+x.B);
            }
        }
    }
    return dp[H];
}

int main()
{
    ll H,N;
    cin >> H >> N;

    vector<Magic> Magics;
    ALLIN_MAGICS(N,Magics);

    OUT0(DP(H,Magics));

    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int maxi = max(a, max(b, c));
    if(maxi == a) cout << "A" << endl;
    if(maxi == b) cout << "B" << endl;
    if(maxi == c) cout << "C" << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <complex>
#include <cstdio>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = (1e-10);    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

namespace std {
  bool operator<(const P a, const P b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecLP(P a1, P a2, P b) {
  return abs(ccw(a1, a2, b)) != 1;
}

bool isecLL(P a1, P a2, P b1, P b2) {
  return !isecLP(a2-a1, b2-b1, 0) || isecLP(a1, b1, b2);
}

VP convexHull(VP &ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  VP ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;  // 余計な点も含むなら == -1 とする
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

D area(const VP& ps) {
  D a = 0;
  rep (i, ps.size()) a += cross(ps[i], ps[(i+1) % ps.size()]);
  return a / 2;
}

P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

P reflection(P a1, P a2, P p) {
  return 2.0*proj(a1, a2, p) - p;
}

int main() {
  D x1, y1, x2, y2, xq, yq;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) {
    P p1 = P(x1, y1);
    P p2 = P(x2, y2);
    P q = P(xq, yq);
    P ans = reflection(p1, p2, q);
    std::cout << fixed << setprecision(9) << ans.X << " " << ans.Y << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
#define MAX_V 300
using namespace std;
typedef pair<int,int> P;

struct edge{int to, cap, rev; };

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to){
	G[from].push_back((edge){to, 1, G[to].size()});
	G[to].push_back((edge){from, 1, G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	for(int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t] < 0) return flow;
		memset(iter,0, sizeof(iter));
		int f;
		while((f = dfs(s, t, INF)) > 0){
			flow += f;
		}
	}
}


int n, m, s, t;
int brd[300][300];
bool used[300][300];

int main(){
	rep(i,300) rep(j,300) brd[i][j] = -1;
	cin >> n >> m;
	rep(i,m){
		int x, y;
		cin >> x >> y;
		x--; y--;
		brd[x][y] = i+1;
		if(!used[x][y]){
			add_edge(x,y);
			used[x][y] = true;
			used[y][x] = true;
		}
	}
	cin >> s >> t;
	s--; t--;
	cout << max_flow(s,t) << endl;
	int r = 0;
	vector<int> out;
	rep(i,n){
		rep(j,G[i].size()){
			if(G[i][j].cap == 0 && brd[i][G[i][j].to] == -1){
				r++;
				out.push_back(brd[G[i][j].to][i]);
			}
		}
	}
	cout << r << endl;
	sort(out.begin(),out.end());
	rep(i,out.size()) cout << out[i] << endl;
}

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

int main(){

    int a,b;
    cin >> a >> b;

    string s;
    cin >> s;

    int flag = 1;
    for(int i=0; i<a; i++){
        if((int)(s[i]) - (int)'0' > 10 || (int)(s[i]) - (int)'0' < 0){
            flag = 0;
        }
    }

    if(s[a] != '-'){
        flag = 0;
    }
    for(int i=a+1; i<b+a+1; i++){
        if((int)(s[i]) - (int)'0' > 10 || (int)(s[i]) - (int)'0' < 0){
            flag = 0;
        }
    }

    if(flag == 1){
        cout << "Yes" << '\n';
    }else{
        cout << "No " << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int n,i,max,j,wari,b;

        scanf("%d",&n);


        max = 0;
        b = 1;
        for(i=1;i<=n;i++){
                wari = i;
                j = 0;
                while(!(wari%2)){
                        j++;
                        wari = wari / 2.0;
                }
                if(max<j){
                        b = i;
                        max = j;
                }
        }

        printf("%d\n",b);

        return 0;
}


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

const long long MOD = 1e9 + 7;


int main(){
	long long N, M; cin >> N >> M;
	vector<long long> S(N), T(M);
	for (long long i = 0; i < N; i++) cin >> S[i];
	for (long long i = 0; i < M; i++) cin >> T[i];
 
	vector<vector<long long>> dp(N + 1, vector<long long>(M + 1));
	dp[0][0] = 1;
	for (int i = 0; i < N; i++) dp[i + 1][0] = 1;
	for (int j = 0; j < M; j++) dp[0][j + 1] = 1;
	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) {
		dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] - dp[i][j] + MOD) % MOD;
		if (S[i] == T[j]) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
	}

	cout << dp[N][M] << endl;
	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 167, task A, 2020/05/10
//ms,
/*
*/

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

  S+=T.at(T.size()-1);

  if(S==T) cout <<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
 
int main(){
    static int n,t,s,a,b,dp[3000+2][3000+2]={0};
    scanf("%d%d%d",&n,&t,&s);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&a,&b);
        for(int j=1;j<=t;j++){
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            if(j>=b&&!(j-b<s&&j>s))dp[i][j]=max(dp[i][j],dp[i-1][j-b]+a);
        }
    }
    printf("%d\n",dp[n][t]);
}

Measured memory_bytes: 36376
N = int(input())
X = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

fact, rfact = prepare(N, MOD)

ret = 0
inv = 0
for i in range(N-1):
    diff = X[i+1] - X[i]
    inv += fact[i] * rfact[i+1]
    ret += diff * inv
    ret %= MOD

print(ret*fact[N-1]%MOD)



Measured memory_bytes: 15248
#include <iostream>
#include <string>
#include <vector>

using namespace std;
const string stable = "Stable";
const string nstable = "Not stable";

vector<string> bubbleSort(vector<string> A, int &N){
    for(int  i=0; i<N;i++){
        for(int j=N-1;j > i; j--){
            string A1 = A[j];
            string A2 = A[j-1];
            if(A1[1] < A2[1]){
                string temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(i == N-1){
            cout<<A[i]<<endl;
        }else{
            cout<<A[i] << " ";
        }
    }
    cout << stable <<endl;
    return A;
}

void selectionSort(vector<string> A, int &N){
    vector<string> B = bubbleSort(A,N);
    for(int i=0;i<N;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            string A1 = A[j];
            string A2 = A[minj];
            if(A1[1] < A2[1]){
                minj = j;
            }
        }
        if(i != minj){
            string temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
        }
    }
    for(int i=0;i<N;i++){
        if(i == N-1){
            cout<<A[i]<<endl;
        }else{
            cout<<A[i] << " ";
        }
    }
    bool isStable = true;
    for(int i=0;i<N;i++){
        if(A[i] != B[i]){
            isStable = false;
        }
    }
    if(isStable){
        cout<< stable << endl;
    }else{
        cout<< nstable << endl;
    }
}

int main(void){
    // Your code here!
    int N;
    vector<string> A;
    cin >> N;
    for(int i=0;i<N;i++){
        string temp;
        cin >> temp;
        A.push_back(temp);
    }
    selectionSort(A,N);
    
    return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;

ll N;
ll a[300002];


int main(){
    cin>>N;
    Rep(i,3*N) cin>>a[i];
    sort(a,a+3*N);
    ll sum=0;
    Rep(i,N){
        sum+=a[N+2*i];
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 2560
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    var x: number = 0;
    var ans: number = 0;
    // init
    x = Number(input.shift());
    // solve
    if (x == 0) ans = 1;
    if (x == 1) ans = 0;
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29504
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a+b==15) {
			System.out.println("+");
		}
		else if(a*b==15){
			System.out.println("*");
		}
		else {
			System.out.println("x");
		}
		}
}

Measured memory_bytes: 21840
#include <stdio.h>

int main(){
	int row, col, n;
	scanf("%d", &row);
	scanf("%d", &col);
	scanf("%d", &n);
	
	if (row>col){
		n%row > 0 ? printf("%d", (n/row)+1) : printf("%d", (n/row));
	}
	else {
		n%col > 0 ? printf("%d", (n/col)+1) : printf("%d", (n/col));
	}
	return 0;
}

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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;


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

    ll ans = 1;

    for(int i = n; i >= 1; i--)
    {
        if((i & (i-1)) == 0)
        {
            cout << i;
            return;
        }
    }
    cout << ans;
    
}

int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

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

int main() {
  	int num;
  	long tmp, total = 1;
  	scanf("%d", &num);
  	string s;
  	vector<long> vec;
  	while(cin>>s) {
      	tmp = stol(s);
      	if (tmp == 0) {
        	cout << "0" << endl;
          	return 0;
        }
      	vec.push_back(stol(s));
    }
  	
  	for(auto &x: vec) {
	    if(LONG_MAX / x < total) {
          	cout << "-1" << endl;
          	return 0;
        }
        total *= x;
      	if (total > powl(10, 18) || total < 0) {
      		cout << "-1" << endl;
          	return 0;
    	}
    }
  	
  	cout << to_string(total) << endl;
  	
	return 0;  
}

Measured memory_bytes: 4312
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] x = new int[5];
        for(int i=0; i<5; i++) x[i]=sc.nextInt();
        for(int i=0; i<5; i++) if(x[i]==0) System.out.println(i+1);
    }
}

Measured memory_bytes: 35784
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n % 2 == 1) {
        cout << 0;
        return 0;
    }
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    int boundary = (n-1)/2;
    int boundary2 = (n-1)/2 + 1;
    if (arr[boundary] == arr[boundary2]) {
        cout << 0;
    } else {
        cout << arr[boundary2] - arr[boundary];
    }
    return 0;
}

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

int main() {
    std::string s1, s2;
    std::cin >> s1 >> s2;

    bool flag = true;
    for(int i = 0; i < 3; i++) {
        if(s1[i] != s2[2 - i]) {
            flag = false;
        }
    }

    if(flag) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// dp[i][j] represents 
uint64_t knapsack(int weight, int n, uint64_t* w, uint64_t* v)
{
    uint64_t dp[n + 1][weight + 1];
    // dp[i][j] represents the maximum value possible by selecting elements from 0
    // to i such that the maximum weight allowed is j.
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= weight; j++)
        {
            // If no element is selected(i = 0) or if the max weight allowed is 0, then 
            // filling the bag isnt possible
            if(i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if(w[i - 1] <= j)
            {
                dp[i][j] = max(dp[i - 1][j - w[i - 1]] + v[i - 1], dp[i - 1][j]);
            }
            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    return dp[n][weight]; 
}

int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, weight;
    cin >> n >> weight;
    uint64_t w[n], v[n];    
    uint64_t value;
    for(int i = 0; i < n; i++)
    {
        cin >> value;
        w[i] = value;
        cin >> value;
        v[i] = value;
    }
    uint64_t a = knapsack(weight, n, w, v); 
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define scan(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;


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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int k;
    	cin>>k;
    	string str;
    	cin>>str;
    	
    	if(k>=str.length())
    	{
    		cout<<str<<endl;

    	}
    	else{
    	for(int i=0;i<k;i++)
    		cout<<str[i];
    	cout<<"..."<<endl;
    }

    	
    	
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int gcd(int a,int b) {return b==0?a:gcd(b,a%b);}
int main() {
    int x;
    cin >> x;
    cout << 360 / gcd(x, 360) << endl;
}

Measured memory_bytes: 3596
#include<math.h>
#include <iostream>
using namespace std;
int main(void){

	int A; //高橋(笑)の歳
	int B; //金(偶数)
	int c; //予備

	cin >> A;
	cin >> B;
	
	if (A < 6) {
		cout << 0 << endl;
	}
	else if (A > 12) {
		cout << B << endl;
	}
	else {
		cout << B / 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
H = LI() + [1]
dp = [1] * (n + 1)

for k in range(n):
    new_dp = [0] * (n + 1)
    for i in range(n + 1):
        if H[i] > H[k]:
            new_dp[i] = dp[k] * 2
        elif H[k - 1] <= H[i]:
            new_dp[i] = dp[i] * 2 * pow(2, H[k] - H[i], mod)
        elif H[k - 1] > H[k]:
            new_dp[i] = dp[i] + dp[k]
        else:
            new_dp[i] = (dp[i] + dp[k - 1]) * pow(2, H[k] - H[k - 1], mod)
        new_dp[i] %= mod
    dp = new_dp


print(dp[-1])


Measured memory_bytes: 83424
#include <bits/stdc++.h>
using namespace std;
int main(){
  string divide[4]={"dream","dreamer","erase","eraser"};
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  for(int i=0;i<4;i++){
    reverse(divide[i].begin(),divide[i].end());
  }
  bool c=true;
  for(int i=0;i<s.size();){
    bool d=false;
    for(int j=0;j<4;j++){
      if(s.substr(i,divide[j].size())==divide[j]){
        d=true;
        i+=divide[j].size();
      }
    }
    if(!d){
      c=false;
      break;
    }
  }
  if(c){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(s[0]=='0' || s[n-1]== '1'){ cout << -1 << endl; return 0; }
  rep(i,n/2){
    if(s[i]!=s[n-2-i]){ cout << -1 << endl; return 0; }
  }

  s[n-1] = '1';
  vector<P> a;
  int cnt = 0;
  REP(i,1,n){
    if(s[i]=='1'){
      for(; cnt<i; cnt++){
        a.emplace_back(i,cnt);
      }
    }
  }
  for(auto it:a){ cout << it.F+1 << " " << it.S+1 << endl; }
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	string s;
	vll cnt(2, 0);
	in(s);

	rep(i, 0, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == '0') {
				cnt[0]++;
			}
			else {
				cnt[1]++;
			}
		}
		else {
			if (s[i] == '1') {
				cnt[0]++;
			}
			else {
				cnt[1]++;
			}
		}
	}

	cnt[0] < cnt[1] ? out(cnt[0]) : out(cnt[1]);

	return 0;
}


Measured memory_bytes: 512
from math import *
N,M = map(int,input().split())
if abs(N - M) > 1:
    print(0)
    exit(0)

if N == M:
    print(2 * factorial(N) * factorial(M) % (10**9+7))
else:
    print(factorial(N) * factorial(M) % (10**9+7))


Measured memory_bytes: 11096
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
 
 
#define ll long long int
#define ld long double
 
#define fr first
#define se second
 
 
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))
 
 
#define pb push_back
#define mp make_pair
 
 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))
#define easm(a, b) (a + b - 1) /b 
 
#define PI 3.141592653589793238
 
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

 

//bool valid(int i, int j){return i >= 0 && i < n && j >= 0 && j < m;}

int n, s;
int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //clock_t z = clock();
  cin >> n;
  vector<int>v(n);
  for(auto &i : v){
    cin >> i;
    s += i;
  }
  if(s%10 != 0){
    cout << s << endl;
    return 0;
  }
  sort(all(v));
  for(int i : v){
    if(i%10 != 0){
      s -= i;
      break;
    }
  }
  if(s%10 == 0)
    return cout << 0 << endl, 0;
  cout << s << endl;
  //debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

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

const int MAXN = 100010;
int tmp[MAXN];
int n, K;
struct pr {
	int A[MAXN];
	pr() {}
	pr(int * B) { memcpy(A, B, n + 1 << 2); }
	pr inv() {
		for (int i = 1; i <= n; ++i) tmp[A[i]] = i;
		return tmp;
	}
	pr operator () (pr b) {
		for (int i = 1; i <= n; ++i)
			tmp[i] = A[b.A[i]];
		return tmp;
	}
	pr pow(int x) {
		static bool vis[MAXN];
		static int li[MAXN], bak;
		memset(vis, 0, n + 1);
		for (int i = 1; i <= n; ++i) if (!vis[i]) {
			bak = 0;
			int now = i;
			while (!vis[now]) {
				vis[now] = true;
				li[bak++] = now;
				now = A[now];
			}
			int sx = x % bak;
			for (int j = 0; j < bak; ++j)
				tmp[li[j]] = li[(j + sx) % bak];
		}
		return tmp;
	}
} f[7];
int main() {
	std::cin >> n >> K;
	for (int i = 1; i <= n; ++i) std::cin >> f[1].A[i];
	for (int i = 1; i <= n; ++i) std::cin >> f[2].A[i];
	pr x = f[2](f[1].inv()(f[2].inv()(f[1])));
	for (int i = 3; i <= 6; ++i)
		f[i] = f[i - 1](f[i - 2].inv());
	int tar = K % 6 + (K % 6 == 0) * 6;
	pr ans = x.pow((K - tar) / 6)(f[tar](x.inv().pow((K - tar) / 6)));
	for (int i = 1; i <= n; ++i) std::cout << ans.A[i] << ' ';
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 10240
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars,
    }

    let n = s.len();
    let mut visited = vec![false; n];
    let mut ans = vec![0_u32; n];
    for start in 0..n {
        let flg = visited[start] ||
            (start < n-1 && s[start] == 'L' && s[start+1] == 'L');
        if flg { continue; }
        let mut trace = Vec::with_capacity(n);
        let mut cursor = start;
        trace.push(std::usize::MAX);
        trace.push(start);
        loop {
            if s[cursor] == 'L' {
                cursor -= 1;
            } else {
                cursor += 1
            }
            if trace[trace.len()-2] == cursor { break; }
            trace.push(cursor);
        }
        let l = trace.len() - if visited[cursor] { 3 } else { 1 };
        if l%2 == 0 {
            ans[cursor] += (l>>1) as u32;
            ans[*trace.last().unwrap()] += (l>>1) as u32;
        } else {
            ans[cursor] += (l>>1) as u32;
            ans[*trace.last().unwrap()] += ((l>>1)+1) as u32;
        }
        for i in 2..trace.len() {
            visited[trace[i]] = true;
        }
    }

    for i in ans {
        print!("{} ", i);
    }
}


Measured memory_bytes: 4048
S = gets.chomp

ks, l = [12,3,4,1,10,9], []
ks.each{|k|
	l[k] = a = Array.new(13){ [] }
	js = [*0..12]
	9.times{
		js.rotate! k
		js.each_with_index{|j,i|
			a[i] << j
		}
	}
}
ks = ks.cycle

m = [1]+[0]*12
S.each_char.reverse_each.with_index{|c,i|
	k = ks.next
	if c != ??
		m.rotate! (c.ord-?0.ord)*k
	else
		m = l[k].map.with_index{|a,i|
			m.values_at(*a).inject(m[i],:+) % 1000000007
		}
	end
}
p m[5]


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

int main() {
  int N, K, x, A, B, Ans;
  cin>>N>>K;
  
  for (int i=1; i<N+1; i++){
    cin>>x;
    A=x*2;
    B=(K-x)*2;
    if (A<B)
      Ans+=A;
    else
      Ans+=B;
  }
  cout<<Ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  map<int64_t, int64_t> count;
  for (int64_t i = 0; i < N; i++) {
    count[A.at(i)] = 0;
  }
  for (int64_t i = 0; i < N; i++) {
    count.at(A.at(i)) += 1;
  }
  int64_t sum = 0;
  for (auto p : count) {
    auto number = p.second;
    sum += number*(number - 1) / 2;
  }
  int64_t result;
  for (int64_t i = 0; i < N; i++) {
    result = sum - count.at(A.at(i)) + 1;
    cout << result << endl;
  }
}

Measured memory_bytes: 11136
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.collection.mutable
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  case class Mountain(id: Int, rock: Int)

  implicit val mountainOrdering = new Ordering[Mountain] {
    override def compare(x: Mountain, y: Mountain): Int = {
      if (x.rock != y.rock) {
        x.rock - y.rock
      } else {
        x.id - y.id
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = get[Int]
    val as = getArray[Int]

    val result = Array.ofDim[Long](n)

    val rock2queue = mutable.HashMap.empty[Int, mutable.PriorityQueue[Int]]

    as.zipWithIndex.foreach { case (a, i) =>
      val queue = rock2queue.getOrElseUpdate(a, mutable.PriorityQueue.empty[Int](Ordering.Int.reverse))
      queue += i
    }

    val asDesc = as.sorted.reverse

    asDesc.zip(asDesc.tail :+ 0).zipWithIndex.filter {
      case ((a1, a2), i) => a1 != a2
    }.foreach { case ((a1, a2), i) =>
      val queue = rock2queue(a1)
      result(queue.head) += 1L * (a1 - a2) * (i + 1)
      if (a2 != 0) {
        rock2queue(a2) += queue.head
      }
      queue.clear()
    }

    result.foreach { r =>
      out.println(r)
    }

    out.flush()
  }
}

Measured memory_bytes: 111908
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cassert>
#include <cstdint>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<long long>;
using VVL = vector<VL>;

const long long INF = 1e18;
const int N_CONTEST = 26;

// すべて 0-indexで考える。結果の出力時に1を足す

struct Input {
	int D;
	VI c;
	VVI s;
};

Input get_input() {
	int D;
	cin >> D;
	VI c(N_CONTEST);
	VVI s(D, VI(N_CONTEST));

	for (int i = 0; i < c.size(); i++) {
		cin >> c[i];
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < s[i].size(); j++) {
			cin >> s[i][j];
		}
	}

	Input input;
	input.D = D;
	input.c = c;
	input.s = s;

	return input;
}

long long calc_score(const Input& input, const VI& t) {
	long long score = 0;
	VI lastdays(N_CONTEST, -1);
	for (int i = 0; i < t.size(); i++) {
		score += input.s[i][t[i]];

		lastdays[t[i]] = i;
		for (int j = 0; j < N_CONTEST; j++) {
			score -= (long long) input.c[j] * (i - lastdays[j]);
		}
	}

	return score;
}

void show_results(const VI &t) {
	for (auto x: t) {
		cout << x + 1 << endl;
	}
}
void show_score(const Input& input, const VI& t) {
	auto score = calc_score(input, t);
	auto score2 = max<long long>(0, score + (long long)1e6);

	printf("score:  %10lld\n", score);
	printf("score2: %10lld\n", score2);
}

void solve_b() {
	auto input = get_input();
	int tmp;
	VI t;
	VL scores(input.D);
	for (int i = 0; i < input.D; i++) {
		cin >> tmp;
		// 0-index
		t.emplace_back(tmp - 1);
		scores[i] = calc_score(input, t);
	}

	for (auto x: scores) {
		cout << x << endl;
	}
}

VI solve_greedy(const Input& input) {
	VI t;

	for (int i = 0; i < input.D; i++) {

		long long max_score = -INF;
		int cand = -1;

		for (int j = 0; j < N_CONTEST; j++) {
			t.emplace_back(j);
			auto score = calc_score(input, t);
			if (score > max_score) {
				max_score = score;
				cand = j;
			}
			t.pop_back();
		}
		t.emplace_back(cand);
	}
	return t;
}


int main() {
	// solve_b();

	Input input = get_input();
	VI t = solve_greedy(input);
	show_results(t);
	// show_score(input, t);

	return 0;
}

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

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 

int N;
ll A[201010], B[201010];

pair<ll, ll> rev(pair<ll, ll> x)
{
    ll a = -x.first;
    ll b = x.second;

    if (a < 0)
        return make_pair(-b, -a);
    return make_pair(b, a);
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }

    int zero_zero = 0;
    int zero_no = 0;
    int no_zero = 0;
    map<pair<ll, ll>, int> cnt;

    for (int i = 0; i < N; i++)
    {
        if (A[i] == 0 && B[i] == 0)
        {
            zero_zero++;
        }
        else if (A[i] == 0)
        {
            zero_no++;
        }
        else if (B[i] == 0)
        {
            no_zero++;
        }
        else
        {
            ll g = __gcd(abs(A[i]), abs(B[i]));
            A[i] /= g;
            B[i] /= g;
            if (B[i] < 0)
            {
                A[i] *= -1;
                B[i] *= -1;
            }
            cnt[make_pair(A[i], B[i])]++;
        }
    }

    mint ans = mint(2).pow(zero_no) + mint(2).pow(no_zero) - 1;
    set<pair<ll, ll>> used;
    for (auto cn : cnt)
    {
        if (!used.count(cn.first))
        {
            auto p = cn.first;
            auto pp = rev(p);
            if (cnt.count(pp))
            {
                ans *= mint(2).pow(cnt[p]) + mint(2).pow(cnt[pp]) - 1;
                used.insert(pp);
            }
            else
            {
                ans *= mint(2).pow(cnt[p]);
            }
        }
    }

    ans += zero_zero;
    ans -= 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') s.at(i) = '9';
    else if (s.at(i) == '9') s.at(i) = '1';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)==3)
    {
        if(a+b>=c)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**18


if __name__ == "__main__":
    a = int(input())
    print(a+a**2+a**3)

Measured memory_bytes: 68592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }

    class Solution
    {
        string N;
        string[] M_split = new string[2];
        int N1;
        int T = 0;

        public Solution()
        {
            N = Console.ReadLine();
            M_split = N.Split(' ');
            N1 = Convert.ToInt32(M_split[0]) - Convert.ToInt32(M_split[1]);
            if (N1 >= 0)
            {
                T = N1;
            }
        }

        public void answer()
        {
            Console.WriteLine(T.ToString());
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str,q,p;
  int n,a,b;
  cin>>str>>n;
  for(int i=0;i<n;i++){
    cin>>q>>a>>b;
    if(q=="replace"){
      cin>>p;
      str.replace(a,b-a+1,p);
    }
    if(q=="reverse") reverse(str.begin() + a,str.begin() + b+1);
    if(q=="print") cout<<str.substr(a,b-a+1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 n, k; scanf("%lld%lld", &n, &k);
	
	auto getSegment = [&](i64 x) {
		if(x == 0) return n + 1;
		i64 ok = 0, ng = n;
		while(ng - ok > 1) {
			i64 mid = (ok + ng) >> 1;
			
			if(n / mid > x) ok = mid;
			else ng = mid;
		}
		return ok + 1;
	};
	
	std::vector<int> latte;
	for(i64 i = 1; i * i <= n; i++) {
		latte.push_back(i);
		latte.push_back(n / i);
	}
	sort(begin(latte), end(latte)); latte.erase(unique(begin(latte), end(latte)), end(latte));
	reverse(begin(latte), end(latte));
	
	std::vector<std::pair<i64, i64>> vec;
	for(auto x: latte) {
		i64 L = getSegment(x), R = std::min(n + 1, getSegment(x - 1));
		if(L < R) vec.push_back({L, R});
	}
	
	const int MOD = 1e9 + 7;
	auto dp = make_v<i64>(k + 1, (int)vec.size()); dp[0][0] = 1;
	for(int i = 0; i < k; i++) {
		i64 cur = 0, tmp = 0;
		for(int j = (int)vec.size() - 1; j >= 0; j--) {
			i64 Y = vec[j].second - 1;
			while(cur < vec.size() and (vec[cur].second - 1) * Y <= n) {
				(tmp += dp[i][cur++]) %= MOD;
			}
			
			i64 width = vec[j].second - vec[j].first;
			(dp[i + 1][j] += tmp * width % MOD) %= MOD;
		}
	}
	
	i64 ans = 0;
	for(auto v: dp[k]) (ans += v) %= MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 51828
#include <bits/stdc++.h>
#define szof(s) (int)s.size()
#define pb push_back
#define int long long
#define all(s) s.begin(), s.end()
#define pii pair<int, int>
#define fr first
#define sc second

using namespace std;
const int N = (int)2e5 + 5;

void solve() {
  int cnt, n;
  cin >> cnt >> n;
  cout << (cnt * 500 >= n ? "Yes" : "No");
}

main() {
  solve();
}


Measured memory_bytes: 256
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	const ll LLINF=0x3f3f3f3f3f3f3f3fll;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<int,int>
	#define PB push_back
	inline void chmax(ll &x,const ll y) {x=x>y?x:y;}
	inline void chmin(ll &x,const ll y) {x=x<y?x:y;}

	const int MAX_N=5e5+10;
	struct DSU
	{
		int fa[MAX_N];DSU(){for(int i=0;i<MAX_N;i++) fa[i]=i;}
		int findfa(int x) {return x==fa[x]?x:fa[x]=findfa(fa[x]);}
		bool okay(int x,int y) {return findfa(x)==findfa(y);}
		void merg(int x,int y) {fa[findfa(x)]=findfa(y);}
	}dsu;
	int gcd(int x,int y) {return y==0?x:gcd(y,x%y);}
	struct Edge{int x,y,c;}e[MAX_N];
	int calc(int x,int a,int b){return 6*(x-1)+3*a+b;}
	bool tmp[2][1100000];
	void main()
	{
		int n,m,q,M;scanf("%d%d%d%d",&n,&m,&q,&M);int g=M;
		for(int i=1;i<=m;i++) scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].c),g=gcd(g,abs(e[i].c-e[1].c));
		M=gcd(M,3*g);int z=e[1].c%g;
		for(int i=1;i<=m;i++)
		{
			int x=e[i].x,y=e[i].y,c=(e[i].c-z)/g;
			for(int a=0;a<=1;a++) for(int b=0;b<=2;b++)
			{
				dsu.merg(calc(x,a,b),calc(y,a^1,(b*2+c)%3));
				dsu.merg(calc(y,a,b),calc(x,a^1,(b*2+c)%3));
			}
		}
		for(int i=0,j=z;i<M;i++,j=j*2%M) tmp[i&1][j]=1;

		while(q--)
		{
			int x,y,r;scanf("%d%d%d",&x,&y,&r);
			bool bk=0;
			for(int a=0;a<=1;a++) for(int b=0;b<=2;b++)
				if(dsu.okay(calc(y,0,0),calc(x,a,b)) and tmp[a][ (r+z+(3-b)*g)%M ]) bk=1;
			puts(bk?"YES":"NO");
		}
	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 8192