akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n;
int c[200100];
int a[200100], b[200100];

vector<int> G[200100];
ll s[200100];
ll rem[200100];

ll dfs(int v, int prev) {
    ll sum = 0;
    for (int u : G[v]) {
        if (u == prev) continue;
        sum += dfs(u, v);
    }
    s[v] = sum+1;
    return s[v];
}

map<int, ll> calc(int v, int prev) {
    map<int, ll> m0;
    for (int u : G[v]) {
        if (u == prev) continue;
        map<int, ll> m = calc(u, v);
        ll num = s[u] - m[c[v]];
        rem[c[v]] += num * (num+1) / 2;

        if (m0.size() < m.size()) swap(m0, m);
        for (auto& v : m) {
            m0[v.first] += v.second;
        }
    }
    m0[c[v]] = s[v];
    return m0;
}

void solve() {
    for (int i = 0; i < n-1; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    dfs(0, -1);
    map<int, ll> m = calc(0, -1);
    for (int i = 1; i <= n; i++) {       
        ll num = s[0] - m[i];
        rem[i] += num * (num+1) / 2;
    }

    for (int i = 1; i <= n; i++) {
        cout << n * (n+1) / 2 - rem[i] << endl;
    }
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> c[i];
    for (int i = 0; i < n-1; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
}

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

    input();
    solve();
}


Measured memory_bytes: 70020
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int i,j,n,a,b;
  stack<char>k;
  string s,t;
  cin>>s>>t;
  a=s.size();
  b=t.size();
  int d[a+1][b+1];
  for(i=0;i<=a;i++)
  {
    for(j=0;j<=b;j++)
    {
      if(i==0||j==0)
        d[i][j]=0;
      else if(s[i-1]==t[j-1])
      {
        //k.push(s[i-1]);
        d[i][j]=1+d[i-1][j-1];
        //break;
      }
      else
      {
        d[i][j]=max(d[i-1][j],d[i][j-1]);
      }
    }
  }
  i=a;
  j=b;
  while(i>0&&j>0)
  {
    if(s[i-1]==t[j-1])
    {
      k.push(s[i-1]);
      i--;j--;
    }
    else if(d[i-1][j]>d[i][j-1])
    i--;
    else
    j--;
    
  }
  while(k.size())
  {
    cout<<k.top();
    k.pop();
  }
}


Measured memory_bytes: 35456
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>

std::multiset<int, std::greater<int>> list;
int A, B, C;

int main(){
  scanf("%d %d %d", &A, &B, &C);
  printf("%d\n", std::min(A + B + 1, C) + B);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	int h = round((double)H / 3.0);
	int w = round((double)W / 3.0);
	cout << min({ abs(h * W - (H - h - h) * W),
		abs(w * H - (W - w - w) * H),
		max(abs(h * W - (H - h) * (W / 2)), abs(h * W - (H - h) * (W - W / 2))),
		max(abs(w * H - (W - w) * (H / 2)), abs(w * H - (W - w) * (H - H / 2))),
		}) << endl;;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion
void Main();

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

void Main(){
    string S;
    cin >> S;
    int cnt0 = 0;
    REP(i, S.length()){
        if(S[i] == '0'){
            cnt0 ++;
        }
    }
    cout << 2*min(cnt0, (int)S.length()-cnt0) << el;
}



Measured memory_bytes: 3748
#include <algorithm>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>


#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    int a;
    cin >> a;

    cout << a + a * a + a * a * a << endl;

    return 0;
}


Measured memory_bytes: 3140
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int ans[2100][2100];

int main(){
  for(int i=0;i<2100;i++){
    for(int j=0;j<2100;j++){
      ans[i][j]=-1;
    }
  }
  vector<int> V;
  int H,W;
  cin>>H>>W;
  string S[2100];
  for(int i=0;i<H;i++){
    cin>>S[i];
  }
  int count=0;
  for(int i=0;i<H;i++,count=0){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#'){
        if(count!=0) V.push_back(count);
        V.push_back(0);
        count=0;
      }else count++;
    }
    if(count!=0) V.push_back(count);
    int now=0;
    for(int k=0;k<V.size();k++){
      if(V[k]==0) now++;
      else{
        for(int l=0;l<V[k];l++){
          ans[i][now]=V[k];
          //cout<<i<<" "<<now<<" "<<ans[i][now]<<endl;
          now++;
        }
      }
    }
    V.erase(V.begin(),V.end());
  }

  for(int i=0;i<W;i++,count=0){
    for(int j=0;j<H;j++){
      if(S[j][i]=='#'){
        if(count!=0) V.push_back(count);
        V.push_back(0);
        count=0;
      }else count++;
    }
    if(count!=0) V.push_back(count);
    int now=0;
    for(int k=0;k<V.size();k++){
      if(V[k]==0) now++;
      else{
        for(int l=0;l<V[k];l++){
          ans[now][i]+=V[k];
          //cout<<i<<" "<<now<<" "<<V[k]<<endl;
          now++;
        }
      }
    }
    V.erase(V.begin(),V.end());
  }

  int a=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      //cout<<i<<" "<<j<<" "<<ans[i][j]<<endl;
      a=max(a,ans[i][j]);
    }
  }
  cout<<a-1<<endl;
}


Measured memory_bytes: 23552
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,a[200010],i,s=0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    s=s^a[i];
  }
  for(i=0;i<n;i++){
    int x=s^a[i];
    if(i==0){
      printf("%d",x);
    }
    else{
      printf(" %d",x);
    }
  }
  printf("\n");
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5+7;
const int M = 1e9+7;

int a[maxn];

struct tree_node
{
    int l,r,sum,lazy;
};

struct segtree
{
    tree_node t[maxn*4];
    void pushup(int k)
    {
        t[k].sum = max(t[k*2].sum,t[k*2+1].sum);
    }
    void build(int k,int l,int r)
    {
        t[k].l = l,t[k].r = r;
        if(l == r)
        {
            t[k].sum = 0;           //初始值
            return;
        }
        int mid = (l+r)/2;
        build(k*2,l,mid);
        build(k*2+1,mid+1,r);
        pushup(k);
    }
    void update(int x,int y,int k = 1)
    {
        if(t[k].l == x && t[k].r == x)
        {
            t[k].sum = y;
            return;
        }
        if(t[k*2].r >= x) update(x,y,k*2);
        else update(x,y,k*2+1);
        pushup(k);
    }
    int query(int l,int r,int k = 1)
    {
        if(l <= t[k].l && t[k].r <= r)
        {
            return t[k].sum;
        }
        int res = 0;
        if(t[k*2].r >= l) res = max(res,query(l,r,k*2));
        if(t[k*2+1].l <= r) res = max(res,query(l,r,k*2+1));
        return res;
    }
}st;

signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,k;cin>>n>>k;
    for(int i = 1; i <= n; i++) 
    {
        cin>>a[i];
        a[i]++;
    }
    st.build(1,1,300001);
    for(int i = 1; i <= n; i++) 
    {
        int l = a[i]-k,r = a[i]+k;
        l = max(l,1);r = min(r,300001);
        int res = st.query(l,r);
        st.update(a[i],res+1);
    }
    cout<<st.t[1].sum<<endl;
    return 0;
}

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

using namespace std;
static int value[200000];
static int SortedValue[200000];

int main()
{
    int N;
    cin >> N;
    int tmp;
    for(int i = 0; i < N; i++) {
        cin >> tmp;
        value[i] = tmp;
        SortedValue[i] = tmp;
    }
    sort(SortedValue, SortedValue + N);
    //for(int i = 0; i < N; i++) { cout << SortedValue[i] << " "; }
    int MedIdx = (N / 2);
    int LeftMed = SortedValue[MedIdx - 1];
    int RightMed = SortedValue[MedIdx];
    //cout << LeftMed << endl;
    //cout << RightMed << endl;
    for(int i = 0; i < N; i++) {
        if((value[i] == RightMed) && (value[i] == LeftMed)) {
            cout << LeftMed << endl;
        }
        else {
            if(value[i] >= RightMed) {
                cout << LeftMed << endl;
            }
            else {
                cout << RightMed << endl;
            }
        }

    }
    return 0;
}


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

using namespace std;

int F(int64_t A, int64_t B) {
    return max(to_string(A).size(), to_string(B).size());
}

int main(void) {
    int64_t N;
    cin >> N;

    int ans = INT32_MAX;
    for(int64_t i=1; i*i<=N; i++) {
        if(N%i) continue;
        int64_t j = N/i;
        ans = min(ans, F(i, j));
    }

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


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int w,h,a[50][50];
bool dfs(int x,int y){
	a[x][y]=0;
	for(int dx=-1;dx<=1;dx++) for(int dy=-1;dy<=1;dy++){
		int nx=x+dx,ny=y+dy;
		if(0<=nx && nx<h && 0<=ny && ny<w && a[nx][ny]==1) dfs(nx,ny);
	}
}
int main(){
	while(true){
		scanf("%d%d",&w,&h);
		if(w==0) break;
		int ans=0;
		rep(i,h) rep(j,w) scanf("%d",&a[i][j]);
		rep(i,h) rep(j,w) if(a[i][j]) { dfs(i,j); ans++; }
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    vector<ll> cs(n);
    cs.at(0) = a.at(0);
    for(ll i = 1; i < n; ++i){
        cs.at(i) = cs.at(i - 1) + a.at(i);
    }

    vector<ll> cands;
    REP(i, n){
        for(ll j = 1; i + j <= n; ++j){
            ll tmp = cs.at(i + j - 1);
            if(i > 0){
                tmp -= cs.at(i - 1);
            }
            cands.push_back(tmp);
        }
    }

    for(ll i = 40; i >= 0; --i){
        vector<ll> nxt;
        for(ll c : cands){
            if((c >> i) & 1){
                nxt.push_back(c);
            }
        }
        if(nxt.size() >= k){
            cands.swap(nxt);
        }
    }

    ll ans = cands.at(0);
    for(ll i = 1; i < k; ++i){
        ans &= cands.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6516
#include<iostream>
using namespace std;
int main(){
  long long int n,ss;
  while(cin>>n){
  long long int s = 0;
  for(int i=0;i<n;i++){
    cin >> ss;
    s += ss;
  }
  cout << s / n << endl;
  }
  return 0;
}   

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

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    int rem = A - B;

    if (rem != 0){
        if (rem > C) {
            C = 0;
        } else {
            C -= rem;
        }
    }

    cout << C << endl;

    return 0;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def main():
  V, E = int(input()), int(input())
  L = []
  app = L.append
  visited = [0 for i in range(V)]
  edges = [[] for i in range(V)]
  
  def visit(x):
    if not visited[x]:
      visited[x] = 1
      for e in edges[x]:
        visit(e)
      app(x)
  
  for i in range(E):
    s, t = map(int,input().split())
    edges[s - 1].append(t - 1)
  
  for i in range(V):
    if not visited[i]:
      visit(i)
  L.reverse()
  
  flag = 0
  temp = L[0]
  print(temp + 1)
  for i in range(V - 1):
    v = L[i + 1]
    print(v + 1)
    if not flag and i < V - 1 and (v not in edges[temp]):
      flag = 1
    temp = v
  print(flag)
main()


Measured memory_bytes: 13308
#include <cstdio>
#include <numeric>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

const int mod = 1000000007;
long long dp[2002][2002];

vector<int> factorials;
vector<int> ifactorials;

vector<int> range_mod_inverse(int n, const int mod) {
  vector<int> ret(n + 1);
  ret[1] = 1;
  for (int i = 2; i <= n; i++)
    ret[i] = (long long)(mod - mod / i) * ret[mod%i] % mod;
  return ret;
}

vector<int> getFactorials(int n, const int mod) {
  vector<int> ret(1, 1);
  for (int i = 1; i <= n; i++) ret.push_back((long long)ret.back()*i%mod);
  return ret;
}

vector<int> getInverseFactorials(int n, const int mod) {
  vector<int> invmod(range_mod_inverse(n, mod));
  vector<int> ret(1, 1);
  for (int i = 1; i <= n; i++) ret.push_back((long long)ret.back()*invmod[i] % mod);
  return ret;
}

long long binom(int n, int r) {
  if (n < 0 || r < 0 || r > n)
    return 0;
  return (long long)factorials[n] * (long long)ifactorials[r] % mod * ifactorials[n-r] % mod;
}

int main()
{
  factorials = getFactorials(4000003, mod);
  ifactorials = getInverseFactorials(4000003, mod);
  int n, K;
  scanf("%d%d", &n, &K);
  if (K == 1) {
    printf("1\n");
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      long long subval = 0;
      if (j > 0) subval += dp[i][j - 1];
      if (i > j) subval += dp[i - 1][j] * binom((K - 1)*i + j - 1, K - 2);
      subval %= mod;
      dp[i][j] = subval;
    }
  }
  long long ans = dp[n][n];
  ans *= factorials[n];
  ans %= mod;
  ans += mod;
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 56036
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    if n == 1 {
        println!("Hello World");
    } else {
        let a = input::<i64>();
        let b = input::<i64>();
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;

    ll a[12];
    a[0]=1, a[1]=2;
    set<ll> st;
    st.insert(1); st.insert(2); st.insert(3);
    for(int i=2; i<=n; i++){
        for(a[i]=a[i-1]+1; ; a[i]++){
            if(st.find(a[i])!=st.end()) continue;
            bool ok=1;
            for(int j=0; j<i; j++){
                if(st.find(a[j]+a[i])!=st.end()){
                    ok=0; break;
                }
            }
            if(ok){
                st.insert(a[i]);
                for(int j=0; j<i; j++) st.insert(a[j]+a[i]);
                break;
            }
        }
    }

    ll w[12][12]={};
    w[0][1]=w[1][0]=1, w[0][2]=w[2][0]=2, w[1][2]=w[2][1]=3;
    ll m=5;
    for(int i=3; i<n; i++){
        for(int j=0; j<i; j++) w[j][i]=w[i][j]=(m+1)*a[j];
        vector<int> v(i+1);
        for(int j=0; j<=i; j++) v[j]=j;
        while(1){
            ll s=0;
            for(int j=0; j<i; j++){
                s+=w[v[j]][v[j+1]];
            }
            m=max(m, s);
            if(!next_permutation(v.begin(), v.end())) break;
        }
    }
    
    //cerr<<m<<endl;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cout<<w[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int a[110];
int main()
{
	int n;
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		a[x]=1;
	}
	int sum=0;
	for(int i=0;i<110;i++)
	{
		if(a[i]==1) sum++;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<Integer> d = new HashSet();

        for (int i = 0; i < N; i++) {
            d.add(sc.nextInt());
        }
        sc.close();
        System.out.println(d.size());
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  int num = 0;
  num = pow(10,9);
  int a = 0;
  a = (num - n % num) % num;
  int b = 0;
  b = (n + a) / num;
  cout << 0 << " " << 0 << " " << (int)pow(10,9) << " " << 1 << " " << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
a = [int(input()) for _ in range(5)]
b = 0
c = []
for s in a:
    b = 10 - s % 10
    if b == 10:
        b = 0
    c.append(b)
d = zip(c,a)
e = sorted(d)
ans = 0
count = 0
for x,y in e:
    count += 1
    if count == 5:
        ans = ans + y
        break
    ans = ans + x + y

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, W;
  string DE[4] = {"maerd","esare","remaerd","resare"};
  int L, N;
  cin >> S;
  L = S.size();
  N = L;
  bool H = true;
  reverse(S.begin(), S.end());
  
  
  while(H){
     W = "";
     bool H2 = true;
    
     if(N == 0){
     break;
     }
     if(N < 5){
     H = false;
     break;
     }
    
     if(S.at(L - N) == 'm' || S.at(L - N) == 'e'){
        for(int i = 0;i < 5;i++){
        W = W + S.at(L - N + i);
        }
        if(W == DE[0] || W == DE[1]){
        N = N - 5;
        H2 = false;
        }
     }
    
     else if(S.at(L - N) == 'r'){
        if(S.at(L - N + 2) == 'm'){
           for(int i = 0;i < 7;i++){
           W = W + S.at(L - N + i);
           }
           if(W == DE[2]){
           N = N - 7;
           H2 = false;
           }
        }
        else if(S.at(L - N + 2) == 's'){
           for(int i = 0;i < 6;i++){
           W = W + S.at(L - N + i);
           }
           if(W == DE[3]){
           N = N - 6;
           H2 = false;
           }
        }
     }
     if(H2){
     H = false;
     }
  }
 
  if(H){
  cout << "YES" << endl;
  }
  else{
  cout << "NO" << endl;
  }
}

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

using namespace std;

const int MAXN = 301;
int dp[MAXN][MAXN][MAXN];

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;

    int n = s.length();
    int mx = 0;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; i + j <= n; j++) {
            for (int c = 0; c <= k; c++) {
                mx = max(mx, dp[i][j][c]);

                if (i + j + 1 <= n) {
                    dp[i + 1][j][c] = max(dp[i + 1][j][c], dp[i][j][c]);
                    dp[i][j + 1][c] = max(dp[i][j + 1][c], dp[i][j][c]);
                }
                if (i + j + 1 == n) {
                    dp[i + 1][j][c] = max(dp[i + 1][j][c], dp[i][j][c] + 1);
                    dp[i][j + 1][c] = max(dp[i][j + 1][c], dp[i][j][c] + 1);
                }

                // don't change
                if (i + j + 1 <= n && s[i] == s[n - 1 - j]) {
                    dp[i + 1][j + 1][c] = max(dp[i + 1][j + 1][c], dp[i][j][c] + 2);
                }

                // change
                if (i + j + 1 <= n && c + 1 <= k) {
                    dp[i + 1][j + 1][c + 1] = max(dp[i + 1][j + 1][c + 1], dp[i][j][c] + 2);
                }
            }
        }
    }

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int len[200];

int main()
{
	int n;
	cin >> n;
	n *= 2;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &len[i]);
	}
	sort(len, len + n);
	int sum = 0;
	for (int i = n - 2; i >= 0; i -= 2) {
		sum += len[i];
	}
	cout << sum << '\n';
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    List<int>[] es;

    void calc()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();

        if (A <= 8 && B <= 8) Console.WriteLine("Yay!");
        else Console.WriteLine(":(");
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
#include	<stdio.h>

int main(void)
{
	int	w,h,x,y,r;
	int	enyu,enyd,enxl,enxr;
	int	tyyu,tyyd,tyxl,tyxr;
	
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	

	enyu=y+r;	/*????????????*/
	enyd=y-r;	/*????????????*/
	enxl=x-r;	/*????????????*/
	enxr=x+r;	/*????????????*/

	if(w>=enxr){
		if(enxl>=0){
			if(h>=enyu){
				if(enyd>=0)
				  puts("Yes");
				else
				  puts("No");
			}
			else
			  puts("No");
		}
		else
		  puts("No");
	}
	else
		puts("No");

	return(0);
}

Measured memory_bytes: 1016
package main

import (
	"fmt"
)

var N, K int

func main() {
	fmt.Scan(&N, &K)
	r := 1
	for i := 0; i < N; i++ {
		if r*2 < r+K {
			r *= 2
		} else {
			r += K
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
def su(n):
    if n < 0:
        return 0
    return n*(n+1)//2
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
num = [i for i in range(N+1)]
ans = 0
su_N = su(N)
for i in range(K, N+2):
    min = su(i-1)
    max = su_N - su(N-i)
    ans += max - min + 1
    ans %= MOD
print(ans)

Measured memory_bytes: 16820
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
 
int main(){
  int N, K;cin>>N>>K;
  vi a;
  a.push_back(0);
  for (int i=0;i<N;++i){
    int a_;cin>>a_;a.push_back(a_);
  }
  a.push_back(0);
 
  int left[2][K+1], right[2][K+1];
  memset(left, -1, sizeof(left));
  memset(right, -1, sizeof(right));
 
  left[0][0]=1;
  right[0][0]=1;
  vi l_sum[N+2], r_sum[N+2];
  l_sum[0].push_back(0);r_sum[N+1].push_back(0);
 
  for (int i=0;i<N+1;++i){
    for (int j=0;j<K+1;++j){
      if(left[0][j]==1||(j>=a[i+1]&&left[0][j-a[i+1]]==1)) {
        left[1][j]=1;
        l_sum[i+1].push_back(j);
      }
    }
    for (int j=0;j<K+1;++j) {left[0][j]=left[1][j];}
  }
 
  for (int i=N+1;i>=1;--i){
    for (int j=0;j<K+1;++j){
      if(right[0][j]==1||(j>=a[i-1]&&right[0][j-a[i-1]]==1)) {
        right[1][j]=1;
        r_sum[i-1].push_back(j);
      }
    }
    for (int j=0;j<K+1;++j) {right[0][j]=right[1][j];}
  }
 
  
  int ans=0;
  
 
  for (int i=1;i<N+1;++i){
    int L=l_sum[i-1].size();
    int patience=1;
    for (int l=0;l<L;++l){
      int R=r_sum[i+1].size();
      int x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-r_sum[i+1].begin();
      if (x>R-1) continue;
      if(r_sum[i+1][x]+l_sum[i-1][l]<K) patience=0;
    }
    if(patience==1) ans++;
  }
 
  cout << ans << endl;
  return 0;
}

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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c.at(i).at(j);
        }
        
    }
    
    for (int a1 = 0; a1 <= max(max(c.at(0).at(0), c.at(0).at(1)), c.at(0).at(2)); a1++)
    {
        bool isOk = true;
        
        vector<int> b(3);
        for (int i = 0; i < 3; i++)
        {
            b.at(i) = c.at(0).at(i) - a1;
            if (b.at(i) < 0) {
                isOk = false;
            }
        }

        vector<int> a2(3);
        for (int i = 0; i < 3; i++)
        {
            a2.at(i) = c.at(1).at(i) - b.at(i);
            if (a2.at(i) < 0) {
                isOk = false;
            }
        }
        vector<int> a3(3);
        for (int i = 0; i < 3; i++)
        {
            a3.at(i) = c.at(2).at(i) - b.at(i);
            if (a3.at(i) < 0) {
                isOk = false;
            }
        }
        
        if (!(a2.at(0) == a2.at(1) && a2.at(1) == a2.at(2))) {
            isOk = false;
        }
        if (!(a3.at(0) == a3.at(1) && a3.at(1) == a3.at(2))) {
            isOk = false;
        }
         
        if (!isOk) continue;
        
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="ABC") puts("ARC");
    else puts("ABC");
}


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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________


int32_t main()
{ 
  __
  
  
  int k, x;
  cin >> k >> x;

  cout << max({k + x, k - x, k * x});
  
 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int c[123];

int main(void){
	int a,n,i,r=-INF,d;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a;
		++c[a];
		r = max(r,a);
	}
	for(i=0; i<=r; ++i){
		d = max(i,r-i);
		if(!c[d]){
			cout << "Impossible" << endl;
			return 0;
		}
		--c[d];
	}
	for(i=1; i<r; ++i){
		d = max(i,r-i)+1;
		c[d] = 0;
	}
	for(i=0; i<=r; ++i){
		if(c[i]){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;
	return 0;
}


Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  int N;
  cin >> N;

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

  sort(A.begin(), A.end());
  int sum_a = 0, sum_b = 0;
  while (A.size()) {
    sum_a += A.back();
    A.pop_back();
    if (A.size()) {
      sum_b += A.back();
      A.pop_back();
    }
  }
  cout << sum_a - sum_b << endl;

  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  long long a,b,res;
  cin >> a >> b;
  if((a+b)%2==1){
    cout << "IMPOSSIBLE" << endl;
  } else {
    res=(a+b)/2;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static BufferedReader in;

    public static void solve() throws IOException {
        int n = nextInt();
        Integer[] arr = nextArray(n);

        PriorityQueue<Integer> pq = new PriorityQueue<>();

        int res= 0;
        for(int num : arr){
            if(pq.isEmpty() || pq.peek() >= num)res++;
            pq.add(num);
        }

        System.out.println(res);

    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        solve();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(in.readLine().trim());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(in.readLine().trim());
    }

    static Integer[] nextArray(int n) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        Integer[] tmp = new Integer[n];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Integer.parseInt(st.nextToken());
        }

        return tmp;
    }

}



Measured memory_bytes: 54884
#include<stdio.h>
int main(void) {
    int a,b,x;
    scanf("%d %d",&a,&b);

    if (a<b) {
      while (a != 0){
        x = a;
        a = b%x;
        b = x;
        }
    }
    else {
      while (b != 0) {
        x = b;
        b = a%x;
        a = x;
      }
    }

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

    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.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; }


int main()
{
    int A,B;
    cin >> A >> B;

    if( A+B > 23 ) cout << A+B-24 << endl;
    else cout << A+B << endl;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a,b;
    cin >> a >> b;
    if(a*b<=0){
        cout << "Zero" << endl;
    }
    else if(a>0||(b-a)%2==1){
        cout << "Positive" << endl;
    }
    else{
        cout << "Negative" << endl;
    }
}

Measured memory_bytes: 3604
n=int(input())

v=list(map(int,input().split()))
c=list(map(int,input().split()))

x=0
for i in range(2**n):
    cost=0
    value=0
    for j in range(n):
        if i>>j&1:
            cost+=c[j]
            value+=v[j]
    else:
        if value-cost>x:
            x=value-cost
            


print(x)
         


Measured memory_bytes: 73668
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int p[300010];
int val[2];
bool check(int l,int r)
{
	if(p[l]==l)l++;
	if(p[r]==r)r--;
	if(l>r)return true;
	val[0]=val[1]=0;
	for(int i=l;i<=r;i+=2)
	{
		if(p[i]<l||p[i]>r)return false;
		int x=p[i]>i;
		if(val[x]>p[i])return false;
		val[x]=p[i];
	}
	return true;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	int lst=1;
	for(int i=1;i<=n;i++)
	{
		if((p[i]==i)^(p[i+1]==i+1))
			continue;
		if(!check(lst,i)){
			printf("No\n");
			return 0;
		}
		lst=i+1;
	}
	if(!check(lst,n)){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
    int x=1,y=n;
    for (int i=0; i<m; i++) {
        int a,b;
        cin >> a >> b;
        x = max(x,a);
        y = min(y,b);
    }
    cout << max(y-x+1,0) << endl;
}


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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<int,int>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
ll dp[100009][106];
vector<ll> weights, values;
int n, W;

ll solve(ll w, ll i){
    ll &ret = dp[w][i];
    if(ret != -1) return ret;

    if(i == n) return ret = 0;

    if(w + weights[i] <= W) ret= max(ret, values[i] + solve(w + weights[i], i+1));
    ret = max(ret, solve(w, i+1));

    return ret;

}
int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    clr(dp , -1);

    cin>>n>>W;
    weights = vector<ll> (n);
    values = vector<ll> (n);


    loop(i, n) cin>>weights[i]>>values[i];

    cout<<solve(0, 0);

}



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

using namespace std;


int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++) if (i*m+j*n-2*i*j==k){
            cout<<"Yes";
            return 0;
        }
    cout<<"No";
}


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

signed main(){
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vector<int> l(N);
    REP(i, N) cin >> l[i];
    int ans=LLONG_MAX;
    REP(i,pow(4,N)){
        int bamboo[3]={0,0,0};
        int now=i;
        int res=0;
        REP(j,N){
            int use=now%4;
            now/=4;
            if(use==0) continue;
            res+=10;
            bamboo[use-1]+=l[j];
        }
        if(!bamboo[0]||!bamboo[1]||!bamboo[2]) continue;
        ans = min(ans,res+abs(A-bamboo[0])+abs(B-bamboo[1])+abs(C-bamboo[2])-30);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 200100;
int n, k, p[MAXN];

long long dp[MAXN];

int main() {
	scanf("%d",&n);
	k = 2;
	for (int i = 0; i < n; i++) scanf("%d",&p[i]);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = (1LL << 40);
		for (int j = i - 1; j >= max(0, i - k); j--) {
			dp[i] = min(dp[i], dp[j] + max(p[i] - p[j], p[j] - p[i]));
		}
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

int main(){
    int i,j;
    int H,W;
    
    while(1){
        scanf("%d %d", &H, &W);
        if(H==0 && W==0){
            //printf("\n");
            break;
        }
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        
    }
    
}



Measured memory_bytes: 2024
#include <stdio.h>
int main(){
	int H,W,i,j;
	while(1){
	scanf("%d %d",&H,&W);
	if(H!=0 && W!=0){
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
	}else{
		break;
	}
	printf("\n");
	}
}

Measured memory_bytes: 1000
n = int(input())

if n == 1:
    print(0)
else:
    # 試し割り
    data = []
    t = n
    for i in range(2, int(n**0.5)+1):
        while t % i == 0:
            t //= i
            if i not in data:
                data.append(i)
    # 自身が √n より大きな素数だった場合
    if t % n == 0:
        t //= n
        data.append(n)
    # よくわからない大きな塊が残ったら足すw?
    if t != 1:
        data.append(t)
        t //= t

    # print(data)

    # 処理系
    ans = 0
    for j in range(len(data)):
        for k in range(1, 41):
            p_e = data[j] ** k
            if n % p_e == 0:
                n //= p_e
                ans += 1
            else:
                break

    print(ans)


Measured memory_bytes: 9308
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
const bool DEBUG = false;

signed main() {
	int a[12] = { 1 };
	int b[12] = {};
	rep(i, 1, 12) a[i] = a[i - 1] + pow(3, i);
	rep(i, 0, 12) b[i] = pow(3, i);
	dumpc(a);
	dumpc(b);
	for (int w; cin >> w;) {
		int cnt[12] = {};
		int head;
		rep(i, 0, 12)if (w <= a[i]) {
			w = a[i] - w;
			head = i + 1;
			break;
		}
		dump(w);
		rrep(i, 0, 12) {
			if (b[i] <= w) {
				w -= b[i]; cnt[i]++;
			}
			if (b[i] <= w) {
				w -= b[i]; cnt[i]++;
			}
		}
		dump(w);
		dumpc(cnt);
		rrep(i, 0, head) {
			if (cnt[i] == 0) cout << "+";
			else if (cnt[i] == 1) cout << "0";
			else cout << "-";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3268
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split('/').Select(int.Parse).ToArray();
            
            if(s[0] <= 2019 && s[1] <=04 && s[2] <=30)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }
        }
    }
}


Measured memory_bytes: 13268
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)
    
n, *a = map(int, sys.stdin.read().split())

def main():
    return reduce(gcd, a)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14548
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cmath>

using namespace std;

int main()
{
    string s;
    cin >> s;
    vector<char> v;
    for (char c: s) {
        v.push_back(c);
    }
    sort(v.begin(), v.end());
    char prev = v[0];
    int cnt = 1;
    for (int i=1; i<s.length(); i++) {
        if (prev == v[i]) {
            cnt++;
            prev = v[i];
        }
        else {
            if (cnt % 2 == 1) {
                cout << "No\n";
                return 0;
            }
            else {
                cnt = 1;
                prev = v[i];
            }
        }
    }
    if (cnt % 2 == 1) cout << "No\n";
    else cout << "Yes\n";
    
    return 0;
}

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

int main(){
  int a=0;
  string s, t;
  cin >> s >> t;
  for(int i=0; i<s.size(); i++){
    if( s.at(i)!=t.at(i)){
      a++;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 3916
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] p = new int[n];
		int ans = 0;
		for(int i = 0;i < n;i++){
			p[i] = saori.saori_hayami();
		}
		int min = p[0];
		for(int i  = 0;i < n;i++){
			min = Math.min(min, p[i]);
			if(p[i] <= min){
				ans++;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 24332
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
double startTime;
double getCurrentTime()
{return ((double)clock() - startTime) / CLOCKS_PER_SEC;}
typedef long long int ll;
typedef pair<int,int> ii;
int mod=int(1e9+7);
char arr[1010][1010];
int cnt[1010][1010];
int dp(int m,int n)
{
  if(m<=0||n<=0)return 0;
  if(arr[m-1][n-1]=='#')return 0;
  if(cnt[m][n]!=-1)return cnt[m][n];
  if((m==1&&n==2)||(n==1&&m==2)) return cnt[m][n]=1;
  int ans;
  if(m-1>0&&n-1>0)
  ans=(dp(m-1,n)%mod+dp(m,n-1)%mod)%mod;
  else
  {
    if(m-1>0)
      ans=dp(m-1,n)%mod;
    else
      ans=dp(m,n-1)%mod;
  }

  return cnt[m][n]=ans;
}
int main()
{  
  fast
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
      cin>>arr[i][j]; 
    memset(cnt,-1,sizeof(cnt));
    //startTime = (double)clock();
    cout<<dp(h,w)%mod<<endl;
    //cout<<getCurrentTime()<<endl;

}


Measured memory_bytes: 5376
n = int(input())
a = [None] * 2
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))

dp = [[0] * n for i in range(2)]
dp[0][0] = a[0][0]

for i in range(n):
    if i == 0:
        dp[1][i] = dp[0][i] + a[1][i]
    else:
        dp[0][i] = dp[0][i - 1] + a[0][i]
        dp[1][i] = max(dp[0][i], dp[1][i - 1]) + a[1][i]

print(dp[1][n - 1])

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

void solve()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(n + 1);
    rep(i, m)
    {
        int p;
        cin >> p;
        a[p] = 1;
    }
    int ans = 1e9, tmp = 0;
    for (int i = x; i >= 0; i--)
    {
        if (a[i] == 1)
            tmp++;
    }
    ans = min(ans, tmp);
    tmp = 0;
    for (int i = x; i <= n; i++)
    {
        if (a[i] == 1)
            tmp++;
    }
    ans = min(ans, tmp);
    cout << ans << endl;
}

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

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AtCoder solver = new AtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class AtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int times = in.nextInt();
            int x = 800;
            int discount = 200;

            out.println(x * times - (int) (times / 15) * discount);
        }

    }
}



Measured memory_bytes: 21844