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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    double L;
    scanf("%lf" , &L);

    double side = L / 3.0;

    printf("%.9f\n" , side * side * side);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h;
vector<ll> ans;
vector<ll> s;
map<ll,ll> m;


int main()
{
	ll n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		h.push_back(tmp);
		s.push_back(tmp);
		ans.push_back(0);
	}
	ll fi = 0;
	ll se = 0;
	sort(s.begin(), s.end());
	
	fi = s[s.size()-1];
	se = s[s.size()-2];
	
	for (int i = 0; i < n; i++) {
		if (h[i] == fi) {
			ans[i] = se;
		}
		else {
			ans[i] = fi;
		}
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	

	return 0;
}


Measured memory_bytes: 6612
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll umax(ll a ,ll b)
{
	if(a>b)return a;return b;
}
int main()
{
	ll n;cin >> n;
	ll a[n][3];
	for(ll i=0;i<n;i++)
	{
		ll a1,b,c;cin >> a1 >> b >> c;
		if(i==0)
		{
			a[0][0]=a1;
			a[0][1]=b;
			a[0][2]=c;
		}
		else
		{
			a[i][0]=umax(a1+a[i-1][1],a1+a[i-1][2]);
			a[i][1]=umax(b+a[i-1][0],b+a[i-1][2]);
			a[i][2]=umax(c+a[i-1][0],c+a[i-1][1]);
		}
	}
	cout << umax(a[n-1][0],umax(a[n-1][1],a[n-1][2]));
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				c[i][j]= sc.nextInt();
			}
		}
		for(int i=0; i<3; i++){
			for(int j=1; j<3; j++){
				c[i][j] -= c[i][0];
			}
		}
		System.out.println(c[0][1]==c[1][1] && c[1][1]==c[2][1] && c[0][2]==c[1][2] && c[1][2]==c[2][2] ? "Yes" : "No");
	}
}

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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int a,b; std::cin >> a >> b;
  std::cout << max(0,a - 2*b) << '\n';
  return 0;
}


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

using namespace std;

long long inf=1000000007;

int main(){
	int n;
	cin>>n;
	vector<vector<pair<int,int>>> tes(n);
	for(int i=0;i<n;i++){
		int cnt;
		cin>>cnt;
		for(int j=0;j<cnt;j++){
			int a,b;
			cin>>a>>b;
			tes.at(i).push_back(make_pair(a,b));
		}
	}

	int ans=0;

	for(int i=0;i<(1<<15);i++){
		bitset<15> bits=i;
		bool flag=true;
		int pre=0;

		for(int j=0;j<n;j++){
			if(bits.test(j)) pre++;
		}

		for(int j=0;j<n;j++){
			if(!bits.test(j)) continue;

			for(auto a:tes.at(j)){
				if(bits.test(a.first-1)!=a.second) flag=false;
			}
		}

		if(flag) ans=max(ans,pre);
	}

	cout<<ans<<endl;

	return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A);
    vector<ll> q(B);
    vector<ll> r(C);
    REP(i, A)
    cin >> p[i];
    REP(j, B)
    cin >> q[j];
    REP(k, C)
    {
        cin >> r.at(k);
    }

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    REP(n, X)
    r.push_back(p[n]);
    REP(m, Y)
    r.push_back(q[m]);

    sort(r.begin(), r.end(), greater<ll>());

    ll ans = 0;
    REP(x, X + Y)
    ans += r[x];

    cout << ans << endl;
}

Measured memory_bytes: 6128
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// using namespace std;

using ll = long long;

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

const int mod = 1e9 + 7;
class mint {
private:
  std::int64_t m_x;

public:
  mint(int64_t m_x = 0) : m_x(m_x % mod) {}
  mint &operator+=(const mint a) {
    if ((m_x += a.m_x) >= mod)
      m_x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((m_x += mod - a.m_x) >= mod)
      m_x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (m_x *= a.m_x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  std::int64_t get() { return m_x; }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  rep(i, 4000) {
    for (int j = 0; j <= i; ++j) {
      c[i + 1][j] += c[i][j];
      c[i + 1][j + 1] += c[i][j];
    }
  }
}

mint comb(int n, int k) { return c[n][k]; }
mint f2(int x, int y) { return comb(x + y - 1, y - 1); }
mint f(int x, int y) { return f2(x - y, y); }

void Main() {
  init();
  int N, K;
  std::cin >> N >> K;

  for (int i = 1; i < K + 1; ++i) {
    mint b = f(K, i);
    mint r = f2(N - K - (i - 1), i + 1);
    mint res = b * r;
    std::cout << res.get() << std::endl;
  }
}

int main() {
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 125696
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 1e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 1e9 + 7;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

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

	int n;
	cin >> n;
	vector<ll> a(n), p(n + 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) {
		p[i] = a[i - 1] + p[i - 1];
	}
	vector<vector<ll>> dp(n, vector<ll>(n, 0));
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (j + i - 1 >= n) break;
			int ind = j + i - 1;
			dp[j][ind] = dp[j][j] + dp[j + 1][ind] + p[ind + 1] - p[j];
			for (int k = 2; k < i; k++) {
				int ind2 = j + k - 1;
				dp[j][ind] = min(dp[j][ind], dp[j][ind2] + dp[ind2 + 1][ind] + p[ind + 1] - p[j]);
			}
		}
	}
	cout << dp[0][n - 1];
	return 0;
}


Measured memory_bytes: 1536
def main():
	X,Y,Z,k=map(int,input().split())
	a=list(map(int,input().split()))
	b=list(map(int,input().split()))
	c=list(map(int,input().split()))
	ab=[]
	for x in a:
		for y in b:
			ab.append(x+y)
	ab.sort(reverse=True)
	if len(ab)>k:
		ab=ab[:k+1]
	c.sort()
	l=0
	r=max(ab)+max(c)+1
	import bisect
	while r-l>1:
		cnt=0
		mid=(l+r)//2
		for x in ab:
			cnt+=Z-bisect.bisect_left(c,mid-x)
		if cnt>=k:
			l=mid
		else:
			r=mid
	ans=[]
	for i in range(len(ab)):
		for j in range(bisect.bisect_left(c,l-ab[i]),Z):
			ans.append(ab[i]+c[j])
	ans.sort(reverse=True)
	for i in range(min(k,len(ans))):
		print(ans[i])
if __name__=="__main__":
	main()

Measured memory_bytes: 142868
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, ANS = 0;
	static long long A[200000], B[200000];
	priority_queue<pair<long long, int> > PQ;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i], PQ.push({ B[i], i });
	while (!PQ.empty()) {
		pair<long long, int> P = PQ.top();
		PQ.pop();
		long long X = P.first, Y = P.second;
		long long L = B[(Y + N - 1) % N], R = B[(Y + 1) % N];
		if (X  - A[Y] < L + R) continue;
		long long Diff = X - A[Y];
		long long Z = Diff / (L + R);
		B[Y] -= Z * (L + R);
		ANS += Z;
		PQ.push({ B[Y], Y });
	}
	for (int i = 0; i < N; i++) {
		if (A[i] != B[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ANS << endl;
}

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

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

    int len = (int)(S.length());

    int count = 0;
    for (int t = 0; t < len; t++)
    {
        if (S[t] != T[t])
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) comp(const void *a, const void *b)
#define MOD  1000000007
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;

void TF_print(char boolean, char T[], char F[]){
    if(boolean){
        printf("%s\n", T);
    }else{
        printf("%s\n", F);
    }
}

int main(){
    uint N, M;
    scanf("%u %u", &N, &M);
    uint a, b;
    char mat[N][2];
    uint i, j;
    REP(i, N){
        REP(j, 2){
            mat[i][j] = 0;
        }
    }
    REP(i, M){
        scanf("%u %u", &a, &b);
        if(a == 1){
            mat[b - 1][0] = 1;
        }else if(a == N){
            mat[b - 1][1] = 1;
        }else if(b == 1){
            mat[a - 1][0] = 1;
        }else if(b == N){
            mat[a - 1][1] = 1;
        }
    }
    char flag = 0;
    REP(i, N){
        if(i!=0 && i!= N - 1){
        flag |= mat[i][0] && mat[i][1];
        if(flag){
            break;
        }
        }
    }
    TF_print(flag, "POSSIBLE", "IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define repn(i,n) for(int i=1;i<=n;i++)
int a[15][15],n,m;
int main(){
    while(1){
        cin>>n>>m;
        if(n==0) return 0;
        repn(i,n) repn(j,m) cin>>a[i][j];
        int ans = 0;
        repn(i,n) for(int ii=i+2;ii<=n;ii++)
            repn(j,m) for(int jj=j+2;jj<=m;jj++){
                int mn = 1e9;
                for(int x=i;x<=ii;x++) mn = min(mn,a[x][j]);
                for(int x=i;x<=ii;x++) mn = min(mn,a[x][jj]);
                for(int y=j;y<=jj;y++) mn = min(mn,a[i][y]);
                for(int y=j;y<=jj;y++) mn = min(mn,a[ii][y]);
                int mx = 0, sum = 0;
                for(int x=i+1;x<ii;x++) for(int y=j+1;y<jj;y++){
                    mx = max(mx,a[x][y]);
                    sum += a[x][y];
                }
            
        if(mn > mx) ans = max(ans,mn*(ii-i-1)*(jj-j-1)-sum);
            }
        cout << ans << endl;
        
    }
}



Measured memory_bytes: 3080
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
ans=chk=sum(a)+b[-1]
for i in range(-1,-n,-1):
    chk=chk-a[i]+b[i-1]
    ans=max(ans,chk)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

/* Iterative Function to calculate (x^y) in O(log y) */
ll power(ll x, ll y)
{
    ll res = 1;     // Initialize result
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = res*x;res%=MOD;
 
        // n must be even now
        y = y>>1; // y = y/2
        x = x*x;x%=MOD;  // Change x to x^2
    }
    return res%MOD;
}

int main(){
	SPEED;
	string t;cin>>t;
	
	ll a[t.length()]={};
	
	ll c[t.length()]={};
	ll q=0,q1=0;
	
	for(ll i=0;i<t.length();i++){
		if(t[i]=='?'){
			q++;
		}
		if(t[i]=='A'){
			a[i]++;
		}
		if(i==0){
			continue;
		}
		a[i]+=a[i-1];
	}
	
	for(ll i=t.length()-1;i>=0;i--){
		if(t[i]=='C'){
			c[i]++;
		}
		if(i==t.length()-1){
			continue;
		}
		c[i]+=c[i+1];
	}
	
	ll ans=0;
	
	for(ll i=0;i<t.length();i++){
		if(t[i]=='?'){
			q--;
			
			ll temp=a[i]*c[i];temp%=MOD;
			temp*=power(3,q);temp%=MOD;
			
			if(q1!=0&&q!=0)
			temp=temp + (((q1*c[i])%MOD)*power(3,q-1))%MOD;temp%=MOD;
			
			if(q!=0){
				temp=temp + (((a[i]*(q-q1))%MOD)*power(3,q-1))%MOD;temp%=MOD;
			}
			
			if(q1!=0&&q>=2){
				temp=temp + (((q1*(q-q1))%MOD)*power(3,q-2))%MOD;temp%=MOD;
			}
			ans+=temp;ans%=MOD;
			
			q1++;q++;
		}
		if(t[i]=='B'){
			
			ll temp=a[i]*c[i];temp%=MOD;
			temp*=power(3,q);temp%=MOD;
			
			if(q1!=0&&q!=0)
			temp=temp + (((q1*c[i])%MOD)*power(3,q-1))%MOD;temp%=MOD;
			
			if(q!=0){
				temp=temp + (((a[i]*(q-q1))%MOD)*power(3,q-1))%MOD;temp%=MOD;
			}
			
			if(q1!=0&&q>=2){
				temp=temp + (((q1*(q-q1))%MOD)*power(3,q-2))%MOD;temp%=MOD;
			}
			ans+=temp;ans%=MOD;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long int
int n, m, k;
bool possible(int sum)
{
    int dup = m - sum;

    int value = dup / (n - 1);

    if (value == 0) return (sum < 2);

    cout << value << "\n";


    int rem = dup % (n - 1);

    if (rem != 0) rem = 1;
    else
        rem = 0;

    return (abs(sum - value - rem) < 2);

}
void findAns()
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    if (n < 3)
    {
        cout << "0";
        return ;
    }

    int ans = 0;

    for (int i = 0; i < n - 2; i++)
    {
        if (s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C') ans++;
    }
    cout << ans;
}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("test.txt", "w", stdout);
//     //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s" << "\n";
// #endif

    FAST;
    ll  t = 1;
    //cin >> t;

    while (t--) findAns();
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int segtree[(1<<24)][26];

void init(int i, char aft) {
  i += (1<<23) - 1;
  while(i!=0) {
    segtree[i][aft-'a']++;
    i = (i-1)/2;
  }
}

void change(int i, char aft, char bef) {
  i += (1<<23)-1;
  while(i!=0) {
    segtree[i][bef-'a']--;
    segtree[i][aft-'a']++;
    i = (i-1)/2;
  }
}

int solve(int l, int r) {
  l += (1<<23)-1;
  r += (1<<23)-1;
  map<int, int> amap;
  while(l<r) {
    if(l%2==0) {
      for(int i=0;i<26;++i) amap[i] += segtree[l][i];
      l++;
    }
    l /= 2;
    if(r%2==0) {
      for(int i=0;i<26;++i) amap[i] += segtree[r-1][i];
      r--;
    }
    r /= 2;
  }
  int ans = 0;
  for(int i=0;i<26;++i) {
    if(amap[i]>0) ans++;
  }
  return ans;
}

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  for(int i=0;i<N;++i) {
    init(i, S[i]);
  }
  int Q;
  cin>>Q;
  int query;
  int l, r;
  int index;
  char aft, bef;
  vector<int> answer;
  for(int i=0;i<Q;++i) {
    cin>>query;
    if(query==1) {
      cin>>index>>aft;
      index--;
      bef = S[index];
      change(index, aft, bef);
      S[index] = aft;
    }
    else {
      cin>>l>>r;
      l--;
      answer.push_back(solve(l, r));
    }
  }
  for(int i=0;i<answer.size();++i) cout<<answer[i]<<endl;
}



Measured memory_bytes: 105576
def main():
    _, k = map(int, input().split())
    a = [int(s) for s in input().split()]

    print(solve(k, a))

def solve(k, a):
    b = max(k.bit_length(), max(ai.bit_length() for ai in a))
    dp = [[0, 0] for _ in range(b + 1)]

    mask = 1
    for i in range(1, b + 1):
        x = sum(ai & mask for ai in a)
        y = sum((ai ^ mask) & mask for ai in a)
        if k & mask != 0:
            dp[i][0] = max(x + dp[i-1][1], y + dp[i-1][0])
        else:
            dp[i][0] = x + dp[i-1][0]
        dp[i][1] = dp[i-1][1] + max(x, y)
        mask <<= 1
    
    return dp[b][0]

def build_table(k, a):
    dp = dict()
    dp[1] = (0, 0)

    mask = 1
    while mask < k * 2:
        x = sum(t & mask for t in a)
        y = sum((t & mask) ^ mask for t in a)
        dp[mask << 1] = (max(x, y), max(x, y) + dp[mask][1])
        mask = mask << 1

    return dp

def _solve(k, a):
    def memoize(f):
        memo = dict()
        def wrapped(k, mask):
            key = (k, mask)
            r = memo.get(key, None)
            if r is None:
                r = f(k, mask)
                memo[key] = r
            return r
        return wrapped
    
    @memoize
    def rec(k, mask):
        b = k.bit_length()
        return b
    
    b = max(k.bit_length(), max(x.bit_length() for x in a))
    mask = (1 << b) - 1
    return rec(k, mask)

main()


Measured memory_bytes: 14748
import numpy as np
def main():
  N = int(input())
  A = list(map(int, input().split()))
  ans = 1
  for i in range(N):
    ans *= A[i]
    if ans > 10**18:
      ans = -1
      break
  if 0 in A:
    ans = 0
  print(ans)
if __name__  == "__main__":
  main()

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

int main(){
    int n, q;
    cin >> n >> q;
    atcoder::dsu dsu(n);
    
    for (int i = 0; i < q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            dsu.merge(u, v);
        else
            cout << dsu.same(u, v) << endl;
    }
}


Measured memory_bytes: 3940
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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 S, W;
    cin >> S >> W;
    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, m, x = map(int, input().split())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
#print(l)
ans = []
mon = [0]*(2**n)

def ok(anss,x):
    for i in range(len(anss)):
        if anss[i]<x:
            return False
    return True

for i in range(2**n):
    #print(bin(i))
    #print(anss, mon)
    anss=[0]*m
    for j in range(n):
        #print(l[j][0])
        #print(i-2**(n-1))
        if ((i >> j) & 1):
            mon[i] += l[j][0]
            for k in range(1,m+1):
                anss[k-1]+=l[j][k]
    #print(anss)
    if ok(anss,x):
        #print(ans)
        ans.append(mon[i])
#print(mon,ans)
if ans != []:
    print(min(ans))
else:
    print(-1)


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

int main(void) {
	int N, M, i, j, l, r, cnt = 0;

	scanf("%d %d", &N, &M);
	int l_max = 1;
	int r_min = N;
	for (i = 0; i < M; i++) {
		scanf("%d %d", &l, &r);
		if (l > l_max) {
			l_max = l;
		}
		if (r < r_min) {
			r_min = r;
		}
	}
	if (l_max <= r_min) {
		printf("%d", r_min - l_max + 1);
	}
	else {
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
m=n//2
x=[a[i] for i in range(n) if i%2==0] #kisuu
y=[a[i] for i in range(n) if i%2==1] #guusuu
x=sorted(x)
y=sorted(y)
inx=[]
iny=[]
p=1
q=1

for i in range(m-1):
    if x[i]==x[i+1]:
        p+=1
    else:
        inx.append([p,x[i]])
        p=1
inx.append([p,x[-1]])
for i in range(m-1):
    if y[i]==y[i+1]:
        q+=1
    else:
        iny.append([q,y[i]])
        q=1
iny.append([q,y[-1]])
inx=sorted(inx)
iny=sorted(iny)
inx.insert(0,[0,0])
iny.insert(0,[0,0])

if inx[-1][1]!=iny[-1][1]:
    print(2*m-inx[-1][0]-iny[-1][0])
else:
    print(min(2*m-inx[-1][0]-iny[-2][0],2*m-inx[-2][0]-iny[-1][0]))
    
        




Measured memory_bytes: 94088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n,k;cin>>n>>k;
    vector<int> ak(n);
    rep(i,n){
        cin>>ak[i];
    }
    sort(ALL(ak));
    ll ans=0;
    rep(i,k){
        ans+=ak[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
cardlist = []
card = []

for j in range(1,5):
    for k in range(1,14):
        if j == 1:
            cardlist.append(["S", "{}".format(k)])
        elif j == 2:
            cardlist.append(["H", "{}".format(k)])
        elif j == 3:
            cardlist.append(["C", "{}".format(k)])
        elif j == 4:
            cardlist.append(["D", "{}".format(k)])

num = int(input())

for i in range(num):
    card.append(input().split())

for i in range(num):
    cardlist.remove(card[i])

for i in range(52-num):
    print("{0} {1}".format(cardlist[i][0], cardlist[i][1]))

Measured memory_bytes: 7704
S = input()
Y = int(S[:2])
M = int(S[2:])

if 0 < Y <13 and 0 < M < 13:
  print("AMBIGUOUS")
elif 0 < M < 13:
  print("YYMM")
elif 0 < Y < 13:
  print("MMYY")
else:
  print("NA")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

int cnt[70],tot;
char c[70];

int ask(string s){
	cout<<"? "<<s<<endl;
	int ret; read(ret);
	return ret;
}

string solve(int l,int r){
	if(l==r){
		string s="";
		REP(i,cnt[l]) s=s+c[l];
		return s;
	}
	int m=(l+r)>>1;
	string L=solve(l,m);
	string R=solve(m+1,r);
	int nL=L.size(),pL=0;
	int nR=R.size(),pR=0;
	string res="";
	while(pL<nL&&pR<nR){
		string now=res;
		now=now+L[pL];
		rep(i,pR,nR-1) now=now+R[i];
		if(ask(now)==tot-now.size()){
			res=res+L[pL++];
		}
		else{
			res=res+R[pR++];
		}
	}
	while(pL<nL){
		res=res+L[pL++];
	}
	while(pR<nR){
		res=res+R[pR++];
	}
	return res;
}

int main(){
	REP(i,26){
		c[i]='a'+i;
		c[i+26]='A'+i;
	}
	REP(i,10){
		c[i+52]='0'+i;
	}
	REP(i,62){
		string s;
		REP(k,128) s=s+c[i];
		cnt[i]=128-ask(s);
		tot+=cnt[i];
	}
	string ans=solve(0,61);
	cout<<"! "<<ans<<endl;
	return 0;
}

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

int main(void)
{
  string str;
  str.reserve(4);

  cin >> str;
  int sum=0;

  for(int i=0;i<4;i++)
  {
    if(str[i]=='+')
    {
      sum +=1;
    }
    else
    {
      sum-=1;
    }
  }
    cout << sum;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(C, B / A) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 1e4 + 100;

int n, a[N];
vector<int> A, B, others;
vector<int> BA;

int32_t main(){_

   cin>>n;
   vector<string> v(n);

   for (int i = 0; i < n; ++i)
   {
      cin>>v[i];
      if (v[i][0] == 'B' and v[i].back() == 'A'){
         BA.pb(i);
      }
      else if (v[i][0] == 'B'){
         B.pb(i);
      }
      else if (v[i].back() == 'A'){
         A.pb(i);
      }
      else{
         others.pb(i);
      }
   }


   tr(BA, B, A, others);

   int ans = 0;
   vector<int> perm;

   if (!A.empty()){
      perm.pb(A.back());
      A.pop_back();
   }

   while(sz(BA)){
      perm.pb(BA.back());
      BA.pop_back();
   }

   while(sz(A) and sz(B)){
      perm.pb(B.back());
      perm.pb(A.back());
      B.pop_back();
      A.pop_back();
   }

   while(sz(A)){
      perm.pb(A.back());
      A.pop_back();      
   }
   
   while(sz(B)){
      perm.pb(B.back());
      B.pop_back();      
   }

   while(sz(others)){
      perm.pb(others.back());
      others.pop_back();      
   }

   string vals = "";
   for (int i = 0; i < sz(perm); ++i)
   {
      int idx = perm[i];
      vals += v[idx];
   }

   tr(vals);

   for (int i = 0; i+1 < sz(vals); ++i)
   {
      ans += (vals[i] == 'A' and vals[i+1] == 'B');
   }

   cout<<ans;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

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

long long n,dp[100002][3],nums[100002][3];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin>>nums[i][j];
	dp[0][0]=nums[0][0];
	dp[0][1]=nums[0][1];
	dp[0][2]=nums[0][2];
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1]+nums[i][0],dp[i-1][2]+nums[i][0]);
		dp[i][1]=max(dp[i-1][0]+nums[i][1],dp[i-1][2]+nums[i][1]);
		dp[i][2]=max(dp[i-1][0]+nums[i][2],dp[i-1][1]+nums[i][2]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0; 
}

Measured memory_bytes: 4992
_, _, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
low = min(a) + min(b)
for _ in range(m):
    x, y, c = map(int, input().split())
    low = min(low, a[x - 1] + b[y - 1] - c)
print(low)

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

int main() {
	//入力
	string s, t;
	cin >> s >> t;

	//処理
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;

}

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

signed main(){
	int n,m,k,a[100010],dp[2][100010] = {},*now = dp[0],*nxt = dp[1],ma = 0;
	cin >> n >> m >> k;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 1;i <= k;i++){
		deque<int> deq;
		for(int j = 0;j <= n;j++) nxt[j] = -INF;
		for(int j = 0;j < n;j++){
			while(!deq.empty() && now[deq.back()] <= now[j]) deq.pop_back();
			deq.push_back(j);
			nxt[j + 1] = now[deq.front()] + a[j] * i;
			if(deq.front() == j - m + 1) deq.pop_front();
		}
		swap(now,nxt);
	}
	for(int i = 0;i <= n;i++) ma = max(ma,now[i]);
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
int main()
{
	int n,m,a,b,c,max;
	while(~scanf("%d%d",&n,&m))
	{
		a=m+n;
		b=n-m;
		c=n*m;
		max=a>b?a:b;
		max=max>c?max:c;
		printf("%d\n",max);
	}
}

Measured memory_bytes: 384
import java.util.Scanner;
     
    public class Main {
    	public static void main(String args[]) {
    		Scanner scanner = new Scanner(System.in);
    		int N, K;
    		N = scanner.nextInt();
    		K = scanner.nextInt();
     
    		String[] D = new String[K];
    		for (int i = 0; i < K; i++) {
    			D[i] = scanner.next();
     
    		}
    		a: while (true) {
    			for (int i = 0; i < D.length; i++) {
    				if (Integer.toString(N).contains(D[i])) {
    					N++;
    					continue a;
    				}
    			}
    			break;
    		}
    		System.out.println(N);
     
    	}
    }

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

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

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

    // start
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((a+b)>(c+d))
        cout << "Left" << endl;
    if ((a + b) == (c + d))
        cout << "Balanced" << endl;
    if ((a + b) < (c + d))
        cout << "Right" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import math


class Solution:
    def solve(self, a: int, b: int, c: int) -> str:

        if c - a - b < 0 or 4 * a * b >= (c-a-b)**2:
            return 'No'
        else:
            return 'Yes'


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(a, b, c))


Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>


int main(void){
  
  int i, j;
  int ar[10];
  int temp;

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

  //printf("\n%d\n", ar[9]);
  for(i = 9; i > 6; i--){
    for(j = 0; j < i; j++){
      if(ar[j] > ar[j+1]){
	temp = ar[j];
	ar[j] = ar[j+1];
	ar[j+1] = temp;
      }
    }
  }
  
  for(i = 9; i > 6; i--){
    printf("%d\n", ar[i]);
  }

  return 0;
  
}
  

Measured memory_bytes: 600
#include <iostream>
#include <utility>
#include <algorithm>


int n,m;
int AS[60];
int BS[60];
int A[60];
int B[60];

bool used[60][60][60][60][2][2][2];
int dp[60][60][60][60][2][2][2];

int func(int a, int b, int da, int db, bool turnA, bool passed, bool empty)
{
	//if(turnA)std::cerr << a << ' ' << b << ' ' << da << ' ' << db << ' ' << passed << ' ' << empty << std::endl;
    auto& memo = dp[a][b][da][db][turnA][passed][empty];
    if(used[a][b][da][db][turnA][passed][empty]){
        return memo;
    }
    used[a][b][da][db][turnA][passed][empty] = true;
    if(turnA){
        if(a>n)
        {
            if(passed){
                return memo = 0;
            }
            else{
                return memo = AS[a-1]-AS[da-1]-(BS[b-1]-BS[db-1])-func(a,b,a,b,false, empty, true);
            }
        }
		auto post = -func(a + 1, b, da, A[a] == -1 ? b : db, false, false, false);
        memo = std::max(
			passed ? 0 : (AS[a - 1] - AS[da - 1] - (BS[b - 1] - BS[db - 1]) - func(a, b, a, b, false, empty, true)),
            -func(a+1,b,da,A[a]==-1?b:db,false,false, false)
        );
		//std::cerr << a << ' ' << b << ' ' << da << ' ' << db << ' ' << passed << ' ' << empty <<':'<<memo<<','<<(PASS!=memo?"PASS":"POST")<<std::endl;
		return memo;
    }
    else{
        
        if(b>m)
        {
            if(passed){
                return memo = 0;
            }
            else{
                return memo = -(AS[a-1]-AS[da-1]-(BS[b-1]-BS[db-1]))-func(a,b,a,b,true, empty, true);
            }
        }
        return memo = std::max(
			passed ? 0 : (-(AS[a-1]-AS[da-1]-(BS[b-1]-BS[db-1]))-func(a,b,a,b,true, empty, true)),
            -func(a,b+1,B[b]==-1?a:da,db,true,false, false)
        );
    }
}

auto& in = std::cin;
auto& out = std::cout;
int main()
{
    using std::endl;
    in >> n>>m;
    for(int i = 0;i < n;++i){
        in >> A[i+1];
    }
    for(int i = 0;i < n;++i){
        AS[i+1] = AS[i] + std::max(0,A[i+1]);
    }
	for (int i = 0; i <= n; ++i) {
		//std::cerr << AS[i] <<endl;
	}
    for(int i = 0;i < m;++i){
        in >> B[i+1];
    }
    for(int i = 0;i < m;++i){
        BS[i+1] = BS[i] + std::max(0,B[i+1]);
    }
	for (int i = 0; i <= m; ++i) {
		//std::cerr << BS[i] << endl;
	}

    out << func(1,1,1,1,true, false, true)<<endl;
}



Measured memory_bytes: 129688
import sys
sys.setrecursionlimit(2000000)

def dfschain(L, i, j):
    if L[i][j] == " ":
        return
    else:
        P = L[i][j]
        L[i][j] = " "
    for k in [-1, 1]:
        ni = i + k
        if ni not in range(len(L)):
            continue
        if L[ni][j] == P:
            dfschain(L, ni, j)
    for k in [-1, 1]:
        nj = j + k
        if nj not in range(len(L[0])):
            continue
        if L[i][nj] == P:
            dfschain(L, i, nj)
    return

while True:
    line, row = [int(x) for x in input().split()]
    if line == 0 and row == 0:
        break

    L = []
    for _ in range(line):
        l = list(input())
        L.append(l)

    cnt=0

    for i in range(line):
        for j in range(row):
            if L[i][j] != " ":
                cnt += 1
                dfschain(L, i, j)
    #print(L)
    print(cnt)



Measured memory_bytes: 16552
#include <bits/stdc++.h>
using namespace std;
long gcd(long n,long m){
	if (m == 0) return n;
	return gcd(m, n % m);
}

long lcm(long n, long m) {
	return m / gcd(n, m)*n;
}

int main(void) {
	int w, n, a, b, tmp;
	int ans[30];
	for (int i = 0; i < 30; i++)
		ans[i] = i + 1;
	scanf("%d\n%d", &w, &n);
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		tmp = ans[a - 1];
		ans[a - 1] = ans[b - 1];
		ans[b - 1] = tmp;
	}
	for (int i = 0; i < w; i++)
		cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3124
H, W = map(int, input().split())

a = [0] * H
for i in range(H):
    a[i] = list(map(int, input().split()))


ans = []
for i in range(H):
    for j in range(W-1):
        if a[i][j] % 2 != 0:
            a[i][j+1] += 1
            ans.append([i+1, j+1, i+1, j+2])

for i in range(H-1):
    if a[i][W-1] % 2 != 0:
        a[i+1][W-1] += 1
        ans.append([i+1, W, i+2, W])


print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Measured memory_bytes: 30276
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong(), b = sc.nextLong(), x = sc.nextLong(), sum;
		sum = b/x - (a-1)/x;
		if(a == 0 && x != 1) sum++;
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int x,t;cin>>x>>t;
  P(max(0,x-t));
  return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
   
     
        if (s[s.size()-1]=='2'||s[s.size()-1]=='4'||s[s.size()-1]=='5'||s[s.size()-1]=='7'||s[s.size()-1]=='9')
        
cout<<"hon ";
   if (s[s.size()-1]=='0'||s[s.size()-1]=='1'||s[s.size()-1]=='6'||s[s.size()-1]=='8')
        
cout<<"pon "; 
        if (s[s.size()-1]=='3')
        
cout<<"bon ";

              
   
        
      
    

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  long long int ans=0;
  for(int i=1; i<=n; i++){
    ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  string s,t;cin>>s>>t;
  int n=s.length();
  int ans=0;
  rep(i,n){
    if(s[i]!=t[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

ll A[200005];

int main()
{
    ll N,K,sum=0;

    cin>>N>>K;

    for(int i=1;i<=N;i++)
        cin>>A[i];

    sort(A+1,A+N+1);
    reverse(A+1,A+N+1);

    for(int i=K+1;i<=N;i++)
        sum+=A[i];

    cout<<sum<<endl;
    return 0;

}


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

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

int solve(int y, int x){

  if(y < 0 || x < 0 || y == 12 || x == 12 || t[y][x] == '0') return 0;

  t[y][x] = '0';
  for(int i=0;i<4;i++) solve(y+dy[i], x+dx[i]);

  return 1;
}

int main(){

  while(cin >> t[0]){

    for(int i=1;i<12;i++) cin >> t[i];

    int ans = 0;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++) ans += solve(i, j); //y, x
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1184
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner164
{
    public class ABC164B
    {
        public static void Main(string[] args)
        {
            int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = nums[0];
            int B = nums[1];
            int C = nums[2];
            int D = nums[3];

            var TACount = Math.Ceiling(C / (double)B);
            var AACount = Math.Ceiling(A / (double)D);

            Console.WriteLine(TACount <= AACount ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 28296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B > C+D)
  {
    cout<<"Left"<<endl;
  }else if(A+B < C+D)
  {
    cout<<"Right"<<endl;
  }else
  {
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
A, B, C, K = gets.split.map(&:to_i)

sum = 0
k = K

d = [A, k].min
k -= d
sum += 1 * d
(puts sum; exit) if k == 0

d = [B, k].min
k -= d
sum += 0 * d
(puts sum; exit) if k == 0

d = [C, k].min
k -= d
sum += -1 * d
(puts sum; exit) if k == 0


Measured memory_bytes: 14288
from operator import itemgetter
N=int(input())
S=[];P=[];R=[]
for i in range(N):
  s,p =[i for i in input().split()]
  p=int(p)
  r=i+1
  S+=[s];P+=[p];R+=[r]
Z=zip(S,P,R)
Y=sorted(Z,key=itemgetter(1),reverse=True)
#print(Y)
X=sorted(Y,key=itemgetter(0))
#print(X)
S,P,R=zip(*X)
#print(S,P,R)
for i in R:
  print(i)

Measured memory_bytes: 3064
N,M = map(int, input().split())

maxi = 1
for i in range(int(M**0.5), 0, -1):
    if M % i != 0:
        continue
    if M//i >= N:
        maxi = max(maxi, i)
    if i >= N:
        maxi = max(maxi, M//i)

print(maxi)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

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

  ll ans = 0;
  for(int i=1; i<=N; i++) {
    if ( i % 3 != 0 && i % 5 != 0 ) ans += i;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	static List<List<Integer>> fullLIst;
	
	static void perm(List<Integer> seed) {
		List<Integer> list = new ArrayList<>(seed);
		boolean[] used = new boolean[seed.size()];
		build(seed, list, used, 0);
	}
	
	static void build(List<Integer> seed, List<Integer> list, boolean[] used, int index) {
		if (index == seed.size()) {
			fullLIst.add(new ArrayList<>(list));
			return;
		}
		
		for (int i = 0; i < seed.size(); i++) {
			if (used[i]) {
				continue;
			} else {
				list.set(index, seed.get(i));
				used[i] = true;
				build(seed, list, used, index + 1);
				used[i] = false;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> sortedList = new ArrayList<>();
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			sortedList.add(i);
		}
		fullLIst = new ArrayList<>();
		Collections.sort(sortedList);
		perm(sortedList);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < fullLIst.size(); i++) {
			for (int j = 0; j < fullLIst.get(i).size() - 1; j++) {
				sb.append(fullLIst.get(i).get(j));
				sb.append(' ');
			}
			
			sb.append(fullLIst.get(i).get(fullLIst.get(i).size() - 1));
			sb.append('\n');
		}
		System.out.print(sb.toString());
	}
}



Measured memory_bytes: 132936
#include<stdio.h>
#define N 100
#define MAX 2000
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2


int A[N][N], n;

int prim(){
  int i, u, v, minv, sum = 0;
  int d[N], p[N], color[N];

  for(i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && A[u][v] != INFTY){
        if(d[v] > A[u][v]){
          d[v] = A[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }

  for(i = 0; i < n; i++){
    if(p[i] != -1) sum += A[i][p[i]];
  }

  return sum;
}

int main(){
  int i, j, s;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &s);
      A[i][j] = (s == -1) ? INFTY : s;
    }
  }

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

  return 0;
}



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

using namespace std;

#define il inline
#define Rep(i, s, e) for (int i = s; i <= e; ++i)
#define Dep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (!isdigit(c)) {if (c == '-') f = false; c = getchar();}
    while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int main() {
    printf("%s", read() >= 30 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3688