akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, a[202020];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n,greater<int>());
	
	i64 cnt = a[0];
	for(int i = 2; i < n; i++){
		cnt += a[i/2];
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 4444
Sa=input()
Sb=input()
Sc=input()
a=len(Sa)
b=len(Sb)
c=len(Sc)
l=[]
tmp=Sa[0]
anum=0
bnum=0
cnum=0
anum+=1
ans=""
while(1):
    #print(tmp)
    if tmp=="a":
        if anum>=(a):
            ans="A"
            break
        tmp=Sa[anum]
        anum+=1

    elif tmp=="b":
        if bnum>=(b):
            ans="B"
            break
        tmp=Sb[bnum]
        bnum+=1

    elif tmp=="c":
        if cnum>=c:
            ans="C"
            break
        tmp=Sc[cnum]
        cnum+=1
        #print(cnum)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double r = sc.nextDouble();
    System.out.println(String.format("%.6f", Math.PI*r*r) + " "+ String.format("%.6f",2*Math.PI*r));
  }
}



Measured memory_bytes: 28340
import math

Q = int(input())
for _ in range(Q):
    A, B = map(int, input().split())
    if A > B:
        A, B = B, A
    C1 = math.floor(math.sqrt(A) * math.sqrt(B))
    if C1 ** 2 >= A*B:
        C1 -= 1
    if C1 == 0:
        print(0)
        continue
    C2 = (A*B-1) // C1
    ans = C1 * 2
    if C1 == C2:
        ans -= 1
    if C1 >= A:
        ans -= 1
    print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

void PrintOutput(int inputK, int inputA, int inputB, int multiplyA, int multiplyB)
{
    if (inputK * multiplyA == inputA)
    {
        printf("OK \n");
    }
    else if (inputK * (multiplyA + 1) <= inputB)
    {
        printf("OK \n");
    }
    else
    {
        printf("NG \n");
    }
}

void StartProgram()
{
    int inputK, inputA, inputB, multiplyA, multiplyB;
    
    //printf("Enter the value of K \n");
    scanf("%d", &inputK);
    //printf("Enter the value of A and B \n");
    scanf("%d %d", &inputA, &inputB);
    
    if(inputK > 1000)
    {
        printf("Wrong input... \n");
        StartProgram();
    }
    else if(inputB > 1000)
    {
        printf("Wrong input... \n");
        StartProgram();
    }
    else if(inputA > inputB)
    {
        printf("Wrong input... \n");
        StartProgram();
    }
    
    multiplyA = inputA / inputK;
    multiplyB = inputB / inputK;
    
    PrintOutput(inputK, inputA, inputB, multiplyA, multiplyB);
}

int main(int argc, const char * argv[]) {
  
    StartProgram();
    
    return 0;
}

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

int main(){
	string s;	cin>>s;
	string ans="Yes";
	for(int i=0;i<4;i++){
		int count=0;
		for(int j=0;j<4;j++){
			if(s[i]==s[j])count++;
		}
		if(count!=2){
			ans="No";
			break;
		}
	}

	cout<<ans<<endl;


	return 0;
}


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

using namespace std;
typedef long long LL;

LL gcd(LL a, LL b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
LL calc_lcm(LL a, LL b) { return a * b / gcd(a, b); }

int main() {
  int n;
  LL m;
  cin >> n >> m;
  vector<LL> input(n);
  for (int i = 0; i < n; i++) cin >> input[i];

  LL lcm = 1;

  for (int i = 0; i < n; i++) {
    input[i] /= 2;
    lcm = calc_lcm(lcm, input[i]);
    if (lcm > m) break;
  }

  //  cout << lcm << endl;
  LL ans = 0;
  if (lcm > m) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
    if ((lcm / input[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  cout << m / lcm - m / (lcm * 2) << endl;

  return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = 1000000000;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N,M;
    cin >> N >> M;
    int a[M],b[M];
    VVI c(M);
    REP(i,M){
        cin >> a[i] >> b[i];
        c[i] = VI(b[i]);
        REP(j,b[i]) cin >> c[i][j];
    }

    int S = (int)pow(2, N);
    int dp[M+1][S];
    REP(i,M+1)REP(j,S) dp[i][j] = INF;
    dp[0][0] = 0;
    
    set<int> s_b, s_a;
    s_b.insert(0);
    FOR(i,1,M+1){
        int key = 0;
        REP(j, b[i-1]) key += (int)pow(2, c[i-1][j]-1);
        for(int state : s_b){
            chmin(dp[i][state], dp[i-1][state]);
            chmin(dp[i][state | key], dp[i-1][state] + a[i-1]);
            s_a.insert(state); s_a.insert(state | key);
        }
        s_b = s_a; s_a.clear();
    }
    
    cout << (dp[M][S-1] == INF ? -1 : dp[M][S-1]) << endl;

    return 0;
}

Measured memory_bytes: 16512
import sys
n, m = list(map(int, input().split()))
res = [list(map(int, input().split())) for _ in range(m)]

ans = [-1 for _ in range(n)]



if n == 1:
	tmp = 0
	for i in range(m):
		tmp += res[i][1]
	if tmp == 0:
		print(0)
		sys.exit()

for r in res:
	if ans[r[0] - 1] >= 0:
		if ans[r[0] - 1] != r[1]:
			print(-1)
			sys.exit()
	ans[r[0] - 1] = r[1]

#print(res)
#print(ans)
flag = 0
for i in range(n):
	if ans[i] == -1:
		if flag:
			ans[i] = 0
		else:
			ans[i] = 1
	if i == 0 and ans[i] == 0:
		print(-1)
		sys.exit()
	else:
		flag = 1


print("".join([str(a) for a in ans]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define int long long
#define ld long double
#define endl '\n'
const int mod= 1e9+7;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define trace(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
#define reset(x,val) memset(x,val,sizeof(x))
#define flush fflush(stdout)
#define sz(a) a.size()
#define pii pair<int,int>
using namespace std;
const int W=100005;
const int N=105;
int wt[N],v[N];
int dp[N][W];
void smax(int &x,int y)
{
 x=max(x,y);
}
int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,w;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    cin>>wt[i]>>v[i];
    
    for(int i=1;i<=n;i++)
    {
     for(int weigh=1;weigh<=w;weigh++)
     {
      if(wt[i-1]>weigh)
      dp[i][weigh]=dp[i-1][weigh];
      else
      dp[i][weigh]=max(v[i-1]+dp[i-1][weigh-wt[i-1]], dp[i-1][weigh] );
     }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}



Measured memory_bytes: 79360
n = int( raw_input( ) )
s = [ int( val ) for val in raw_input( ).split( " " ) ]
q = int( raw_input( ) )
t = [ int( val ) for val in raw_input( ).split( " " ) ]

cnt = 0
cnt = 0
for ti in t:
	low = 0
	high = n - 1
	while low <= high:
		m = ( low+high )//2
		if ti < s[m]:
			high = m - 1
		elif s[m] < ti:
			low = m + 1
		else:
			cnt += 1
			break

print( cnt )

Measured memory_bytes: 13160
n,m = map(int,input().split())
coins = list(map(int,input().split()))

inf = 10 ** 6

dp = [inf] * (n + 1)
dp[0] = 0

for c in range(m):
  for v in range(n + 1):
    if v >= coins[c]:
      dp[v] = min(dp[v - coins[c]] + 1,dp[v])
    else:
      dp[v] = dp[v]
      
print(dp[n])


Measured memory_bytes: 7516
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int N;
char S[200050];

int check(int a, int b) {
  for (int i = a; i < b; ++i) {
    if (S[i] == '#' && S[i + 1] == '#') {
      return 0;
    }
  }
  for (int i = a; i <= b; ++i) {
    if (i - 1 >= 0 && i + 1 < N && S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
      return 2;
    }
  }
  return 1;
}

int main() {
  N = in();
  int A = in() - 1;
  int B = in() - 1;
  int C = in() - 1;
  int D = in() - 1;
  scanf("%s", S);

  int snk = check(A, C);
  int fnk = check(B, D);

  if (snk == 0 || fnk == 0) {
    puts("No");
    return 0;
  }

  if (C > D) {
    puts(fnk == 2 ? "Yes" : "No");
  } else {
    puts("Yes");
  }

  return 0;
}


Measured memory_bytes: 384
from math import ceil

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

a_btm = ceil(a*100/8)
a_top = int((a+1)*100/8)

b_btm = b*10
b_top = (b+1)*10 -1

minn = min(a_btm,a_top,b_btm,b_top)
maxx = max(a_btm,a_top,b_btm,b_top)

ans = -1
for i in range(minn,maxx+1):
    if int(i*0.08)==a and int(i*0.1)==b:
        ans = i
        break

print(ans)

# ans = -1
# for aa in range(a_btm,a_top):
#     for bb in range(b_btm,b_top):
#         if aa == bb:
#             ans = aa
#             break
#     break



Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
public class Main {
    static int INF = 1001001009;
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 1000000000+7;
    long[] inv, fac;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Main main = new Main();
        main.solve();
//        long ans = main.solve();
//        out.println(ans);
//        main.solve();
        out.flush();
    }
    void solve() throws Exception{
        int n = sc.nextInt(), m = sc.nextInt();
        ini(m);
        // Calculate basic case with inclusion-exclusion
        long base = 0, co = 1;
        for(int i=0; i<=n; i++){
            base += co*(comb(n,i)*permu(m-i, n-i)%mod);
            base = (base+mod)%mod;
            co *= -1;
        }
        base = base*permu(m,n)%mod;
        out.println(base);
    }
    long permu(int n, int m){
        if(n<m) return 0;
        return fac[n]*inv[n-m]%mod;
    }
    long comb(int n, int m){
        if(n<m) return 0;
        return fac[n]*inv[m]%mod*inv[n-m]%mod;
    }
    void ini(int n){
        inv = new long[n+1]; fac = new long[n+1];
        fac[0] = 1;
        for(int i=1; i<=n; i++) fac[i] = fac[i-1]*i%mod;
        inv[0] = 1;
        inv[n] = power(fac[n], mod-2);
        for(int i=n-1;i>0;i--) inv[i] = inv[i+1]*(i+1)%mod;
    }
    int paIn(String s){return Integer.parseInt(s);}
    long power(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
}

Measured memory_bytes: 43556
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(int i=0; i<N-1; i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  auto bfs = [&](int root){
    vector<int> dist(N,-1);
    dist[root] = 0;
    queue<int> que;
    que.emplace(root);
    while(que.size()){
      int v = que.front();
      que.pop();
      for(int nv: G[v]){
        if(dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        que.emplace(nv);
      } 
    }
    int mx = -1;
    int id;
    for(int i=0; i<N; i++){
      if(chmax(mx,dist[i])) id = i;
    }
    return P(mx,id);
  };
  P suzu = bfs(0);
  suzu = bfs(suzu.second);
  if((suzu.first+1)%3 == 2){
    cout << "Second\n";
  }else{
    cout << "First\n";
  }
  return 0;
}

Measured memory_bytes: 16548
//knapsack
#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n, weight_max;
    cin >> n >> weight_max;
    vector<vector<int>> vec(n, vector<int>(2)); //vec.at(count) = {weight, value}
    for ( int i = 0; i < n; ++i){
        cin >> vec.at(i).at(0) >> vec.at(i).at(1);
    }

    vector<vector<long long>> dp(n+1, vector<long long>(weight_max+1, 0)); //dp.at(count).at(weight) = max_value
    for ( int count = 0; count < n; ++count) {
        for ( int weight = 0; weight < weight_max+1; ++weight) {
            if ( weight < vec.at(count).at(0)) {
                dp.at(count+1).at(weight) = dp.at(count).at(weight);
            }
            else {
                dp.at(count+1).at(weight) = max(dp.at(count).at(weight-vec.at(count).at(0)) + vec.at(count).at(1), dp.at(count).at(weight));
            }
        }
    }
    cout << dp.at(n).at(weight_max) << endl;
}

Measured memory_bytes: 80256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FIO ios_base::sync_with_stdio(false); cin.tie(0);
#define trav(x,a) for (auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define endl "\n"
#define case(t) cout << "Case #" << (t) << ": "
#define reada(a, n) for (int _i = 0; _i < (n); _i++) read(a[_i])
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;

template<class T> void read(T& x) { cin >> x; }
template<class X, class Y> void read(pair<X,Y>& a) { read(a.first), read(a.second); }
template<class T> void read(vector<T>& x) { trav(y, x) read(y); }
template<class T, class... O> void read(T& x, O&... y) { read(x), read(y...); }

string to_string(const char& x) { return string(1,x); }
string to_string(const char*& x) { return (string)x; }
string to_string(const string& x) { return x; }
template<class T, class U> string to_string(const pair<T,U>& x) { return to_string(x.first) + " " + to_string(x.second); }
template<class T> string to_string(const vector<T>& x) { string ret = ""; bool f = 0; trav(y, x) ret += (!f ? "" : " ") + to_string(y), f = 1; return ret; }
void print() { cout << endl; }
template<class T> void pr(const T& x) { cout << to_string(x); }
template<class T, class... O> void print(const T& x, const O&... y) { pr(x); if (sizeof...(y)) pr(" "); print(y...); }

int a[N], b[N];

int main() {
  FIO
  int n, q; read(n, q);
  set<pii> v[2];
  while (q--) {
    int t, x; read(t, x); t--;
    auto it = v[t^1].lower_bound(mp(x - 1, -1));
    int& val = t == 0 ? a[x] : b[x];
    if (it == v[t^1].end()) {
      val = n-2;
    } else {
      val = it->nd - 2;
    }
    v[t].insert(mp(val, x));
  }
  ll ans = (n - 2) * 1ll * (n - 2);
  for (int i = 0; i < n; i++)
    ans -= a[i] + b[i];
  print(ans);
  return 0;
}


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

string ans(int x, int y){
    string S;
    if(x > y) S = "a > b";
    if(x == y) S = "a == b";
    if(x < y) S = "a < b";
    return S;
}

int main(){
    int a,b;
    cin >> a >> b;
    cout << ans(a,b) << endl;
    return 0;
}


Measured memory_bytes: 3136
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 100*1000+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
vector<int> whr[256];

int main(){
  IO;
  int n,nn;
  cin>>n;
  nn=1<<n;
  string s;
  cin>>s;
  map<pair<string, string>, int>  mp1,mp2;
  for(int i=0;i<nn;i++){
    string red,blu;
    for(int j=0;j<n;j++){
      if((i>>j)&1){
        red+=s[j];
      }else{
        blu+=s[j];
      }
    }
    reverse(blu.begin(),blu.end());
    mp1[{red,blu}]++;
    // cout<<red<<' '<<blu<<endl;
  }
  for(int i=0;i<nn;i++){
    string red,blu;
    for(int j=0;j<n;j++){
      if((i>>j)&1){
        red+=s[j+n];
      }else{
        blu+=s[j+n];
      }
    }
    reverse(red.begin(),red.end());
    mp2[{red,blu}]++;
  }
  ll ans=0;
  for(auto i:mp1){
    ans+=(ll)mp1[i.X]*mp2[i.X];
  }
  cout<<ans;
}


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

int main()
{
	int n;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	for (int i=1; i<=n; i++)
	{
		cin>>t[i]>>x[i]>>y[i];
	}
	int k=0;
	for (int i=1; i<=n; i++)
	{
		if (x[i]+y[i]<=t[i] && (x[i]+y[i]-t[i])%2==0)
			k++;
	}
	if (k==n)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

typedef long long ll;

int main(){
  ll t[2],a[2],b[2];
  cin >> t[0] >> t[1];
  cin >> a[0] >> a[1];
  cin >> b[0] >> b[1];
  if(t[0]*a[0]+t[1]*a[1] == t[0]*b[0]+t[1]*b[1]){
    puts("infinity");
    return 0;
  }
  
  if(t[0]*a[0]+t[1]*a[1] > t[0]*b[0]+t[1]*b[1]){
    swap(a[0],b[0]);
    swap(a[1],b[1]);
  }
  if(a[0]<b[0])cout << 0 << endl;
  else if((t[0]*a[0]-t[0]*b[0])%(-t[0]*a[0]-t[1]*a[1]+t[0]*b[0]+t[1]*b[1])==0){
    cout << 2*((t[0]*a[0]-t[0]*b[0])/(-t[0]*a[0]-t[1]*a[1]+t[0]*b[0]+t[1]*b[1])) << endl;
  }
  else {
    cout << 2*((t[0]*a[0]-t[0]*b[0])/(-t[0]*a[0]-t[1]*a[1]+t[0]*b[0]+t[1]*b[1]))+1 << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n,l,r,ans=1000000;
	cin >> n;
	vector<pi>human(n+1);
	human[0] = pi(0, 0);
	map<char,int>mp;
	string s;
	cin >> s;
	rep(i,n) {
		mp[s[i]]++;
		human[i+1] = pi(mp['W'], mp['E']);
	}
	rep(i, n) {
		l = human[i].first;
		r = human[n].second - human[i+1].second;
		ans = min(ans, l + r);
		}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 6244
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 4e5 + 10;
const int M = 1e5 + 10;
const int K = 26;
char s[N];
int len[M];
int cnt[M][K][K];
int prefix[M];

struct Node {
  int sum;
  bool visit;
  Node *child[K];
};

Node pool[N], *last;

Node* new_node() {
  Node* ret = last++;
  ret->sum = ret->visit = 0;
  fill(ret->child, ret->child + K, nullptr);
  return ret;
}

void insert(Node* p, char s[]) {
  for (int i = 0; s[i]; ++i) {
    int k = s[i] - 'a';
    if (!p->child[k]) {
      p->child[k] = new_node();
    }
    p = p->child[k];
    p->sum++;
  }
  p->visit = true;
}

int main() {
  int n, m;
  scanf("%d", &n);
  last = pool;
  Node* root = new_node();
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%s", s + pos);
    insert(root, s + pos);
    len[i] = strlen(s + pos);
    pos += len[i];
  }
  pos = 0;
  for (int i = 0; i < n; ++i) {
    Node* p = root;
    for (int j = pos; j < pos + len[i]; ++j) {
      int k = s[j] - 'a';
      for (int u = 0; u < K; ++u) {
        if (u == k || !p->child[u]) continue;
        cnt[i][u][k] += p->child[u]->sum;
      }
      p = p->child[k];
      if (j != pos + len[i] - 1 && p->visit) prefix[i]++;
    }
    pos += len[i];
  }
  scanf("%d", &m);
  while (m--) {
    int k, ret;
    scanf("%d%s", &k, s);
    --k;
    ret = 1 + prefix[k];
    for (int i = 0; i < K; ++i) {
      for (int j = i + 1; j < K; ++j) {
        int x = s[i] - 'a';
        int y = s[j] - 'a';
        ret += cnt[k][x][y];
      }
    }
    printf("%d\n", ret);
  }
  return 0;
}


Measured memory_bytes: 293120
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;
int main(){
  int N, T;
  scanf("%d%d", &N, &T);
  vector<long long int> A(N, 0);
  for (int i = 0; i < N; i++){
    scanf("%lld", &(A[i]));
  }
  long long int max = 0;
  int max_counter = 0;
  long long int begin = A[N-1];
  for (int i = N-2; i >= 0; i--){
    if (A[i] > begin){
      begin = A[i];
    }else if ((begin-A[i]) == max){
      max_counter++;
    }else if ((begin-A[i]) > max){
      max_counter = 1;
      max = begin-A[i];
    }
  }
  cout << max_counter << endl;
  return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: i32,
  }
  for a in 1 .. 10 {
    for b in 1 .. 10 {
      if a * b == n {
        puts!("Yes\n");
        return;
      }
    }
  }
  puts!("No\n");
}


Measured memory_bytes: 4352
import sys

L, R = map(int, input().split())
mod = 2019
ans = []
if R-L > 3000:
    print(0)
    sys.exit()
elif R-L <= 3000:
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            tmp = (i * j) % mod
            ans.append(tmp)
print(min(ans))


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

struct card{
    char c;
    int num;
};

template<typename T>
void bsort( typename vector<T>::iterator itr_first, typename vector<T>::iterator itr_last){ 
    for(int i=0; i < itr_last - itr_first; ++i){
        for(auto itr=itr_last-1;itr!=itr_first-1+i;--itr){
            if((*itr).num>=(*(itr-1)).num) continue;
            swap(*itr,*(itr-1));
        }
    }
}

template<typename T>
void ssort( typename vector<T>::iterator itr_first, typename vector<T>::iterator itr_last){ 
    for(auto i=itr_first; i!=itr_last; ++i){
        auto itr_min = i;
        for(auto itr=i;itr!=itr_last;++itr) if((*itr_min).num>(*itr).num) itr_min = itr;
        if ((*i).num<=(*itr_min).num) continue;
        swap(*i,*itr_min);
    }
}

template<typename T>
std::vector<T> bsorted(std::vector<T> vec){
    bsort<T>(vec.begin(),vec.end());
    return vec;
}

template<typename T>
std::vector<T> ssorted(std::vector<T> vec){
    ssort<T>(vec.begin(),vec.end());
    return vec;
}

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

    int nb; cin>>nb;
    std::vector<card> cards; cards.resize(nb);
    for(auto& a:cards){
        string s; cin>>s;
        a.c = s[0];
        a.num = (int)(s[1]-'0');
    }
    auto bsorted_cards = bsorted<card>(cards);
    for(auto& a:bsorted_cards) cout<<a.c<<a.num<<(&a!=&bsorted_cards.back()? " ":"\n");
    cout<<"Stable\n";
    
    auto ssorted_cards = ssorted<card>(cards);
    for(auto& a:ssorted_cards) cout<<a.c<<a.num<<(&a!=&ssorted_cards.back()? " ":"\n");;
    bool isStable=true;
    for(int i=0;i<cards.size();++i) if(bsorted_cards[i].c!=ssorted_cards[i].c) isStable=false;
    cout<<(isStable? "Stable\n":"Not stable\n");
}

Measured memory_bytes: 3228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
 
 
public class Main{
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
	
	static class Pair
	{
		int p;
		int q;
		Pair(int p,int q)
		{
			this.p = p;
			this.q = q;
		}
	}
	
	static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	static long gcd(long a,long b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}
	static void preCompute(long fact[])
	{
		fact[0] = 1;
		for(int i = 1; i < fact.length; i++)
		{
			fact[i] = i*fact[i-1]%rem;
		}
	}
	static long power(long x, long y, long p) 
    { 
        long res = 1; 
        x = x % p; 
                      
        while (y > 0) 
        {
            if (y % 2 == 1) 
                res = (res * x) % p; 
 
            y = y >> 1; 
            x = (x * x) % p; 
        }
        return res; 
    } 
	static long modInverse(long n, long p) 
    { 
        return power(n, p-2, p); 
    }
	
	static long nCrModPFermat(int n, int r, long p) 
	{ 
 
		if (r == 0) 
			return 1; 
 
		return (fact[n]* modInverse(fact[r], p) % p * modInverse(fact[n-r], p) % p) % p; 
	}
	static long rem = (long)(1e9)+7;
	static long fact[];
	
 
	public static void main(String[] args) 
	{
		OutputStream outputStream = System.out;
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(outputStream);
        
        String s = sc.nextLine();
        
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5))
        {
        	out.println("Yes");
        }
        else out.println("No");
        out.close();
	}
 
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int A, B, K;
    scanf("%d%d%d", &A, &B, &K);

    int count = 0;
    int i;
    if(A >= B) {
        i = B;
    }
    else{
        i = A;
    }

    while(i > 0){
        if(A % i == 0 && B % i == 0) {
            count++;
            if(count == K) {
                printf("%d\n", i);
                return 0;
            }
        }
        i--;
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	int m,n;
	scanf("%d %d",&n,&m);

	int A[n][m],a[m],c[n];
	int i,j;

	for(i = 0;i < n;i++){
		c[i] = 0;
	}

	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%d",&A[i][j]);
		}
	}

	for(i = 0;i < m;i++){
		scanf("%d",&a[i]);
	}

	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			c[i] +=  (A[i][j] * a[j]);
		}
		printf("%d\n",c[i]);
	}
	return 0;
}

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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e9;

int n, m;
vector<vector<int>> e;
vector<int> c;
vector<vector<int>> vs;
vector<int> f;

void dfs(int i, vector<int> &v) {
	if (f[i] == 1) return;
	f[i] = 1;
	v.push_back(c[i]);

	each(j, e[i]) {
		dfs(j, v);
	}
}

signed main() {
	cin >> n >> m;
	e.resize(n);
	c.resize(n);

	rep(i, n) {
		cin >> c[i];
	}

	rep(i, m) {
		int x, y;
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}

	f.clear();
	f.resize(n, 0);
	rep(i, n) {
		if (f[i] == 0) {
			vs.push_back(vector<int>());
			dfs(i, vs.back());
		}
	}
	each(v, vs) {
		sort(all(v));
	}

	priority_queue<P, vector<P>, greater<P>> q;

	rep(i, vs.size()) {
		if (vs[i].size() >= 2) {
			q.push(P(vs[i][1], i));
		}
	}

	int ans = 0;
	set<int> se;
	priority_queue<int, vector<int>, greater<int>> sq;
	each(i, vs[0]) {
		sq.push(i);
	}
	se.insert(0);

	while (se.size() < vs.size()) {
		if (q.size() == 0) break;
		if (sq.size() == 0) {
			cout << "Impossible" << endl;
			return 0;
		}

		auto p = q.top();
		q.pop();
		int i = p.second;
		if (se.count(i)) continue;
		ans += sq.top() + vs[i][0];
		sq.pop();
		se.insert(i);
		REP(j, 1, vs[i].size()) {
			sq.push(vs[i][j]);
		}
	}

	rep(i, vs.size()) {
		if (se.count(i)) continue;
		if (sq.size() == 0) {
			cout << "Impossible" << endl;
			return 0;
		}
		ans += sq.top();
		sq.pop();
		ans += vs[i][0];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 10804
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("water.in","r",stdin);
	freopen("water.out","w",stdout);
#endif
}

const int MAXN=2011;

static int n,k,dp[MAXN][MAXN];

inline void init()
{
	read(n);read(k);
}

const int mod=1e9+7;

inline int ad(int u,int v){return(u+=v)>=mod?u-mod:u;}

static int func[MAXN*MAXN],inv[MAXN*MAXN];

inline int power(int u,int v)
{
	static int sm;
	for(sm=1;v;v>>=1,u=(uint64)u*u%mod)if(v&1)
		sm=(uint64)sm*u%mod;
	return sm;
}

inline int C(int u,int v)
{return u>=v?(uint64)func[u]*inv[v]%mod*inv[u-v]%mod:0;}

inline void solve()
{
	if(k==1)return (void)printf("1\n");

	dp[0][0]=1;
	
	func[0]=1;
	Rep(i,1,n*k)func[i]=(uint64)func[i-1]*i%mod;
	inv[n*k]=power(func[n*k],mod-2);
	Repe(i,n*k,1)inv[i-1]=(uint64)inv[i]*i%mod;

	Rep(i,0,n)Rep(j,i,n)
	{
		if(j>i)dp[i][j]=dp[i][j-1];
		if(i)dp[i][j]=ad(dp[i][j],(uint64)dp[i-1][j]*
			C(n*k-(i-1)*(k-1)-j-1,k-2)%mod);
	}
	printf("%d\n",(uint64)dp[n][n]*func[n]%mod);
}

int main()
{
    init();
    solve();
    return 0;
}


Measured memory_bytes: 47488
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/

int main() {
	ll H, W; cin >> H >> W;
	char s[50][50] = {};
	rep(i, 0, H) {
		rep(j, 0, W) {
			cin >> s[i][j];
		}
	}
	ll x[8] = { 1,0,0,-1 };
	ll y[8] = { 0,1,-1,0 };

	rep(i, 0, H) {
		rep(j, 0, W) {
			if (s[i][j] == '.') {
				continue;
			}

			ll cnt = 0;
			rep(k, 0, 4) {
				ll ny = i + y[k];
				ll nx = j + x[k];
				if (nx >= 0 && nx < W && ny >= 0 && ny < H) {
					if (s[ny][nx] == '#') {
						cnt++;
					}
				}
			}

			if (cnt == 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	}

}


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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int result = 0;
  for (int r = 0; r*R <= N; r++) {
    for (int g = 0; r*R + g*G <= N; g++) {
      if ((N - r*R - g*G) % B == 0) result++;
    }
  }
  
  cout << result << endl;
  
  return 0;
}

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

int len[51],pat[51];

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

  int n,x; cin >> n >> x;

  len[0] = pat[0] = 1;
  for(int i = 1; i <= n; i++){
    len[i] = len[i-1] * 2 + 3;
    pat[i] = pat[i-1] * 2 + 1;
  }

  function< int(int,int) > rec =
  [&](int k,int x){ //{レベル,食べる層}
    if(x == len[k]) return pat[k];

    int ans = 0;
    //下のバン
    x--;
    //下のk-1バーガー
    if(x > 0){
      int l = min(x,len[k-1]);
      ans += rec(k-1,l);
      x -= l;
    }
    //真ん中のパティ
    if(x > 0){
      ans++;
      x--;
    }
    //上のk-1バーガー
    if(x > 0){
      int l = min(x,len[k-1]);
      ans += rec(k-1,l);
      x -= l;
    }
    return ans;
  };
  cout << rec(n,x) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 10000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    ll N,M; cin>>N; M=0;
    map<string, ll> mp;
    for(int i=0; i<N; i++){
        string s; cin>>s;
        if(mp[s]!=0){
            mp[s]++;
        }
        else{
            mp[s]=1;
        }
        M=max(M,mp[s]);
    }
    for (auto i = mp.begin(); i != mp.end(); i++) {
        if(i->second==M){
            cout<<i->first<<endl;
        }
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
const long long mx = 1000000000000000000;
int n;
long long a, acum = 1LL;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "a", stdout);
    // #endif
    cin >> n;
    bool flag = true;
    for(int i = 0; i < n; i++) {
        cin >> a;
        if(a == 0) {
            flag = true;
            acum = 0;
            break;
        }
        else if(acum <= mx / a) acum *= a;
        else {
            flag = false;
        }
    }
    if(flag)    cout << acum << "\n";
    else    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define vs vector<string>
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<pair<string,int>, int> &a,const pair<pair<string,int>, int> &b)
{
    if(a.ff.ff == b.ff.ff) {
        return (a.ff.ss > b.ff.ss);
    }
    return (a.ff.ff<b.ff.ff);
}
int min(int a, int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int max(int a, int b){
    if(a>b){
        return a;
    }
    else{
        return b;
    }
}
int poww(int a, int b)
{
    int res = 1;
    for(int i = 1; i<=b; ++i)
        res *= a;

    return res;
}
int findlcm(int arr[], int n) 
{ 
    // Initialize result 
    int ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}
bool prime[100001];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
  }
}

//Define mx for maximum range and MOD for large numbers
#define mx 200001
#define MOD 1000000007;
// Declare all the variables and global functions here - 
int n,m;
int32_t main(){
    IOS;
    string s;
    cin >> s;
    int c = 0;
    rep(i, 0, s.length()){
        if(s[i] == 'o'){
            c++;
        }
    }

    if(c + 15-s.length() >= 8){
        cout << "YES" << '\n';
    }
    else{
        cout << "NO";
    }

 }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n;
int a[100005];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	rep(n)
	{
		scanf("%d",a+i);
	}
	ll cost=abs(a[0]);
	for(int i=1;i<n;i++)
	{
		cost+=abs(a[i]-a[i-1]);
	}
	cost+=abs(a[n-1]);
	cout<<cost-abs(a[0])-abs(a[0]-a[1])+abs(a[1])<<endl;
	for(int i=1;i<n;i++)
	{
		cout<<cost-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
	}
//	cout<<cost-abs(a[n-1])-abs(a[n-2]-a[n-1])+abs(a[n-2])<<endl;
	return 0;
}

Measured memory_bytes: 1664
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
h = list(map(int, readline().split()))
ab = [list(map(int, readline().split())) for _ in range(m)]
memo = [True] * n
for a, b in ab:
    if h[a - 1] > h[b - 1]:
        memo[b - 1] = False
    elif h[a - 1] < h[b - 1]:
        memo[a - 1] = False
    else:
        memo[a - 1] = False
        memo[b - 1] = False
print(memo.count(True))


Measured memory_bytes: 32440
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll A[N];
  REP(i,N){
    cin>>A[i];
    if(A[i]==0){
      co(0);
      return 0;
    }
  }
  
  ll ans=1;
  REP(i,N){
    if(1000000000000000001/ans<A[i]){
      co(-1);
      return 0;
    }
    ans*=A[i];
  }
  
  if(ans>1000000000000000000){
    co(-1);
    return 0;
  }
  co(ans);
  return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    vb isPrime(1e8+1, true); isPrime[0] = isPrime[1] = false;
    for(int i = 2; i * i <= 1e8; i++)
    {
        if(isPrime[i])
        {
            for(int j = i*2; j <= 1e8; j += i) isPrime[j] = false;
        }
    }

    int n; cin >> n;
    int ans = 0;
    REP(i, n)
    {
        int x; cin >> x;
        if(isPrime[x]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14824