akhauriyash/Code-Regression huggingface dataset:
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;

int main(){
  while(1){
    double n;
    cin>>n;
    if(n==-1.0)break;
    double x=n/2;
    while(1){
      if(abs(x*x*x-n)<0.00001*n)break;
      x=(x-((x*x*x)-n)/(3*x*x));
    }
    printf("%.6lf\n",x);

  }

}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,a,b,c;
char s[N];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++) if(s[i]=='0') b++;
    ll ans=0;
    for(int i=1;i<=n;i++)
        if(s[i]=='0') a++,b--;
        else
        {
            c++;
            if(s[i+1]=='1'){ans+=a+b+1;i++;c++;continue;}
            if(i&1)
                ans+=a/2+1+b;
            else ans+=(a+1)/2+b;
        }
    while(c)
    {
        c--;ans+=(c+1)/2;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3988
#include<stdio.h>
#define N 44

int F[N];

int fibonacci(int n){
  if (n == 0 || n == 1)
    return F[n]=1;
  if(F[n])
    return F[n];
  return F[n]=fibonacci(n - 2) + fibonacci(n - 1);
}

int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
ll ans[100001];
ll d[100001];
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>z;
	for (int i = 0; i < num; i++)
	{
		scanf("%lld", &d[i]);
		z.push_back(make_pair(d[i], i));
	}
	z.push_back(make_pair(0, num));
	sort(z.begin(), z.end());
	reverse(z.begin(), z.end());
	ll mini = num;
	for (int i = 0; i < num; i++)
	{
		mini = min(mini, z[i].second);
		ans[mini] += (ll)(i + 1)*(z[i].first - z[i + 1].first);
	}
	for (int i = 0; i < num; i++)printf("%lld ", ans[i]); printf("\n");
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
  }
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

int main(){

  int n;
  cin >> n;
  int a[n][n];
  rep(i,n){
    rep(j,n){      
      cin >> a[i][j];
    }
  }

  vector<vector<int> > dp(n+1,vector<int>(1LL<<n));
  rep(i,n+1)rep(j,1<<n) dp[i][j]=0;
  dp[0][0]=1;      
  rep1(i,n){
    rep(j,1LL<<n){
      rep(k,n){
	if(__builtin_popcount(j)!=i-1) continue;
	if(a[i-1][k]==1 && ((j&(1LL<<k))==0) ){
	  dp[i][(j|(1LL<<k))]=ad(dp[i-1][j],dp[i][(j|(1LL<<k))]);
	}
      }
    }
  }
  cout << dp[n][(1<<n)-1] << endl;
  
  return 0;

}


Measured memory_bytes: 188800
#include<iostream>

#define LL  long long
using namespace std;

LL N, M;

int main()
{
    cin>>N;
    cin>>M;
    LL sum = 0;
    int a;
    for(int i=0; i<M; i++) {
        scanf("%d", &a);
        sum += a;
    }
    if(sum>N) {
        printf("-1\n");
    }else {
        cout<< N-sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
n, m, x, y = map(int, input().split())
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))

for z in range(-100, 101):
    war = False
    if x < z and z <= y:
        for i in range(n):
            for j in range(m):
                if xn[i] >= z or ym[j] < z:
                    war = True
        if war == False:
            print("No War")
            exit()
print("War")

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

int main(){
  int a, b, c, d, e, f, g, h, i;
  cin >> a >> b >> c >> d >> e;

  if(a > b) f = a, a = b;
  else f = b;

  if(a > c) g = f, f = a, a = c;
  else if(a <= c && c < f) g = f, f = c;
  else g = c;

  if(a > d)  h = g, g = f, f = a, a = d;
  else if(a <= d && d < f) h = g, g = f, f = d;
  else if(f <= d && d < g) h = g, g = d;
  else h = d;

  if(a > e) i = h, h = g, g = f, f = a, a = e;
  else if(a <= e && e < f) i = h, h = g, g = f, f = e;
  else if(f <= e && e < g) i = h, h = g, g = e;
  else if(g <= e && e < h) i = h, h = e;
  else i = e;

  cout << i << " " << h << " " << g << " " << f << " " << a << endl;

  return 0;
}

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

int main(void) {
    long n;
    cin >> n;
    vector<long> a(n), b(n), c(n), d(n+1);
    for(auto &e: a) cin >> e;
    for(auto &e: b) cin >> e;
    for(auto &e: c) cin >> e;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    for(long i=0; i<n; i++) {
        long x = b[i];
        long cnt = c.end() - lower_bound(c.begin(), c.end(), x+1);
        d[i+1] = cnt;
    }
    for(long i=0; i<n; i++)
        d[i+1] += d[i];

    long r = 0;
    for(long i=0; i<n; i++) {
        long x = a[i];
        long j = lower_bound(b.begin(), b.end(), x+1) - b.begin();
        r += d[n] - d[j];
    }
    cout << r << endl;
}


Measured memory_bytes: 3328
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    
    string S;
    cin >> S;
    ll N=S.size();
    ll P = 2019;
    
//    reverse(S.begin(),S.end());
    
    vector<ll> d(N);
    for(ll i=0;i<N;i++){
        d[i] = ctoi(S[N-i-1]);
    }
    
    if(10%P==0){
        ll ans=0;
        for(ll i=0;i<N;i++){
            if(d[i]%P==0){
                ans += N-i;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> s(N+1);
    s[0] = 0;
    
    ll ten=1;
    for(ll i=0; i<N; i++){
        
        s[i+1] = (ten * d[i] + s[i])%P;
//        ten *= 10 % P;
        ten = ten*10% P;
    }
    
    vector<ll> kind(P,0);
    
    for(ll i=0;i<N+1;i++){
        kind[s[i]]++;
    }
    
    
    ll cnt=0;
    for(ll i=0;i<P;i++){
        cnt += ((kind[i]-1)*(kind[i]))/2;
    }

    cout << cnt << endl;
    
    return 0;
}




Measured memory_bytes: 6768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,x,la,pos;
ll ans=0;
int a[200010];
int las[30];
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;++i){
		scanf("%d",&x);
		pos=1;
		while(x){
			if(x&1){la=max(las[pos],la);las[pos]=i;}
			pos++;x>>=1;
		}
		ans+=(ll)(i-la);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashSet<String> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            set.add(sc.next());
        }
        System.out.println(set.size());
    }
}

Measured memory_bytes: 78444
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#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 repl(i, a, b) for(long long i = a; i < b; i++)
#define rrepl(i, a, b) for(long long i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
using pii = pair<int,int>;
using piii = pair<pii,int>;
using pll = pair<long long, long long>;
using plll = pair<pll, long long>;
// #pragma GCC optimize("Ofast")
// #define _GLIBCXX_DEBUG
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
template<class T>inline bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>inline bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void in(void){return;}
template <typename First, typename... Rest> void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
// const int mod = 998244353;
const int INF = 1e9;
const long long INFLL = 1e18;
void iosetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
}
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
    os << p.first << " " << p.second;
    return os;
}
template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
    is >> p.first >> p.second;
    return is;
}
template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
    for(int i = 0; i < (int) v.size(); i++) {
        os << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return os;
}
template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
    for(T &in : v) is >> in;
    return is;
}
template<class T> vector<T> make_vec(size_t a) {return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S, T>& t){return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S, T>& t){return pair<S,T>(s.first-t.first, s.second-t.second);}
template<class S, class T> pair<S,T> operator*(const pair<S,T> &s, const S& t){return pair<S,T>(s.first*t, s.second*t);}
template <typename T> void Exit(T first){cout << first << endl;exit(0); };
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const pii dxy[4] = {pii(1,0), pii(0, 1), pii(-1, 0), pii(0, -1)};

//----------------------- edit from here ---------------------------------

int main(){
    iosetup();
    int T; cin >> T;
    while(T--){
        ll n, m, a, b; cin >>  n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
#define min(x,y) ((x)<(y)?(x):(y))

int n,m;
int c[16],x[20000];

long dp[20001][256];

long rec(int p, int y){ //現在p番目に注目しており、その手前の値はy。x[n]との差の二乗を返す
    if(dp[p][y]>=0) return dp[p][y];
    
    //終条件
    if(p==n) return 0;
    
    long ret=10000000000;
    for(int i=0; i<m; ++i){ //コードブックの値全てに対して再帰をかける
        //次のyの値(丸めが発生することを考慮)
        int ny = y+c[i];
        if(ny<0) ny=0;
        else if(ny>255) ny=255;
        
        //コードブックの選んだ値の中で、二乗和が最小になるよう選ぶ
        ret = min(ret, rec(p+1,ny)+(ny-x[p])*(ny-x[p]));
    }
    
    return dp[p][y]=ret;
}

int main(){
    while(1){
        //input
        scanf(" %d %d", &n, &m);
        if(n==0) break;
        for(int i=0; i<m; ++i) scanf(" %d", &c[i]);
        for(int i=0; i<n; ++i) scanf(" %d", &x[i]);
        //solve
        memset(dp,-1,sizeof(dp));
        //最初はy_0=128
        printf("%ld\n", rec(0,128));
    }
}



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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<vector<int>> dp(n+1,vector<int>(3,0));
    for (int i = 0;i < n;++i) {
        int a,b,c;
        cin >> a >> b >> c;
        dp[i+1][0] = max(dp[i][1],dp[i][2])+a;
        dp[i+1][1] = max(dp[i][0],dp[i][2])+b;
        dp[i+1][2] = max(dp[i][0],dp[i][1])+c;
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> T;

const int MN = 50500; 
const int MD = 1000003;

int n, m;
P g[MN];
int calc(int l, int r) {
    ll res = 1;
    while (l < r) {
        res *= g[l].second; res %= MD;
        l = g[l].first;
    }
    return res;
}
T e[MN];
int solve() {
    if (n % 2) return 0;
    for (int i = 0; i < n-1; i++) {
        g[i] = P(i+2, 1);
    }
    e[0] = T(n-1, P(0, n));
    int ec = 1;
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        if (a > b) swap(a, b); a--;
        if ((b-a) % 2) continue;
        e[ec] = T(b-a, P(a, b));
        ec++;
    }
    sort(e, e+ec);
    for (int i = 0; i < ec; i++) {
        int a, b;
        tie(a, b) = e[i].second;
        g[a+1] = P(b-1, calc(a+1, b-1));
        g[a] = P(b, (calc(a, b) + g[a+1].second) % MD);
    }
    return g[0].second;
}

int main() {
    while (true) {
        scanf("%d %d", &n, &m);
        if (!n) break;
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 2000
s = input()
while True:
    if s[-7:] == 'dreamer':
        s = s[:-7]
    elif s[-6:] == 'eraser':
        s = s[:-6]
    elif s[-5:] == 'dream':
        s = s[:-5]
    elif s[-5:] == 'erase':
        s = s[:-5]
    else:
        print('NO')
        break

    if len(s) == 0:
        print('YES')
        break


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

template <typename T>
void print(T a){
   std::for_each(a.begin(), a.end(), [](auto x){std::cerr << x << " ";});
   std::cerr << std::endl;
}

int main(){
   int N;
   std::cin >> N;
   std::vector<int> A(N);
   for (int i=0; i<N; i++){
      std::cin >> A.at(i);
   }
   int cnt = 0;
   while (std::all_of(A.begin(), A.end(), [](auto x){return (x % 2 == 0);})){
      print(A);
      std::for_each(A.begin(), A.end(), [](auto &x){x = x/2;});
      cnt++;
   }
   std::cout << cnt << std::endl;
}



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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int A[310][310];
int d[310][310];

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

	rep(i, N) rep(j, N) {
		cin >> A[i][j];
		d[i][j] = A[i][j];
	}

	rep(k, N) rep(i, N) rep(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	int ret = 0;
	rep(i, N) rep(j, N) {
		if (d[i][j] < A[i][j]) {
			cout << -1 << endl;
			return 0;
		}
	}

	rep(i, N) rep(j, N) {
		bool plus = true;
		rep(k, N) {
			if (i == k || j == k) continue;
			if (d[i][j] == d[i][k] + d[k][j]) {
				plus = false;
			}
		}
		if (plus) ret += d[i][j];
	}

	ret /= 2;
	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1664
n,m=map(int,input().split())
a=[list(map(int,input().split())) for a in range(n)]
c=[list(map(int,input().split())) for b in range(m)]
dist=0
minnum=0
for indi,i in enumerate(a):
    min=abs(i[0]-c[0][0])+abs(i[1]-c[0][1])
    minnum=0
    for indj,j in enumerate(c):
        dist=0 
        dist+=abs(i[0]-j[0])
        dist+=abs(i[1]-j[1])
        #print("dist={}".format(dist))
        if min>dist:
            min=dist
            minnum=indj
    print(minnum+1)

Measured memory_bytes: 3064
a =[]
N,H,W = map(int, input().split())
for i in range(N):
    a.append(list(map(int, input().split())))

num =0
for i in range(N):
    if a[i][0]>=H:
        if a[i][1] >= W:
            num +=1
print(num)          

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
Int n, T;
Int a, b;

vector<Int> light;
vector<P> heavy;


int main(){
    cin >> n >> T;
    for(Int i = 0;i < n;i++){
        cin >> a >> b;
        if(a == 0)light.push_back(b+1);
        else heavy.push_back(P(a,b));
    }
    sort(light.begin(), light.end());
    sort(heavy.begin(), heavy.end(),
              [](P p, P q) {
                  Int ap = p.first, bp = p.second;
                  Int aq = q.first, bq = q.second;
                  ap++,bp++,aq++,bq++;
        return aq*bp+bq < ap*bq+bp;   
    });

    vector<Int> dp(33, LINF);
    dp[0] = 0;
    for(auto p: heavy){
        Int a = p.first, b= p.second;
        for(Int i = 32;i > 0;i--){
            if(dp[i-1] > T)continue;
            dp[i] = min(dp[i], (dp[i-1] + 1) * (a + 1) + b);
        }
    }

    Int l_cnt =0, l_sum= 0;
    Int ans = 0;
    for(Int i = 32;i >= 0;i--){
        if(T < dp[i])continue;
        Int rest = T - dp[i];
        while(l_cnt < light.size() && l_sum + light[l_cnt] <= rest){
            l_sum += light[l_cnt];
            l_cnt++;
        }
        ans = max(ans, i + l_cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll n;
ll a[114514];
ll memo[114514];
signed main() {
	ll inf = 1e9 + 7;
	cin >> n;
	rep(i, n)cin >> a[i];
	ll ans = 0;
	rep(i, n)inf = min(abs(a[i] - 0), inf);
	rep(i, n) {
		if (a[i] < 0)memo[i] = 1;
		else if (a[i] == 0)memo[i] = 2;
		else memo[i] = 0;
	}
	ll p = 0;
	rep(i, n) {
		if (memo[i] == 1)ans++;
		if (memo[i] == 2)p++;
	}
	ll b = 0;
	rep(i, n) {
		b += abs(a[i] - 0);
	}
	if (p == 0 && ans % 2 == 1)cout << b - inf * 2 << endl;
	else cout << b << endl;
	ggr
}




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

using namespace std;

bool f[26];
vector<string> ans;
string str;
void dfs(int pos) {
	if ( pos >= str.size() ) {
		ans.push_back(str);
	}
	else {
		char c = str[pos];
		int cid = (int)(c-'a');
		if (f[(cid+25)%26]) {
			dfs(pos+1);
		}
		if (!f[cid]) {
			++str[pos];
			f[cid] = true;
			dfs(pos+1);
			f[cid] = false;
			--str[pos];
		}
	}
}
int main() {
	while (cin >> str, str != "#") {
		ans.clear();
		fill(&f[0], &f[0]+26, false); f[25] = true;
		dfs(0);
		cout << ans.size() << endl;
		if (ans.size() <= 10) {
			for (int i = 0; i < ans.size(); ++i) cout << ans[i] << endl;
		}
		else {
			for (int i = 0; i < 5; ++i) cout << ans[i] << endl;
			for (int i = ans.size()-5; i < ans.size(); ++i) cout << ans[i] << endl;
		}
	}
}

Measured memory_bytes: 2344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,a[N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	ll ans=1e16,cnt=0;
	for (int i=1,s=0;i<=n;i++){
		s+=a[i];
		if ((i&1)&&s<1) cnt+=1-s,s=1;
		if (!(i&1)&&s>-1) cnt+=s+1,s=-1;
	}
	ans=min(ans,cnt);
	cnt=0;
	for (int i=1,s=0;i<=n;i++){
		s+=a[i];
		if ((i&1)&&s>-1) cnt+=s+1,s=-1;
		if (!(i&1)&&s<1) cnt+=1-s,s=1;
	}
	ans=min(ans,cnt);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

fill table (c : cs) = do
  point <- VUM.read table c
  VUM.write table c (point + 1)
  when (cs /= []) $ fill table cs

fillVector table (a : as) n = do
  point <- VUM.read table a
  if point == 0 || point == 1
    then do
      if point == 1
        then do
          VUM.write table a 2
        else do
          let diva = n `div` a
          let cs = map (\x -> x * a) [1 .. diva]
          fill table cs
      when (as /= []) $ fillVector table as n
    else do
      when (as /= []) $ fillVector table as n

seek table (a : as) xs = do
  point <- VUM.read table a
  let xs' = if point == 1 then a : xs else xs
  if as == []
    then return xs'
    else seek table as xs'

main = do
  n <- getInt
  as <- getIntList
  let m = maximum as
  table <- VUM.replicate (m + 1) 0 :: IO (VUM.IOVector Int)
  fillVector table as m
  rs <- seek table as []
  print $ length rs


Measured memory_bytes: 35856
n = int(input())
C = [int(input()) for i in range(n)]
nc = 2 * 10 ** 5 + 3
mod = 10**9+7

A = [0] * n
B = [-1] * nc

A[-1] = 1
B[C[-1]] = n-1
# print(B)

for i in range(n-2, -1, -1):
    if B[C[i]] != -1 and B[C[i]] != i+1:
        A[i] = (A[i+1] + A[B[C[i]]]) % mod
    else:
        A[i] = A[i+1]
    B[C[i]] = i
    # print(A,B)

# print(A)
# print(B)
print(A[0])

Measured memory_bytes: 60940
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 15:37:51 2020

@author: naoki
"""
import sys

X,Y = map(int, input().split()) # input values of X and Y 
i = 0 
if Y % 2 == 1 or Y > 4*X or Y < 2 * X:
    print("No") # it is impossible if the number of legs is not even or is over 4X or fewer 4Y.
    sys.exit()
else:
    while 4*i <= Y and i<= X:
        if 4*i + 2*(X-i) == Y:
            print("Yes")
            sys.exit()
        else:
            i+=1
print("No")

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    char a,b,c;
    int x=0;
    cin>>a>>b>>c;
    if (a=='1')x++;
    if (b=='1')x++;
    if (c=='1')x++;
    cout<<x;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn lower_bound<F>(l: usize, r: usize, criterion: F) -> usize
where
    F: Fn(usize) -> bool,
{
    let mut l = l;
    let mut r = r;
    while r - l > 1 {
        let mid = l + (r - l) / 2;
        if criterion(mid) {
            r = mid;
        } else {
            l = mid;
        }
    }
    l
}

fn solve() {
    let n = get!(usize);
    let mut l = get!([usize]);

    l.sort();
    let mut count: usize = 0;
    for i in 0..n {
        for j in i+1..n {
            let a = l[i];
            let b = l[j];
            let k = lower_bound(j,n,|index| {
                a+b <= l[index]
            });
            count += k-j;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 8572
#include <iostream>

using namespace std;

int
main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    for (int i = 3; i <= n; ++i) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (x) {
                if (x % 10 == 3) { cout << " " << i; break; }
                x /= 10;
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100010
struct edge {
    int to, color; long long dist;
};

vector<edge> v[MAXN];
map<int, pair<int, long long>> m[MAXN];
int parent[20][MAXN];
int height[MAXN];
int colorcnt[MAXN];
long long colordist[MAXN];

void dfs(int curr, int prev) {
    parent[0][curr] = prev;
    height[curr] = height[prev]+1;
    for (auto &e: v[curr]) {
        if (e.to == prev) continue;
        m[e.to][0] = {0, m[curr][0].second + e.dist};
        dfs(e.to, curr);
    }
}

void dfs2(int curr, int prev) {
    for (auto &it: m[curr]) {
        if (it.first == 0) continue;
        m[curr][it.first] = {colorcnt[it.first], colordist[it.first]};
    }
    for (auto &e: v[curr]) {
        if (e.to == prev) continue;
        colorcnt[e.color]++;
        colordist[e.color] += e.dist;
        dfs2(e.to, curr);
        colorcnt[e.color]--;
        colordist[e.color] -= e.dist;
    } 
}

void doubling() {
    for (int k = 0; k < 19; k++) {
        for (int i = 0; i < MAXN; i++) {
            parent[k+1][i] = parent[k][parent[k][i]];
        }
    }
}

int get(int u, int v) {
    if (height[u] > height[v]) swap(u, v);
    int t = height[v] - height[u];
    for (int i = 0; i < 20; i++) {
        if (t & (1 << i)) {
            v = parent[i][v];
        }
    }
    if (u == v) return u;
    for (int i = 19; i >= 0; i--) {
        if (parent[i][u] != parent[i][v]) {
            u = parent[i][u]; v = parent[i][v];
        }
    }
    return parent[0][u];
}

int main() {
    int n, q; cin >> n >> q;
    for (int i = 0; i < n-1; i++) {
        int a, b, c; long long d;
        cin >> a >> b >> c >> d;
        v[a].push_back({b, c, d});
        v[b].push_back({a, c, d});
    }
    dfs(1, 0); doubling();
    vector<int> xq(q), yq(q), uq(q), vq(q);
    for (int qi = 0; qi < q; qi++) {
        int x, y, u, v; cin >> x >> y >> u >> v;
        xq[qi] = x, yq[qi] = y, uq[qi] = u, vq[qi] = v;
        int w = get(u, v);
        m[u][x] = {0, 0}, m[v][x] = {0, 0}, m[w][x] = {0, 0}; 
    }
    dfs2(1, 0);
    for (int qi = 0; qi < q; qi++) {
        int x, y, u, v;
        x = xq[qi], y = yq[qi], u = uq[qi], v = vq[qi];
        int w = get(u, v);
        long long d = m[u][0].second + m[v][0].second - m[w][0].second * 2;
        long long cnt = m[u][x].first + m[v][x].first - m[w][x].first * 2;
        long long sub = m[u][x].second + m[v][x].second - m[w][x].second * 2;
        d += cnt * y - sub;
        cout << d << endl;
    }
    return 0;
}

Measured memory_bytes: 49536
N = int(input())

dpa,dpb,dpc = 0,0,0
for n in range(N):
  a,b,c = map(int, input().split())  
  dpa,dpb,dpc = max(dpb+a,dpc+a),max(dpa+b,dpc+b),max(dpa+c,dpb+c)
  
ans = max(dpa,dpb,dpc)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
#define N 1000015
const int p=1e9+7;
int n,m,dp[3002][3002],mx[N],s[N];
char ch[N];
inline int ksm(int d,int tk){int ret=1;while(tk){if(tk&1)ret=1ll*ret*d%p;d=1ll*d*d%p;tk>>=1;}return ret;}
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",ch+1);
    for(int i=1;i<=n;i++)s[i]=s[i-1]+ch[i]-'0',mx[i]=i;s[n+1]=s[n];
    for(int i=1;i<=m;i++)
    {
    	int l,r;scanf("%d%d",&l,&r);
    	mx[l]=max(mx[l],r);
	}
	for(int i=1;i<=n;i++)mx[i]=max(mx[i],mx[i-1]);mx[n+1]=mx[n];
	dp[0][s[mx[1]]]=1;
	for(int i=0;i<n;i++)for(int j=0;j<=n;j++)
	{
		if(j)(dp[i+1][j+s[mx[i+2]]-s[mx[i+1]]-1]+=dp[i][j])%=p;
		if(mx[i+1]-i-j>0)(dp[i+1][j+s[mx[i+2]]-s[mx[i+1]]]+=dp[i][j])%=p;
	}
	printf("%d\n",dp[n][0]);
}


Measured memory_bytes: 38144
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
H,W=map(int, input().split())
S,T=map(int, input().split())

print(H*W - W*S - (H-S)*T)

Measured memory_bytes: 72836
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    while(true){
        string s;
        cin >> s;
        if(s == "0") break;
        int sum = 0;
        for(int i=0; i<s.size(); i++){
            int s_i = s[i] - '0';
            sum += s_i;
        }
        cout << sum << endl;
    }

    /*
    while(true){
        ll x;
        cin >> x;
        if(x == 0) break;
        ll sum = 0;
        while(true){
            ll x_1 = x % 10;
            if(x_1 == 0 && x == 0) break;
            else sum += x_1;
            x /= 10;
        }
        cout << sum << endl;
    }
    */
}


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

int main()
{
	bool edge[4][4]{};
	for (int i = 0; i < 3; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a][b] = edge[b][a] = true;
	}
	int arr[4] = {0, 1, 2, 3};
	do
	{
		bool f = true;
		for (int i = 0; i < 3; i++)
		{
			f &= edge[arr[i]][arr[i + 1]];
		}
		if (f)
		{
			cout << "YES" << endl;
			return 0;
		}
	} while (next_permutation(arr, arr + 4));
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  n/=200;
  cout <<10-n<<'\n';

  
  return(0);
}

Measured memory_bytes: 3644
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#m = int(input())
#h1, m1, h2, m2, k = map(int, sys.stdin.readline().split())
t = input()
#a = list(map(int, sys.stdin.readline().split()))


for i in range(len(t)):
    if t[i] == "?":
        print("D", end="")
    else:
        print(t[i], end="")
        


Measured memory_bytes: 9592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	cin >> n;
	
	string s;
	cin >> s;
	
	long ans = 0;
	long x = 0;
	long y = 0;
	for(long long i = 0; i < n; i++)
	{
		if(s[i] == 'W')
		{
			x++;
		}
		else
		{
			y++;
		}
	}
	
	long d = 0;
	for(long long i = 0; i < n; i++)
	{
		if(s[i] == 'E')
		{
			y--;
		}
		
		long tmp = d + y;
		
		if(s[i] == 'W')
		{
			d++;
		}
		
		if(i == 0)
		{
			ans = tmp;
		}
		
		if(ans > tmp)
		{
			ans = tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 900
#include <iostream>

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}

Measured memory_bytes: 3012
#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> ;
const int INF = 1e9;
const int MOD = 1000000007;

int tax(int p,int q){
    return (p*(100+q))/100;
}

int main(){
    while(1){
        int x,y,s,mx = 0;
        cin >> x >> y >> s;
        if(x==0 && y==0 && s==0) break;
        for(int i=1;i<s;i++){
            for(int j=1;j<s;j++){
                if(tax(i,x) + tax(j,x) == s){
                    mx = max(mx,tax(i,y) + tax(j,y));
                }
            }
        }
        cout << mx << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
int n,i,sum=0;
bool prime(int x)
{
	int i,k=(int)sqrt(x);
	for (i=2;i<=k;i++)
		if (x%i==0) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for (i=11;i<=55555;i+=10)
		if (prime(i))
		{
			printf("%d ",i);
			sum++;
			if (sum==n) break;
		}
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>s;
	cout<<"ABC"<<s<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

class Atcoder
{
    static void Main(string[] args)
    {
        string mae = "";
        string usiro = "";
        int are = 0;
        string a = Console.ReadLine();
        int b = a.Length;
        int count = 0;
        for(int c=0;b/2 > c; c++)
            {
            are = a.Length-1 - c;
            mae = a[c].ToString();
            usiro = a[are].ToString();
            if (mae ==usiro)
            {

            }
                else
                {
                    count++;
                }
            }
        Console.WriteLine(count);
        
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define LLI long long int
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int s,w;

    scanf("%d %d", &s, &w);
    if( w >= s)
        printf("unsafe\n");
    else
        printf("safe\n");


    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3764
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    String s = stdIn.next();
    int k = stdIn.nextInt();

    char[] answer = new char[n];
    char x = s.charAt(k-1);

    for(int i=0; i<n; i++) {
      char a = s.charAt(i);
      if(a == x) {
        answer[i] = a;
      }else {
        answer[i] = '*';
      }
    }

    System.out.println(answer);
  }
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

set<string> st;

void f(string s , string & t , int k){
	bool ck = 1;
	rep(i , sz(t)){
		if(i + k>= sz(s)){
			ck = 0;
			break;
		}
		if(s[i + k] != '?' && s[i + k] != t[i]){
			ck = 0;
			break;
		}
		s[i + k] = t[i];
	}
	if(ck){
		rep(i , sz(s)){
			if(s[i] == '?')s[i] = 'a';
		}
		st.insert(s);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	string s , t;
	cin >> s >> t;
	
	rep(i , sz(s)){
		f(s , t , i);
	}
	if(sz(st) == 0)st.insert("UNRESTORABLE");
	cout << (*st.begin());

	return 0;
}

Measured memory_bytes: 256
// C - Grand Garden
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vi H(N);
	rp(i, N) cin>>H[i];

	int ans = 0, pre = 0;
	rp(i, N){
		int now = H[i];
		ans += now - min(pre, now);
		pre = now;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
N = int(input())
Ss = list(input())
if em: sys.stdin = open('/dev/tty')
ans = []
for S in Ss:
  if ans == []:
    ans.append(S)
  elif ans[-1] == S or S == '\n':
    continue
  else:
    ans.append(S)
print(len(ans))


Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IL inline
#define RG register
#define gi geti<int>()
#define gl geti<ll>()
#define gc getchar()
#define File(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
template<typename T>IL bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
template<typename T>IL bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>
IL T geti()
{
	T xi=0;
	char ch=gc;
	bool f=0;
	while(!isdigit(ch))ch=='-'?f=1:f,ch=gc;
	while(isdigit(ch))xi=xi*10+ch-48,ch=gc;
	return f?-xi:xi;
}
template<typename T>
IL void pi(T k,char ch=0)
{
	if(k<0)k=-k,putchar('-');
	if(k>=10)pi(k/10);
	putchar(k%10+'0');
	if(ch)putchar(ch);
}
/*
IL unsigned int LOG2(unsigned int x)
{
	unsigned int ret;
	__asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));
	return ret;
}
*/
const int N=2e3+7;
int a[N],n,sum;
bitset<N*N>t,w;
int main(void)
{
	n=gi;
	for(int i=1;i<=n;++i)a[i]=gi;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i){
		sum+=a[i];
		t|=t<<a[i];
		t[a[i]]=1;
	}
	int s=t.count()/2;
	for(int i=sum;i;--i)
	{
		if(t[i])
		{
			if(!s){pi(i);break;}
			--s;
		}
	}
	return 0;
}


Measured memory_bytes: 2304
N = int(input())
A = list(map(str, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)
C_index = [str(i)+str(i+1) for i in range(1,N)]
A_index = [A[i]+A[i+1] for i in range(0,N-1)]
C_dict = dict(zip(C_index,C))
for i in A_index:
    if i in C_index:
        ans += C_dict[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int N, K; cin >> N >> K;
    int rst = 0;
    while (N) {
        N /= K;
        rst++;
    }
    cout << rst;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(n) cout<<a[i]<<endl printf("%s\n"," " );
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int v[5],mi=inf;
    rep(5) cin>>v[i];
 	int ans = -1;
    rep(5)
    {
    	if(v[i]%10<mi && v[i]%10)
    	{
	    	ans = i;
	 		mi = min({v[i]%10,mi});
    	}
    }
    int ans2=0;
    rep(5)
    {
    	if(ans!=i)
    	{
    		ans2+=v[i]+(10-v[i]%10)%10;
    	}
    }
    if(ans!=-1)
    cout<<v[ans]+ans2<<endl;
	else
		cout<<ans2<<endl;
    return 0;

}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
	int N, K; 
	cin >> N >> K; 
	string S; 
	cin >> S; 
	vector<int> L = {}; 
	vector<int> R = {}; 
	R.push_back(0);
	for(int i = 0; i < N; i++){
		if((i == 0 && S.at(i) == '0') || (i != 0 && (S.at(i-1) == '1' && S.at(i) == '0'))) 
			L.push_back(i+1); 
		if((i == N - 1 && S.at(i) == '0') || (i != N- 1 && (S.at(i) == '0' && S.at(i+1) == '1')))
			R.push_back(i+1);  
	}
	L.push_back(N+1); 
	int ans = 0; 
	int M = L.size(); 
	if(K >= M - 1) ans = N; 
	else{
		for(int i = 0; i < M - K; i++){
			ans = max(ans, L[i+K] - R[i] - 1); 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 1020
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>ko[100000];
int ans=0;
int gen;
int dfs(int node,int p)
{
	int maxi=0;
	for(int i=0;i<ko[node].size();i++)
	{
		maxi=max(maxi,dfs(ko[node][i],node));
	}
	if(maxi+1==gen)
	{
		if(p!=0)ans++;
		return 0;
	}
	else return maxi+1;
}
int main()
{
	int num;
	scanf("%d%d",&num,&gen);
	for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		z--;
		if(i==0)
		{
			if(z!=0)ans++;
		}
		else ko[z].push_back(i);
	}
	dfs(0,0);
	printf("%d\n",ans);
}

Measured memory_bytes: 11904
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		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 || a*b>c*d){
			System.out.println(a*b);
		}else{
			System.out.println(c*d);
		}
		sc.close();
	}
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using piii = pair<int, pii>;
using plll = pair<ll, pll>;
using pib = pair<int, bool>;
using pdi = pair<double, int>;
using pid = pair<int, double>;
using ld = long double;
using piiii = pair<pii, pii>;

#define endl "\n"
#define inf 0x3f3f3f3f3f
#define f first
#define s second

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MOD = 1e9+7;

int h, w, n, a, b;
ll fac[200001], inv[200001], dp[200001];
vector<pii> arr;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    fac[0] = 1;
    inv[0] = 1;
    for (int i=1; i<=2e5; i++){
        fac[i] = (i*fac[i-1])%MOD;
        inv[i] = fpow(fac[i], MOD-2, MOD);
    }
    cin >> h >> w >> n;
    for (int i=0; i<n; i++){
        cin >> a >> b;
        arr.push_back({a, b});
    }
    arr.push_back({h, w});
    sort(arr.begin(), arr.end());
    for (int i=0; i<=n; i++){
        dp[i] = ((fac[arr[i].f+arr[i].s-2]*inv[arr[i].f-1])%MOD*inv[arr[i].s-1])%MOD;
        for (int j=0; j<i; j++){
            if (arr[i].f>=arr[j].f&&arr[i].s>=arr[j].s){
                dp[i] = (dp[i]-(dp[j]*((fac[arr[i].f-arr[j].f+arr[i].s-arr[j].s]*inv[arr[i].f-arr[j].f])%MOD*inv[arr[i].s-arr[j].s]%MOD)%MOD)%MOD+MOD)%MOD;
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a > b) {
    ans += a;
    ans += max(a-1, b);
  } else {
    ans += b;
    ans += max(b-1, a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384