akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

void dfs(int r,vector<vector<int>> &g,vector<int> &comp,int cnt){
	comp[r]=cnt;
	for(auto x:g[r]){
		if(comp[x]<0)dfs(x,g,comp,cnt);
	}
}

int main()
{
	int n,m;
	cin>>n>>m;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	vector<vector<int>> g(n,vector<int>());
	rep(i,m){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	if(m==n-1){
		cout<<0<<endl;
		return 0;
	}
	vector<int> comp(n,-1);
	int cnt=0;
	rep(i,n){
		if(comp[i]<0){
			dfs(i,g,comp,cnt);
			cnt++;
		}
	}
	// cnt=n-m;
	// cout<<"cnt = "<<cnt<<endl;

	if(2*(cnt-1)>n){
		cout<<"Impossible"<<endl;
		return 0;
	}

	vector<multiset<ll>> s(cnt);
	rep(i,n){
		s[comp[i]].emplace(a[i]);
	}
	priority_queue<ll,vector<ll>,greater<ll>> que;

	ll ans=0;
	int num=0;
	rep(i,cnt){
		ans+=*s[i].begin();
		// s[i].erase(*s[i].begin());
		num++;
	}
	rep(i,cnt){
		auto itr = s[i].begin();
		itr++;
		for(; itr!=s[i].end(); ++itr)que.push(*itr);
	}
	while(num<2*(cnt-1)){
		ans+=que.top();que.pop();
		num++;
	}
	cout<<ans<<endl;

	
	return 0;
}

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

int main(){
    char a[3]={};
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    bool isYes=false;
    char p=a[0];
    for(int i=1;i<3;i++ ){
        if(p!=a[i]){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int n, c;
  cin >> n >> c;
  int a[n];
  int b[n];
  for (int i=0; i<n; i++){
      cin >> a[i];
  }
  for (int i=0; i<n; i++){
      cin >> b[i];
  }
  long long buckets[c+1] = {0};
  buckets[0] = 1;
  
  for (int i=n-1; i>=0; i--){
      int cura = a[i];
      int curb = b[i];
      long long newbuckets[c+1] = {0};
      for (int j=cura; j<=curb; j++){
          long long temp[c+1] = {0};
          temp[0] = buckets[0];
          newbuckets[0] += temp[0];
          newbuckets[0] %= mod;
          for (int k=1; k<=c; k++){
              temp[k] += mymod(buckets[k]+mymod(temp[k-1]*j));
              temp[k] %= mod;
              newbuckets[k] += temp[k];
              newbuckets[k] %= mod;
          }
      }
      
      for (int k=0; k<=c; k++){ 
          buckets[k] = newbuckets[k];
          //cout << buckets[k] << " ";
      }
      //cout << endl;
  }
  cout << buckets[c];
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[2000];
ll dp[2000][2000];
ll mod=1000000007;
ll solve(ll n,ll m)
{
   if(n<0 || m<0)
    return 0;
   if(dp[n][m] != -1)
    return dp[n][m];
   if(n==0 && m==0)
    return 1;
   if(s[n][m]=='#')
    return 0;
   dp[n][m]=(solve(n,m-1)%mod+solve(n-1,m)%mod)%mod;
   return dp[n][m];
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>s[i];
    memset(dp, -1, sizeof(dp));
    cout<<solve(n-1,m-1);
}


Measured memory_bytes: 32640
#include <iostream>
#include <cmath>
#include <cctype>
#include<cstdio>
#include <string>
#include<algorithm>
using namespace std;
int main(){
    string s;
    cin>>s;
    transform(s.begin(),s.end(),s.begin(),::toupper);
    int ans=0;
    while(true){
        string u;
        cin>>u;
        if(u=="END_OF_TEXT")break;
        transform(u.begin(),u.end(),u.begin(),::toupper);
        if(s==u)ans++;
        
        
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3240
#include <iostream>

using namespace std;

static const int MAX = 100;
int cnt = 0;

void trace(int *a, int n) {
    for (int i = 0; i < n; i++) {
        if(i > 0) cout << ' ';
        cout << a[i];
    }
    cout << '\n';
}

void selection_sort(int *a, int n) {
    int mini, tmp;
    for (int i = 0; i < n; i++){
        mini = i;
        for (int j = i; j < n; j++){
            if (a[j] < a[mini]) {
                mini = j;
            }
        }
        if (i != mini){
            tmp = a[i];
            a[i] = a[mini];
            a[mini] = tmp;
            cnt++;
        }
    }
}


int main(){
    int R[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];

    selection_sort(R, n);
    trace(R, n);
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int mod = (int)1e9 + 7;
char in[1000001];
int pos;

#define RETURN \
	RES.pb(res); \
	if(RET.back() == 1) goto EXPR1; \
	if(RET.back() == 2) goto EXPR2; \
	if(RET.back() == 11) goto TERM1; \
	if(RET.back() == 12) goto TERM2; \
	if(RET.back() == 21) goto FACTOR1; \
	if(RET.back() == 22) goto FACTOR2;

pi expr(){
	vi RET;
	vector<pi> RES;
	vector<bool> NEG;
	pi res, tmp; bool neg;
	ll f, t;
	
	EXPR:
	RET.pb(1);
	goto TERM;
	EXPR1:
	res = RES.back(); RES.pop_back(); RET.pop_back();
	while(in[pos] == '|'){
		pos++;
		RET.pb(2);
		RES.pb(res);
		goto EXPR;
		EXPR2:
		tmp = RES.back(); RES.pop_back(); RET.pop_back();
		res = RES.back(); RES.pop_back();
		f = (ll)res.S * tmp.S;
		t = ll(res.F + res.S) * (tmp.F + tmp.S) - f % mod + mod;
		res = mp(t % mod, f % mod);
	}
	if(RET.empty()) return res;
	RETURN
	
	TERM:
	RET.pb(11);
	goto FACTOR;
	TERM1:
	res = RES.back(); RES.pop_back(); RET.pop_back();
	while(in[pos] == '&'){
		pos++;
		RES.pb(res);
		RET.pb(12);
		goto FACTOR;
		TERM2:
		tmp = RES.back(); RES.pop_back(); RET.pop_back();
		res = RES.back(); RES.pop_back();
		t = (ll)res.F * tmp.F;
		f = ll(res.F + res.S) * (tmp.F + tmp.S) - t % mod + mod;
		res = mp(t % mod, f % mod);
	}
	RETURN
	
	FACTOR:
	neg = 0;
	while(in[pos] == '~') neg ^= 1, pos++;
	if(in[pos] == 'x'){
		RET.pb(21);
		NEG.pb(neg);
		goto VAR;
		FACTOR1:
		neg = NEG.back(); NEG.pop_back(); RET.pop_back();
		res = RES.back(); RES.pop_back();
		RETURN
	}
	assert(in[pos] == '(');
	pos++;
	RET.pb(22);
	NEG.pb(neg);
	goto EXPR;
	FACTOR2:
	res = RES.back(); RES.pop_back(); RET.pop_back();
	neg = NEG.back(); NEG.pop_back();
	if(neg) swap(res.first, res.second);
	pos++;
	RETURN
	
	VAR:
	assert(in[pos] == 'x');
	pos++;
	while(isdigit(in[pos])) pos++;
	res = mp(1, 1);
	RETURN
}

int main(){
	gets(in);
	cout << expr().first << endl;
	return 0;
}

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

using namespace std;
using lint = long long;


int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if (max(a,c)>min(b,d)) {
        
        cout<<"0"<<endl;
    }else{
        cout<<min(b,d)-max(a,c)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    ci(s);
  ll k;
    ci(k);
  ll n=s.sz;

  vst A(0);

  FOR(i,0,n){
    FOR(j,1,k+1){
      st t=s.substr(i,j);
      A.push_back(t);
    }
  }

  SORT(A);
  n=A.sz;
  ll count=1;
  FOR(i,1,n){
    if(A[i-1]!=A[i]){
      count++;
    }

    if(count==k){
      co(A[i])
      break;
    }
  }
  if(s.sz==1){
    co(s)
  }
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,k,ans=0;
    string s;
    cin >> n >> k >> s;
    rep(i,n-1){
        if(s[i]==s[i+1]) ans++;
    }
    cout << min(n-1,ans+2*k) << endl;
}


Measured memory_bytes: 512
using System;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var N = int.Parse(Console.ReadLine());

            var max1 = 0;
            var max2 = 0;
            var A = new int[N];
            for (var i = 0; i < N; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
                if (max1 < A[i])
                {
                    max2 = max1;
                    max1 = A[i];
                }
                else if (max2 < A[i])
                {
                    max2 = A[i];
                }
            }

            for (var i = 0; i < N; i++)
            {
                if (A[i] == max1)
                {
                    Console.WriteLine(max2);
                }
                else
                {
                    Console.WriteLine(max1);
                }
            }
        }
    }
}


Measured memory_bytes: 18608
n, tm = map(int, input().split())
ctl = []
for i in range(n):
    c, t = map(int, input().split())
    ctl.append([c, t])

filctl = []
for elm in ctl:
    if elm[1] <= tm:
        filctl.append(elm)
if len(filctl) != 0:
    filctl = sorted(filctl)
    print((filctl[0])[0])
else:
    print("TLE")

Measured memory_bytes: 3060
import math

n, k = map(int,input().split())
log_k = math.log2(k)
p = 0

for i in range(1,n+1):
    j = math.ceil(log_k - math.log2(i))
    if j<0:
        j = 0
    p += (1/n)*(1/2)**j

print(p)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}


int main() {
    int n,y;
    cin >> n >> y;
    string ans = "-1 -1 -1";
    for(int i = 0;i <= n;++i){
        for(int j = 0;j <= n-i;++j){
            int k = n-i-j;
            if(y == i*10000+j*5000+k*1000){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
template<typename Iterator>void print(const Iterator &s, const Iterator &t) { for(auto it=s;it+1!=t;++it)cout<<*it<<" ";cout<<*(t-1)<<"\n"; }
const int MOD = 1e9+7;

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

  int T[N], A[N];
  int h[N];
  fill(h, h+N, -1);
  rep(i, N) {
    in(T[i]);
    if (i == 0 || T[i] > T[i-1])
      h[i] = T[i];
  }
  rep(i, N) in(A[i]);

  if (h[N-1] != -1 && h[N-1] != A[N-1]) {
    out(0);
    return 0;
  }
  h[N-1] = A[N-1];
  rep(i, N-1) {
    if (A[i] > A[i+1]) {
      if (h[i] == -1 || h[i] == A[i])
        h[i] = A[i];
      else {
        out(0);
        return 0;
      }
    }
  }
  rep(i, N) {
    if (h[i] != -1) {
      if (h[i] > T[i] || h[i] > A[i]) {
        out(0);
        return 0;
      }
    }
  }
  ll ans = 1;
  rep(i, N) {
    if (h[i] == -1)
      ans = (ll)(ans * min(T[i], A[i])) % MOD;
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;

  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  std::cout << (gap_num+1) << '\n';

  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';

  std::cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

Measured memory_bytes: 5100
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }

    void solve(){
        int n;
        cin>>n;
        vector<ll>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        ll total=0;
        for(int i=1;i<n;i++){
            if(a[i]<a[i-1]){
                total+=a[i-1]-a[i];
                a[i]=a[i-1];
            }
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 4776
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func cmpStrNum(a, b string) bool {
	if a == "---" {
		return true
	}
	if len(a) < len(b) {
		return true
	} else if len(a) > len(b) {
		return false
	}
	return a < b
}

func main() {
	line := nextLine()

	spl := intSprit(line)

	N := spl[0]

	a := intSprit(nextLine())
	tb := []int{2, 5, 5, 4, 5, 6, 3, 7, 6}

	dp := make([]string, 100000)
	for i := 1; i < len(dp); i++ {
		dp[i] = "---"
	}
	dp[0] = ""

	for i := 0; i <= N; i++ {
		if dp[i] == "---" {
			continue
		}
		for _, v := range a {
			if cmpStrNum(dp[i+tb[v-1]], dp[i]+strconv.Itoa(v)) {
				dp[i+tb[v-1]] = dp[i] + fmt.Sprint(v)
			}
		}
	}
	fmt.Println(dp[N])
}


Measured memory_bytes: 131392
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

s = sum(A)

x = 0
ans = 1 << 60
for a in A[:-1]:
    x += a
    ans = min(ans, abs(s - 2 * x))

print(ans)

Measured memory_bytes: 24416
#include <stdio.h>
#include <iostream>
#define Re register int
#define LL long long

int N,M,cnt[45][2];
LL K,X,A[100005],ans;

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	var=w?-x:x;
}
inline int max(int a,int b) {return a>b?a:b;}
int main(int argc, char const *argv[])
{
	//freopen("1.in","r",stdin);
	read(N),read(K);
	for (Re i=1; i<=N; ++i) read(A[i]);
	for (Re i=1; i<=N; ++i)
		for (Re j=40; j>=0; --j)
			++cnt[j][A[i]&(1LL<<j)?1:0];
	for (Re i=40; i>=0; --i)
	{
		if (K<(1LL<<i)) continue;
		if (cnt[i][1]<cnt[i][0])
			if (X+(1LL<<i)<=K) X+=(1LL<<i);
	}
	for (Re i=1; i<=N; ++i) ans+=X^A[i];
	printf("%lld\n",ans); return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long n,m;
	cin>>n>>m;
	if(n==1||m==1) cout<<1<<endl;
	else cout<<(n+1)/2*((m+1)/2)+n/2*(m/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  string s;
  cin >>s;
  set<char> se;
  rep(i,s.length()) {
    se.insert(s[i]);
  }
  if(se.size()==s.length())cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  ll A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  ll diff = V - W;
  if(abs(B-A) <= T*diff){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
n=int(input())
dp=[[0 for i in range(3)] for i in range(n)]
dp[0]=list(map(int,input().split()))
for i in range(1,n):
    S=list(map(int,input().split()))
    for j in range(3):
        dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+S[j]

print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))
#dp[i][j]=i番目にjを選んだ時の最大値(jはa,b,cに対応している。)

Measured memory_bytes: 87616
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,m,x;
int a[1000000];

int main(){
  cin>>n>>m>>x;
  rep(i,m){
    int b;
    cin>>b;
    a[b]++;
  }

  int suma=0,sumb=0;

  for(int i=x;i<n;i++){
    sumb+=a[i];
  }
  for(int i=0;i<x;i++){
    suma+=a[i];
  }

  cout<<min(suma,sumb)<<endl;

  return 0;
}


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

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

  vector<int>x,y;
  for(int i=0;i<=f/100;++i){
    for(int j=0;j<=f/100;++j){
        if(100*a*i+100*b*j<=f&&100*a*i+100*b*j>0){
            x.push_back(100*a*i+100*b*j);
        }
    }
  }

  for(int i=0;i<f;++i){
    for(int j=0;j<f;++j){
        if(c*i+d*j<=f&&c*i+d*j>=0){
            y.push_back(c*i+d*j);
        }
    }
  }

  double m=0;
  int water,sugar;
  for(int i=0;i<x.size();++i){
    for(int j=0;j<y.size();++j){
        if(x[i]+y[j]<=f&&(double)y[j]/(x[i]/100)<=e){
            if((double)y[j]/(x[i]+y[j])>=m){
              m=(double)y[j]/(x[i]+y[j]);
              water=x[i];
              sugar=y[j];
            }
        }
    }
  }

  cout << water+sugar << " " << sugar << endl;

  return 0;
}


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

using namespace std;
int main(){
    int n,m;cin>>n>>m;

    if(n<=m) cout << "unsafe" << endl;                                                                                   else cout << "safe" << endl;                                                                                     
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


const ll INF = 1e18;

int N;
ll D, X[35], Y[35];
ll len[2] = {};
vector<PLL> h[2];
void dfs(int id, int l, int r, ll x = 0, ll y = 0) {
	if (l == r) {
		h[id].emplace_back(x, y);
		return;
	}
	dfs(id, l + 1, r, x, y);
	dfs(id, l + 1, r, x + X[l], y + Y[l]);
	dfs(id, l + 1, r, x - X[l], y - Y[l]);
}
int main() {
	cin >> N >> D;
	rep(i, N) cin >> X[i] >> Y[i];
	dfs(0, 0, N / 2);
	dfs(1, N / 2, N);
	sort(h[0].begin(), h[0].end(), greater<>());
	sort(h[1].begin(), h[1].end());
	ll l = 0, r = 0;
	deque<ll> que;
	ll ans = -INF;
	rep(i, h[0].size()) {
		while (r < h[1].size() && h[0][i].first + h[1][r].first <= D)
		{
			while (!que.empty() && que.back() < h[1][r].second) que.pop_back();
			que.push_back(h[1][r].second);
			r++;
		}
		while (l < h[1].size() && h[0][i].first + h[1][l].first < -D) {
			if (!que.empty() && que.front()==h[1][l].second) que.pop_front();
			l++;
		}
		if (!que.empty()) ans = max(ans, h[0][i].second + que.front());
	}

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



Measured memory_bytes: 489128
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

template<typename T>
struct MP {
    int n;
    T t;
    vector<int> a;
    MP() {}
    MP(const T t): t(t) {
        n = t.size();
        a = vector<int>(n+1);
        a[0] = -1;
        int j = -1;
        for (int i = 0; i < n; ++i) {
            while(j != -1 && t[j] != t[i]) j = a[j];
            j++;
            a[i+1] = j;
        }
    }
    int operator[](int i) { return a[i];}
    vector<int> findAll(const T& s){
        vector<int> res;
        int j = 0;
        for (int i = 0; i < s.size(); ++i) {
            while(j != -1 && t[j] != s[i]) j = a[j];
            j++;
            if (j == n) {
                res.push_back(i - j + 1);
                j = a[j];
            }

        }
        return res;
    }

};

vector<int> f(vector<int>& a) {
    int n = a.size();
    vector<int> res(n);
    rep(i, n) res[i] = a[i]^a[(i+1)%n];
    return res;
}


int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<int> xa = f(a);
    vector<int> xb = f(b);
    MP<vector<int>> mp (xa);
    xb.insert(xb.end(), xb.begin(), xb.end());
    vector<int> res = mp.findAll(xb);
    vector<int> ks;
    for (int p : res) ks.push_back(n-p);
    sort(ks.begin(), ks.end());
    for (int k: ks) {
        if (k >= n) continue;
//        cout << k << endl;
        int x = a[k]^b[0];
        printf("%d %d\n", k, x);
    }
    return 0;

}

Measured memory_bytes: 11616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc155/tasks/abc155_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long a = inputLongArray[0];
            long b = inputLongArray[1];
            long c = inputLongArray[2];

            if(a == b)
            {
                if(b == c)
                {
                    Console.WriteLine("No");
                }
                else
                {
                    Console.WriteLine("Yes");
                }
            }
            else
            {
                if(b == c && a != c)
                {
                    Console.WriteLine("Yes");
                }
                else if (b != c && a == c)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11348
// in the name if Allah
// YA Ali!
#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const ll INF = 1<<30 ;
const ll N= 1e6 ;

#define f first
#define s second

ll n , a[N] , ans = 0  , b[N] ;

int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
for(int i = 1 ; i <= n+1 ; i ++)cin >> a[i] ;
for(int i = 1 ; i <= n ; i ++){
    cin >> b[i] ;
    if(b[i] <= a[i]){
        a[i] -= b[i] ;
        ans += b[i] ;
    }
    else{
        ans += a[i] ;
        b[i] -= a[i] ;
        a[i] = 0 ;
        if(b[i] <= a[i+1]){
            a[i+1] -= b[i] ;
            ans += b[i] ;
        }
        else{
            ans += a[i+1] ;
            a[i+1] =0 ;
        }
    }
}
cout << ans ;
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll N = 720006;
const ll INF = 1e18;
vector<ll> p(N);

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

    ll n, m, x;
    cin >> n >> x >> m;
    for(ll i = 0; i < m; i++) {
        p[i] = (i * i) % m;
    }

    ll st = x % m;
    ll ans = 0;
    ll cur = 0;
    vector<bool>seen(m + 1, false);
    seen[st] = true;
    ans += st;
    cur++;
    st = p[st];
    
    while(cur < n && !seen[st]) {
        ans += st;
        cur++;
        seen[st] = true;
        st = p[st];
    }
    if(cur == n) {
        cout << ans << '\n';
        return 0;
    }

    vector<ll> cyc;
    ll nd = st;
    while(p[st] != nd) {
        cyc.pb(st);
        st = p[st];
    }
    cyc.pb(st);
    for(int i = 1; i < cyc.size(); i++) {
        cyc[i] += cyc[i - 1];
    }


    n -= cur;
    ans += cyc.back() * (n / (ll) cyc.size());
    if(n % (ll) cyc.size()) {
        ans += cyc[(n % (ll) cyc.size()) - 1];
    }
    cout << ans << '\n';

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()


void fast() {

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



int main() {
    fast();
    int n;
    cin>>n;
    vector<int>v;
    int A[n];
    int B[n];
    int cnt1=0;
    int cnt2=0;
    int cnt=0;
    for (int j = 0; j <n ; ++j) {
        cin>>A[j];
    }
    for (int j = 0; j <n ; ++j) {
        cin>>B[j];
    }
    for (int i = 1; i <=n ; ++i) {
        v.push_back(i);
    }

    do{
        cnt++;
        bool a=true;
        bool b=true;
        for (int i = 0; i <n ; ++i) {
            if(v[i]!=A[i])a=false;
            if(v[i]!=B[i])b=false;
        }
        if(a)cnt1=cnt;
        if(b)cnt2=cnt;
        if(a&&b)break;
    }while(next_permutation(all(v)));
    cout<<abs(cnt1-cnt2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DEBUG(x)                   cout << '>' << #x << ':' << x << endl;
int arr[110000];
int main()
{
    string s;
    int n,k,q,a;
    cin>>n>>k>>q;
    for(int i=0;i<q;i++)
    {
        cin>>a;
        if(a==1)
        {
            arr[2]--;
        }
        else if(a==n)
        {
            arr[1]--;
            arr[n]++;
        }
        else
        {arr[1]--;
        arr[a]++;
        arr[a+1]--;
        arr[n+1]++;}
    }
    ll cnt=0;
    for(int i=1;i<=n;i++)
    {
        cnt+=arr[i];
        if(cnt+k>0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;


    }
    return 0;
}




Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int w, h, x, y, r;
int main() {
	cin >> w >> h >> x >> y >> r;
	if (x < r || y < r) {
		cout << "No" << endl;
	}
	else if (x + r <= w && y + r <= h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

#define SZ(v) ((int)(v).size())
using ll = long long;

const int MAXP = 60;
const int MAXN = 2e5;

int nxt[MAXP][MAXN];

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

	ll N, K;
	cin >> N >> K;
	for (int i(0); i < N; ++i)
	{
		cin >> nxt[0][i];
		--nxt[0][i];
	}
	for (ll p(1); p < MAXP; ++p)
		for (int i(0); i < N; ++i)
			nxt[p][i] = nxt[p-1][nxt[p-1][i]];

	int cur(0);
	for (ll p(0); p < MAXP; ++p)
		if ((1LL<<p) & K)
			cur = nxt[p][cur];
	cout <<cur+1 << endl;
}


Measured memory_bytes: 50528
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, q; cin >> n >> q;
	VI x(q), y(q), z(q);
	vector<VI> a(n);
	rep(i, q) {
		cin >> x[i];
		if (x[i] == 0)cin >> y[i] >> z[i];
		else cin >> y[i];
	}

	rep(i, q) {
		if (x[i] == 0) {
			a[y[i]].pb(z[i]);
		}
		else if (x[i] == 1) {
			rep(j, SZ(a[y[i]])) {
				cout << a[y[i]][j];
				if (j != SZ(a[y[i]]) - 1)cout << " ";
			}
			puts("");
		}
		else if (x[i] == 2) {
			if (!a[y[i]].empty())a[y[i]].clear();
		}
	}
}


Measured memory_bytes: 11664
/* Simplicity and Goodness */
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg()
{
    cout << endl;
}
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{
    cout << ' ' << A;
    my_dbg(B...);
}
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, k;
    scn(n);
    scn(k);

    vi a(n);

    for(int& i : a)
        scn(i);

    vector<bool> dp(k+1, 0);
    // dp[i] = TRUE if first player wins when i stones are left.

    for(int stones = 0; stones <= k; stones ++)
    {
        //see(stones)
        for(int x : a)
        {
            if(stones >= x and !dp[stones - x])
            {
                   dp[stones] = 1;
                   //see(x)
            }
        }
    }

    puts(dp[k]? "First": "Second");
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --)
    {
        solve();
    }
    return 0;
}


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

int main(){
bool cards[4][14];
int n,rank;
char mark;
for(int i=0;i<4;i++){
for(int j=1;j<=13;j++){
cards[i][j]=0;
}
}
cin >>n;
for(int i=0;i<n;i++){
cin >>mark >>rank;
if(mark=='S') cards[0][rank]=1;
if(mark=='H') cards[1][rank]=1;
if(mark=='C') cards[2][rank]=1;
if(mark=='D') cards[3][rank]=1;
}

for(int i=0;i<4;i++){
for(int j=1;j<=13;j++){
if(cards[i][j]) continue;
if(i==0) mark='S';
if(i==1) mark='H';
if(i==2) mark='C';
if(i==3) mark='D';
cout <<mark <<" " <<j <<endl;
}
}
return 0;
}

Measured memory_bytes: 3064
n,m = list(map(int,input().split()))

a = n //2
b = a + 1
abset = set()

for i in range(m):
    print(a,b)
    abset.add(b-a)
    abset.add(n-b+a)
    a -= 1
    b += 1
    if n % 2 == 0 and (b - a == abs(n - b + a) or b - a in abset or n - b + a in abset):
        b += 1

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

int main(void)
{
  int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
// 配列の添字は 0 から始まるので，a [0] は 0 にしている．
  int x , y ; 
  cin >> x >> y ;
  cout << ( a [ x ] == a [ y ] ? " Yes " : " No ") << endl ;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    cout << (S == "abc" ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>


#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

using ll = unsigned long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

namespace mp = boost::multiprecision;
using BigInt = mp::cpp_int;


int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) {
		cin >> l[i];
	}
	int count = 0;
	sort(l.begin(), l.end());

	rep(i,n) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				int a = l[i];
				int b = l[j];
				int c = l[k];

				if (a == b || b == c || a == c) {
					continue;
				}
				if (a + b <= c) {
					continue;
				}
				count++;
			}
		}
	}

	cout << count << endl;


	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int x = 0;
  for(int i=0; i<n; i++) {
    int l,r;
    cin >> l >> r;
    x = x + r - l + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll S;

int main()
{
  std::cin >> S;

  ll x2 = 1e9, y2 = 1, x3, y3;

  y3 = (S+x2-1)/x2;

  S = y3*x2-S;

  x3 = S;

  std::cout << 0 << ' ' << 0 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << std::endl;

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main(){
    ll n;
    std::cin >> n;
    ll ans=1000000;
    rrep(i,1,sqrt(n)+10){
     if(n%i==0){
         ll m=n/i;
         ans=min(ans,max(GetDigit(m),GetDigit(n/m)));
         
     }   
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s,ans;cin>>s;
    if(s.size()!=26){
        vector<int> vec(26);
        for(char c:s){
            vec[(c-'a')]++;
        }
        for(int i=0;i<26;i++){
            if(vec[i]==0){
                ans=s+(char)('a'+i);
                break;
            }
        }
    }
    else{
        bool answer=false;
        vector<int> vec(26);
        for(int i=25;i>=0;i--){
            int tmp=s[i]-'a';
            vec[tmp]++;
            for(int j=tmp+1;j<26;j++){
                if(vec[j]){
                    ans=s.substr(0,i)+(char)('a'+j);
                    answer=true;
                    break;
                }
            }
            if(answer)break;
        }
        if(!answer)ans="-1";
    }
    cout<<ans<<endl;
}


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

int main() {
    int n;
    cin >> n;
    ll a[n];
    for (int i1 = 0; i1 < n; ++i1) {
        cin >> a[i1];
    }

    ll s_even_p = 0;
    ll s_odd_p = 0;
    ll p_even_p = 0;
    ll p_odd_p = 0;
    for (int i = 0; i < n; ++i) {
        s_even_p += a[i];
        s_odd_p += a[i];
        bool is_odd = i % 2 == 1;
        if (is_odd) {
            if (s_odd_p <= 0) {
                p_odd_p += abs(s_odd_p) + 1;
                s_odd_p = 1;
            }
            if (0 <= s_even_p) {
                p_even_p += s_even_p + 1;
                s_even_p = -1;
            }
        } else {
            if (0 <= s_odd_p) {
                p_odd_p += s_odd_p + 1;
                s_odd_p = -1;
            }
            if (s_even_p <= 0) {
                p_even_p += abs(s_even_p) + 1;
                s_even_p = 1;
            }
        }
    }
    cout << min(p_even_p, p_odd_p) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

const ll INF = 1000000000000000000;

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

  int a, b, q;
  cin >> a >> b >> q;

  vector<ll> s(a + 2), t(b + 2);
  s[0] = t[0] = -INF;
  s[a + 1] = t[b + 1] = INF;

  rep(i, 1, a + 1) cin >> s[i];
  rep(i, 1, b + 1) cin >> t[i];

  while (q--) {
    ll x;
    cin >> x;
    int si = lower_bound(s.begin(), s.end(), x) - s.begin();
    int ti = lower_bound(t.begin(), t.end(), x) - t.begin();
    ll sl = s[si - 1], sr = s[si], tl = t[ti - 1], tr = t[ti];

    ll a1 = max(sr, tr) - x, a2 = x - min(sl, tl);
    ll a3 = (sr - x) + (sr - tl), a4 = (tr - x) + (tr - sl);
    ll a5 = (x - sl) + (tr - sl), a6 = (x - tl) + (sr - tl);

    cout << min({a1, a2, a3, a4, a5, a6}) << endl;
  }
}


Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
int main(){
    int k;cin>>k;
    int a=k/2,b=k/2+k%2;
    cout<<a*b<<endl;
}   


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X,string Y){
  int c[N+1][N+1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' '+Y;
  for(int i = 0;i <= m;i++ ) c[i][0] = 0;
  for(int j = 1;j <= n;j++) c[0][j] = 0;

  for(int i = 1;i <= m;i++){
    for(int j = 1;j <= n;j++){
      if(X[i] == Y[j]){
        c[i][j] = c[i - 1][j - 1] + 1;
      }else{
        c[i][j] = max(c[i - 1][j],c[i][j-1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }
  return  maxl;
}

int main(){
  string s1,s2;
  int n;cin >> n;
  for(int i = 0;i < n;i++){
    cin >> s1 >> s2;
    cout << lcs(s1,s2) << endl;
  }
  return 0;
}



Measured memory_bytes: 7104
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val words = sc.nextLine().split(" ")

    if (words(0).last == words(1).head && words(1).last == words(2).head) {
      println("YES")
    } else {
      println("NO")
    }
  }
}

Measured memory_bytes: 25552
=begin
方針：K - max{distance(A[i], A[i+1]) | i in 0...N}
=end
k, n = gets.split.map &:to_i
a = gets.split.map(&:to_i).sort
a << k + a[0]
d_max = a.each_cons(2).map { |a, b| (b - a).abs }.max
p k - d_max

Measured memory_bytes: 32180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine(Math.Min(V[0] * V[1], V[2]));
        }
    }
}


Measured memory_bytes: 11092