akhauriyash/Code-Regression huggingface dataset:
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)
#define Sort(a) sort(a.begin(),a.end())

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int ans=0;
	str s;cin>>s;
	rep(i,0,SZ(s)/2){
		if(s[i]!=s[SZ(s)-i-1])ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 105;
int n, m, r[N], c[N];
char arr[N][N];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 0;i < n;++i)
    {
        for(int j = 0;j < m;++j)
        {
            cin >> arr[i][j];
            if(arr[i][j] == '.')
                ++r[i], ++c[j];
        }
    }
    for(int i = 0;i < n;++i)
    {
        if(r[i] != m)
        {
            for(int j = 0;j < m;++j)
                if(c[j] != n)
                    cout << arr[i][j];
            cout << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3608
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;

    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner(Stream source)
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    int A, B;
    private void Scan()
    {
        var cin= new Scanner(Console.OpenStandardInput());
        A = cin.NextInt();
        B = cin.NextInt();
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine((A + B) % 24);
    }
}

Measured memory_bytes: 11092
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int k[] = new int[N];
		Boolean allZero = false;
		int count = 0;

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

		while (!allZero) {
			allZero = true;
			int now = 0;
			Boolean isZero = true;
			while (now < N) {
				if (k[now] > 0) {
					k[now] -= 1;
					isZero = false;
					allZero = false;
				} else if (k[now] <= 0 && isZero) {
				} else {
					count++;
					isZero = true;
				}
				now++;
			}
			if (!isZero) {
				count++;
			}
		}

		sc.close();
		System.out.println(count);
	}
};

Measured memory_bytes: 35896
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge& operator=(const int& x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T >& g, int s) {
	const auto INF = numeric_limits< T >::max();
	vector< T > dist(g.size(), INF);

	using Pi = pair< T, int >;
	priority_queue< Pi, vector< Pi >, greater< Pi > > que;
	dist[s] = 0;
	que.emplace(dist[s], s);
	while (!que.empty()) {
		T cost;
		int idx;
		tie(cost, idx) = que.top();
		que.pop();
		if (dist[idx] < cost) continue;
		for (auto& e : g[idx]) {
			auto next_cost = cost + e.cost;
			if (dist[e.to] <= next_cost) continue;
			dist[e.to] = next_cost;
			que.emplace(dist[e.to], e.to);
		}
	}
	return dist;
}

long long N;
WeightedGraph<long long> G;

int main() {
	cin >> N;
	G.resize(N);
	for (int t = 0; t < N; t++) {
		string S;
		cin >> S;
		for (int s = 0; s < N; s++) {
			if (S[s] == '1')G[s].push_back({ s,t,1 });
		}
	}
	long long ans = -1;
	for (int s = 0; s < N; s++) {
		vector<long long> dijkans = dijkstra(G, s);
		bool flag = true;
		for (long long s = 0; s < N && flag; s++) {
			for (auto e : G[s]) {
				if (abs(dijkans[s] - dijkans[e.to]) != 1) {
					flag = false;
					break;
				}
			}
		}
		if (!flag)continue;
		for (int n = 0; n < N; n++) {
			ans = max(ans, dijkans[n]+1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys, random, math
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20

#    t = int(input())
#    t, a, b = map(int, input().split())
    t = 1
    
    for _ in range(1, t+1):
    #    print("Case #{}: ".format(_), end = '')
        
        aa, bb = input().split()
        a, b = -1, -1
        for i in range(len(aa)):
            if(aa[i] == '.'):
                a = int(aa[:i]) * 100
                if(i == len(aa)-2):
                    a += int(aa[-1]) * 10
                else:
                    a += int(aa[-2:])
        if(a == -1):
            a = int(aa) * 100
        for i in range(len(bb)):
            if(bb[i] == '.'):
                b = int(bb[:i]) * 100
                if(i == len(bb)-2):
                    b += int(bb[-1]) * 10
                else:
                    b += int(bb[-2:])
        if(b == -1):
            b = int(bb) * 100
    
            
    #    print(a, b)
        
        print((a*b//10000))
        
main()

Measured memory_bytes: 76864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){

			double num = sc.nextDouble();

			if(num <= 48){
				System.out.println("light fly");
			} else if(48 < num && num <= 51){
				System.out.println("fly");
			} else if(51 < num && num <= 54){
				System.out.println("bantam");
			} else if(54 < num && num <= 57){
				System.out.println("feather");
			} else if(57 < num && num <= 60){
				System.out.println("light");
			} else if(60 < num && num <= 64){
				System.out.println("light welter");
			} else if(64 < num && num <= 69){
				System.out.println("welter");
			} else if(69 < num && num <= 75){
				System.out.println("light middle");
			} else if(75 < num && num <= 81){
				System.out.println("middle");
			} else if(81 < num && num <= 91){
				System.out.println("light heavy");
			} else{
				System.out.println("heavy");
			}
		}
	}
}

Measured memory_bytes: 27688
#include<bits/stdc++.h>
#define M 1000000007
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;

using namespace std;
ll fac[200005],inf[200005];
ll power(ll x,ll y){
    ll t=1;
    while(y){
        if(y&1) t=(t*x)%M;
        y>>=1;
        x=(x*x)%M;
    }
    return t;
}
ll per(ll n,ll r){
    return (fac[n]*((power(fac[r],M-2)*power(fac[n-r],M-2))%M)%M);
}
void pre(){
    fac[0]=fac[1]=1;
    ll i=2;
    while(i<200003){
        fac[i]=(fac[i-1]*i)%M;
        i++;
    }
}
void pre2(){
    inf[0]=inf[1]=1;
    ll i=2;
    while(i<200003){
        inf[i]=power(fac[i],M-2);
        i++;
    }
}
int main(){
    cs;
    pre();
    pre2();
    ll n,k,ans=0;
    cin>>n>>k;
    if(k>n-1) k=n-1;
    for(ll i=0;i<=k;i++) ans=(ans+per(n,i)*per(n-1,i))%M; 
    while(ans<0) ans+=M;
    cout<<ans;
}

Measured memory_bytes: 3328
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, a, b) = readLongList()
    if (n == 1L) {
        val ans = if (a == b) 1  else 0
        out.println(ans)
        return
    }

    if (a > b) {
        out.println(0)
        return
    }

    out.println(((n - 1) * b + a) - ((n - 1) * a + b) + 1)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int main() {
	int n;
  	cin>>n;
  
	vector<int> p(n);
  	vector<int> q(n);
  
  int cp=0;
  int cq=0;
  
  rep(i,n)cin>>p[i];
  rep(i,n)cin>>q[i];
  
  while(prev_permutation(p.begin(),p.end())){
  	cp++;
  }
  
  while(prev_permutation(q.begin(),q.end())){
  	cq++;
  }

  cout<<abs(cp-cq)<<endl;
  
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;

int main() {
  IN(ll, K);
  IN(ll, A);
  IN(ll, B);
  string ans = "NG";
  for(ll i = A; i <= B; i++){
    if(i % K == 0)
      ans = "OK";
  }
  OUT(ans);
}




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

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

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

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
string s,t;
int main(void){
    cin>>n>>s>>t;
    for(int i=n;i>=0;i--){
        bool x=true;
        for(int j=0;j<i;j++){
            if(s[n-i+j]==t[j]){
                
            }else{
                x=false;
            }
        }
        if(x){
            cout<<n+n-i<<endl;
            return 0;
        }
    }

}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    string s;
    int k;
    cin>>s>>k;
    set<string>  all;
    for(int i=0;i<s.length();i++)
    {
        for(int j=1;j<=5&&i+j-1<s.length();j++)
        {
            string cur;
            for(int k=i;k<i+j;k++)
                cur+=s[k];
            all.insert(cur);
        }
    }
    for(auto u:all)
    {
        k--;
        if(!k)
        {
            cout<<u<<'\n';
            break;
        }
    }
}

Measured memory_bytes: 1664
using System;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
	int n = int.Parse(input[0]);
	int l = int.Parse(input[1]);
    string[] s = new string[n];
      for(int i = 0; i < n; i++)
      {
        s[i] = Console.ReadLine();
      }
      Array.Sort(s);//小さい順にする
      string answer = "";
      for(int i = 0; i < n; i++)
      {
        answer += s[i];
      }
	
	//出力
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

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

int main()
{
  
  int n,i;
  cin>>n;
  int arr[n];
  int temp[n+1];
  memset(temp,0,sizeof(temp));
  for(i=1; i<n; i++)
  {
    cin>>arr[i];
    temp[arr[i]]+=1;
  }
  for(i=1; i<=n; i++)
    cout<<temp[i]<<'\n';

  return 0;
}


Measured memory_bytes: 5160
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

vector<bool> eratosthenes(int n) {
  vector<bool> isPrime(n + 1, true);
  if(n >= 0) isPrime[0] = false;
  if(n >= 1) isPrime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!isPrime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      isPrime[j] = false;
    }
  }
  return isPrime;
}

const int MAX=55555;

int main(){
  int N;
  cin >> N;
  vector<bool> prime = eratosthenes(MAX);
  vector<int> ans(1,2);
  for(int i=6; ans.size()<N; i+=5){
    if(prime[i])
      ans.push_back(i);
  }
  rep(i,ans.size()){
    if(i)
      cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Date: Aug 19th, 2018
 * Prob: AGC017F Zigzag
 * Email: hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
#define rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define x first
#define y second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read() {
	static int _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

const int maxn = 21, maxs = 1 << 20, maxk = maxn * maxn, MOD = 1e9 + 7;

struct Limits { int a, b, c; }lmt[maxk];
inline bool operator < (Limits A, Limits B) { return A.a < B.a; }

int n, m, k, f[2][maxn][maxs], all, cur, Ans, t;

inline void ad(int& x, int y) { if ((x += y) >= MOD) x -= MOD; }

int main()
{
#ifdef hany01
	freopen("agc017f.in", "r", stdin);
	freopen("agc017f.out", "w", stdout);
#endif

	n = read() - 1, m = read(), k = read();
	For(i, 1, k) lmt[i].a = read(), lmt[i].b = read(), lmt[i].c = read();
	sort(lmt + 1, lmt + 1 + k);

	f[0][n][0] = 1, all = 1 << n, cur = 1, t = 0;
	For(i, 1, m) {
		t ^= 1, Set(f[t], 0);
		rep(j, all) f[t][0][j] = f[t ^ 1][n][j];
		For(j, 1, n) rep(S, all) {
			ad(f[t][j][S], f[t][j - 1][S]);
			if (!(S >> (j - 1) & 1)) {
				int nS = S | (1 << (j - 1));
				For(k, j, n - 1) if (S >> k & 1) { nS ^= (1 << k); break; }
				ad(f[t][j][nS], f[t][j - 1][S]);
			}
		}
		while (cur <= k && lmt[cur].a == i) {
			rep(S, all) if ((S ^ ((lmt[cur].c) << (lmt[cur].b - 1))) & (1 << (lmt[cur].b - 1))) f[t][n][S] = 0;
			++ cur;
		}
	}

	rep(S, all) ad(Ans, f[t][n][S]);
	printf("%d\n", Ans);

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s; cin >> s;
  string t = "keyence";
  reps(i, 7 - 1) {
    string b = t.substr(0, i);
    string a = t.substr(i);
    if (s.substr(0, i) == b && s.substr(s.size() - (7 - i)) == a) yes();
  }
  no();
}


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

int main(){
    long long n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2 == 0){
        cout << (b-a)/2 << endl;
        return 0; 
    }
    if(n-b > a-1){
        cout << (1+a+b-2)/2 << endl;
        return 0;
    }else{
        cout << (1+2*n-a-b)/2 << endl;
        return 0;
    }

}

Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
ans=B-A+1
from fractions import gcd
lcm=int(C*D/gcd(C,D))
print(ans-((B//C-(A-1)//C)+(B//D-(A-1)//D)-(B//lcm-(A-1)//lcm)))

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

int main(){
    int n; cin >> n;
    int m = n % 10;
    if(m == 2 || m == 4 || m == 5 || m == 7 || m == 9) cout << "hon" << endl;
    else if(m == 3) cout << "bon" << endl;
    else cout << "pon" << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))

char m[55][55];
int h,w;
bool f(int a,int b)
{
    if(a<h&&a>=0&&b<w&&b>=0){
        if(m[a][b]=='#') return true;
    }
    return false;
}
int dir[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);
    while(~scanf("%d%d",&h,&w)){
        for(int i=0;i<h;i++) scanf("%s",m[i]);
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(f(i,j)){printf("#");continue;}
                int ans=0;
                for(int k=0;k<8;k++){
                    if(f(i+dir[k][0],j+dir[k][1])) ans++;
                }
                printf("%d",ans);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())

    print(((n ** 2) - n) // 2)


# region fastio

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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29036
n = gets.to_i
numbers = n.times.map { gets.to_i }
def prime?(x)
  return true if x == 2
  return false if x < 2 || x.even?
  3.step(Math.sqrt(x), 2).each do |i|
    return false if x % i == 0
  end
  return true
end
puts numbers.count {|x| prime?(x) }

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> deli(n,0);
	for(int &i:deli){
		cin>>i;
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=(deli[i]*deli[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 50 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int M,N,A,B,C,T;
int s[MAXN];

struct Matrix{
    LL a[MAXN][MAXN];
}st,mp;

Matrix Matrix_Multiply(const Matrix& a,const Matrix& b,int MOD){
    Matrix c;
    memset(c.a,0,sizeof(c.a));
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            for(int k=1;k<=N;k++){
                c.a[i][k]=(c.a[i][k]+a.a[i][j]*b.a[j][k])%MOD;
            }
        }
    }
    return c;
}

void Power(int X,int MOD){
    while(X){
        if(X&1) st=Matrix_Multiply(st,mp,MOD);
        mp=Matrix_Multiply(mp,mp,MOD);
        X>>=1;
    }
}

void work(){
    while(~scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T)){
        for(int i=1;i<=N;i++) scanf("%d",&s[i]);
        memset(mp.a,0,sizeof(mp.a));
        for(int i=1;i<=N;i++){
            mp.a[i][i-1]=A;
            mp.a[i][i]=B;
            mp.a[i][i+1]=C;
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++) st.a[i][j]=(i==j);
        }
        Power(T,M);
        for(int i=1;i<=N;i++){
            LL ans=0;
            for(int j=1;j<=N;j++){
                ans=(ans+st.a[i][j]*s[j])%M;
            }
            printf("%lld%s",ans,i==N ? "\n" : " ");
        }
    }
}

int main(){
#ifdef NNever
    freopen("data.in","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}










Measured memory_bytes: 3228
# https://atcoder.jp/contests/abc096/tasks/abc096_d

N = int(input())

# 最大55,555以下の素数
MAX_N = 55556
primes = [True] * MAX_N
primes[0] = primes[1] = False
for p in range(2, MAX_N):
    if not primes[p]:
        continue
    for m in range(2 * p, MAX_N, p):
        primes[m] = False
lps = [i for i in range(2, MAX_N) if primes[i] and i % 5 == 1]

ans = lps[:N]
print(*ans)

Measured memory_bytes: 69012
N = int(input())
a = list(map(int,input().split()))
dev = lambda x : x/2
amari = lambda x : x % 2
for i in range(1000):
    amari_a = list(map(amari, a))
    if amari_a.count(1) > 0: break
    a = list(map(dev,a))
print(i)

Measured memory_bytes: 9184
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(_n, k; usize);
    scan!(array; Vec<usize>);

    let mut left = 0;
    let mut right = *array.iter().max().unwrap();

    while left < right {
        let m = (left + right) / 2;

        if left == m {
            println!("{}", m+1);
            return;
        }
        if right == m {
            println!("{}", m);
            return;
        }

        let mut s = 0;
        for &a in array.iter() {
            s += if a % m == 0 {
                a / m - 1
            } else {
                a / m
            };
        }

        if s <= k {
            right = m;
        } else {
            left = m;
        }
    }

    let m = (left + right) / 2;
    println!("{}", m);
}


Measured memory_bytes: 5656
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;



int main()
{
    string word;
    string sentence;
    int count = 0;

    cin >> word;
    transform(word.begin(), word.end(), word.begin(),::tolower);
    
    while (1) {
        cin >> sentence;
        if (sentence == "END_OF_TEXT") break;


        transform(sentence.begin(), sentence.end(), sentence.begin(), ::tolower);
        if (word == sentence) count++;

    }

    cout << count << endl;

    return 0;


}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    int a = in<int>();
    int p = in<int>();
    int s = (a * 3 + p) / 2;
    cout << s << "\n";
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = sum(a)
c = 0
index = 0
for i in range(n):
    c += a[i]
    if c >= b / 2:
        index = i
        break
print(min(abs(sum(a[:index+1]) - sum(a[index+1:])), abs(sum(a[:index]) - sum(a[index:]))))

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  vector<int> a;
  rep(i, n) {
    int x; cin >> x;
    a.push_back(x);
  }

  sort(all(a), greater<int>());

  int A = 0, B = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (i % 2 == 0) A += a[i];
    else B += a[i];
  }

  cout << A - B << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

class BellmanFord
{
public:
  static const ll MAX_V = 1010 * 1010;

  struct edge
  {
    ll from, to;
    ll cost;
  };

  ll V;
  vector<edge> E;
  ll d[MAX_V];

  BellmanFord(ll V_num) : V(V_num) {}

  void calc(ll s)
  {
    fill(d, d + V + 1, LINF);
    d[s] = 0;
    bool update;
    while (1)
    {
      update = false;
      for (auto e : E)
      {
        if (d[e.from] != LINF && d[e.to] > d[e.from] + e.cost)
        {
          d[e.to] = d[e.from] + e.cost;
          update = true;
        }
      }
      if (!update)
        return;
    }
  }

  bool negative[MAX_V];

  bool calc_and_find_negative_loop(ll s, ll g)
  {
    fill(d, d + V + 1, LINF);
    fill(negative, negative + V + 1, false);
    d[s] = 0;

    rep(i, V)
    {
      bool update = false;
      for (auto e : E)
      {
        if (d[e.from] != LINF && d[e.to] > d[e.from] + e.cost)
        {
          d[e.to] = d[e.from] + e.cost;
          update = true;
          if (i == V - 1)
            negative[e.from] = negative[e.to] = true;
        }
      }
      if (!update)
        return false;
    }
    return negative[g];
  }

  bool find_any_negative_loop()
  {
    ll d_[MAX_V];
    rep(i, V) for (auto e : E)
    {
      if (d_[e.to] > d_[e.from] + e.cost)
      {
        d_[e.to] = d_[e.from] + e.cost;
        if (i == V - 1)
          return true;
      }
    }
    return false;
  }
};

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

  ll v, e, r;
  cin >> v >> e >> r;
  BellmanFord bf(v);
  rep(i, e)
  {
    ll s, t, d;
    cin >> s >> t >> d;
    bf.E.push_back({s, t, d});
  }
  bf.calc_and_find_negative_loop(r, 0);
  bool neg = false;
  rep(i, v) neg |= bf.negative[i];
  if (neg)
  {
    cout << "NEGATIVE CYCLE\n";
  }
  else
  {
    rep(i, v)
    {
      if (bf.d[i] == LINF)
        cout << "INF\n";
      else
        cout << bf.d[i] << endl;
    }
  }
  return 0;
}



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

int main() {
  int n, m = 0, t;
  string s;
  cin >> n >> s;
  for(int i = 1; i < n; i++) {
    vector<int> c(26);
    for(int j = 0; j < i; j++)
      if(!c.at(s.at(j) - 'a'))
        c.at(s.at(j) - 'a')++;
    for(int j = i; j < n; j++)
      if(c.at(s.at(j) - 'a') == 1)
        c.at(s.at(j) - 'a')++;
    t = 0;
    for(int i = 0; i < 26; i++)
      if(c.at(i) == 2)
        t++;
    m = max(m, t);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line printf("-----------------------------\n")
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
vector<pair<int,int> >  v[100009];
bool color[100009];
bool visit[100009];
void dfs(ll s,ll d)
{
    visit[s]=true;
    if(d%2==0) color[s]=1;
    for(auto x: v[s])
    {
        if(visit[x.first]==false)
        {
            dfs(x.first,d+x.second);
        }
    }
}
int   main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<n;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        v[a].pb(mp(b,c));
        v[b].pb(mp(a,c));
    }
    dfs(1,0);
    for(ll i=1;i<=n;i++)
    {
        cout<<color[i]<<endl;
    }
}


Measured memory_bytes: 7424
import java.util.*;

public class Main{
	static final long MOD = 1000000007L;
	static final int WIDTH = 64;
	static final long[] BIN_EXPS = buildBinExps();
	static Scanner sc = new Scanner(System.in);
	static int n = 0;
	
	public static void main(String[] args){
		n = sc.nextInt();
		int[][] binaries = new int[n][WIDTH];
		for(int i = 0; i < n; ++i){
			binaries[i] = getBinary(sc.nextLong());
			
			//System.out.println(Arrays.toString(binaries[i]));
		}
		
		long ans = 0L;
		for(int iw = 0; iw < WIDTH; ++iw){
			long z = count0(binaries, iw);
			long prod = z * (n - z) % MOD;
			ans += prod * BIN_EXPS[iw] % MOD;
			ans %= MOD;
			//System.out.println("z = " + z + ", prod = " + prod + ", BIN = " + BIN_EXPS[iw] + ", ans = " + ans);
		}
		System.out.println(ans);
	}
	
	static long[] buildBinExps(){
		long[] res = new long[WIDTH];
		for(int i = 0; i < WIDTH; ++i){
			res[i] = (i == 0) ? 1L : 2L * res[i - 1] % MOD;
		}
		return res;
	}
	
	static int[] getBinary(long num){
		int[] res = new int[WIDTH];
		for(int i = 0; i < WIDTH; ++i){
			res[i] = (num % 2L == 1L) ? 1 : 0;
			num /= 2L;
		}
		return res;
	}
	
	static long count0(int[][] binaries, int iw){
		long res = 0L;
		for(int id = 0; id < n; ++id){
			if(binaries[id][iw] == 0) ++res;
		}
		return res;
	}
}

Measured memory_bytes: 294780
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;
int a[100500];
void solve(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int x = 0, y = 0;
    for(int i = n - 1; i > 0; i--){
        if(a[i] == a[i - 1]){
            if(x == 0) x = a[i];
            else{
                y = a[i];
                break;
            }
            i--;
        }
    }
    
    cout << x * 1ll * y;
    
}

int main(){
    barsik;
    int q = 1;

    //cin >> q;

    for(int i = 1; i <= q; i++){
//        cout << "Case " << i << ": ";
        solve();
    }
}


Measured memory_bytes: 640
package main

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

func main() {
	A := nextInt()
	B := nextInt()

	for i := 1; true; i++ {
		if int(float64(i)*0.08) == A && int(float64(i)*0.1) == B {
			fmt.Println(i)
			return
		}

		if int(float64(i)*0.08) > A || int(float64(i)*0.1) > B {
			break
		}
	}

	fmt.Println(-1)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

ll maxll(ll x , ll y){
    return x>y?x:y;
}
signed main() {
    ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans=a*x+b*y;
    ll z = x * 2;
    ans=min(ans,a*maxll(0,x-z/2)+b*maxll(0,y-z/2)+c*z);
    z = y * 2;
    ans=min(ans,a*maxll(0,x-z/2)+b*maxll(0,y-z/2)+c*z);
    cout<<ans<<endl;
    return 0;
}


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

void fnInput(int &riLodC, int &riTrkC, vector<int> &rviLod)
{
  cin >> riLodC >> riTrkC;

  rviLod.resize(riLodC);
  for (int i = 0; i < riLodC; i++)
    cin >> rviLod[i];
}

int fnSimuAlloc(const vector<int> &cnrviLod, int iTrkC, int iLod)
{
  int iCurLod;
  int iCntTrk = 0;

  for (int i = 0; i < cnrviLod.size();    )
  {
    if (cnrviLod[i] > iLod)  return 0;

    iCntTrk++;
    iCurLod = 0;
    while (i < cnrviLod.size())
    {
      iCurLod += cnrviLod[i];
      if (iCurLod > iLod)  break;

      i++;
    }
  }
  return (iCntTrk <= iTrkC);
}

void fnAlloc(const vector<int> &cnrviLod, int iTrkC, int &riMinLod)
{
  const int cniMinLod = 0;
  const int cniMaxLod = 1000000000;

  int iLow  = cniMinLod;
  int iHigh = cniMaxLod;
  riMinLod = cniMaxLod;

  while (iLow < iHigh)
  {
    int iMid = (iLow + iHigh) / 2;
    if (fnSimuAlloc(cnrviLod, iTrkC, iMid))
    {
      riMinLod = min(riMinLod, iMid);
      iHigh = iMid;
    }
    else
      iLow = iMid + 1;
  }
}

void fnReSult(int iMinLod)
{
  cout << iMinLod << endl;
}

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

  int iLodC, iTrkC;
  vector<int> viLod;
  int iMinLod = 0;

  fnInput(iLodC, iTrkC, viLod);
  fnAlloc(viLod, iTrkC, iMinLod);
  fnReSult(iMinLod);

  return 0;
}

Measured memory_bytes: 1524
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main(void) {
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  vector<set<int> > posByChar(26);
  for (size_t i = 0; i < N; i++) posByChar[S[i] - 'a'].insert(i);
  for (size_t i = 0; i < Q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      int j;
      char c;
      cin >> j >> c;
      j--;
      if (S[j] != (c - 'a')) {
        posByChar[S[j] - 'a'].erase(j);
        posByChar[c - 'a'].insert(j);
        S[j] = c;
      }
    } else {  // t = 2
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      int cnt = 0;
      for (int i = 0; i < 26; i++) {
        set<int>::iterator it = posByChar[i].lower_bound(l);
        if (it != posByChar[i].end() && *it <= r) cnt++;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 27252
#include <stdio.h>

int main(){
	int n,x;
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		x = i;
		if(x % 3 == 0){  //3の倍数ごとに動く処理
			printf(" %d",x);
		}
		else {
			while(x){
				if(x % 10 == 3){//3+=10ごとに動く処理
					printf(" %d",i);
					break;
				}
				x /= 10;
			}
		}
	}printf("\n");
	return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define sz(A) (int)A.size()
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define in input_int()
#define ins input_string()
int input_int(){int a;cin>>a;return a;}
string input_string(){string s;cin>>s;return s;}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};



int n,m,k,a,b,c,d,x,y,arr[N];
string s;

int dp[6001][18001];

void solve()
{
    cin>>n>>a>>b;
    forn(i,3,n)
    {
        cin>>x;
        c^=x;
    }
    
    int sum=a+b;
    int aandb=sum-c;
    if(aandb<0 or aandb%2)
    {
        cout<<-1;
        return;
    }
    aandb/=2;

    //cout<<c<<" "<<aandb<<"\n";

    if(c&aandb)
    {
        cout<<-1;
        return;
    }

    int ans=aandb;

    if(ans>a)
    {
        cout<<-1;
        return;
    }

    rfor(i,60,0)
    {
        if((1LL<<i)&c)
        {
            //cout<<i<<" "<<ans+(1LL<<i)<<"\n";
            if(ans+(1LL<<i)<=a)
            {
                ans+=1LL<<i;
            }
        }
    }
    if(ans==0)
    {
        cout<<-1;
        return;
    }
    cout<<a-ans;



}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}
//       clang++ c.cpp ; ./a.out < a.txt ;

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

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

using namespace std;

typedef long long int llint;

const long long int INF = 1 << 30; //10^10
const llint MOD = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];

  if ( d[0] != 0) {cout << 0 << endl; return 0;}

  vector<llint> cntv(n,0);
  rep(i, n) {
    if (i > 0 && d[i] == 0) {cout << 0 << endl; return 0;}
    cntv[d[i]]++;
  }
  
  llint ans = 1;
  rep(i,n-1){
    ans = (ans * cntv[d[i+1]-1]) % MOD;
  }
  cout << ans << endl;
}


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



int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    string a, b, c; cin >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; i++) {
    	if (a[i] == b[i] && b[i] == c[i]) continue;
    	else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
    		ans++;
    	}
    	else ans += 2;
    }
    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if (A >= 13) cout << B << endl;
    else if (A >= 6) cout << B / 2 << endl;
    else cout << 0 << endl;
}

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

int main(){
	int n;
	long long ans= 0;
	std::vector<long long> aList;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	int left=0;
	int right=0;
	long long xorSum=0;

	for(; left<n; left++){
		for(; right<n+1; right++){
			if(right==n)
				break;

			if((xorSum^aList[right]) != (xorSum+aList[right]))
				break;

			xorSum+=aList[right];
		}
		ans+= right-left;
		xorSum-= aList[left];
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 1792