akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int n,m,p;
vector< vector<pi> >adj;
vector<int>dis,vis,ok;
void dfs(int u)
{
    if(vis[u])return;
    vis[u]=1;
    for(auto tmp:adj[u])
    {
        int v=tmp.fi;
        if(vis[v])continue;
        dfs(v);
    }
}
 main()

{
    fast
    cin>>n>>m>>p;
    adj.resize(n);
    f(i,0,m-1)
    {
        int u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        adj[u].pb(mp(v,p-w));
    }
    ok.resize(n,0);
    vis.resize(n,0);
    f(i,0,n-1)
    {
        vis.assign(n,0);
        dfs(i);
        if(vis[n-1])ok[i]=1;
        else ok[i]=0;
    }
    dis.resize(n,inf);
    dis[0]=0;
    f(i,0,n-1)
    {
        f(u,0,n-1)
        {
            for(auto tmp:adj[u])
            {
                int v=tmp.fi;
                int c=tmp.si;
                if(ok[v]==0)continue;
                if(dis[u]<inf && dis[u]+c<dis[v])
                {
                    dis[v]=dis[u]+c;
                    if(i==n-1)
                    {
                        cout<<"-1"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    int ses=-dis[n-1];
    ses=max(ses,0LL);
    cout<<ses<<endl;
    return 0;

}




































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

int su[2005];
vector< pair<int,int> > v;
int ok[2005];
int suu[2005];
priority_queue<int> pq[2005];

int main(){
    int n, m, q;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++){
        scanf("%d",&su[i]);
        v.push_back({su[i], i});
    }
    int ans = 2100000000;
    sort(v.begin(), v.end(), greater< pair<int, int> >());
    for(int i=0;i<n;i++){
        int me = v[i].second;
        ok[me] = 1;
        if(ok[me-1] && ok[me+1]){
            for(int jj=me;ok[jj];jj++){
                for(int j=jj-1;ok[j];j--){
                    if(su[j] > su[j+1]){
                        int tmp = su[j]; su[j] = su[j+1]; su[j+1] = tmp;
                    }else{
                        break;
                    }
                }
            }
        }else if(ok[me+1]){
            for(int j=me;ok[j+1];j++){
                if(su[j] > su[j+1]){
                    int tmp = su[j]; su[j] = su[j+1]; su[j+1] = tmp;
                }else{
                    break;
                }
            }
        }else if(ok[me-1]){
            //printf("!\n");
            for(int j=me-1;ok[j];j--){
                if(su[j] > su[j+1]){
                    int tmp = su[j]; su[j] = su[j+1]; su[j+1] = tmp;
                }else{
                    break;
                }
            }
        }
        int now = 1, sz = 0;
        int mn = 2100000000;
        while(now <= n){
            if(!ok[now]) now++;
            else{
                int nxt = now;
                while(ok[nxt]) nxt++;
                for(int j=now;j<=nxt-m;j++){
                    pq[i].push(su[j]);
                    mn = min(mn, su[j]);
                    //printf("push %d\n", su[j]);
                    sz++;
                    if(sz > q){
                        pq[i].pop();
                        sz--;
                    }
                }
                now = nxt;
            }
        }
        //printf("%d\n", sz);
        if(sz == q){
            ans = min(ans, pq[i].top() - mn);
        }
        //for(int j=1;j<=n;j++) printf("(%d,%d) ", ok[j], su[j]);
        //printf("\n");
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N,M;
	cin>>N>>M;
	vecsize(A,N+1)
	fx(N+1){
		A.at(x)=0;
	}
	fx(M){
		int m,l;
		cin>>m>>l;
		A.at(m)++;
		A.at(l)++;
	}
	fx(N){
		ce(A.at(x+1))
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e3 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int t, a, b, c, d, n;
unordered_map < int, int > dp;

int calc (int n) {
	if (dp.count(n))
		return dp[n];
	int res = INF;
	if (n <= INF / d)
		res = d*n;

	int nn = ((n + 1) / 2) * 2;
	res = min(res, calc(n / 2) + (n % 2) * d + a);
	res = min(res, calc(nn / 2) + (nn - n) * d + a);
	
	nn = ((n + 2) / 3) * 3;
	res = min(res, calc(n / 3) + (n % 3) * d + b);
	res = min(res, calc(nn / 3) + (nn - n) * d + b);

	nn = ((n + 4) / 5) * 5;
	res = min(res, calc(n / 5) + (n % 5) * d + c);
	res = min(res, calc(nn / 5) + (nn - n) * d + c);
	return dp[n] = res;
}



main () {
	cin >> t;
	while (t--) {
		cin >> n >> a >> b >> c >> d;
		dp.clear();
		dp[0] = 0;
		dp[1] = d;
		cout << calc(n) << endl;
	}
}





Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
ll power(ll a,int n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return power(a*a,n/2);
	else
	  return a*power(a*a,n/2);    
}
int main(){
FASTIO
int a,b,c;
cin>>a>>b>>c;
int d;
d=a;
a=b;
b=d;
d=a;
a=c;
c=d;
cout<<a<<" "<<b<<" "<<c;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long int ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n; ll k; cin >> k;
    vector<pair<int,ll>> v;
    for(int i=0;i<n;i++){
        int a,b; cin >> a >> b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    ll cnt=0;
    for(int i=0;i<n;i++){
        cnt+=v[i].second;
        if(cnt>=k){
            cout << v[i].first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vi clu(222222);
vi clu2(222222);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,c;cin>>n>>k>>c;
  string s;
  cin>>s;
  ll cnt = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'o'){
      cnt++;
      clu[i] = cnt;
      i += c;

    }
  }
  //cout<<cnt<<endl;

  if(cnt != k){
    return 0;
  }
  for(int i=n-1;i>=0;i--){
    if(s[i] == 'o'){
      clu2[i] = cnt;
      i-=c;

      cnt--;
    }
  }
  vi ans;
  /*  for(int i=0;i<n;i++)
    cout<<clu[i]<<" ";
  cout<<endl;
  for(int j=0;j<n;j++)
    cout<<clu2[j]<<" ";
    cout<<endl;*/
  for(int i=0;i<n;i++){
    if(clu[i] > 0 && clu[i] == clu2[i] && s[i] == 'o')
      ans.pb(i+1);
  }
  for(auto a:ans)cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 6920
#include <iostream>
#include <climits>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;
using namespace std;

int main(void) {
  ll N; cin >> N;
  ll sum = 0;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) { cin >> A[i]; sum += A[i]; }
  // sort(A.begin(), A.end());

  ll csum = 0;
  ll ans = LONG_MAX;
  for (int i = 0; i < N; i++) {
    csum += A[i];
    if (i + 1 < N) {
      ans = min(ans, abs(sum - 2 * csum));
    }
  }
  // ll csum = 0;
  // for (int i = 0; i < N - 1; i++) {
  //   csum += A[i];
  //   if (csum + A[i + 1] > sum / 2)
  //     break;
  // }
  // ll ans = abs(csum - (sum - csum));
  cout << ans << endl;
}


Measured memory_bytes: 1792
s = list(input())
t = list(input())
ans_bag = []
possible_ans_bag = []
flag = False
for i in range(len(s)-len(t)+1):
  ans = []
  check = True
  for j in range(len(t)):
    if j == 0:
      for k in range(i):
        ans += s[k]
    if s[i+j] == '?':
      ans += [t[j]]
    elif s[i+j] != t[j]:
      ans += [s[i+j]]
      check = False
      break
    else:
      ans += [s[i+j]]
  if len(t) <= i+len(t) and check:
    for k in range(i+len(t), len(s)):
      ans += [s[k]]
  if len(ans) == len(s) and check:
    ans_bag += [ans]
    flag = True
    
if flag:
  for possible_ans in ans_bag:
    for i in range(len(s)):
      if possible_ans[i] == '?':
        possible_ans[i] = 'a'
    possible_ans_bag += [possible_ans]

  print(''.join(sorted(possible_ans_bag)[0]))
else:
  print('UNRESTORABLE')

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

const int N = pow(10,5);

vector<int> is_prime(N+2, 1);

void sieve() {
  is_prime[0] = 0;
  is_prime[1] = 0;
  for (int i=2; pow(i,2)<=N+1; i++) {
    if (is_prime[i]==1) for(int j=2; i*j<=N+1; j++) is_prime[i*j] = 0;
  }
}

int main(){
    // エラストテネスの篩
    sieve();

    // like 2017
    vector<int> is_like_2017(N+1, 0);
    for (int i = 0; i <= N; i++)
    {
        if (i%2 == 0){
            continue;
        } 
        if (is_prime[i] == 1 && is_prime[(i+1)/2]==1)
        {
            is_like_2017[i] = 1;
        }
    }

    // 累積和
    vector<int> sums_like_2017(N+1, 0);
    int sum_like_2017 = 0;
    for (int i = 0; i <= N; i++)
    {
        if (is_like_2017[i] == 1)
        {
            sum_like_2017++;
        }
        sums_like_2017[i] = sum_like_2017;
    }
    
    // query
    int Q;
    cin >> Q;
    int l, r;
    for (int i = 0; i < Q; i++)
    {
        cin >> l >> r;
        cout << sums_like_2017[r] - sums_like_2017[l-1] << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int c=0,d=0;
    for (int i=0; i<s.size(); i++) {
        if (s.at(i)=='R') c++;
        else d++;
    }
    cout<<((c>d) ? "Yes":"No")<<endl;
    return 0;
}


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;
using P = pair<int, int>;

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s;
  cin >> s;
  s.at(5) = ' ';
  s.at(13) = ' ';
  cout << s << endl;
}


Measured memory_bytes: 256
from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin).rstrip()
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]


def main():
	s=nextLine()
	if s=="ABC":
		print("ARC")
	else:
		print("ABC")
	
if __name__=="__main__":
	main()


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

using namespace std;
int main() 
{
	int n,m,c;
	cin >> n >> m >> c;
	int b[m], a[n][m], sum[n], cnt=0;
	for (int i = 0; i < n; ++i)
	{
		sum[i] = c;
	}
	for (int i = 0; i < m; ++i)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			sum[i] += a[i][j]*b[j];
		}
		if(sum[i] > 0)
			cnt++;
	}
	cout << cnt << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 main()
{
    int n;cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
        if(i==0){
            if(a[i]!=0){
                cout << -1 << endl;
                return 0;
            }
        }
        else{
            if(a[i]-a[i-1]>=2){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ll ans=0;
    REP(i,n){
        if(i==0)continue;
        if(a[i]-a[i-1]==1){
            ans++;
        }
        else{
            ans+=a[i];
        }
    }
    cout << ans << endl;
}


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

int main() {
    ll N,W;
    ll w[101],v[101];
    std::cin >> N>>W;
    for (int i = 0; i < N; i++) {
        std::cin >> w[i]>>v[i];
    }
    ll dp[101][100001];
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i+1][j] = dp[i][j];
            if(j-w[i]>=0){
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i] );
            }
        }
    }
    std::cout << dp[N][W] << std::endl;
    
}



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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,d[200000],m,t[200000],i,j = 0;

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

    qsort(d,n,sizeof(int),asc);
    qsort(t,m,sizeof(int),asc);

    for (i = 0; i < n; i++)
    {
        if(d[i] == t[j])
        {
            j++;
            if(j == m)break;
        }
    }

    printf("%s\n",i == n ? "NO" : "YES");
}

Measured memory_bytes: 2556
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 1e5+5;

vector<int> G[N];
bool vis[N];
LL dp[N][2];
LL mod = 1e9+7;

void dfs(int u) {
  vis[u] = 1;
  bool leaf = true;
  dp[u][0] = dp[u][1] = 1;
  for(auto v: G[u]) {
    if(vis[v] == 0) {
      leaf = false;
      dfs(v);
      dp[u][0] *= (dp[v][0] + dp[v][1]);
      dp[u][1] *= dp[v][0];
      dp[u][0] %= mod;
      dp[u][1] %= mod;
    }
  }
}


int main()
{
  int n;
  in(n);
  for(int i = 0; i < n-1; i ++) {
    int u,v;
    in2(u,v);
    G[u].pb(v);
    G[v].pb(u);
  }
  dfs(1);
  cout <<(dp[1][0] + dp[1][1]) % mod << endl;
}




Measured memory_bytes: 11520
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;


int N, M, X;
int buy[12];

int judge(vector<int> &cost, vector<vector<int>> &up){
    int ret=0;
    vector<int> skill(M,0);
    for(int i=0; i<N; i++){
        if(buy[i]==0)continue;
        ret+=cost[i];
        for(int j=0; j<M; j++){
            skill[j]+=up[i][j];
        }
    }

    for(int i=0; i<M; i++){
        if(skill[i]<X){
            return (int)MOD;
        }
    }

    return ret;
}


int dfs(int cnt, vector<int> &cost, vector<vector<int>> &up){
    if(cnt==N){
        return judge(cost, up);
    }

    int ret=MOD;
    buy[cnt]=1;
    ret=min(ret,dfs(cnt+1,cost,up));
    buy[cnt]=0;
    ret=min(ret,dfs(cnt+1,cost,up));
    
    return ret;
}

int main(){
    
    cin >> N >> M >> X;

    vector<int> cost(N);
    vector<vector<int>> up(N,vector<int>(M));
    for(int i=0; i<N; i++){
        cin >> cost[i];
        for(int j=0; j<M; j++){
            cin >> up[i][j];
        }
    }
    int ans=dfs(0,cost,up);
    if(ans==(int)MOD){
        ans=-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;
struct data {
  int l, r;
} seg[6];
ll a[N], qz[N];

ll get(int l1, int r1, int l2, int r2) {
  ll pos = qz[r1] - qz[l1 - 1];
  ll tmp = qz[r2] - qz[l2 - 1];
  return abs(pos - tmp);
}

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    qz[i] = qz[i - 1] + a[i];
  }
  int l = 1, p = 3, r = p + 1;
  ll ans = 1e18;
  while(p <= n - 1) {
    while(l + 1 < p && get(1, l, l + 1, p - 1) > get(1, l + 1, l + 2, p - 1)) l++;
    r = max(r, p);
    while(r + 1 <= n && get(p, r - 1, r, n) > get(p, r, r + 1, n)) r++;
    seg[1] = (data){1, l}, seg[2] = (data){l + 1, p - 1}, seg[3] = (data){p, r - 1}, seg[4] = (data){r, n};
    ll res = 0;
    for(int i = 1; i <= 4; ++i)
      for(int j = 1; j <= 4; ++j)
        res = max(res, get(seg[i].l, seg[i].r, seg[j].l, seg[j].r));
/*    for(int i = 1; i <= 4; ++i) {
      printf("%d %d\n", seg[i].l, seg[i].r);
    }
    puts("hello");*/
    ans = min(ans, res);
    ++p;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = 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 fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

// largest rectangle in histogram
int calc(const vector<int> &h)
{
    int n = h.size();
    vector<int> L(n),R(n),st(n);

    int t=0;
    rep(i,n)
    {
        while(t>0 && h[st[t-1]]>=h[i]) --t;
        L[i] = (t==0?0:st[t-1]+1);
        st[t++] = i;
    }

    t = 0;
    for(int i=n-1; i>=0; --i)
    {
        while(t>0 && h[st[t-1]]>=h[i]) --t;
        R[i] = (t==0?n:st[t-1]);
        st[t++] = i;
    }

    int ret = 0;
    rep(i,n) ret = max(ret, (h[i]+1)*(R[i]-L[i]+1));
    return ret;
}

int main()
{
    int h,w;
    cin >>h >>w;
    vector<string> s(h);
    rep(i,h) cin >>s[i];

    vector<vector<int>> f(h-1,vector<int>(w-1,-1));
    rep(i,h-1)rep(j,w-1)
    {
        int ct = 0;
        rep(ii,2)rep(jj,2) ct += (s[i+ii][j+jj]=='#');
        if(ct%2==1) f[i][j] = 0;
    }

    rep(j,w-1)if(f[0][j]!=0) f[0][j]=1;
    for(int i=1; i<h-1; ++i)rep(j,w-1)if(f[i][j]!=0)f[i][j] = f[i-1][j]+1;

    int ans = max(h,w);
    rep(i,h-1) ans = max(ans,calc(f[i]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20096
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()
  val t = sc.next()


  var max = 0
  for (i in 0 until s.length - t.length+1) {
    val ssub = s.substring(i, t.length+i)
    var count = 0
    for (j in 0 until t.length) {
      val cs = ssub[j]
      val ct = t[j]
      if (cs == ct) count++
    }
    max = Math.max(count, max)
  }

  println(t.length - max)
}


Measured memory_bytes: 37844
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		int 偶数 = 0;
		int 奇数 = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] % 2 == 0) {
				偶数++;
			} else {
				奇数++;
			}
		}

		System.out.println(奇数 % 2 == 0 ? "YES" : "NO");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}
}


Measured memory_bytes: 34300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
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
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

ll f(ll a) {
	ll n = (a + 1) / 2;
	ll x = (n & 1) ? 1 : 0;
	x ^= (a & 1) ? 0 : a;
	return x;
}

int main() {
	ll a, b; cin >> a >> b;
	cout << (f(a - 1) ^ f(b)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[]) {
		while(true) {
			int N = sc.nextInt();
			if(N == 0) break;
			int ans = 0;
			while(true) {
				ans += (N /= 5);
				if(N < 5) break;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int x = Math.max(a*b,Math.max(a+b,a-b));
      System.out.println(x);
    }
}

Measured memory_bytes: 23764
a, b = map(int, input().split())

if a <= 0 and 0 <= b:
    print("Zero")
elif  b < 0:
    cnt = abs(a) - abs(b) + 1
    if cnt%2:
        print("Negative")
    else:
        print("Positive")
elif 0 < a:
    print("Positive")




Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using vvv = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>
#define VVI(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVI(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N, 0);
  REP(i, N) cin >> A[i];

  ll left = 1;
  ll right = N;
  bool end = true;
  ll LAST = 0;
  AUTO(a, A) {
    if (LAST >= a)
      end = false;
    LAST = a;
  }
  if (end) {
    cout << 1 << endl;
    return 0;
  }

  while (right - left > 1) {
    ll mid = left + (right - left) / 2;
    ll LAST = 0;
    vector<Pair>
        X; //辞書順先頭の文字(0)以外の文字を格納、{先頭から何番目か,記号の種類}
    AUTO(a, A) {
      if (LAST >= a) {
        while (!X.empty() && X.back().first > a)
          X.pop_back();
        X.push_back(make_pair(a + 1, mid));
      }
      LAST = a;
      while (!X.empty() && X.back().second == mid) {
        ll po = X.back().first;
        X.pop_back();
        if (!X.empty() && X.back().first == po - 1) {
          ll yo = X.back().second;
          X.pop_back();
          X.push_back(make_pair(po - 1, yo + 1));
        } else {
          X.push_back(make_pair(po - 1, 1));
        }
      }
    }

    // 最初の桁が0以下だとオーバーフローしている
    if (X.front().first > 0)
      right = mid;
    else
      left = mid;
  }
  cout << right << endl;

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define endl "\n"
    #define space " "
    #define ll long long int
    #define vl vector<ll>
    #define vvl vector < vll >
    #define pii pair<int,int>
    #define pll pair<ll,ll>
    #define vpl vector < pll >
    #define mod 1000000007
    #define pi 3.1415926535897932384626433
    #define inf 1000000000000000001;
    #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y) 
    #define mem(a,val) memset(a,val,sizeof(a))
    #define pb push_back
    #define f first
    #define s second
    
    void solve()
    {
        ll a,b,c,d; cin>>a>>b>>c>>d;
        ll p=a*c, q=a*d, r=b*c, s=b*d;
        ll ans = max(p, q);
        ans = max(ans, r); ans = max(ans, s);
        cout<<ans;
    }

    signed main()
    {

    fast;
    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

    ll T=1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
    }


Measured memory_bytes: 3648
import math
a,b,h,m=map(int,input().split())
kakudo_b = float(m * 6)
kakudo_a = float(h * 30 + m / 2)

if kakudo_a > kakudo_b and kakudo_a - kakudo_b < 180:
    kakudo_kyori = kakudo_a - kakudo_b
elif kakudo_a > kakudo_b and kakudo_a - kakudo_b > 180:
    kakudo_kyori = kakudo_b + (360 - kakudo_a)
elif kakudo_a == kakudo_b:
    kakudo_kyori = 0
elif kakudo_b > kakudo_a and kakudo_b - kakudo_a < 180:
    kakudo_kyori = kakudo_b - kakudo_a
elif kakudo_b > kakudo_a and kakudo_b - kakudo_a > 180:
    kakudo_kyori = kakudo_a -kakudo_b
else:
    kakudo_kyori = 180

if kakudo_kyori == 0:
    if a > b:
        ans = a-b
        print('{:.20f}'.format(ans))
    elif a==b:
        ans = 0
        print('{:.20f}'.format(ans))
    else:
        ans = b-a
        print('{:.20f}'.format(ans))
elif kakudo_kyori == 180:
    ans = a + b
    print('{:.20f}'.format(ans))
else:
    cos = math.cos(math.radians(kakudo_kyori))
    ans_2 = a * a + b * b - 2 * a*b*cos
    ans = ans_2 ** 0.5
    print('{:.20f}'.format(ans))


Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000


int prim(int v, vector<vector<pair<int, int> > > adjlist){

    priority_queue<pair<int, int> >  wait;    // first := 候補辺のコスト   second　:= 行先ノード
    vector<int> result(v, INF);               // 頂点iと木の間の最小コスト
    int ans = 0, size = 0;                    // 木のコスト　頂点数

    //初期条件
    result[0] = 0;
    wait.push(make_pair(0, 0));

    while(!wait.empty() && size < v){

        //候補辺のうち最小のものを取り出す
        int newpoint = wait.top().second;
        int newcost = -wait.top().first;
        wait.pop();

        if(result[newpoint] < newcost) continue;

        //出てきた頂点を木に追加
        ans += newcost;
        result[newpoint] = -INF;
        size++;

        // 新しい点から出ている辺をすべてなめる
        for(int i = 0; i < adjlist[newpoint].size(); i++){
            int nextpoint = adjlist[newpoint][i].second;
            int nextcost = adjlist[newpoint][i].first;
            //より木に近くなった頂点があれば,　そこへの枝をqueueに追加
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }

    return ans;
}


struct point{
    int idx, x, y;
};

bool comp_x(point a, point b){
    return a.x < b.x;
}

bool comp_y(point a, point b){
    return a.y < b.y;
}


int main(){

    int n; cin >> n;
    vector<point> vec(n);
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        vec[i].idx = i;
        vec[i].x = x;
        vec[i].y = y;
    }

    vector<vector<pair<int, int> > > adj(n);
    
    //xを基準にsort
    sort(vec.begin(), vec.end(), comp_x);
    for(int i = 0; i < n - 1; i++){
        int u = vec[i].idx;
        int v = vec[i + 1].idx;
        int cost = min((int)abs(vec[i].x - vec[i + 1].x), (int)abs(vec[i].y - vec[i + 1].y));
        adj[u].push_back({cost, v});
        adj[v].push_back({cost, u});
    }

    //y,,
    sort(vec.begin(), vec.end(), comp_y);
    for(int i = 0; i < n - 1; i++){
        int u = vec[i].idx;
        int v = vec[i + 1].idx;
        int cost = min((int)abs(vec[i].x - vec[i + 1].x), (int)abs(vec[i].y - vec[i + 1].y));
        adj[u].push_back({cost, v});
        adj[v].push_back({cost, u});
    }

    int ans = prim(n, adj);

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

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

int main(){
  string S,T;
  cin>>S>>T;
  ll ans=0,cnt=-1,roop=0,SS=S.size(),TT=T.size();
  
  bool SC[26];
  REP(i,26) SC[i]=false;
  REP(i,SS) SC[S[i]-'a']=true;
  REP(i,TT){
    if(SC[T[i]-'a']==false){
      co(-1);
      return 0;
    }
  }
  
  vector<vector<ll>> L(26);
  REP(i,SS){
    L[S[i]-'a'].PB(i);
  }
  
  for(int i=0; i<TT; ++i){
    if(cnt>=L[T[i]-'a'][L[T[i]-'a'].size()-1]){
      roop++;
      cnt=L[T[i]-'a'][0];
    }
    else{
      auto it=upper_bound(ALL(L[T[i]-'a']),cnt);
      cnt=*it;
    }
  }
  
  ans=roop*SS+cnt+1;
  co(ans);
  return 0;
}

Measured memory_bytes: 4624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  string s;
  cin >> s;
  if (s[s.length() - 1] == 's')
    s += 'e';
  s += 's';
  cout << s;
  return (0);
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

ll calculate_gcd(ll a, ll b){
    if(a<b){swap(a,b);}
    if(b<1){return 0;}
    ll r;
    while((r = a%b) != 0){
        a = b;
        b = r;
    }
    return b;
}

ll calculate_lcm(ll a,ll b){
    return a*b/calculate_gcd(a,b);
}

int main(){
    ll n, k;
    cin >> n >> k;

    ll ans = calculate_lcm(n,k);
    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 4e5 + 5, M = 2 * N + 5;

ll f(ll x){
    ll ret = 1;
    for(int i = 0 ; i < 5 ; ++i)ret *= x;
    return ret;
}

ll bs(ll x){
    ll l = -4000, r = 4000, mid;
    while(l <= r){
        ll mid = (l + r) / 2;
        ll rkm = f(mid);
        if(rkm == x)return mid;
        if(rkm > x)r = mid - 1;
        else l = mid + 1;
    }
    return -1;
}

int main(){
    ll x;
    scanf("%lld", &x);
    for(ll A = -4000 ; A <= 4000 ; ++A){
        ll a = f(A);
        ll b = a - x;
        ll B = bs(b);
        if(~B){
            printf("%lld %lld\n", A, B);
            return 0;
        }
    }
}

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

int main() {
	string N;
	cin >> N;
  
  	int year = stoi(N.substr(0, 4));
    int manth = stoi(N.substr(5, 2));

  	if(year == 2019 && manth >= 5) cout << "TBD" << endl;
  	else if (year > 2019) cout << "TBD" << endl;
  	else cout << "Heisei" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define show(x) cerr << #x << " = " << x << endl
using namespace std;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<int> w(n);
        for (int i = 0; i < n; i++) {
            cin >> w[i];
        }

        vector<vector<bool>> ok(n, vector<bool>(n, false));  // [i,j]?????¨????????¨?????????
        for (int d = 1; d < n; d += 2) {
            for (int i = 0; i + d < n; i++) {
                if (d == 1) {
                    if (abs(w[i] - w[i + d]) <= 1) {
                        ok[i][i + d] = true;
                    }
                } else {
                    if (ok[i + 1][i + d - 1] and abs(w[i] - w[i + d]) <= 1) {
                        ok[i][i + d] = true;
                    } else {
                        for (int j = i + 1; j < i + d; j += 2) {
                            if (ok[i][j] and ok[j + 1][i + d]) {
                                ok[i][i + d] = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
        vector<pair<int, int>> interval;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (ok[i][j]) {
                    interval.push_back(make_pair(i + 1, j + 1));
                }
            }
        }
        const int size = interval.size();
        vector<vector<int>> dp(size + 1, vector<int>(n + 1, 0));
        for (int i = 0; i < size; i++) {
            for (int j = 0; j <= n; j++) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
                if (j < interval[i].first) {
                    dp[i + 1][interval[i].second] = max(dp[i + 1][interval[i].second], dp[i][j] + (interval[i].second - interval[i].first + 1));
                }
            }
        }

        int maxi = 0;
        for (int i = 0; i <= n; i++) {
            maxi = max(maxi, dp[size][i]);
        }
        cout << maxi << endl;
    }

    return 0;
}

Measured memory_bytes: 29016
cat<<EOF>Source.cpp
using namespace std;

extern "C"{
int printf (const char *__restrict __format, ...);
int scanf (const char *__restrict __format, ...) ;
}
int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	for(int i=0;i<k;i++){
		int d=max(n,k);
		int cnt[d];
		for(int j=0;j<d;j++)cnt[j]=0;
		for(int j=0;j<n;j++){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		for(int j=0;j<k;j++){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	for(int i=0;i<k;i++)Max=max(Max,ans[i]);
	printf("%d\n",Max);
}
EOF
g++ -Ofast Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 11316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

#define P pair<int, int>

int main() {
    P xy[4];
    cin >> xy[0].first >> xy[0].second >> xy[1].first >> xy[1].second;
    int dx = xy[0].first - xy[1].first, dy = xy[0].second - xy[1].second;
    xy[2] = P(xy[1].first + dy, xy[1].second - dx);
    xy[3] = P(xy[0].first + dy, xy[0].second - dx);
    cout << xy[2].first << ' ' << xy[2].second << ' ' << xy[3].first << ' ' << xy[3].second << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.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());
	//strcmp：第一引数 < 第二引数ならマイナスの値、等しいなら0、第一引数 > 第二引数ならプラスの値
	if (strcmp(s.c_str(), t.c_str()) < 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	
	return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    int ls, lt, cnt=0;
    cin >> s >> t;
    ls = s.size();
    lt = t.size();
    if(ls==lt-1){
        for(int i=0; i<ls; i++){
            if(s[i]==t[i]) ++cnt;
        }
        if(cnt==ls) cout << "Yes\n";
        else cout << "No\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if ((a + b) > (c + d)) {
            System.out.println("Left");
        } else if ((a + b) < (c + d)) {
            System.out.println("Right");
        } else {
            System.out.println("Balanced");
        }
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
int main(){
  int n=0,i=0;
  int num[10000];
  int count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<n;i++){
    if(Sosu(num[i])==2){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}
int Sosu(int x){
  int i=0;
  if(x==2)return 2;
  if(x%2==0||x<2)return 1;
  
  for(i=3;i<=sqrt((double)x);i+=2){
    if(x%i==0)return 1;
  }
  return 2;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(C, B / A);
  return 0;
}

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


int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n,k;
		cin>>n>>k;
		int a[n];
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		int dp[k+1];
		memset(dp,0,sizeof(dp));
		for(int j=0;j<=k;j++)
		{
			for(int i=0;i<n;i++)
			{
				if(j-a[i]>=0&&!dp[j-a[i]])
				{
					dp[j]=true;
				}
			}
		}
		if(dp[k])
		{
			cout<<"First";
		}
		else
		{
			cout<<"Second";
		}
	}
		
}


Measured memory_bytes: 3952