akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b;

    cin >> a >> b;

    a += b;
    if (a >= 24) {
        cout << a - 24;
    } else {
        cout << a;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    if(vec[vec[i]-1]==i+1){
      ans++;
    }
  }
  
  cout<<ans/2<<endl;
}

Measured memory_bytes: 3712
class Problem
  attr_accessor :a, :b, :n, :m, :h, :w

  def initialize
    @a = gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    a.sort == [5,5,7]
  end

  def show(ans)
    puts ans ? "YES" : "NO"
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14248
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/22
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 2e5+50;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int n;
int a[maxn];
int dp[maxn];

int main(int argc, char* argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    int res = 0;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (dp[a[i] - 1]) dp[a[i]] = 1, res = max(res, a[i]);
    }
    if (res == 0) printf("-1\n");
    else printf("%d\n", n - res);
    return 0;
}

Measured memory_bytes: 1792
n,k=map(int,input().split())
mods=[0]*k
mods[0]=n//k
for i in range(1,k):
    mods[i]=(n-i)//k+1
ans=0

for i in range(k):
    if (2*k-i)%k == i:
        ans+=mods[i]**3
print(ans)

Measured memory_bytes: 40432
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

std::unordered_set<int32_t> map;
int32_t N;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		int a;
		in >> a;
		auto iter = map.find(a);
		if (map.end() == iter) {
			map.insert(a);
		}
		else {
			map.erase(iter);
		}
	}
	out << map.size() << endl;
	return 0;
}
#endif


Measured memory_bytes: 4256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		String s = ns();
		long k = nl()-1;
		int i=0;
		while (s.charAt(i)=='1' && i<k)
			i++;
		out.println(s.charAt(i));
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}


int main(void){
    long long n;
    cin >> n;
    
    vector<long long> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    
    long long ans = t[0];
    
    for (int i = 0; i < n; i++) ans = LCM(ans,t[i]);
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string>v(n);
  REP(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  REP(i,n)cout<<v[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);
    String s = sc.next();
    if (Integer.parseInt(s.substring(5, 7)) < 5) System.out.println("Heisei");
    else System.out.println("TBD");
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdlib>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <string>

using namespace std;

int main()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <cstdlib>
#include <iostream>
#include <string>


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

  std::string s;
  while (std::cin >> s) {
    std::cout.put(s[0]);
  }
  std::cout << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

int main() {
  int n;
  cin >> n;
  set<int> s;
  rep(i, n) {
    int a;
    cin >> a;
    if(s.count(a))
      s.erase(a);
    else
      s.insert(a);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>

#include <unordered_map>
#include <unordered_set>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define DFOR(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define rep(i,n) FOR(i,0,n)
#define repn(i,n) FORN(i,1,n)
#define drep(i,n) DFOR(i,n-1,0)
#define drepn(i,n) DFOR(i,n,1)
#define MAX(a,b) a = Max(a,b)
#define MIN(a,b) a = Min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define Reset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(all(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define forever for(;;)
#define PINF 1000000000000
#define newline '\n'

#define test if(1)if(0)cerr
using namespace std;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double pi = acos(-1.0);


const int maxn = 2e2;
int l[maxn];
int n, ans;

int main()
{
    cin >> n;
    rep(i, 2*n)
    {
        cin >> l[i];
    }
    ans = 0;
    sort(l, l+2*n);
    for (int i = 2*n-1; i >= 1; i -= 2)
    {
        ans += l[i-1];
    }
    cout << ans << newline;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, sum, p_sum, pp_sum;
  cin >>N;
  sum = 0;
  p_sum =0;
  vector<int> w(N);
  for(int i=0;i<N;i++){
    cin >> w.at(i);
    sum += w.at(i);
  }
  for(int i=0;i<N;i++){
    p_sum += w.at(i);
    if(p_sum > sum/2){
      pp_sum = p_sum - w.at(i);
      break;
    }
  }
  cout << min(2*p_sum - sum, sum - 2*pp_sum) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout<<(a==b?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(string, a);
    Cin(int, b);
    Cin(int, c);
    Cin(int, d);
    Cout(a[0] == '9' || a[1] == '9' ? "Yes" : "No");
}

Measured memory_bytes: 256
# input here
_INPUT = """\

"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    a, b, c, d = map(int, input().split())

    if ((a >= 0)&(b >= 0)):
        if ((c >= 0)&(d >= 0)):
            print(b*d) 
        elif ((c < 0)&(d >= 0)):
            print(b*d)
        elif ((c < 0)&(d < 0)):
            print(a*d)
    
    elif ((a < 0)&(b >= 0)):
        if ((c >= 0)&(d >= 0)):
            print(b*d) 
        elif ((c < 0)&(d >= 0)):
            print(max(abs(b*d),abs(a*c)))
        elif ((c < 0)&(d < 0)):
            print(a*c)

    elif ((a < 0)&(b < 0)):
        if ((c >= 0)&(d >= 0)):
            print(b*c) 
        elif ((c < 0)&(d >= 0)):
            print(a*c)
        elif ((c < 0)&(d < 0)):
            print(a*c)


            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int d; cin >> d;

	if(d == 22){
		cout << "Christmas Eve Eve Eve" << endl;
		return 0;
	}

	if(d == 23){
		cout << "Christmas Eve Eve" << endl;
		return 0;
	}

	if(d == 24){
		cout << "Christmas Eve" << endl;
		return 0;
	}

	if(d == 25){
		cout << "Christmas" << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

long long n, m;
vector<int> connect[200001];
queue<int> searchq;
static int dist[200001];
static int flag[200001];

void bfs() {
	while (!searchq.empty()) {
		int s = searchq.front();
		searchq.pop();
		for (int i = 0; i < connect[s].size(); i++) {
			if (dist[s] + 1 < dist[connect[s][i]]) {
				dist[connect[s][i]] = dist[s] + 1;
				flag[connect[s][i]] = s;
				searchq.push(connect[s][i]);
			}
		}
	}
}

int main() {
	bool check = true;

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		connect[a].push_back(b);
		connect[b].push_back(a);
	}

	for (int i = 1; i <= n; i++) {
		dist[i] = 999999;
		flag[i] = 999999;
	}
	dist[1] = 0;

	searchq.push(1);
	bfs();
	
	for (int i = 2; i <= n; i++) {
		if (flag[i] == 999999) {
			check = false;
			break;
		}
	}

	if (check) {
		cout << "Yes" << endl;
		for (int i = 2; i <= n; i++) {
			cout << flag[i] << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}

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

int main() {
  int n, m, x;
  cin>>n>>m>>x;
  int a[m];
  for (int i=0; i<m; i++) cin>>a[i];
  int b[n+1];
  for (int i=0; i<n+1; i++) b[i] = 0;
  for (int i=0; i<m; i++) {
    ++b[a[i]];
  }
  int tmp1 = 0;
  for (int i=x+1; i<n+1; i++) {
    tmp1 += b[i];
  }
  int tmp2 = 0;
  for (int i=x-1; i>=0; i--) {
    tmp2 += b[i];
  }
  cout<<min(tmp1, tmp2)<<endl;
}

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

using namespace std;
#define ll long long


int main()
{
    // Value
    ll H,W;
    vector<vector<bool>> in;
    vector<vector<bool>> out;

    // Input
    cin>>H>>W;
    for(ll i=0;i<H;++i){
        static string line;
        cin >>line;
        in.push_back(vector<bool>());
        for(ll j=0;j<W;++j){
            char* c = ".";
            bool b = line[j] == *c;
            in[i].push_back(b?0:1);
        }
    }

    for(ll i=0;i<H*2;++i){
        out.push_back(vector<bool>());
        for(ll j=0;j<W;++j){
            out[i].push_back(in[i/2][j]);
        }
    }

    // Cal

    // Output
    bool ff = false;
    for(ll i=0;i<2*H;++i){
        if(ff==false){
            ff=true;
        }else{
            cout<<endl;
        }
        for(ll j=0;j<W;++j){
            cout<<(out[i][j]?"*":".");
        }
    }

    // Fin
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a,b;
void solve(){
	cin >> a >> b;
	if(b == 1) cout << 0 << endl;
	else cout << 1+(b-2)/(a-1) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
bool is[U];
int w[U];
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, n;
	cin>>x>>n;
	rep(i, 0, n) cin>>w[i], is[w[i]] = 1;
	rep(i, 0, 55)
	{
		int l = x+i, r = x-i;
		if (is[r] == 0) { cout<<r<<endl; return 0; }
		if (is[l] == 0) { cout<<l<<endl; return 0; }
		
	}
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N; std::string S; std::cin >> N >> S;
  if(N%2 != 0) fin("No");
  N/=2;
  for(int i = 0; i < N; ++i) if(S[i] != S[i+N]) fin("No");
  fin("Yes");
  return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
    
  long long h, w;
  cin >> h >> w;
  if(h == 1 || w == 1)
    cout << 1 << '\n';
  else {
    long long total = h * w;
    cout << total/2 + total%2 << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())
A = [0]
B = [0]
for i in range(n-1):
    if s[i] == "W":
        A.append(A[i]+1)
    elif s[i] == "E":
        A.append(A[i])
    if s[n-i-1] == "E":
        B.append(B[i]+1)
    elif s[n-i-1] == "W":
        B.append(B[i])
m = n
for i in range(n):
    if A[i] + B[n-i-1] < m:
        m = A[i] + B[n-i-1]
print(m)

Measured memory_bytes: 20204
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
const ll INF = 1000000000000007;

using namespace std;

int main(){
    ll N;
    cin >> N;
    vector <ll> X(N,0);
    vector <ll> moto_X(N,0);

    REP(i,N)
    {
      cin >> X[i];
    }
    //元の状態をとっておく
    moto_X = X;

    sort(X.begin(),X.end());

    //1番目を取り除いたもの 
    //値は中央値付近のN/2 or N/2 - 1どちらかになるはず、、、
    //moto_X[i] <= X[N/2 -1] なら X[N/2]が中央値

    REP(i,N)
    {
      if(moto_X[i] <= X[N/2 - 1])
      {
        cout << X[N/2] << endl;
      }
      else
      {
        cout << X[N/2 - 1] << endl;
      }
    }
    return 0;

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    double T, X;
    cin >> T >> X;
    cout << T / X << endl;
    return 0;
}

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

namespace D_After
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int[] a = new int[input.Length + 1];
            a[0] = 0;
            for (int i = 1; i < a.Length; i++)
                a[i] = a[i - 1] ^ (1 << (input[i - 1] - 'a'));

            int[] opt = new int[input.Length + 1];

            Dictionary<int, int> dp = new Dictionary<int, int>();

            opt[0] = 0;

            List<int> X = new List<int>();
            for (int i = -1; i < 26; i++)
            {
                if (i < 0)
                    X.Add(0);
                else
                    X.Add(1 << i);
            }

            Dictionary<int, List<int>> T = new Dictionary<int, List<int>>();

            for (int i = 1; i <= input.Length; i++)
            {
                /*
                // O(n^2) method
                List<int> s = new List<int>();
                for (int j = 0; j < i; j++)
                    if ((a[i] ^ a[j]) == 0 ? true : ((a[i] ^ a[j]) & ((a[i] ^ a[j]) - 1)) == 0)
                        s.Add(j);
                opt[i] = s.Select(x => opt[x]).Min() + 1;
                */

                // O(n) method
                if (!dp.ContainsKey(a[i - 1]))
                    dp.Add(a[i - 1], int.MaxValue);
                dp[a[i - 1]] = dp[a[i - 1]] <= opt[i - 1] ? dp[a[i - 1]] : opt[i - 1];
                opt[i] = X.Select(x => dp.ContainsKey(a[i] ^ x) ? dp[a[i] ^ x] : int.MaxValue).Min() + 1;
            }

            Console.WriteLine(opt[opt.Length - 1]);
# if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 31808
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    string s;cin>>s;
    bool f=1;
    if(s.size()%2)f=0;
    rep(i,s.size()-1){
        if(s[i]=='h'){
            if(s[i+1]!='i')f=0;
        }
        else if(s[i]=='i'){
            if(s[i+1]!='h')f=0;
        }else{
            f=0;
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(y%2!=0 || y<2*x || y>4*x)
    {
        cout<<"No"<<endl;

    }
    else
    {
        cout<<"Yes"<<endl;

    }



}


Measured memory_bytes: 3628
// ConsoleApplication2.cpp : This file contains the 'main' function. Program execution begins and ends there.
//


#include <iostream>
#include <string>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty; string s;
    for(int i=sx;i<tx;i++){
        cout<<"R";
    }
    for(int i=sy;i<ty;i++){
        cout<<"U";
    }
    for(int i=sx;i<tx;i++){
        cout<<"L";
    }
    for(int i=sy;i<ty;i++){
        cout<<"D";
    }
    int a=tx+1;
    cout<<"D";
    for(int i=sx;i<a;i++){
        cout<<"R";
    }
    for(int i=sy;i<ty+1;i++){
        cout<<"U";
    }
    cout<<"LU";
    for(int i=sx;i<tx;i++){
        cout<<"L";
    } cout<<"L";
    for(int i=sy;i<ty;i++){
        cout<<"D";
    } cout<<"DR";
    return 0;
}




Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readline().strip()
    mod = pow(10, 9) + 7
    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt
        res %= mod

    mod = pow(10, 9) + 7
    print(res-1)

if __name__ == "__main__":
    resolve()


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, input;
long long sum = 0;
long long ans;

map<long long, int> M;

int main(){
	scanf("%d", &n);
	M[0LL] = 1;
	for(int i = 1; i <= n; i++){
		scanf("%d", &input);
		sum += input;
		if(M.count(sum)){
			ans += M[sum];
			M[sum]++;
		}else{
			M[sum] = 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 12800
def main():
    N, K, C = map(int, input().split())
    s = input()

    L = [-1] * K
    R = [-1] * K

    i = 0
    cur = 0
    while i < N and cur < K:
        if s[i] == 'o':
            L[cur] = i
            cur += 1
            i += C + 1
        else:
            i += 1

    i = N - 1
    cur = K - 1
    while i >= 0 and cur >= 0:
        if s[i] == 'o':
            R[cur] = i
            cur -= 1
            i -= C + 1
        else:
            i -= 1

    ans = (left + 1 for left, right in zip(L, R) if left == right)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 30076
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
int main() {
    long long n ; 
    cin>>n ; 
    vector <int> prime;
    int t = 0;
    while (n % 2 == 0)  
    {  
        t++;  
        n = n/2;  
    }
    prime.push_back(t);
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        t = 0; 
        while (n % i == 0)  
        {  
            t++; 
            n = n/i;  
        }
        prime.push_back(t);
    }
    if (n > 2)  prime.push_back(1); 
    int number = 0; 
   for(auto x : prime){
       if(x >= 1 && x < 3){
           number += 1;
       }
       else if(x >= 3 && x < 6){
           number += 2;
       }
       else if(x >= 6 && x < 10){
           number += 3;
       }
        else if(x >= 10 && x < 15){
           number += 4;
       }
        else if(x >= 15 && x < 21){
           number += 5;
       }
        else if(x >= 21 && x < 28){
           number += 6;
       }
        else if(x >= 28 && x < 36){
           number += 7;
       }
       else if(x >= 36 && x < 45){
           number += 8;
       }
   }
    cout<<number<<endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N;
  cin >> N;
  bool yellow=false;
  REP(i,N){
    char c;
    cin >> c;
    if(c=='Y')yellow=true;
  }

  cout << (yellow ? "Four" : "Three") << endl;
}



Measured memory_bytes: 256
li =[0]*4
for i in range(3):
  l =[int(i) for i in input().split()]
  for i in l:
    li[i-1] += 1

foo = 0
for i in li:
  if i%2!=0:
    foo += 1
if foo >2:
  print("NO")
else:
  print("YES")

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<lint, lint> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
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;
}
//

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

  lint n, m;
  cin >> n >> m;

  priority_queue<P, vector<P>, greater<P>> ab;
  priority_queue<P> que;
  rep(i, n) {
    lint a, b;
    cin >> a >> b;
    ab.push(P(a, b));
  }

  lint ans = 0;
  int d = 1;
  ab.push(P(INF, INF));
  while (d <= m) {
    P p = ab.top();

    // cout << d << " " << p.first << " " << p.second << endl;

    if (p.first <= d) {
      que.push(P(p.second, p.first));
      ab.pop();
    } else {
      if (que.empty()) {
        d++;
        continue;
      }
      P pp = que.top();
      que.pop();
      ans += pp.first;
      d++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(){
    ll n;
    ll h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
}

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

const int M = 1e9+7;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    int sum = 0;
    for(int i = 1; i <= n; i++) {
        if(i % 3 == 0 && i % 5 == 0) continue;
        if(i % 3 == 0 && i % 5 != 0) continue;
        if(i % 3 != 0 && i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 3640
n = gets.to_i
m = gets.to_i
es = []
m.times do
  a, b, c, d = gets.split(?,).map(&:to_i)
  es << [a-1, b-1, c]
  es << [b-1, a-1, d]
end
s, g, v, p = gets.split(?,).map(&:to_i)
s, g = s-1, g-1
bf = lambda do |s, g|
  cs = Array.new n
  cs[s] = 0
  (n-1).times do
    es.each do |a, b, c|
      if cs[a] && (!cs[b] || cs[a] + c < cs[b])
        cs[b] = cs[a] + c
      end
    end
  end
  cs[g]
end
p v - (p + bf[s, g] + bf[g, s])

Measured memory_bytes: 8652
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-16 22:01
# @url:https://atcoder.jp/contests/abc052/tasks/arc067_a
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    mod=10**9+7
    d=[0]*(n+1)
    def check(x):
        for i in range(2,math.ceil(math.sqrt(x))+1):
            if x%i==0:
                return False
        return True
    q=[2]
    for j in range(3,1001):
        if check(j):
            q.append(j)
    while n>1:
        temp=n
        while temp!=1:
            for i in q:
                if temp%i==0:
                    d[i]+=1
                    temp=temp//i
                    break
        n=n-1
    ans=1
    for x in d:
        if x!=0:
            ans=ans*(x+1)
    print (ans%mod)
if __name__ == "__main__":
    main()

Measured memory_bytes: 77604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int mod = 0;
    for (int i = 0; i < s.size(); ++i) {
        mod = (mod + s[i]-'0')%9;
    }
    if (mod) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
using namespace std;
int gcd(int a,int b){
    while(b!=0){
        int t=a%b;
        a=b;
        b=t;
    }
    return a;
}
int main(){
    int n;
    while(~scanf("%d",&n)){
        int sum=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                for(int k=1;k<=n;k++){
                    sum+=gcd(i,gcd(j,k));
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3828
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(); 
		int x=sc.nextInt(); 
		int t=sc.nextInt(); 
		
		int min=(n+x-1)/x;
		
		int result=(min)*t;
		
		System.out.println(result);
	}

}


Measured memory_bytes: 35616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    ll D,T,S;
    cin>>D>>T>>S;

    double time=((double)D)/S;
    if(time<=T)
        cout<<"Yes\n";
    else cout<<"No\n";

}


Measured memory_bytes: 3636
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double hensai = 100000;
        for(int i=0;i<n;i++){
            hensai *= 105;
            hensai = (long)Math.ceil((double)hensai/100000);
            hensai *=1000;
        }    
        System.out.println((long)hensai);
    }
}

Measured memory_bytes: 17164
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

ll n, ans;
ll p[100001];
int idx[100001];
set<int> s;
int main(void) {
    int i, x;
    cin >> n;
    rep1(i,n) {
        cin >> p[i];
    }
    rep1(i,n) {
        idx[p[i]] = i;
    }
    rrep1(i,n) {
        x = idx[i];
        s.insert(x);
        ll l[2] = {}, r[2] = {}, l1, l2, r1, r2;
        auto it = s.find(x);
        do {
            if (it == s.begin()) break;
            rep(j,2) {
                --it;
                l[j] = *it;
                if (it == s.begin()) break;
            }
        } while (0);
        it = s.find(x);
        rep(j,2) {
            ++it;
            if (it == s.end()) break;
            r[j] = *it;
        }
        l1 = x-l[0];
        if (l[0] == 0) l2 = 0; else l2 = l[0]-l[1];
        if (r[0] == 0) {
            r1 = n-x+1;
            r2 = 0;
        } else {
            r1 = r[0]-x;
            if (r[1] == 0) {
                r2 = n-r[0]+1;
            } else {
                r2 = r[1]-r[0];
            }
        }
        //cout << l1 << l2 << r1 << r2 << n << endl;
        ans += i*(l2*r1+r2*l1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> istream& operator>>(istream &is, pair<S, T> &p){ return is >> p.first >> p.second; }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ return os << "[" << p.first << ", " << p.second << "]"; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rof(i, n) for(int i = (n)-1; i >= 0; i --)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)
#define Return(x) { Cout(x); return 0; }

// constexpr int MOD = 1e9+7;

struct UFT{
    vector<int> par;
    vector<int> pot;
    UFT(int n) : par(vector<int>(n)), pot(vector<int>(n, 0)){ For(i, n) par[i] = i; }
    bool unite(int x, int y, int d){
        int px = find(x), py = find(y);
        d += pot[x] - pot[y];
        if(px == py){
            if(pot[py] - pot[px] != d) return false;
        }
        else{
            par[py] = px;
            pot[py] = d;
        }
        return true;
    }
    int find(int x){
        if(par[x] == x) return x;
        int root = find(par[x]);
        pot[x] += pot[par[x]];
        return par[x] = root;
    }
    void print() const{ Couts(par); Couts(pot); }
};

int main(void){
    Cin(int, n, m);
    UFT u(n+1);
    Rep(m){
        Cin(int, l, r, d);
        if(!u.unite(l, r, d)) Return("No");
    }
    Cout("Yes");
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  vector<int> v[2];
  int dp[2][2][22222];
  mem(dp);
  int c=0,t=0,f=1,M=10000;
  rep(i,s.size()) {
    if(s[i]=='F') c++;
    else {
      if(f) dp[0][0][M+c]=1;
      else v[t].pb(c);
      c=0;
      t^=1;
      f=0;
    }
  }
  if(c) {
    if(f) dp[0][0][M+c]=1;
    else v[t].pb(c);
  }
  dp[1][0][M]=1;
  int z[2];
  cin >> z[0] >> z[1];
  rep(k,2) {
    t=0;
    rep(i,v[k].size()) {
      rep(j,22222) {
        if(j-v[k][i]>=0) dp[k][t^1][j-v[k][i]]|=dp[k][t][j];
        if(j+v[k][i]<22222) dp[k][t^1][j+v[k][i]]|=dp[k][t][j];
      }
      mem(dp[k][t]);
      t^=1;
    }
    if(!dp[k][t][M+z[k]]) {
      pr("No");
      return;
    }
  }
  pr("Yes");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 2e5 + 1;
int dp[N][2];
signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    dp[0][0] = 0;
    dp[0][1] = v[0];
    dp[1][0] = max(v[0], v[1]);
    dp[1][1] = max(v[0], v[1]);
    for (int i = 2; i < n; ++i) {
        if ((i + 1) % 2) {
            dp[i][0] = max(dp[i - 1][0], dp[i - 2][0] + v[i]);
            dp[i][1] = dp[i - 2][1] + v[i];
        } else {
            dp[i][0] = max(dp[i - 2][0] + v[i], dp[i - 1][1]);
            dp[i][1] = dp[i][0];
        }
    }

    cout << dp[n - 1][0];
}


Measured memory_bytes: 7952
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)
#define PI 3.14159265358979323846

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    long double a, b;
    cin >> a >> b;
    long double ans = a * b;

    cout << (ll)ans << endl;

    return 0;
}

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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

int main(){
    int a, b; cin >> a >> b;
    if( a >= 10 || b >= 10 ) cout << -1 << endl;
    else cout << a * b << endl;
}


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


int main()
{
	string a, b;
	cin >> a >> b;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	if (a < b) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
}


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

int n, k;

int a[101];
int memo[100010][2];

int fPlayer(int);
int sPlayer(int);

int fPlayer (int wt) { // first
	//cout << "first player with wt = " << wt << "\n";
	if (wt < a[0]) { // impossible
	//	cout << "first loses with wt = " << wt << "\n";
		memo[wt][0] = 0; // f lost
		return 0;
	}
	if (memo[wt][0] != -1) {
	//	cout << "1already known " << memo[wt][0];
		return memo[wt][0];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] <= wt) {
			if (sPlayer(wt - a[i])) // second wins
				continue;
			else {
				memo[wt][0] = 1;
				return 1;
			}
		}
	}
	memo[wt][0] = 0;
	return 0;
}

int sPlayer (int wt) { // second
	//cout << "second player with wt = " << wt << "\n";
	if (wt < a[0]) {
	//		cout << "second loses with wt = " << wt << "\n";
		memo[wt][1] = 0;
		return 0; // s lost
	}
	if (memo[wt][1] != -1) {
		cout << "";
	//	cout << "memo[" << wt << "][" << "1] = " << memo[wt][1] << "\n";
		return memo[wt][1];
	//	cout << "already known " << memo[wt][1];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] <= wt) {
			if (fPlayer(wt - a[i])) // first player wins
				continue;
			else {
				memo[wt][1] = 1;
				return 1;
			}
		}
	}
	memo[wt][1] = 0;
	return 0;
}

int main () {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i <= k; i++) // TODO <= is important
		for (int j = 0; j < 2; j++)
			memo[i][j] = -1;
//	for (int i = 0; i <= k; i++) 	// TODO <= is important!
//		for (int j = 0; j < 2; j++)
//			cout << memo[i][j] << " ";
	if (fPlayer(k))
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}

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

int n, m, sum;
int main()
{
	cin >> n >> m >> sum;
	if (sum < 1000000000)
	{
		for (int i = 1; i <= n; ++i)
			printf("%d ", i<=m?sum:1000000000);
	}
	else
	{
		for (int i = 1; i <= n; ++i)
			printf("%d ", i<=m?sum:sum-1);
	}
	printf("\n");
}

Measured memory_bytes: 3700
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int a, b;
    std::cin >> a >> b;

    std::cout << std::max(a - b * 2, 0) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll a,b;
  ll k;
  cin >> a >> b >> k;
  for (int i = 0; i < k; i++) {
    if (i %2 == 0) {
      //akunn
      if (a %2 == 1) {
        a--;
      }
      b += a/2;
      a = a/2;
    }
    else {
      //b
      if (b %2 == 1) {
        b--;
      }
      a += b/2;
      b = b/2;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

typedef  long long int ll;
char s[11];
int l;

ll func(int plus){
	ll ret = 0;
	ll cur = 0;
	for(int i=0;i<l;i++){
		cur *= 10;
		cur += s[i] - '0';
		if(i==l-1||(plus>>i)&1){
			ret += cur;
			cur = 0;
		}
	}
	ret += cur;
	return ret;
}

int main(){
	ll ans = 0;
	scanf("%s",s);
	l = strlen(s);
	for(int i=0;i<(1<<(l-1));i++){
		ans += func(i);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

constexpr lint mod = 1e9 + 7;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> x(n); for (int i = 0; i < n; i++) cin >> x[i];
  lint res = 1;
  int s = 0;
  for (int i = 1; i < n; i++) {
    (res *= i + 1 - s) %= mod;
    if (x[i] < 2 * (i - s) + 1) s++;
  }
  cout << emod(res) << '\n';
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt() - i;
		}
		Arrays.sort(arr);
		int a = arr[n / 2];
		int b = arr[Math.max(n / 2 - 1, 0)];
		long totalA = 0;
		long totalB = 0;
		for (int i = 0; i < n; i++) {
			totalA += Math.abs(arr[i] - a);
			totalB += Math.abs(arr[i] - b);
		}
		System.out.println(Math.min(totalA, totalB));
	}
}


Measured memory_bytes: 66268