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

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;
int m,k;

int main()
{
	cin>>m>>k;
	if(k > (1 << m) - 1){
		puts("-1");
		return 0;
	}
	if(m == 1){
		if(k == 0)
		    printf("0 0 1 1\n");
		else
		    puts("-1");
		return 0;
	}
	
	printf("%d ",k);
	for(int i = 0;i <= (1 << m) - 1;i++){
		if(i != k)
		    printf("%d ",i);
	}
	printf("%d ",k);
	for(int i = (1 << m) - 1;i >= 0;i--){
		if(i != k)
		    printf("%d ",i);
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>

using namespace std;

int get_root(vector<int>& parent, int i)
{
    if (parent[i] != i) parent[i] = get_root(parent, parent[i]);
    return parent[i];
}

vector<int>
build(int N, int K)
{
    vector<int> parent(N);
    for (int i = 0; i < N; ++i) parent[i] = i;
    for (int k = 0; k < K; ++k) {
        int i, j;
        cin >> i >> j;
        --i; --j;
        auto root_i = get_root(parent, i);
        auto root_j = get_root(parent, j);
        parent[root_j] = root_i;
    }
    return parent;
}

int main()
{
    int N, K, L;
    cin >> N >> K >> L;
    auto road = build(N, K);
    auto railway = build(N, L);

    /*
    for (const auto& p: road) cout << p << " ";
    cout << endl;
    for (const auto& p: railway) cout << p << " ";
    cout << endl;
    */

    map<pair<int, int>, int> ans;
    for (int i = 0; i < N; ++i) {
        ++ans[make_pair(get_root(road, i), get_root(railway, i))];
    }

    for (int i = 0; i < N; ++i) {
        cout << (i == 0 ? "" : " ") << ans[make_pair(get_root(road, i), get_root(railway, i))];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 13568
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define K 1000000000000000000

int main(){
long long ans = 1;
int n;
bool flag = false;
cin >> n;
for(int i=0;i<n;++i){
  long long b;
  cin >> b;
  if (b == 0){
    cout << 0 << endl;
    return 0;
  }


  if(flag || (K+1) / ans < b || ans * b > K){
    flag = true;
  }
  ans *= b;

}

if (flag){
  cout << -1 << endl;
  return 0;
}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
 
int main(){
  string s;
  cin>>s;
  int si=s.size();
  vector<int> a(si);
  int r=0;
  int l=0;
  for(int i=0;i<si;i++){
    if(s[i]=='R'){
      while(s[i]!='L'){
        r++;
        i++;
      }
      a[i-1]+=(r+1)/2;
      a[i]+=r/2;
      r=0;
    }
  }
  for(int i=si-1;i>=0;i--){
   if(s[i]=='L'){ 
      while(s[i]!='R'){
        l++;
        i--;
      }
      a[i+1]+=(l+1)/2;
      a[i]+=l/2;
      l=0;
   }
  }
  for(int i=0;i<si-1;i++){
    cout<<a[i]<<" ";
  }
  cout<<a[si-1]<<endl;
}


Measured memory_bytes: 1024
using System;

public class Program{
  public static void Main(string[] args){
    var input = Console.ReadLine();
    var output = "Yes";
    for(int i = 0; i < input.Length; i += 2){
      var jyouken = (input[i] == 'R' || input[i] == 'U' || input[i] == 'D');
      if(!jyouken)
      {
        output = "No";
      }
    }
    
    for(int i = 1; i < input.Length; i += 2){
      var jyouken = (input[i] == 'L' || input[i] == 'U' || input[i] == 'D');
      if(!jyouken)
      {
        output = "No";
      }
    }
    Console.WriteLine(output);
  }
}

Measured memory_bytes: 13140
n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 104372
#include<stdio.h>
int main()
{
	char a;
	char b;
	
	scanf("%s %s", &a, &b);
		
	if((a=='H' && b=='H') || (a=='D' && b=='D')){
		printf("H\n");
	}
	
	else printf("D\n");
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll power(ll x,ll y,ll p) 
{ 
    ll r = 1;
  
    x = x % p;
    while (y > 0) {
        if (y & 1) 
            r = (r * x) % p;
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return r; 
}  
ll modInverse(ll n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
 ll fac[100005];
ll nCrModP(ll n,ll r, ll p) 
{ 
   
    if (r == 0) 
        return 1; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,s,c,h,k,m,maxi,d,x;
	cin>>s;
	c=s/3;
	ll ans=0;
	fac[0]=1;
	for(j=1;j<=100000;j++)
	{
		fac[j]=(j*fac[j-1])%MOD;
	}
	for(i=1;i<=c;i++)
	{
		k=(i*3);
		k=s-k;
		h=nCrModP(i+k-1,i-1,MOD);
		ans=(ans+h)%MOD;

	}
	cout<<ans;

}



	

		

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

const int INF = 1<<29;

int main() {
    int n; cin >> n;
    vector<int> b(n + 2, INF);
    for (int i = 1; i < n; ++i) cin >> b[i];

    int res = 0;
    for (int i = 1; i <= n; ++i) res += min(b[i - 1], b[i]);

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    vector<int>ans(26,51);
    rep(i,n){
        cin>>s[i];
        vector<int>x(26,0);
        rep(j,s[i].size()){
            x[s[i][j]-'a']++;
        }
        rep(j,26){
            ans[j]=min(x[j],ans[j]);
        }
    }
    rep(i,26){
        rep(j,ans[i]){
            if(ans[i]==51)continue;
            cout<<char(i+'a');
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[1005],b[1005],c[1005][150],dp[(1<<12)+5];
int main(){
  long long n,m,key=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    for(int j=0;j<b[i];j++){
      cin>>c[i][j];
    }
  }
  // for(int i=0;i<=n;i++){
    for(int j=0;j<=(1<<n);j++){
      dp[j]=200000000; 
    }
    // }
  dp[0]=0;
  for(int i=0;i<m;i++){
    key=0;
    for(int k=0;k<b[i];k++){
      key|=(1<<c[i][k]-1);
    }
    for(int j=0;j<(1<<n);j++){
      // if(dp[i][j]!=200000000){
	dp[j|key]=min(dp[j|key],dp[j]+a[i]);
	// }
	// dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  if(dp[(1<<n)-1]==200000000)
    cout<<"-1"<<endl;
  else
    cout<<dp[(1<<n)-1]<<endl;
  return (0);
}


Measured memory_bytes: 1408
#include <iostream>
#include <regex>
#include <string>

int main()
{
    const std::regex pattern(R"(A.*Z)");

    std::string s;
    std::cin >> s;

    std::smatch match;
    std::regex_search(s, match, pattern);
    std::cout << match.str().length() << std::endl;
}

Measured memory_bytes: 88324
n = int(input())
a = list(map(int, input().split()))

cnt1 = sum(i % 4 == 2 for i in a)
cnt2 = sum(i % 4 == 0 for i in a)
if n - 2 * cnt2 - max(1, cnt1) <= 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 85384
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
vector<int> b;
int nn;
ll seg[530000];
void init(int n_){
	nn = 1;
	while(nn<n_)nn*=2;
	for(int i=0;i<2*nn-1;i++)seg[i]=0;
}

void update(int k,int a){
	k += nn-1;
	seg[k]+=a;
	while(k>0){
		k = (k-1)/2;
		seg[k] = seg[k*2+1]+ seg[k*2+2];
	}
}

ll query(int a,int b, int k, int l, int r){
	if(r<=a || b<=l) return 0;
	if(a<=l && r<=b) return seg[k];
	else{
		ll vl = query(a,b,k*2+1,l,(l+r)/2);
		ll vr = query(a,b,k*2+2,(l+r)/2,r);
		return vl+vr;
	}
}
signed main(){
	int n,k;
	cin>>n>>k;
	vector<int> a;
	a.pb(0);
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	int sum = 0;
	for(int i=0;i<=n;i++){
		sum += a[i];
		b.pb(sum-i*k);
	}
	vector<int> vec;
	vector<int> c;
	vec=b;
	map<int,int> iidx;
	sort(vec.begin(),vec.end());
	vec.erase( unique(vec.begin(),vec.end()), vec.end() );
	for(int i=0;i<vec.size();i++){
		iidx[ vec[i] ] = i;
	}
	for(int i=0;i<=n;i++){
		c.pb(iidx[b[i]]);
	}
	int cnt=0;
	init(n);
	for(int i=n;i>=0;i--){
		cnt += query(0,c[i],0,0,nn);
		update(c[i],1);
	}
	cout<<(n+1)*n/2-cnt<<endl;
	return 0;
}

Measured memory_bytes: 23280
/*
 *  * main.cpp
 *   *
 *    */

#include<bits/stdc++.h>
using namespace std;

int t;
int n;
double res;
long long A[100005];
int main() {
    int w, h, n;
    scanf("%d%d%d", &w, &h, &n);
    
    if (h > w) swap(w, h);
    printf("%d\n", (n + w - 1) / w);

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j,k,c,x,y;
	int m,mx[200],my[200];
	int n,nx[1000],ny[1000];
	
	while(1){
		//m
		scanf("%d",&m);
		if(m==0)break;
		for(i=0;i<m;i++){
			scanf("%d %d", &mx[i], &my[i]);
		}
		
		//n
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d", &nx[i] ,&ny[i]);
		}
		
		for(i=0;i<n;i++){
			
			c=0;
			x=nx[i]-mx[0];
			y=ny[i]-my[0];
			
			for(j=0;j<m;j++){
				for(k=0;k<n;k++){
					if(mx[j]+x==nx[k] && my[j]+y==ny[k])c++;
				}
			}
			
			if(c==m)break;
			
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	tests := scanInt()
	for test := 0; test < tests; test++ {
		n, m, a, b := scanInt(), scanInt(), scanInt(), scanInt()
		fmt.Fprintln(wr, floorSum(n, m, a, b))
	}
}

func floorSum(n, m, a, b int) int {
	ans := 0
	if a >= m {
		ans += (n - 1) * n * (a / m) / 2
		a %= m
	}
	if b >= m {
		ans += n * (b / m)
		b %= m
	}

	yma := (a*n + b) / m
	if yma == 0 {
		return ans
	}
	xma := yma*m - b
	ans += (n - (xma+a-1)/a) * yma
	ans += floorSum(yma, a, m, (a-xma%a)%a)
	return ans
}


Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
typedef unsigned long long ull;
const int maxn=250000+10;
unordered_map<ull,int> mp;
char s[maxn];
ull Pw[maxn<<1],sum[maxn];
int p[maxn];
int main(){
	int n=read();
	Pw[0]=1;
	REP(i,1,maxn*2-10) Pw[i]=Pw[i-1]*101;
	scanf("%s",s+1);
	p[0]=n+5;
	REP(i,1,n){
		sum[i]=sum[i-1],p[i]=p[i-1];
		if(s[i]=='>') ++p[i];
		if(s[i]=='<') --p[i];
		if(s[i]=='+') sum[i]+=Pw[p[i]];
		if(s[i]=='-') sum[i]-=Pw[p[i]];
	}
	ll ans=0;
	REP(i,0,n){
		ull val=sum[n]*Pw[p[i]]+sum[i]*Pw[n+5];
		ans+=mp[sum[i]*Pw[n+5]];
		mp[val]++;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 26996
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long; 

int main() {
    ll a,b,c,count=0;
    ll na,nb,nc;
    cin >> a >> b >> c;
    //if (a==b and b==c) cout << -1 << endl;
    if (false) {}
    else {
        while (true) {
            if (a%2==1 or b%2==1 or c%2==1) {
                cout << count << endl;
                break;
            }
            else {
                na=(b+c)/2;nb=(a+c)/2;nc=(a+b)/2;
                a=na;b=nb;c=nc;
                ++count;
                if (count > 9999999) {
                    cout << "-1" << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	int N=in(),M=in();
	vvll P(M);
	REP(i,N){
		int A=in(),B=in();
		if(A<=M){
			P[A-1].push_back(B);
		}
	}
	priority_queue<ll> Q;
	ll S=0;
	REP(i,M){
		for(auto& x:P[i]) Q.push(x);
		if(!Q.empty()){
			S += Q.top();
			Q.pop();
		}
	}
	out(S);
	return 0;
}


Measured memory_bytes: 5632
#ABC163d
n, k = input().split()
n = int(n)
k = int(k)

mod = 10**9 + 7
# s = (10**100%mod)*(k%mod) # 10**100*kをmod化
ips = []
for i in range(k,n+2):
    t = i*n - (i-1)*i + 1
    ips.append(t)
print(sum(ips)%mod)


Measured memory_bytes: 20088
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )

int main()
{
    int h,n,a,sum=0;
    cin>>h>>n;
    rep(i,n)cin>>a,sum+=a;
    yn(sum>=h);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  double h, a;
  cin >> h >> a;
  cout << ceil(h / a) << endl;
}

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

#define ll long long
#define vi vector<int>
#define vll vector<long long> 
#define str string 
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
ll dp[100][100000];
int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; ll w;
    cin>>n>>w;
    ll weights[n];
    int values[n];
    ll total = 0;
    for(int i=0; i<n; i++){
        cin>>weights[i];
        cin>>values[i];
        total += values[i];
    }
    dp[0][values[0]] = weights[0];
    for(int i=1; i<n; i++){
        for(int j=1; j<=total; j++){

            if(j>values[i]){
                dp[i][j] = min((dp[i-1][j])?dp[i-1][j]:INT_MAX, (dp[i-1][j-values[i]])?dp[i-1][j-values[i]]+weights[i]:INT_MAX);
                if(dp[i][j] == INT_MAX){
                    dp[i][j]=0;
                }
            }
            else if(j==values[i]){
                dp[i][j] = min((dp[i-1][j])?dp[i-1][j]:INT_MAX, weights[i]);
            }
            else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    for(int i=total; i>=0; i--){
        if(dp[n-1][i] && (dp[n-1][i]<=w)){
            cout<<i;
            return 0;
        }
    }
}



Measured memory_bytes: 80796
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() 
{
    fast();
    ll n;
    cin>>n;
    cout<<n+n*n+n*n*n<<nl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

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

  string s;
  cin >> s;

  map<int, vll> m;

  rep(i, s.size()) {
    m[s[i] - 'a'].push_back(i);
  }

  rep(i, 26) {
    auto&& t = m[i];
    REP(i, t.size()) {
      if (t[i] - t[i - 1] <= 2) {
        cout << t[i - 1] + 1 << " " << t[i] + 1 << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << endl;

  return 0;
}


Measured memory_bytes: 1612
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, m;
		cin >> n >> m;
		if (n < 0) return 0;
		int r = m;
		if ((n % 2) == 0) {
			for (int i = 0; i < m / 2; ++i) {
				--r;
				cout << (n / 2 - i) << " " << (n / 2 + i + 2) << endl;
			}
		}
		for (int i = 0; i < r; ++i) {
			cout << (i + 1) << " " << (n - i) << endl;
		}
	}
	return 0;
}


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

int main() {
    char b;
    cin >> b;
    if(b=='A')printf("T\n");
    if(b=='T')printf("A\n");
    if(b=='C')printf("G\n");
    if(b=='G')printf("C\n");

}


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

ll solve() {
    string S;
    cin >> S;
    ll ans = 0, b = 0;
    for ( char c : S ) {
        if ( c == 'B' ) b++;
        else ans += b;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    vector<i64> x(N),y(N);
    vector<vector<i64>> graph(N);
    rep(i,0,N-1){
        cin >> x[i] >> y[i];
        --x[i];
        --y[i];
        graph[x[i]].emplace_back(y[i]);
        graph[y[i]].emplace_back(x[i]);
    }

    const i64 maxn=100000;
    static i64 dp[maxn][2];
    static bool done[maxn][2];
    fill_n((i64*)dp,maxn*2,0);
    fill_n((bool*)done,maxn*2,false);

    function<i64(i64,i64,i64)> rec=[&](i64 u,i64 c,i64 p){
        auto& res=dp[u][c];
        if(done[u][c]) return res;
        done[u][c]=true;

        res=1;
        for(auto v:graph[u]){
            if(v==p) continue;
            i64 tmp=0;
            tmp+=rec(v,1-c,u);
            tmp%=mod;

            if(c!=1){
                tmp+=rec(v,c,u);
                tmp%=mod;
            }

            res*=tmp;
            res%=mod;
        }

        return res;
    };

    cout << (rec(0,0,-1)+rec(0,1,-1))%mod << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 22912
#include <algorithm>
#include <iostream>
#include <vector>

#include <string.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;
}

const int MAX_S = 100;

int main(void) {
    char S[MAX_S + 1];
    cin >> S;
    int N;
    N = strlen(S);

    int count = 0;
    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[N - 1 - i]) {
            count++;
        }
    }

    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)


int main(){
    int n; cin >> n;
    int A[n];
    rep(i,n)cin >> A[i];
    sort(A, A+n);
    cout << A[n-1] - A[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<double> vec;
typedef vector<vec> mat;
vec gauss_jordan(const mat& A, const vec& b){
  int n = A.size();
  mat B(n, vec(n + 1));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      B[i][j] = A[i][j];
    }
  }
  for(int i = 0; i < n; i++) B[i][n] = b[i];
  for(int i = 0; i < n; i++){
    int pivot = i;
    for(int j = i + 1; j < n; j++){
      if(abs(B[j][i]) > abs(B[pivot][i])) pivot = j;
    }
    swap(B[i], B[pivot]);
 
    if(abs(B[i][i]) < EPS) return vec();
 
    for(int j = i + 1; j <= n; j++) B[i][j] /= B[i][i];
    for(int j = 0; j < n; j++){
      if(i != j){
        for(int k = i + 1; k <= n; k++) B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }
  vec x(n);
  for(int i = 0; i < n; i++) x[i] = B[i][n];
  return x;
}
bool ok(int x, double v, vec k){
  vec tmp(k.size());
  tmp[0] = 1;
  tmp[1] = x;
  REP(j, k.size() - 2) tmp[j + 2] = tmp[j + 1] * x;
  double sum = 0;
  REP(i, k.size()) sum += k[i] * tmp[i];
  if(abs(sum - v) < 1e-3) return true;
  else return false;
}
 
int main(){
  int D;
  while(cin>>D && D){
    int N = D + 3;
    vector<double> v(N);
    REP(i, N) cin>>v[i];
    REP(s1, N)FOR(s2, s1 + 1, N){
      vec b;
      mat a;
      REP(i, N){
        if(i == s1 || i == s2) continue;
        vec tmp(D + 1);
        tmp[0] = 1;
        tmp[1] = i;
        REP(j, D - 1) tmp[j + 2] = tmp[j + 1] * i;
        a.push_back(tmp);
        b.push_back(v[i]);
      }
      vec k = gauss_jordan(a, b);
      if(!ok(s1, v[s1], k) && ok(s2, v[s2], k)){
        cout<<s1<<endl;
        goto END;
      }else if(ok(s1, v[s1], k) && !ok(s2, v[s2], k)){
        cout<<s2<<endl;
        goto END;
      }else if(ok(s1, v[s1], k) && ok(s2, v[s2], k)){
        //cout<<"ok"<<endl;
      }else{
        //cout<<"ng"<<endl;
      }
    }
END:;
  }
  return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i=0,s=1;
  cin >> n >> k;
  for(i;i<n;i++){
    if(s<k)
      s*=2;
    else
      s+=k;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
num=[0]*3

for i,co in enumerate(('R','G','B')):
  for c in s:
    if c == co:
      num[i] +=1
      
all = num[0]*num[1]*num[2]

ot = 0
i=1
while i*2 +1 <= len(s):
  idx = 0
  #print(i)
  while idx + i*2 < len(s):
    #print('index',idx)
    wk = s[idx]+s[idx+i]+s[idx+2*i]
    #print(wk)
    if ('R' in wk) and ('G' in wk) and ('B' in wk):
      ot +=1
    idx +=1
  i += 1
  
print(all-ot)

Measured memory_bytes: 67888
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int x=0;
int n=sc.nextInt();
int ans=0;
String s=sc.next();
for(int i=0;i<n;i++) {
	if(s.charAt(i)=='I') {
		x=x+1;
	}else if(s.charAt(i)=='D'){
		x=x-1;
	}
	ans=Math.max(ans, x);
	
}System.out.println(ans);
	}

}


Measured memory_bytes: 35692
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
	using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, A;
  cin >> N >> A;
  bool ans = N % 500 <= A;
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<long>A(N),X(N),Y(N);
  vector<long>C; //id->値
  map<long,long>D;// 値->id
  for(long i=0;i<N;i++){
    cin>>A[i];
    X[i]=i-A[i];
    Y[i]=i+A[i];
    C.push_back(X[i]);
    C.push_back(Y[i]);
  }sort(C.begin(),C.end());
  for(long i=0;i<C.size();i++){
    D[C[i]]=i;
  }
  vector<long>L(C.size(),0);
  for(long i=0;i<N;i++){
    L[D[X[i]]]+=1;
  }
  long ans=0;
  for(long i=0;i<N;i++){
    ans+=L[D[Y[i]]];
  }
  
  cout<<ans;
  
}



Measured memory_bytes: 36664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;

template< typename T >
T bellman_ford(Edges< T > &edges, int V, int s) {
    const auto INF = numeric_limits< T >::max();
    vector< T > dist(V, INF);
    vector< int > negative(V);
    dist[s] = 0;
    for(int i = 0; i < V - 1; i++) {
        for(auto &e : edges) {
            if(dist[e.src] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    for(int i = 0; i < V; i++) {
        for(auto &e : edges) {
            if(dist[e.src] == INF) continue;
            if(dist[e.src] + e.cost < dist[e.to]) {
                negative[e.to] = 1;
                dist[e.to] = dist[e.src] + e.cost;
            }
            if(negative[e.src]) {
                negative[e.to] = 1;
            }
        }
    }
    if(negative[V-1]) {
        return 1;
    }
    // for(auto &e : edges) {
    //     if(dist[e.src] == INF) continue;
    //     if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
    // }
    return dist[V-1];
}


int main(void) {
    int N, M, P;
    cin >> N >> M >> P;
    Edges<int> g;
    while(M--) {
        int A, B, C;
        cin >> A >> B >> C;
        --A; --B;
        g.emplace_back(A, B, P-C);
    }

    int ans = bellman_ford(g, N, 0);
    if(ans == 1) {
        cout << -1 << endl;
    } else {
        cout << max(-ans, 0) << endl;
    }

    // auto dist = bellman_ford(g, N, 0);

    // if(dist.empty()) {
    //     cout << 0 << endl;
    // } else if(dist == vector<int>(numeric_limits< int >::max())) {
    //     cout << -1 << endl;
    // } else {
    //     cout << max(-dist[N-1], 0) << endl;
    // }

    return 0;
}


Measured memory_bytes: 384
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s


n = load()
B = load_list()


r = [B[0]]

for i in range(0, len(B)-1):
    r.append(min(B[i], B[i+1]))

r.append(B[-1])

print(sum(r))


Measured memory_bytes: 3316
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

bool FLG;

struct Info{
	int num;
	char color[2];
};

void calc(int R_table[10],int G_table[10],int B_table[10]){
	int trio = 0;

	for(int k=1; k<=7; k++){
		if(R_table[k] > 2){
			trio++;
			R_table[k] -= 3;
		}
		if(G_table[k] > 2){
			trio++;
			G_table[k] -= 3;
		}
		if(B_table[k] > 2){
			trio++;
			B_table[k] -= 3;
		}

		while(R_table[k] > 0 && R_table[k+1] > 0 && R_table[k+2] > 0){
			trio++;
			R_table[k]--;
			R_table[k+1]--;
			R_table[k+2]--;
		}
		while(G_table[k] > 0 && G_table[k+1] > 0 && G_table[k+2] > 0){
			trio++;
			G_table[k]--;
			G_table[k+1]--;
			G_table[k+2]--;
		}
		while(B_table[k] > 0 && B_table[k+1] > 0 && B_table[k+2] > 0){
			trio++;
			B_table[k]--;
			B_table[k+1]--;
			B_table[k+2]--;
		}
	}

	for(int k=1; k <= 9; k++){
		if(R_table[k] == 3){
			trio++;
			R_table[k] -= 3;
		}
		if(G_table[k] == 3){
			trio++;
			G_table[k] -= 3;
		}
		if(B_table[k] == 3){
			trio++;
			B_table[k] -= 3;
		}
	}

	if(trio == 3){
		FLG = true;
	}
}

void func(){
	Info info[9];
	int R_table[10] = {0},G_table[10] = {0},B_table[10] = {0};

	for(int i = 0; i < 9; i++){
		scanf("%d",&info[i].num);
	}

	for(int i = 0; i < 9; i++){
		scanf("%s",info[i].color);
		switch(info[i].color[0]){
		case 'R':
			R_table[info[i].num]++;
			break;
		case 'G':
			G_table[info[i].num]++;
			break;
		case 'B':
			B_table[info[i].num]++;
			break;
		}
	}

	FLG = false;

	calc(R_table,G_table,B_table);

	if(FLG)printf("1\n");
	else{
		printf("0\n");
	}
}

int main(){

	int T;

	scanf("%d",&T);

	for(int i = 0; i < T; i++){
		func();
	}

	return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

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

class State
{
public:
	int x,y,d,p,q,c;
	State(int x, int y, int d, int p, int q, int c)
		:x(x),y(y),d(d),p(p),q(q),c(c)
	{}

	bool operator<(const State& s) const
	{
		return c > s.c;
	}
};

int N,M,A;
bool memo[100][100][4][15][15];
string field[100];

bool invaild(int x, int y)
{
	if(x<0||y<0||x>=M||y>=N) return true;
	if(field[y][x] == '#') return true;
	
	return false;
}

bool newState(State& s)
{
	return !memo[s.x][s.y][s.d][s.p][s.q];
}

State straight(State s)
{
	
	int tx = s.x + dx[s.d];
	int ty = s.y + dy[s.d];

	if(invaild(tx,ty)) return s;

	return State(tx,ty,s.d,s.p,s.q,s.c);
}

State useP(State s)
{
	if(s.p == 0) return s;

	int nd = (s.d+1)%2 + (s.d > 1? 2: 0);
	int tx = s.x + dx[nd];
	int ty = s.y + dy[nd];

	if(invaild(tx,ty)) return s;

	return State(tx,ty,nd,s.p-1,s.q,s.c+1);
}

int refQ(int d)
{
	if(d==0) return 3;
	if(d==3) return 0;
	if(d==1) return 2;

	return 1;
}

State useQ(State s)
{
	if(s.q == 0) return s;

	int nd = refQ(s.d);
	int tx = s.x + dx[nd];
	int ty = s.y + dy[nd];

	if(invaild(tx,ty)) return s;

	return State(tx,ty,nd,s.p,s.q-1,s.c+1);
}



int solve()
{
	memset(memo, 0, sizeof(memo));

	int sx,sy;
	for(int i=0; i<N; i++)
	for(int j=0; j<M; j++) {
		if(field[i][j]=='S') {
			sx = j;
			sy = i;
		}
	}

	for(int i=0; i<=A; i++)
	for(int j=0; j<=A; j++)
		memo[sx][sy][2][i][j] = true;

	priority_queue<State> q;
	q.push(State(sx,sy,0,A,A,0));

	while(!q.empty()) {
		State s=q.top(); q.pop();
		if(!newState(s)) continue;
		memo[s.x][s.y][s.d][s.p][s.q] = true;

		if(field[s.y][s.x] == 'G') return s.c;

		State ns = straight(s);
		if(newState(ns)) q.push(ns);

		if(s.x != sx || s.y != sy) {
			ns = useP(s);
			if(newState(ns)) q.push(ns);

			ns = useQ(s);
			if(newState(ns)) q.push(ns);
		}

	}

	return -1;
}

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

	cout << solve() << endl;
}

Measured memory_bytes: 10000
import java.util.Scanner;

public class Main {

    private static long solve(long H) {
        if (H <= 1L) {
            return 1L;
        } else {
            return 2L * solve((long)Math.floor(H / (double)2)) + 1L;
        }
    }

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

        long H = sc.nextLong();
        // ツリーのノード数分だけ攻撃する必要がある.
        System.out.println(solve(H));
    }
}


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

using namespace std;

typedef long long ll;

bool is_palin(string s){
	int n = s.size();
	for(int i = 0; i < n - i - 1; i++){
		if(s[i] != s[n - i - 1]) return false;
	}

	return true;
}

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

	string s;
	cin >> s;

	int n = s.size();

	bool ans = is_palin(s);
	ans &= is_palin(s.substr(0, (n - 1) / 2));
	ans &= is_palin(s.substr((n + 1) / 2, (n - 1) / 2));

	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x=a+b+c;
  if(x>=22) cout<<"bust"<<endl;
  else  cout<<"win"<<endl;
}


Measured memory_bytes: 256
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())

MOD = 10 ** 9 + 7

def main():
    DP = [1,0,0]
    for _ in range(2000):
        l = len(DP)
        DP.append((DP[l - 1] + DP[l - 3]) % MOD)
    print(DP[i_input()])

if __name__ == "__main__":
    main()


Measured memory_bytes: 63612
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int a[3];
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }

    cout << max({a[0],a[1],a[2]}) - min({a[0],a[1],a[2]}) << "\n";
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
MOD = 10**9+7

def comb(n, k, MOD):
    x = 1
    for i in range(k):
        x *= (n-i)
        x *= pow(i+1, MOD-2, MOD)
        x %= MOD
    return x

ans = pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)
ans += MOD
ans %= MOD
print(ans)

Measured memory_bytes: 67580
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int s, cnt = 0;
  cin >> s;
  
  for (int i = 0; i < 3; i++) {
	if (s % 10 != 0) {
      cnt++;
    }
    s /= 10;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

int main() {
  int x;
  cin >> x;
  cout << !x << endl;
}


Measured memory_bytes: 3568
n = int(input())
N = n
arr = [n]
while n % 2 == 0:
    arr.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        arr.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    arr.append(n)


arr.sort()

import collections
c = collections.Counter(arr)
k = list(c.keys())
v = list(c.values())

x = []
for i in range(len(k)):
    for p in range(1,v[i]+1):
        x.append(k[i]**p)

x.sort()

ans = 0
n = N
while n != 1 and len(x) != 0:
    if n % x[0] == 0:
        n //= x[0]
        x.pop(0)
        ans += 1
    else:
        x.pop(0)
print(ans)


Measured memory_bytes: 9436
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[3][3]; rep(i,3) rep(j,3) cin >> a[i][j];
    int n,b; cin >> n;
    rep(i,n){
        cin >> b;
        rep(i,3) rep(j,3) if(a[i][j] == b) a[i][j] = 0;
    }

    bool flag;
    rep(i,3){
        // 縦
        flag = true;
        rep(j,3) if(a[j][i] != 0) flag = false;
        if(flag) break;
        // 横
        flag = true;
        rep(j,3) if(a[i][j] != 0) flag = false;
        if(flag) break;
    }

    if(flag){
        cout << "Yes" << "\n";
        return 0;
    }

    // 斜め
    flag = true;
    rep(i,3) if(a[i][i]!=0) flag = false;
    
    if(flag){
        cout << "Yes" << "\n";
        return 0;
    }

    flag = true;
    rep(i,3) if(a[i][2-i]!=0) flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int min=1000000000;
    vector<int> mins(n,1000000000);
    for(int i=0;i<n;i++){
        if(min>p[i]){
            min=p[i];
        }
        mins[i]=min;
    }
    int ret=0;
    for(int i=0;i<n;i++){
        if(mins[i]>=p[i]){
            ret++;
        }
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main() {
    int d;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" << endl;
    else if(d==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = [int(x) for x in input().strip().split(" ")]
p = 10**9 + 7

num_list = [int(x) for x in input().strip().split(" ")]
num_list = sorted(num_list, reverse = True)

ans = 1
l_idx = 0
r_idx = -1

if num_list[0] < 0 and k % 2 == 1:
  for i in range(k):
    ans = (ans * num_list[i]) % p
else:
  while True:
    if k >= 2:
      l_prod = num_list[l_idx] * num_list[l_idx+1]
      r_prod = num_list[r_idx] * num_list[r_idx-1]
      if l_prod >= r_prod:
        ans = (ans * num_list[l_idx]) % p
        l_idx +=1
        k -= 1
      else:
        ans = (ans * r_prod) % p
        r_idx -=2
        k -= 2
    elif k == 1:
      ans = (ans * num_list[l_idx]) % p
      ans %= p
      break
    else:
      break

print(ans)


Measured memory_bytes: 31932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
struct par {
	ll a;
	ll k;
	par(ll v, ll w) {a=v;k=w;}
};
ll f(par p, ll x) {
	return (x-p.a)*(x-p.a)+p.k;
}
class ST {
	private:
		//vl a;
		vector<par> st;
		int n;
		int lf(int p) {return p<<1;}
		int rt(int p) {return (p<<1)+1;}
		void add(int i, int l, int r, par p) {
			int m = (l+r)/2;
			bool lft = f(p,l) < f(st[i],l);
			bool mpt = f(p,m) < f(st[i],m);
			if(mpt) {
				swap(st[i],p);
			}
			if(r-l == 1) {
				return;
			}
			if(lft != mpt) {
				add(lf(i),l,m,p);
			} else {
				add(rt(i),m,r,p);
			}
		};
		ll eval(int i, int l, int r, ll x) {
			if(r-l == 1) {
				return f(st[i],x);
			}
			int m = (l+r)/2;
			if(x < m) {
				return min(f(st[i],x),eval(lf(i),l,m,x));
			} else {
				return min(f(st[i],x),eval(rt(i),m,r,x));
			}
		}
	public:
		ST(int sz) {
			n=sz;
			st.assign(4*n,par(0LL,1LL<<62));
		}
		void add(par p) {
			add(1,0,n,p);
		}
		ll eval(ll x) {
			return eval(1,0,n,x);
		}
};
int main() {
	ll n,c;
	scanf("%lld %lld ",&n,&c);
	ST st(1000100);
	for(int i=0;i<n-1;i++) {
		int h;
		scanf("%d ",&h);
		if(i == 0) {
			st.add(par(h,0));
		} else {
			st.add(par(h,st.eval(h)+c));
		}
	}
	int fh;
	scanf("%d ",&fh);
	printf("%lld\n",st.eval(fh)+c);
}


Measured memory_bytes: 62720