akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
const int MOD=1e9+7;

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<string>a(n);
    vector<vector<int>>dp(n,vector<int>(m));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int row = 0; row < n; ++row) {
        for(int col = 0; col < m; ++col) {
            for(int r2 : {row, row + 1}) {
                int c2 = col;
                if(r2 == row) {
                    c2 = col + 1;
                }
                if(r2 < n && c2 < m && a[r2][c2] == '.') {
                    add_self(dp[r2][c2], dp[row][col]);
                }
            }
        }
    }
    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 5248
N = list(map(int,input().split()))
Ai = list(map(int,input().split()))
if N[0]%2 != 0:
    Ai.append(0)
Ai.sort(reverse = True)
Alice = 0
Bob = 0
for i in range(len(Ai)//2):
    Alice += Ai[2*i +1]
    Bob += Ai[2*i]
print(Bob - Alice)


Measured memory_bytes: 3060
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
        int H,N,t,i=0;
        int *A;

        cin >> H >> N;
        A = (int *)malloc(sizeof(int)*N);
        while(cin >> t){
                A[i] = t;
                i++;
                if(i>=N){
                        break;
                }
        }
        for(i=0;i<N;i++){
                H -= A[i];
        }
        if(H<=0){
                cout << "Yes" << endl;
        }else{
                cout << "No" << endl;
        }

        return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
#include <iterator>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i, a, cont, next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i, a, b, step) repfn(i, a, i < b, i + step)
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  int d;
  while (cin >> d) {
    int total=0;
    repby (i, d, 600, d) {
      total += i*i*d;
    }
    cout << total << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        string a,b;
        cin >> a >> b;
        int ans=0;
        for(int i=0; i<a.size(); i++){
            if(a[i]==b[i])ans++;
        }
        cout << ans;
        
        

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		System.out.println((C+B-1)/B <=(A+D-1)/D ? "Yes" : "No");

		sc.close();
	}
}


Measured memory_bytes: 27076
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

vector<int> sieve_of_eratosthenes(int n = 200010) {
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  for (int i = 0; i <= n; ++i) if (is_prime[i]) {
    for (int j = i+i; j <= n; j+=i) is_prime[j] = false;
  }
  vector<int> primes;
  for (int i = 2; i <= n; ++i) if (is_prime[i]) primes.push_back(i);
  return primes;
}

int main() {
  int n; cin>>n;
  auto primes = sieve_of_eratosthenes(55555);
  vector<int> ans;
  for (int i = 0; ans.size() != n; ++i) {
    if (primes[i] % 5 == 1) ans.emplace_back(primes[i]);
  }
  rep(i, n) cout<<ans[i]<<' ';
  cout<<endl;

  return 0;
}

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

void dfs(vector<vector<pair<int,int>>> &path, vector<int> &color, int now){
    int c = color.at(now);
    for(int i=0; i<path.at(now).size(); i++){
        pair<int,int> p = path.at(now).at(i);
        int next,dist;
        next = p.first;
        dist = p.second;
        if(color.at(next) != -1) continue;
        if(dist%2==0) color.at(next) = c;
        else color.at(next) = 1-c;
        dfs(path, color, next);
    }
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> path(n);
    for(int i=0; i<n-1; i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        pair<int,int> p;
        p=make_pair(v,w);
        path.at(u).push_back(p);
        p=make_pair(u,w);
        path.at(v).push_back(p);
    }
    vector<int> color(n,-1);
    color.at(0) = 0;
    dfs(path, color,0);
    for(int i=0; i<n; i++){
        cout << color.at(i) << endl;
    }
}


Measured memory_bytes: 12348
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2;
			return 0;
		} 
	}
	if(s.size()>=3){
		for(int i=0;i<s.size()-2;i++){
			if(s[i]==s[i+2]){
				cout<<i+1<<" "<<i+3;
				return 0;
			}
		}
	}
	cout<<-1<<" "<<-1;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int main(){
    int n;
    cin >> n;
    cout << (n == 0 ? 1 : 0) << endl;
}

Measured memory_bytes: 3616
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Integer>[] edges;
	public static long[] fac,inv;
	public static int mod = (int) (1e9+7),MAX = (int) (1e5+1);
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int a = (2 * x - y) / 3;
		int b =  (2 * y - x) / 3;
		if((x+y) % 3 != 0 || a < 0 || b < 0)
			System.out.println(0);
		else{
			long[] mm = new long[1000005];
			long[] nn = new long[1000005];
			
			mm[0] = 1;
			for(int i=1;i<mm.length;i++){
				mm[i] = mm[i-1] * i % mod;
			}
 
			nn[0] = 1;
			nn[1] = 1;
			for(int i=2;i<nn.length;i++){
				nn[i] = nn[i-1] * pow(i, mod-2) % mod;
			}
			
			out.println(mm[a+b] * nn[a] % mod * nn[b] % mod);
			out.close();
		}
	}
	static long pow(int a, int k){
		
		if(k == 0)
			return 1;
		
		long num = pow(a, k/2);
		if(k % 2 != 0)
			return a * num % mod * num % mod;
		else
			return num * num % mod;
	}
}
	

Measured memory_bytes: 38356
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in a:
    ans^=i
k=~ans
for i in range(n):
    a[i]&=k
rank=0
# 掃き出し法
for i in range(59,-1,-1):
    for j in range(rank,n):
        if a[j]>>i&1:
            break
    if j==n:
        continue
    if j>rank:
        # a[rank]のi番目のbitを1にするswapでもいい
        a[rank]^=a[j]
    for j in range(rank+1,n):
        a[j]=min(a[j],a[j]^a[rank])
    rank+=1
res=0
for i in a:
    res=max(res,res^i)
print(ans+2*res)

Measured memory_bytes: 76960
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;
const int maxn=1e5+5;
int a[maxn];
ll b[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    b[0]=a[0];
    for(int i=1;i<n;i++)
    {
        b[i]=b[i-1]+a[i];
    }
    int cnt=1;
    for(int i=n-2;i>=0;i--)
    {
        if(b[i]*2>=a[i+1])
            cnt++;
        else
            break;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;

ll ta[3][3];

int main(){
    rep(i, 3) rep(j, 3) cin >> ta[i][j];
    rep(i, 101){
        rep(j, 101){
            rep(k, 101){
                ll cnt = 0;
                rep(ii, 3){
                    if(ta[ii][0]-i == ta[ii][1]-j && ta[ii][2]-k == ta[ii][1]-j){
                        cnt++;
                    }
                }
                if(cnt == 3){
                    cout << "Yes" << endl;
                        return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}


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

using namespace std;

namespace {

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    int N, M;
    vector< pair<int, int> > P;
    void input() {
        cin >> N >> M;
        P.resize(M);
        for (int i = 0; i < M; i++) {
            cin >> P[i].first >> P[i].second;
        }
    }

    void solve() {
        if (M == 0) {
            cout << N + 1 << endl;
            return;
        }
        sort(P.begin(), P.end());
        int ans = N + 1;
        int l = P[0].first, r = P[0].second;
        int k = 1;
        while (true) {
            int a = P[k].first, b = P[k].second;
            if (l <= b && a <= r) {
                l = min(l, a);
                r = max(r, b);
                k++;
            } else {
                ans += 2 * (r - l);
                l = a; 
                r = b;
                k++;
            }
            if (k == M) {
                ans += 2 * (r - l);
                break;
            }
        }
        cout << ans << endl;
    }
}

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

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

 bool palin(string s)
{
  if(s.length()==1 || s.length()==0)
   return true;

  for(int i=0,j=s.length()-1;i<=j;i++,j--)
   if(s[i]!=s[j])
   return false;

  return true;
}

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

  int n=s.length();

   if(palin(s) && palin(s.substr(0,(n-1)/2)) && palin(s.substr(((n+3)/2)-1)))
   cout<<"Yes";

  else
   cout<<"No";
return 0;
}


Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/23 14:21:31 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	double	w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << w * h / 2.0 << " " << (w / 2.0 == x && h / 2.0 == y) << endl;
}
// END

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


Measured memory_bytes: 256
N,Y=map(int,input().split())
f=Y//10000
for x in range(f+1):
    for y in range(N+1):
        z=N-x-y
        k=10000*x+5000*y+1000*z
        if k==Y and x+y+z==N and z>=0:
            print(x,y,z)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 40812
#include <stdio.h>
int main(void){
    int N = 0; int T = 0;
    scanf("%ld %ld", &N, &T);
    int t[200000] = {0};
    for(int i = 0; i < N; i++){
        scanf("%ld", &t[i]);
    }
    int total = 0;
    for(int i = 1; i < N; i++){
        int lag = 0;
        lag = t[i] - t[i-1];
        if(lag >= T){
            total += T;
        }else {
            total += lag;
        }
    }
    printf("%d\n", total + T);
    return 0;
}

Measured memory_bytes: 896
def gcd(a, b):
    while b > 0:
        c = a % b
        a = b
        b = c
    return a


def lcm(a, b):
    return (a * b) // gcd(a, b)


def main():
    N = int(input())
    T = []
    for _ in range(N):
        T.append(int(input()))
    t = T[0]
    for i in range(1, N):
        t = lcm(max(t, T[i]), min(t, T[i]))
    print(t)


main()


Measured memory_bytes: 3064
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef struct T {
    int v;
    int w;
    char t;
    ll d;
    string n;
} TT;
bool cmp(TT a, TT b) {
    if (a.v==b.v) {
        if (a.w==b.w) {
            if (a.t==b.t) {
                if (a.d==b.d) {
                    return a.n < b.n;
                }
                return a.d < b.d;
            }
            return a.t < b.t;
        }
        return a.w < b.w;
    }
    return a.v < b.v;
}
int main() {
    int n;
    cin >> n;
    vector<TT> tu(n);
    for (int i = 0; i < n; i++) {
        TT te;
        cin >> te.v >> te.w >> te.t >> te.d >> te.n;
        tu[i] = te;
    }
    sort(tu.begin(), tu.end(), cmp);
    for (auto i : tu) {
        cout << i.v << " " << i.w << " "<< i.t << " "<< i.d << " "<< i.n<< endl;
    }
    return 0;
}


Measured memory_bytes: 12116
def p(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
n=int(input())
a=p(n)
d={}
for i in a:
  d[i]=d.get(i,0)+1
b=list(d.values())
ans=0
d=[0]*50
for i in range(1,50):
    d[i]=d[i-1]+i
for i in b:
    c=sum(j<=i for j in d)-1
    ans+=c    
print(ans)

Measured memory_bytes: 9252
#include<iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX], color[MAX];

  for(int i = 0; i < n; i++){ //??????????????????????????????
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  
  while(1){

    minv = INFTY;
    int u = -1;
    
    for(int i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }

    if(u == -1)break;

    color[u] = BLACK;

    for(int v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u]+M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }      
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}

int main(){
  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;

  for(int i = 0; i < n; i++){
    cin >> u >> k; 
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;

}

Measured memory_bytes: 3100
object Main{
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a, b = sc.nextInt

    val total = (1 to n).map { i =>
      var d = i
      var sumOfDigits = 0
      while (d > 0) {
        sumOfDigits += d % 10
        d /= 10
      }
      if (a <= sumOfDigits && sumOfDigits <= b) i
      else 0
    }.foldLeft(0){ (acc, x) => acc + x }

    println(total)
  }
}

Measured memory_bytes: 26052
#include <stdio.h>
#include <limits.h>

int main(void){
    long long a,b,k;
    scanf("%llu",&a);
    scanf("%llu",&b);
    scanf("%llu",&k);

    if(a < k){
        k = k - a;
        if(b < k){
            printf("0 0");
        }else{
            b = b - k;
            printf("0 %llu",b);
        }
    }else{
        a = a - k;
        printf("%llu %llu",a,b);
    }

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
using namespace std;

inline int jud(int x){
	int tmp=pow(2,ceil(log2(x)))-x;//ceil(x)はx以上の最小の整数.
	if(tmp==0) return x;
	else return tmp;
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);//mmm.
	REP(i,n) cin>>a[i];
	sort(ALL(a));
	
	int cnt=0;
	while(a.size()>1){
		int want=jud(*(a.end()-1));
		auto itr=lower_bound(ALL(a),want);//二分探索.
		if(a.begin()<=itr&&itr<a.end()-1&&*(itr)==want){
			cnt++;
			a.erase(itr);
		}
		a.erase(a.end()-1);
	}
	
	cout<<cnt<<endl;
}//解説参考.

Measured memory_bytes: 1024
#include <iostream>
#define LINF (1LL << 60)
using namespace std;
typedef long long Int;

Int n, a[110000], b[110000], c[110000];
Int dp[110000][3];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for (int i = 0; i < n; i++) {
    dp[i + 1][0] = max(dp[i][1] + a[i + 1], dp[i][2] + a[i + 1]);
    dp[i + 1][1] = max(dp[i][0] + b[i + 1], dp[i][2] + b[i + 1]);
    dp[i + 1][2] = max(dp[i][0] + c[i + 1], dp[i][1] + c[i + 1]);
  }
  Int ans = 0;
  for (int i = 0; i < 3; i++) ans = max(ans, dp[n - 1][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8296
import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    a[i] = a[i]-1


if k<=n:
    current_posi = 0
    for i in range(k):
        current_posi = a[current_posi]
    print(current_posi+1)
    sys.exit()


posi_roop = [0]
for_search = set([0])

current_posi = 0
for i in range(n):
    current_posi = a[current_posi]
    if current_posi not in for_search:
        posi_roop.append(current_posi)
        for_search.add(current_posi)
    else:
        for j in range(len(posi_roop)):
            if posi_roop[j] == current_posi:
                true_start = j
                break
        true_roop = posi_roop[true_start:]
        consume = true_start
        break
pp = (k-consume) % len(true_roop)

print(true_roop[pp]+1)

Measured memory_bytes: 114292
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    int a;
    int last = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a == last + 1) last++;
    }

    if (last == 0)
        cout << -1 << endl;
    else
        cout << N - last << endl;
    return 0;
}


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


int main() {

    int a, b;
    cin >> a >> b;
    if (a + b >= 10) cout << "error" << endl;
    else cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		
		long k = sc.nextLong();
		
		if(k==1)
		{
			System.out.println(2);
			System.out.println("0 2");
		}
		
		
		
		
		for(long n = 2; n <= 50; n++)
		{
			long m = k%n;
			long cutk = k - ((n+1)*m);
			if(cutk < 0)continue;
			
			long typical = (n-1) + (cutk/n);
			long adv = typical + n + 1; //as much as mod
//			System.out.println("typical " + typical + ", cutn " + cutk + ", adv " + adv + ", mod " + m);
			
			if(adv > 10000000000001000l)continue;
			if(typical < 0)continue;
			
			boolean go = true;
			
			if(go)
			{
				System.out.println(n);
				StringBuilder sb = new StringBuilder();
				for(int i = 0; i < n; i++)
				{
					if(i>0)sb.append(' ');
					if(i < m)
					{
						sb.append(adv);
					}
					else
					{
						sb.append(typical);
					}
				}
				System.out.println(sb);
				return;
			}
		}
		
		
	}

}


Measured memory_bytes: 23636
#include <stdio.h>
#include <iostream>
#include<vector>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;

int main() {
	string s;
	cin >> s;
	
	string s_year = s.substr(0, 4);
	string s_month = s.substr(5, 2);
	string s_day = s.substr(8, 2);
	
	istringstream s_y = istringstream(s_year);
	istringstream s_m = istringstream(s_month);
	istringstream s_d = istringstream(s_day);
	
	int year = atoi(s_year.c_str());
	int month = atoi(s_month.c_str());
	int day = atoi(s_day.c_str());
	
	s_y >> year;
	s_m >> month;
	s_d >> day;
	
	if (year <= 2018) {
		cout << "Heisei" << endl;
		return 0;
	}
	else if (month <= 4) {
		cout << "Heisei" << endl;
		return 0;
	}
	else {
		cout << "TBD" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  vector<set<pair<int, int>>> vv(N + 1);
  REP(i, M) {
    cin >> P[i] >> Y[i];
    vv[P[i]].insert(make_pair(Y[i], i));
  }

  for (int i = 1; i <= N; i++) {
    int cnt = 1;
    for (auto e : vv[i]) {
      Y[e.second] = cnt;
      cnt++;
    }
  }
  REP(i, M) {
    cout << setw(6) << setfill('0') << P[i] 
         << setw(6) << setfill('0') << Y[i] << endl;
  }

	return 0;
}



Measured memory_bytes: 12032
#!/usr/bin/env python3

import math


def solve(a, b, x):
    # 面積になおす
    area = a * b
    x = x / a
    # 一杯のとき
    if x == area:
        return 0.0
    # 半分以上のとき
    if x >= area * 0.5:
        not_x = area - x
        h = 2.0 * not_x / a
        # print('x', x)
        # print('not_x', not_x)
        # print('h=', h)
        return math.degrees(math.atan2(h, a))
    # 半分以下のとき
    h = 2.0 * x / b
    # print('x=', x)
    # print('h=', h)
    return 90.0 - math.degrees(math.atan2(h, b))

if __name__ == '__main__':
    a, b, x = map(int, input().split())

    ans = solve(a, b, x)
print(ans)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int n,a,b,c;
cin>>n;
a=n%10;
b=(n/10)%10;
c=(n/100)%10;
if(a==7 or b==7 or c==7)
cout<<"Yes";
else
cout<<"No";

return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(void){
  int a, b, c, x;
  scanf("%d %d %d", &a, &b, &c);
  x = a + 100 * b + 10000 * c;
  if(x==70505||x==50705||x==50507){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> d(n, -1L);
    bool ok = true;
    for (auto i : irange(0L, m)) {
        int64_t s, c;
        cin >> s >> c;
        --s;

        if (d[s] < 0) {
            d[s] = c;
        } else if (d[s] != c) {
            ok = false;
        }
    }

    if (!ok || (d[0] == 0 && n > 1)) {
        cout << -1 << endl;
        return 0;
    }

    if (d[0] == -1) {
        d[0] = (n == 1 ? 0 : 1);
    }
    for (auto i : irange(1L, n)) {
        if (d[i] == -1) {
            d[i] = 0;
        }
    }

    for (auto i : irange(0L, n)) {
        cout << d[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int turn=0;
        int turntmp;
        String[] cards=new String[3];
        for(int i=0;i<3;i++){
            cards[i]=sc.next();
        }
        String[] outputs={"A","B","C"};
        while(true){
            if(cards[turn].length()==0){
                System.out.println(outputs[turn]);
                return;
            }
            turntmp=turn;
            turn=(int)cards[turn].charAt(0)-97;
            cards[turntmp]=cards[turntmp].substring(1,cards[turntmp].length());
        }

    }
    
 
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;
int main(void) {
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(a+b==c+d)cout<<"Balanced"<<endl;
    else if(a+b>c+d)cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
    char isused['z'-'a'+1]={0,};

    char buf;

    while((buf=getchar())!='\n'){
        if(isused[buf-'a']){
            puts("no");
            return 0;
        }else{
            isused[buf-'a']=1;
        }
    }
    puts("yes");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    string tmp = "No";
    int K = n / 2;
    if(n % 2 == 0 && s.substr(0, K) == s.substr(K, K)) tmp = "Yes";
    cout << tmp << endl;
}

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

using namespace std;

long long a, b, k, curr;


int main() 
{
    cin >> k >> a >> b;
    curr = 1;
    
    if (b - a <= 1)
    {
        cout << 1 + k;
    }
    else
    {
        if (a > 1)
        {
            long long inc = min(a - 1, k);
            curr += inc;
            k -= inc;
        }
        
        long long inc = k / 2;
        curr += inc * (b - a);
        k = (k & 1);
        cout << curr + k;
    }
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    int n, m, d, i;
    double ans;
    
    scanf("%d %d %d", &n, &m, &d);
    
    if (d == 0) {
        ans = (double)(m - 1) / n;
    } else {
        ans = (double)(n - d) * 2 * (m - 1) / n / n;
    }
    
    printf("%.12lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  ll num1 = 2;
  ll num2 = 1;
  ll num3;
  if (N == 1) {
    num3 = 1;
  } else {    
    for (int i = 0; i < N - 1; i++) {
      num3 = num1 + num2;
      num1 = num2;
      num2 = num3;
    }
  }
  cout << num3;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll n,p,a=1,ans;
    cin>>n>>p;
    if(n==1){cout<<p<<endl;return 0;}
    while(pow(a,n)<=p){
        if(p%(ll)pow(a,n)==0){
            ans=a;
        }
        a++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();

        if (w - s >= 0){
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }
}






Measured memory_bytes: 35816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n + 1];
		for(int i = 0; i < n; i++) {
			s[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		int[] t = new int[q];
		for(int i = 0; i < q; i++) {
			t[i] = sc.nextInt();
		}
		sc.close();
		int sameValueNum = 0;
		outside: for(int target: t) {
			s[n] = target;
			int index = 0;
			while(true) {
				if(target == s[index]) {
					if(index != n) {
						sameValueNum++;
					}
					continue outside;
				}
				index++;
			}
		}
		System.out.println(sameValueNum);

	}

}

Measured memory_bytes: 40140
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, L;
    int a[200] = {};
    cin >> N >> L;
    int m = 1000, sum=0;
    for(int i=0;i<N;i++){
        a[i] = L + i;
        m = min(m, abs(a[i]));
        sum += a[i];
    }
    for(int i=0;i<N;i++){
        if(m == abs(a[i])){
            sum -= a[i];
            break;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
local A = io.read("*n")
local B = io.read("*n")
local function test(A,B)
    local newMin = math.min(A,B)
    local newMax = math.max(A,B)
    for i=newMin,newMax do
        if A*B*i %2 == 1 then
            return "Yes"
        end
    end
    return "No"
end
print(test(A,B))

Measured memory_bytes: 636
#include<stdio.h>
int main()
{
    char a[100000]={0};
    int i,j,k,joi=0,ioi=0;
    while(scanf("%s",a)!=EOF)
    {
        for(i=0;i<100000;i++)
        {
            if(a[i]=='J'&&a[i+1]=='O'&&a[i+2]=='I')joi++;
            if(a[i]=='I'&&a[i+1]=='O'&&a[i+2]=='I')ioi++;
            a[i]='\0';
        }
        printf("%d\n",joi);
        printf("%d\n",ioi);
        joi=0;ioi=0;
    }
    return 0;
}

Measured memory_bytes: 648
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int digit(u64 n) {
  int digit=0;
  while (n!=0) {
    n /= 10;
    digit++;
  }
  return digit;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 n;
  cin >> n;
  u64 sq = (u64)(sqrt(n));
  int best = 99;
  for (int i = 1; i <= sq; ++i) {
    if (n%i != 0) continue;
    best = min(best, max(digit(i), digit(n/i)));
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
public class Main {

    private static int[] arr;
    private static int N;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        N = Integer.parseInt(br.readLine());
        arr = new int[N+1];
        String[] temp = br.readLine().split(" ");
        for(int i=0;i<N;i++)arr[i+1] = Integer.parseInt(temp[i]);

        int t = 0;
        for(int i=1;i<=N;i++){
            t ^= arr[i];
        }

        for(int i=1;i<=N;i++){
            System.out.print((t ^ arr[i]) + " ");
        }

    }

    private static int solution(int except, int start, int end){
        if(start == end){
            if(except == start)return 0;
            else return arr[start];
        }
        int mid = (start+end)/2;
//        System.out.println(mid);
        return (solution(except, start, mid) ^ solution(except, mid+1, end));

    }
}


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

const int N = 1 << 19;

char s[N];

void upd(int &x, int y) {
    x = max(x, y);
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n;
    while (scanf("%d%s", &n, s) == 2) {
        vector<vector<int> > vct;
        vct.push_back(vector<int>());
        for (int i = 0; i < n; i++) {
            if (s[i] == '0') {
                if (!vct.back().empty()) vct.push_back(vector<int>());
                continue;
            }
            int j = i;
            while (j + 1 < n && s[j + 1] == '1') j++;
            vct.back().push_back(j - i + 1);
            i = j + 1;
        }
        int ans = 0;
        for (auto v : vct) {
            if (v.size() <= 1) continue;

            int m = v.size();
            vector<vector<vector<int> > > dp(m, vector<vector<int> >(2, vector<int>(2, -1)));
            dp[0][0][0] = 0;
            for (int i = 0; i < m - 1; i++) { // neib already
                for (int j = 0; j < 2; j++) { // was -1
                    for (int k = 0; k < 2; k++) { // was to right
                        if (dp[i][j][k] == -1) continue;
                        for (int l = 0; l < 2; l++) {
                            for (int t = 0; t < 2; t++) {
                                if (j && l && v[i] == 1) continue;
                                if (!l && t) continue;
                                int nval = 0;
                                if (k || (l && !t)) {
                                    int cur = v[i] - j - l;
                                    nval += cur;
                                }
                                nval += l;

                                upd(dp[i + 1][l][t], dp[i][j][k] + nval);
                            }
                        }
                    }
                }
            }

            int mx = 0;
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    if (dp[m - 1][j][k] == -1) continue;
                    int add = 0;
                    if (k) add += v.back() - 1;
                    upd(mx, dp[m - 1][j][k] + add);
                }
            }
            ans += mx;
        }

        cout << ans << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 6964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main(){
    int height,width; cin >> height >> width;
    vector<string> maze(height);
    vector<vector<int> > dist(height,vector<int>(width,-1));
    rep(h,height) cin >> maze[h];
    queue<pair<int,int> > que;
    int ans = 0;
    rep(h,height){
        rep(w,width){
            if(maze[h][w]=='#') continue;
            int res=0;
            dist[h][w] = 0;
            que.push(make_pair(h,w));
            while(!que.empty()){
                pair<int,int> pos = que.front();
                que.pop();
                int y = pos.first;//j
                int x = pos.second;//x
                rep(dir,4){
                    int ny = y + dy[dir];
                    int nx = x + dx[dir];
                    if(nx<0 || nx>=width || ny<0 || ny>=height) continue;
                    if(maze[ny][nx]=='#') continue;
                    if(dist[ny][nx]==-1){
                        dist[ny][nx] = dist[y][x]+1;
                        que.push(make_pair(ny,nx));
                    }
                }
            }
            rep(h,height){
                rep(w,width){
                    res = max(res,dist[h][w]);
                }
            }
            ans = max(ans,res);
            rep(h,height) rep(w,width) dist[h][w] = -1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int l = s.length();
  int ans = 0;
  for(int i=0;i<l;++i){
    if(s[i]!=t[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3916
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int a, b, c, d, e, f;
int ans_f = 0, ans_s = 0;
double max_noudo = 0;

int main(){
    cin >> a >> b >> c >> d >> e >> f;

    int i = 0, j = 0, k = 0, l = 0;
    while(1){
        if(100*i*a> f) break;
        j = 0;
        while(1){
            if(100*i*a + 100*j*b > f) break;
            k = 0;
            while(1){
                if(100*i*a + 100*j*b + k*c > f) break;
                l = 0;
                while(1){
                    if(100*i*a + 100*j*b + k*c + l*d > f) break;
                    int water = 100*i*a + 100*j*b;
                    int sugar = c*k + d*l;
                    if(water != 0 && (i*a+j*b) * e >= sugar){
                        double noudo_current = double((100 * sugar)) / (water + sugar);
                        if(noudo_current >= max_noudo){
                            max_noudo = noudo_current;
                            ans_f = water + sugar;
                            ans_s = sugar;
                            //cout << "max_noudo: " << max_noudo << endl;
                            //cout << "water: " << water << " " << "sugar: " << sugar << " " << "sum: " << water+sugar << endl;
                        }
                    }
                    l++;
                }
                k++;
            }
            j++;
        }
        i++;
    }

    cout << ans_f << " " << ans_s << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {

	private static int[] data = new int[10];

	public static void main(String args[]) {
		

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		
		try{
			
			for(int i=0; i<10; i++) {
				
				String s = input.readLine();
				
				data[i] = Integer.parseInt(s);
			}
			
			
		}catch (IOException e) {
			
		}
		
		Arrays.sort(data);
		
		for(int i=9; i>6; i--) {
			System.out.println(data[i]);
		}
		
		
		
	}
}

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

class WaterInfo
{
    public int area;
    public int startPosition;
    public WaterInfo(int a, int s)
    {
        area = a;
        startPosition = s;
    }
}

class Program
{
    public static void Main(string[] args)
    {
        string s = Console.ReadLine();
        Stack<int> slopeinfo = new Stack<int>();
        Stack<WaterInfo> waterinfo = new Stack<WaterInfo>();
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '\\')
            {
                slopeinfo.Push(i);
            }
            if (s[i] == '/')
            {
                if (slopeinfo.Count == 0) continue;
                int startPosition = slopeinfo.Pop();
                int area = i - startPosition;
                while (waterinfo.Count > 0 && startPosition < waterinfo.Peek().startPosition)
                {
                    WaterInfo wi = waterinfo.Pop();
                    area += wi.area;
                }
                waterinfo.Push(new WaterInfo(area, startPosition));
            }
        }
        int[] areas = waterinfo.Select(x => x.area).Reverse().ToArray();
        if (areas.Length == 0)
        {
            Console.WriteLine("0");
            Console.WriteLine("0");
        }
        else
        {
            Console.WriteLine(areas.Sum());
            Console.Write("{0} ", areas.Length);
            for (int i = 0; i < areas.Length - 1; i++) Console.Write("{0} ", areas[i]);
            Console.WriteLine(areas[areas.Length - 1]);
        }
    }
}


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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    char x,y;
    cin >> x;
    cin >> y;

    if(x<y){
        cout << "<" << endl;
    }
    else if(x==y){
        cout << "=" << endl;
    }
    else{
        cout << ">" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    if(n%2)
        cout<<"0"<<endl;
    else{
        long long x=0;
        n/=2;
        while(n){
            n/=5;
            x+=n;
        }
        cout<<x<<endl;
    }
    return 0;
}

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

int main() {
  
  int N, M; cin >> N >> M;
  
  for (int i = 0; i < M; i++) {
    
    int A; cin >> A; N -= A;
    
  }
  
  if (N < 0) cout << -1 << endl;
  
  else cout << N << endl;
  
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  ll a, b; cin >> a >> b;
  // string s; cin >> s;
  // vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = (a - 1) * (b - 1);
  // bool ok = false;

  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3564