akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, a, b;

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b;
	int h = max(a, b);
	int l = min(a, b);
	int w = n + 1 - (h + l);
	if(h + l > n + 1  || (h + l <= n && l == 1) || n > h * l){
		cout << -1 << endl;
		return 0;
	}
	vector<int> ans;
	rep(i, 0, n) ans.push_back(i);
	if(l != 1){
		int t = (n - h + l - 2) / (l - 1);
		int sum = n - h;
		int now = 0;
		int left = 0;
		rep(i, 0, t){
			int len = min(l, sum + 1);
			sum -= len - 1;
			int right = left + len;
			reverse(ans.begin() + left, ans.begin() + right);
			left = right;
			
		}
	}
	if(a < b){
		rep(i, 0, n){
			ans[i] = n - 1 - ans[i];
		}
	}
	for(int ii = 0; ii < ans.size(); ii++){
		if(ii) cout << ' ';
		cout << ans[ii] + 1;
	}
	cout << endl;
}

Measured memory_bytes: 6000
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);++i)
#define pb(x) push_back(x)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
const int M = 1200000;
const int inf = 0x3f3f3f3f;
LL n,m,k;
int main() {
	cin>>n>>m;
  if(n==1||m==1){
    cout<<1<<endl;
    return 0;
  }
	cout<<(n*m+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s == "SUN")return cout << 7 << endl,0;
	else if(s == "MON")return cout << 6 << endl, 0;
	else if(s == "TUE")return cout << 5 << endl, 0;
	else if (s == "WED")return cout << 4 << endl, 0;
	else if (s == "THU")return cout << 3 << endl, 0;
	else if (s == "FRI")return cout << 2 << endl, 0;
	else if(s == "SAT") return cout << 1 << endl, 0;
}





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


int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	int num = a;
	for (int i = 1; i <= 100; i++) {
		if ((a*i)%b == c) {
			std::cout << "YES" << std::endl;
			break;
		}
		if (i == 100) {
			std::cout << "NO" << std::endl;
		}
	}
}

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

int main(){
	string n;
	cin >> n;
	int count = 0;
	int flag = 0;
	for(int i=0;i<n.size();i++){
		if (count==0){
			count++;
		}else{
			if (n[i] == n[i-1]){
				count++;
			}else{
				count=1;
			}
		}
		if (count==3){
			flag = 1;
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int a, b, d;
	int c[100000];
	cin >> a >> b;
	d = 0;
	for (int i = 0; i < b; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < b; i++) {
		d = d + c[i];
	}
	if(d >= a) cout << "Yes";
	if(d < a) cout << "No";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}

ll INF = 1e+18;
int iINF = 1e9;
int MAXI = 1e8 + 1;
using vec = vector<int>;

int 
main()
{
  int N, W; cin >> N >> W;
  vec w(N);
  vec v(N);
  rep(i, 0, N) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(N + 1, vector<ll>(100000 + 1, INF));
  dp[0][0] = 0;

  rep(i, 0, N){
    repe(k, 0, 100000){
      if(v[i] > k){
        dp[i + 1][k] = dp[i][k];
        continue;
      }
      if(dp[i][k] > dp[i][k - v[i]] + w[i]) dp[i + 1][k] = dp[i][k - v[i]] + w[i];
      else dp[i + 1][k] = dp[i][k];
    }
  }

  ll ans = 0;
  rep(i, 0, 100001){
    if(dp[N][i] <= W && ans < i) ans = i;
  }

  cout << ans << endl;

}

Measured memory_bytes: 83236
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N;
	cin >> N;
	vector<int> L(N);
	int a, b;
	a = b = 0;
	rep(i, N) {
		cin >> L[i];
		a += L[i];
		b = max(L[i], b);
	}
	a -= b;
	if (a > b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
X = int(input())
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
n = X
while True:
    if is_prime(n):
        break
    n+=1
print(n)
    

Measured memory_bytes: 38896
#include <stdio.h>
#include <math.h>

int prime[1000000]={0};

int main()
{
  int i, j, n, ans;
  for(i=2; i<1000000; i++){
    if(!prime[i]){
      for(j=2; j*i<1000000; j++) prime[i*j]++;
    }
  }
  while(scanf("%d", &n) != EOF){
    if(n<2) puts("0");
    else{
      ans=1;
      for(i=3; i<=n; i+=2) if(!prime[i]) ans++;
      printf("%d\n", ans);
    }
  }

  return(0);
}

Measured memory_bytes: 4512
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000

int L;

class STR{
public:
    char S[101];
    bool operator < (const STR &a) const {
        REP1(i,L){
            if (S[i] < a.S[i]) {
                return true;
            }else if(S[i] > a.S[i]){
                return false;
            }
        }
        return false;
    }
    void PRINTstr(){
        printf("%s",S);
    };
};

int main(){
    INT(N);INPUT(L);
    STR ST[100];
    REP1(i,N){
        scanf("%s",ST[i].S);
    }
    sort(ST,ST+N);
    REP1(i,N){
        ST[i].PRINTstr();
    }
    BR;
    return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function eval(a::Tuple{Int,Float64},b::Tuple{Int,Float64})
	if a[2]<b[2]
		1
	elseif a[2]==b[2]
		0
	else
		-1
	end
end
 
function hpush(h::Array{Tuple{Int,Float64},1},x::Tuple{Int,Float64})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = l>>1
		while x[2]<h[k][2]&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(k>>1,1)
			l = l>>1
		end
	end
	h
end
 
function hpop(h::Array{Tuple{Int,Float64},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>l
				break
			elseif 2*k+1>l
				if h[2*k][2]<=z[2]
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k<<1
				end
			else
				if z[2]<=h[2*k][2]&&z[2]<=h[2*k+1][2]
					break
				else
					t = h[2*k][2]<=h[2*k+1][2]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end

dist(xa::Int,ya::Int,xb::Int,yb::Int,ra::Int,rb::Int)=sqrt((xa-xb)^2+(ya-yb)^2)-ra-rb

function main()
	xs,ys,xt,yt = readline() |> split |> parseMap
	n = readline() |> parseInt
	a = Tuple{Int,Int,Int}[(0,0,0) for i in 1:n]
	for i in 1:n
		x,y,r = readline() |> split |> parseMap
		a[i] = (x,y,r)
	end
	e = [Tuple{Int,Float64}[] for i in 1:n+2]
	for i in 1:n
		for j in i+1:n
			v = dist(a[i][1],a[i][2],a[j][1],a[j][2],a[i][3],a[j][3])
			push!(e[i], (j,max(0,v)))
			push!(e[j], (i,max(0,v)))
		end
		v = dist(a[i][1],a[i][2],xs,ys,a[i][3],0)
		push!(e[i],(n+1,max(0,v)))
		push!(e[n+1],(i,max(0,v)))
		v = dist(a[i][1],a[i][2],xt,yt,a[i][3],0)
		push!(e[i],(n+2,max(0,v)))
		push!(e[n+2],(i,max(0,v)))
	end
	v = dist(xs,ys,xt,yt,0,0)
	push!(e[n+1],(n+2,max(0,v)))
	push!(e[n+2],(n+1,max(0,v)))

	hs = Tuple{Int,Float64}[(n+1,0.0)]
	hg = Tuple{Int,Float64}[(n+2,0.0)]
	ds = 10^18*ones(Float64,n+2)
	dg = 10^18*ones(Float64,n+2)
	vss = zeros(Int,n+2)
	vsg = zeros(Int,n+2)
	ds[n+1] = 0.0
	dg[n+2] = 0.0
	while !isempty(hs)||!isempty(hg)
		v,w = hpop(hs)
		ds[v] = min(ds[v],w)
		vss[v] = 1
		if vss[v]+vsg[v] > 1
			break
		end
		for i in 1:length(e[v])
			nw = w+e[v][i][2]
			if ds[e[v][i][1]]>nw
				ds[e[v][i][1]] = nw
				hpush(hs,(e[v][i][1],nw))
			end
		end
		vv,ww = hpop(hg)
		dg[vv] = min(dg[vv],ww)
		vsg[vv] = 1
		if vss[vv]+vsg[vv] > 1
			break
		end
		for i in 1:length(e[vv])
			nw = ww+e[vv][i][2]
			if dg[e[vv][i][1]]>nw
				dg[e[vv][i][1]] = nw
				hpush(hg,(e[vv][i][1],nw))
			end
		end
	end
	minim = ds[1]+dg[1]
	for i in 2:n+2
		minim = min(minim,ds[i]+dg[i])
	end
	println(minim)
end

main()

Measured memory_bytes: 170016
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.end());
    double ans=v[0];
    for(int i=1;i<n;++i){
        ans=(double)(ans+v[i])/2;
    }
    cout<<fixed<<setprecision(6)<<ans<<endl;
}
        


Measured memory_bytes: 3700
n,m = map(int,input().split())
s = []
l = []
for i in range(n):
    a = list(map(int,input().split()))
    s.append(a)
for i in range(m):
    b = list(map(int,input().split()))
    l.append(b)
ansl = []
for i in range(n):
    ans1 = abs(s[i][0]-l[0][0]) + abs(s[i][1]-l[0][1])
    ans = 1
    for j in range(m):
        ans2 = abs(s[i][0] - l[j][0]) + abs(s[i][1] - l[j][1])
        if ans2 < ans1:
            ans1 = ans2
            ans = j + 1
    ansl.append(ans)
for i in range(n):
    print(ansl[i])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
class activity
{
public:
	ll int A;
	ll int B;
	ll int C;
};

/*string get_index(int a, int b)
{
	return to_string(a) + "" + to_string(b);
}

ll int solve(ll int i, ll int n, vector<activity>v, ll int prev, unordered_map<string, int>&m)
{
	if (i == n)
	{
		return 0;
	}
	string indx = get_index(i, prev);
	if (m.find(indx) != m.end())
	{
		return m[indx];
	}

	if (prev == 0)
	{
		//agar B chuno
		ll int B_ans = v[i].B + solve(i + 1, n, v, 1 , m);
		//agar C chuno
		ll int C_ans =  v[i].C + solve(i + 1, n, v, 2, m);
		ll int ans = max(B_ans, C_ans);
		return m[indx] = ans;
	}
	else if (prev == 1)
	{
		//agar A chuno
		ll int A_ans = v[i].A + solve(i + 1, n, v, 0, m);

		//agar C chuno
		ll int C_ans = v[i].C + solve(i + 1, n, v, 2, m );
		ll int ans = max(A_ans, C_ans);
		return m[indx] = ans;
	}
	else //agar pichla C ho to
	{
		//agar A chuno
		ll int A_ans = v[i].A + solve(i + 1, n, v, 0, m );
		ll int B_ans = v[i].B + solve(i + 1, n, v, 1, m);
		ll int ans = max(A_ans, B_ans);
		return m[indx] = ans;
	}
}*/

int vacation_BU(vector<activity>v)
{
	int n = v.size();
	vector<vector<int>>dp(n, vector<int>(3));
	//0 => A   1 => B   2 => C
	dp[0][0] = v[0].A;
	dp[0][1] = v[0].B;
	dp[0][2] = v[0].C;
	for (int i = 1; i < n; i++)
	{
		dp[i][0] = v[i].A + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = v[i].B + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = v[i].C + max(dp[i - 1][0], dp[i - 1][1]);
	}
	return max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll int n;
	cin >> n;
	vector<activity>v(n);
	for (ll int i = 0; i < n; i++)
	{
		ll int a, b, c;
		cin >> a >> b >> c;
		v[i].A = a;
		v[i].B = b;
		v[i].C = c;
	}
	cout << vacation_BU(v);
	/*unordered_map<string, int>m;

	ll int A_ans = solve(0, n, v, 0, m);
	ll int B_ans = solve(0, n, v, 1, m);
	ll int C_ans = solve(0, n, v, 2, m);
	ll int ans = max(A_ans, max(B_ans, C_ans));
	cout << ans << endl;*/
	// for (auto i : m)
	// {
	// 	cout << i.first << "  " << i.second << endl;
	// }
	return 0;
}

Measured memory_bytes: 13204
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        final int MOD = 1000000000 + 7;
        char[] s = scanner.next().toCharArray();
        int n = s.length;
        long[][] f = new long[n][2];
        f[0][0] = 1;
        f[0][1] = 2;
        for (int i = 1; i < n; ++i) {
            if (s[i] == '1') {
                f[i][0] = (f[i - 1][0] * 3 + f[i - 1][1]) % MOD;
                f[i][1] = (f[i - 1][1] * 2) % MOD;
            } else {
                f[i][0] = (f[i - 1][0] * 3) % MOD;
                f[i][1] = f[i - 1][1];
            }
        }
        writer.println((f[n - 1][0] + f[n - 1][1]) % MOD);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 28116
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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

int a[10];

int main()
{
    for (int i = 1; i <= 5; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] B = new int[N - 1];

        for (int i = 0; i < N - 1; i++) {
            B[i] = sc.nextInt();
        }

        int sol = 0;

        for (int i = 0; i < N - 2; i++) {
            sol += Math.min(B[i], B[i + 1]);
        }

        sol += B[0] + B[N - 2];

        System.out.println(sol);
    }
}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;
  for (int x = 0; x <= K; ++x) {
    for (int y = 0; y <= K; ++y) {
      int z = S - (x + y);
      if (0 <= z && z <= K) {
        ++cnt;
      }
    }
  }
  cout << cnt << endl;
  
  return 0;
}


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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k; cin>>n>>k;
    int ans=0;
    while(n>0){
        ans++;
        n/=k;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
N = int(raw_input())
A = map(int,raw_input().split())

flag=True
if N%2==0:
    l = [0 for i in range(N/2)]
    for i in range(N):
        if A[i]%2!=1 or A[i]>=N or A[i]<=0:
            print 0
            flag=False
            break
        l[(A[i]-1)/2]+=1
        if l[(A[i]-1)/2]>=3:
            print 0
            flag=False
            break
    if flag:
        print (2**(N/2))%(10**9+7)
else:
    l = [0 for i in range((N+1)/2)]
    for i in range(N):
        if A[i]%2!=0 or A[i]>=N or A[i]<0:
            print 0
            flag=False
            break
        if A[i]==0:
            l[0]+=1
            if l[0]>=2:
                print 0
                flag=False
                break
        else:
            l[A[i]/2]+=1
            if l[A[i]/2]>=3:
                print 0
                flag=False
                break        
    if flag:
        print (2**((N-1)/2))%(10**9+7)

Measured memory_bytes: 11332
#include <stdio.h>

int main(){
  long long n,min=1000001,max=-1000001,sum=0,i;
  scanf("%lld",&n);
  long long data[n];
  for(i=0;i<n;i++){
    scanf("%lld",&data[i]);
  }
  
  i = 0;
  max = data[i];
  for(i=1;i<n;i++){
    if(max<data[i]){
      max = data[i];
    }
  }
  i = 0;
  min = data[i];
  for(i=1;i<n;i++){
    if(min>data[i]){
      min = data[i];
    }
  }
  for(i=0;i<n;i++) sum = sum + data[i];

  printf("%lld %lld %lld\n",min,max,sum);

  return 0;
}

Measured memory_bytes: 676
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<ll, ll> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 2010;
const int MAXM = 10010;
const int MAXK = 110;
const int MAXQ = 200010;
const int MAX = 1000000000;
const int oo = 0x3c3c3c3c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    FORE(i,int(sqrt(n)),1) {
        if (n % i == 0) {
            cout << (ll) i - 1 + n / i - 1;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def inpl(): return input().split()
n, x = map(int, inpl())
a = list(map(int, inpl()))
ans = 0
if a[0] > x:
    ans += a[0] - x
    a[0] = x        
for i in range(1, n):
    if (a[i-1] + a[i]) > x:
        ans += (a[i-1] + a[i]) - x
        a[i] = x - a[i-1]
print(ans)


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

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

  ll X, N; cin >> X >> N;
  if (N == 0) {
    cout << X << '\n';
    return 0;
  }
  vector<ll> A(110, 0);
  for (ll i = 0; i < N; i++) {
    ll temp;
    cin >> temp;
    A[temp] = 1;
  }
  ll l = 0, r = 110;
  for (ll i = 0; i < 105; i++) {
    if (A[i] == 0) {
      if (i <= X) l = i;
      else if (r == 110) r = i;
    }
  }

  ll ans = l;
  if (r - X < X - l) ans = r;
  cout << ans << '\n';
  return 0;
}

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

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

    int ans = 0, cont = 1, prev;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == prev) {
            cont++; 
        } else {
            ans += cont / 2;
            cont = 1;
        }
        prev = a;
    }
    ans += cont / 2;
    
    cout << ans << "\n";
    return 0;
}

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

int main(){
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	
	double tetra = W * H;
	
	cout << tetra / 2 << ' ';
	
	if( x == W / 2 && y == H / 2 ){
		cout << 1 << endl;
	}
  
  	else{
      cout << 0 << endl;
    }
}

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

int main(){
    
    int N,K;
    string S;
    cin >> N >> K >> S;
    if(S.at(K-1)== 'A'){
        S.at(K-1)='a';
    }
    else if(S.at(K-1)== 'B'){
        S.at(K-1)='b';
    }
    else if(S.at(K-1)== 'C'){
        S.at(K-1)='c';
    }

cout << S << endl;



    
    }

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a;
	a.resize(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int alice=0, bob=0;
	for(int i=0; i<n; i++){
		if(i%2==0) alice+=a[i];
		else bob+=a[i];
	}
	cout << alice-bob << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

map<ll, ll> mp;
ll power_sum(ll a, ll x, ll k){
  if(x<0)
    return 0;
  else if(x==0)
    return 1;
  else if(x==1)
    return a+1 % k;
  else if(mp.count(x))
    return mp[x];
  else{
    mp[x] = (power_sum(a, x-1, k) * a) %k + 1;
    return mp[x];
  }
}

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

  ll k;
  cin >> k;
  
  for(ll i=0; i<k; i++){
    if(power_sum(10, i, k)*7%k==0){
      cout << i+1;
      return 0;
    }
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 66008
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;
struct node{
	int a,b,c,d;
	bool operator < (const node&z)const {return d>z.d;}
}arr[100];
int ans;
int p[100],q;
void check(){
	int mark=0;
	rep1(i,q){
		int l=arr[i].a,r=arr[i].b;
		if(p[r]-p[l]==arr[i].c)mark+=arr[i].d;
	}
	ans=max(ans,mark);
}
void dfs(int now,int n,int m,int sta){
	if(now>n){
		check();
		return ;
	}
	for(int i=sta;i<=m;i++){
		p[now]=i;
		dfs(now+1,n,m,i);
	}
}
void solve(){
	int n,m;
	scddd(n,m,q);
	rep1(i,q){
		scdd(arr[i].a,arr[i].b);
		scdd(arr[i].c,arr[i].d);
	}
	dfs(1,n,m,1);
	ac;
}
int main(){
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("D:\\data.txt","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "Yes":"No")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

char A[60][60];
string B,tmp;

int main() {

    Fast_Input
    int n,m; cin>>n>>m;

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

    for(int i=0; i<m; i++){
        cin>>tmp;
        B+=tmp;
    }

    int ok=0;

    for(int i=0; !ok && i<=(n-m); i++){

        for(int j=0; j<=(n-m); j++){
            if(A[i][j]==B[0]){
                tmp="";

                for(int k=i; k<i+m; k++){
                    for(int l=j; l<j+m; l++){
                        tmp+=A[k][l];
                    }
                }
               // cout<<i<<" "<<j<<" "<<tmp<<endl;
                if(tmp==B){
                    ok=1;
                    break;
                }
            }
        }
    }
    PRINT(ok);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int A,B,V,W,T;

inline int a(int x){
	if(x>0)return 1;
	return -1;
}

int main(){
	scanf("%d%d%d%d%d",&A,&V,&B,&W,&T);
	if(V==W){
		puts("NO");
		return 0;
	}
	double x=1.0*(B-A)/(V-W);
			if(max(B,A)-min(B,A)<=1ll*(V-W)*T)
			puts("YES");
		else puts("NO");
}

Measured memory_bytes: 3164
//
//  C.cpp
//  CodeForcesProblems
//
//  Created by Jacob Murry on 1/6/20.
//  Copyright © 2020 Jacob Murry. All rights reserved.
//

//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif

using namespace std;

class Solution {
    
};

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    int a,b,c;
    //in the memo keep track of the maximum enjoyment upto a certain day of picking a certain activity
    //meaning that activity cant be picked next
    //row
    //a: 0
    //b: 1
    //c: 2
    //column is the ith day
    //this method reduces memory even though this problem can be solved with O(1) memory
    vector<int> row(N, 0);
    vector<vector<int> > enjoyment(3, row);
    //first 0th day do the activities as followed
    cin >> enjoyment[0][0] >> enjoyment[1][0] >> enjoyment[2][0];
    for(int i=1; i<N; ++i) {
        cin >> a >> b >> c;
        //do activity a on this day
        enjoyment[0][i] = max(enjoyment[1][i-1], enjoyment[2][i-1])+a;
        //do activity b on this day
        enjoyment[1][i] = max(enjoyment[0][i-1], enjoyment[2][i-1])+b;
        //do activity c on this day
        enjoyment[2][i] = max(enjoyment[0][i-1], enjoyment[1][i-1])+c;
    }
    //find the max of ending with each of the three activities
    int max_enj = max(enjoyment[0][N-1], max(enjoyment[1][N-1], enjoyment[2][N-1]));
    cout << max_enj << "\n";
    return 0;
}


Measured memory_bytes: 1792
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
EPS = 10 ** -10

class ModTools:
    """ 階乗・逆元用のテーブルを構築する """

    def __init__(self, MAX, MOD):
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, -1, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせ """

        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def nHr(self, n, r):
        """ 重複組み合わせ """

        return self.nCr(r+n-1, r)

    def nPr(self, n, r):
        """ 順列 """

        if n < r: return 0
        return self.fact[n] * self.inv[n-r] % self.MOD

    def div(self, x, y):
        """ MOD除算 """

        return x * pow(y, self.MOD-2, self.MOD) % self.MOD

N, K = MAP()

mt = ModTools(max(N, K)+1, MOD)
ans = 0
for i in range(K+1):
    if i % 2 == 0:
        ans += mt.nCr(K, i) * pow(K-i, N, MOD) % MOD
    else:
        ans -= mt.nCr(K, i) * pow(K-i, N, MOD) % MOD
print(ans%MOD)



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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L[] = new int[N];
		for (int i=0;i<N;i++) {
			L[i] = sc.nextInt();
		}
		Arrays.parallelSort(L);
		int sum =0;
		for (int i=0;i<N-1;i++) {
			sum +=L[i];
		}
		if (sum>L[N-1]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35564
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

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

int main() {
    cin >> N;
    vector<ll> v(N);
    rep(i, N){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid=N-1;mid>=0;mid--){
        for(ll low=mid-1;low>=0;low--){
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,temp,dp[3][100005];
	vector<vector<int> >v;
	vector<int>tempv;
	cin>>n;	
	for(i=0;i<n;i++)
		{
			for(j=0;j<3;j++)
				{
					cin>>temp;
					tempv.push_back(temp);
				}
			v.push_back(tempv)	;
			tempv.clear();
		}
	
	dp[0][0]=v[0][0];
	dp[1][0]=v[0][1];
	dp[2][0]=v[0][2];
	for(j=1;j<n;j++)
		{
			dp[0][j]=v[j][0] + max( dp[1][j-1] , dp[2][j-1] );
			dp[1][j]=v[j][1] + max( dp[0][j-1] , dp[2][j-1] );
			dp[2][j]=v[j][2] + max( dp[1][j-1] , dp[0][j-1] );
		}
	cout<<max(dp[0][n-1] , max(dp[1][n-1] , dp[2][n-1])  );	
			
}

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

int main() {
  vector<int> vec(5);
  
  cin >> vec.at(0) >> vec.at(1) >>vec.at(2) >> vec.at(3) >>vec.at(4);
sort(vec.begin(), vec.end());
  int K;
  cin >> K;
  if (vec.at(4) - vec.at(0) <= K){
    cout << "Yay!" <<endl;
  }
  else{
    
  cout << ":(" << endl;
  }
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,x;
    scanf("%d%d",&a,&b);
    if(a>=13)
    {
        x=b;
    }
    else if(a>=6 && a<=12)
    {
        x=b/2;
    }
    else
    {
        x=0;
    }
    printf("%d",x);
    return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  string s;cin>>s;
  ll n=s.size();
  ll ans=0;
  ll count=0;
  rep(i,n){
    if(s[i]=='1'){
      count++;
      ans+=modpow(2,count-1,MOD)*modpow(3,n-i-1,MOD)%MOD;
      ans%=MOD;
    }
  }
  ans+=modpow(2,count,MOD);
  ans%=MOD;
  cout<<ans<<endl;
}
      
    
          
    
    
          

Measured memory_bytes: 512
#include <algorithm>
#include <deque>
#include <iostream>
#include <functional>

using namespace std;

int main()
{
	int i, num;
	deque<int> mountainheight;
	for ( i = 0; i < 10; i++ ) {
		scanf("%d",&num);
		mountainheight.push_back(num);
	}
	sort( mountainheight.begin(), mountainheight.end(), greater<int>() );

	deque<int>::iterator it = mountainheight.begin();
	for( i = 0; i < 3; i++ ) {
		cout << *it << endl;
		it++;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
//#include<>
using namespace std;



int main()
{
    char c[100010];
    memset(c, '\0', sizeof(c));

    long long int K, N, k;
    long long int j = 0;
    cin >> c;

    cin >> K;
    k = K;
    long long int num = strlen(c);

    long long int s = 0;
    for (long long int i = 0; i < num; i++) {
        if (c[s] == 'a') {
            s++;
            continue;
        }
        if (k >= (26 - (c[s] - 'a'))) {


            k = k - (26 - (c[s] - 'a'));
            c[s] = 'a';
        }
        s++;
    }

    if (k != 0) {
        int p = 0;
        // cout << k << c[num - 1] << endl;
        p = (c[num - 1] - 'a' + k) % 26;

        c[num - 1] = 'a' + p;
    }


    cout << c << endl;
    // cout << num << endl;

    return 0;

}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){

	char input[1000];
	fgets(input, 1000, stdin);
	int i = strlen(input);

	

	int now; //入力の番号
	int stacknum=0; 
	int stack[1000];
	//printf("入力された文字列は：%s文字数は%d\n", input, i);
	int j=0;

	while(input[j]!='\0'){
		char str[100];
		int k=0;
		while(1){
			str[k]=input[j];
			if(input[j]==' '  || input[j]=='\0' || input[j]=='\n'){
				str[k]='\0';
				j++;
				break;
			}
			k++;
			j++;
		}
		//printf("入力された文字列strは：%s\n", str);
	
		if(strcmp(str,"+")==0){
			stack[stacknum-2]=stack[stacknum-2]+stack[stacknum-1];
			stacknum=stacknum-1;
			//printf("入力された文字列は：%c\n",'+');
		}else if(strcmp(str,"-")==0){
			stack[stacknum-2]=stack[stacknum-2]-stack[stacknum-1];
			stacknum=stacknum-1;
		//	printf("入力された文字列は：%c\n",'-');
		}else if(strcmp(str,"*")==0){
			stack[stacknum-2]=stack[stacknum-2]*stack[stacknum-1];
			stacknum=stacknum-1;
		//	printf("入力された文字列は：%c\n",'*');
		}else{
			stack[stacknum]=atoi(str);
			stacknum++;
		}
	}
	printf("%d\n",stack[stacknum-1]);
	return 0;
}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    v<int> a(n), b(n), c(n); rep(i,n) cin >> a[i] >> b[i] >> c[i];

    vv<int> dp(3, v<int>(n+5));

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    rep(i,n) {
        dp[0][i+1] = max(dp[1][i] + a[i+1], dp[2][i] + a[i+1]);
        dp[1][i+1] = max(dp[0][i] + b[i+1], dp[2][i] + b[i+1]);
        dp[2][i+1] = max(dp[0][i] + c[i+1], dp[1][i] + c[i+1]);
    }

    int ans = 0;
    rep(i, 3) {
        chmax(ans, dp[i][n]);
    }

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


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

using namespace std;


#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),v).end()

#define PB(a) push_back(a)
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  int x,y,s;
  while(true){
      cin>>x>>y>>s;
      if(x==0&&y==0&&s==0) break;
      int ma=-1;
      for(int i=1;i<s;i++){
          for(int j=1;j<s;j++){
              if(i*(100+x)/100+j*(100+x)/100==s){
                  ma=max(ma,i*(100+y)/100+j*(100+y)/100);
              }
          }
      }
      cout<<ma<<endl;
  }
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
 ll MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

ll n;
string x;
ll popcnt(string x){
  ll res=0;
  rep(i,n) if(x[i]=='1') res++;
  return res;
}
void rev(ll i){
  if(x[i]=='1') x[i]='0';
  else x[i]='1';
}

ll bitcount(ll x){
  if(x==0) return 0;
  return bitcount(x>>1)+(x&1);
}

ll f(ll a){
  ll cnt=bitcount(a);
  return a%cnt;
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>n>>x;
  ll cnt=popcnt(x);
  
  // 1回目の+1, -1のmodを求めたい
  ll aa=0, bb=0;
  MOD=cnt+1;
  rep(i,n){
    if(x[i]=='1') (aa+=modpow(2,n-i-1))%=MOD;
  }
  MOD=cnt-1;
  if(MOD) rep(i,n){
    if(x[i]=='1') (bb+=modpow(2,n-i-1))%=MOD;
  }
  
  // cout<<aa<<bb<<endl;
  
  rep(i,n){
    ll ans=1;
    if(x[i]=='1') {
      MOD=cnt-1;
      if(MOD==0){
        cout<<0<<endl;
        continue;
      }
      ll tmp=modpow(2,n-i-1);
      ll mo=(bb-tmp+MOD)%MOD;
      while(mo>0){
        mo=f(mo);
        ans++;
      }
    }else{
      MOD=cnt+1;
      ll tmp=modpow(2,n-i-1);
      ll mo=(aa+tmp)%MOD;
      while(mo>0){
        mo=f(mo);
        ans++;
      }
    }
    cout<<ans<<endl;
  }
  
}

Measured memory_bytes: 3864
n=int(input())
A=[]
A=input().split()
A=[int(u) for u in A]
A.sort()
q=int(input())
S=[]
S=input().split()
S=[int(u) for u in S]
coun=0
for i in range(0,n):
    coun=coun+A[i]
K=[[0 for j in range(coun+1)] for i in range(n)]
T=[]
for i in range(0,n):
    K[i][0]=0
for j in range(0,coun+1):
    T.append(0)
for j in range(1,coun+1):
    if A[0]==j:
        K[0][j]=1
        T[j]=1
    else:
        K[0][j]=0
koe=A[0]
for i in range(1,n):
    koe=koe+A[i]
    for j in range(1,coun+1):
        j=coun+1-j
        u=j-A[i]
        if koe<j:
            K[i][j]=0
        elif koe==j:
            K[i][j]=1
            T[koe]=1
        elif A[i]==j:
            K[i][j]=1
            T[j]=1
        elif T[u]==1 and j<=koe and u>=0:
            T[j]=1
            K[i][j]=1
        else:
            K[i][j]=0
s=len(S)
for i in range(0,s):
    o=S[i]
    if o>coun:
        print("no")
    elif T[o]==1 and o<=coun:
        print("yes")
    else:
        print("no")


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

const ll MOD = 1e9 + 7;

int main(){
ll N; cin >> N; vector<ll> T(N); vector<ll> A(N);
 for(int i = 0; i < N; i++){ cin >> T[i];}
 for(int j = 0; j < N; j++){ cin >> A[j];}
  
  vector<pair<bool,bool>> asser(N);
  for(ll i = 0; i < N; i++){ asser[i].first = false; asser[i].second = false;}
                                                         
  vector<pair<ll,ll>> hight(N); //暫定的な高さを入れる
  
  hight[0].first = T[0]; asser[0].first = true;
  
  for(ll i = 1; i < N; i++){
    if(T[i] > T[i-1]){ asser[i].first = true;} //真に大きくなる時だけは断言できる
    hight[i].first = T[i];}
  
  hight[N-1].second = A[N-1]; asser[N-1].second = true;
  
  for(ll j = N - 2; j >= 0; j--){
    if( A[j] > A[j+1]){ asser[j].second = true;}
    hight[j].second = A[j];}
  
  ll cnt = 1;
  
  for(ll i = 0; i < N; i++){
    //矛盾するのは、両方とも断言できて範囲が異なるとき、ないし
    //片方は断言できているが、それがもう片方の範囲と矛盾するとき
    if( asser[i].first && asser[i].second){
      
      if( hight[i].first != hight[i].second){ cout << 0 << endl; return 0;}}
    
    else if( asser[i].first){
      
      if( hight[i].first > hight[i].second){ cout << 0 << endl; return 0;}
    }
    
    else if( asser[i].second){
      
      if( hight[i].second > hight[i].first){ cout << 0 << endl; return 0;}
    }
    
    else{ //両方とも断言できない時
      
      cnt *= min( hight[i].first, hight[i].second); cnt %= MOD;}
  }
  
  cout << cnt << endl; return 0;}
       
  

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int[] k = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		sc.close();
		System.out.println(k[K - 1]);
	}
}


Measured memory_bytes: 23636