akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    ll score_red[a] = {};
    ll score_green[b] = {};
    ll score_void[c] = {};
    ll tmp;
    priority_queue<ll, std::vector<ll>, std::greater<ll>> red;
    priority_queue<ll, std::vector<ll>, std::greater<ll>> green;

    for(int i=0;i<a;++i)
    {
        cin >> score_red[i];
    }

    for(int i=0;i<b;++i)
    {
        cin >> score_green[i];
    }

    for(int i=0;i<c;++i) cin >> score_void[i];
    sort(score_void, score_void + c, std::greater<ll>());
    sort(score_red, score_red + a, std::greater<ll>());
    sort(score_green, score_green + b, std::greater<ll>());

    for(int i=0;i<x;++i)
    {
        red.push(score_red[i]);
    }

    for(int i=0;i<y;++i)
    {
        green.push(score_green[i]);
    }

    for(int i=0;i<c;++i)
    {
        ll red_smallest = red.top();
        ll green_smallest = green.top();
        ll void_apple = score_void[i];

        if(void_apple <= red_smallest && void_apple <= green_smallest) continue;

        if(void_apple > red_smallest && void_apple > green_smallest)
        {
            if(red_smallest > green_smallest)
            {
                green.push(void_apple);
                green.pop();
            }
            else
            {
                red.push(void_apple);
                red.pop();
            }
        }else if(void_apple > red_smallest)
        {
                red.push(void_apple);
                red.pop();
        }else{
                green.push(void_apple);
                green.pop();
        }
    }

    ll ret = 0;
    while(!red.empty())
    {
        ret += red.top();
        red.pop();
    }

    while(!green.empty())
    {
        ret += green.top();
        green.pop();
    }

    cout << ret << endl;
}

Measured memory_bytes: 4852
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int a, b, c; cin >> a >> b >> c;
	cout << (a + b + c >= 22 ? "bust" : "win") << endl;
	return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  int r = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      r++;
    } else {
      r = 0;
    }
    ans = max(ans, r);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
//https://atcoder.jp/contests/abc051/tasks/abc051_b
#include <iostream>
using namespace std;

int main() {
	int K,S;
	cin>>K>>S;
	int ans=0;
	for(int i=0;i<=K;i++){
		for(int j=0;j<=K;j++){
				int k=S-i-j;
				if(0<=k&&k<=K)ans++;	
			}
			
		}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void convert(int num){
    if(num < 4){
        printf("%d",num);
        return;
    }
    convert(num/4);
    printf("%d",num%4);
}
int main(void){
    int num;
    for(;scanf("%d",&num),~num;puts(""))
        convert(num);
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int X, N;
    set<int> P;
    cin >> X >> N;
    for (int _ = 0; _ < N; _++)
    {
        int p;
        cin >> p;
        P.insert(p);
    }
    int delta = 0;
    while (true)
    {
        if (P.find(X - delta) == P.end())
        {
            cout << (X - delta) << endl;
            return 0;
        }
        if (P.find(X + delta) == P.end())
        {
            cout << (X + delta) << endl;
            return 0;
        }
        delta++;
    }
}


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

int main(void){
  int A, B;
  int ans;
  cin >> A >> B;
  if(A + B < 24){
    ans = A + B;
  }else{
    ans = A + B - 24;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String T = sc.next();
    for (int i =0; i<N; i++) {
      System.out.print(S.charAt(i));
      System.out.print(T.charAt(i));
    }
  }
}
    

Measured memory_bytes: 22612
// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
//using int = long long;
#define int long long
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

bool check(string S, int a, int b)
{
	// aからbにイク
	if (a > b) swap(a, b);

	vector<int> P(S.size(), -1); // ブロックがあっていけない→1 , なにもない→ 0 
	// いけた 2 
	FOR(i, S.size()) {
		auto c = S[i];
		if (c == '.') {
			P[i] = 0;
		}
		else if (c == '#') {
			P[i] = 1;
		}
	}

	queue<int> Q;
	Q.push(a);
	while (!Q.empty()) {
		auto now = Q.front(); Q.pop();
		if (now >= S.size()) continue;

		if (P[now] == 0) {
			P[now] = 2;
			Q.push(now + 1);
			Q.push(now + 2);
		}
		//S[now] = "x";
	}
	if (P[b] == 2) return true;
	return false;
}

signed  main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	ll A, B, C, D, N;
	cin >> N >> A >> B >> C >> D;
	A -= 1;
	B -= 1;
	C -= 1;
	D -= 1;
	string S;
	cin >> S;
	string ans = "No";
	if (C < D) {
		if (check(S, A, C) and check(S, B, D)) {
			ans = "Yes";
		} else ans = "No";
	} else {
		FOR(_i, N - 2) { // A B D C のパターン
			auto i = _i + 1;
			if (S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.' and (B <= i and i <= D)) {
				if (check(S, A, i) and check(S, i, C) and check(S, B, i) and check(S, i, D)) {
					ans = "Yes";
					break;
				}
			}
		}
	} // この場合が怖い

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2720
#include <iostream>
#include <deque>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    bool flag = true;
    int n;
    cin >> n;
    vector<int> nums(n), res;
    deque<int> que;
    for (int i = 0; i < n; i++) cin >> nums[i];
    for (int i = 0; i < n; i++) {
	if (flag) que.push_back(nums[i]);
	else que.push_front(nums[i]);
	flag = !flag;
    }
    for (int x : que) res.push_back(x);
    if (n % 2 == 1) reverse(res.begin(), res.end());
    for (int x : res) cout << x << " ";
    cout << endl;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i = 0;i<N;i++){
    cin>>a[i];
  }
  bool t = 0;
  for(int i = N-1;i>=0;i--){
    if(a[i]<a[i-1]){
      if(a[i] == (a[i-1]-1)){
        a[i-1] = a[i-1]-1;
      }
      else{
        t = 1;
        break;
      }
    }
  }
  if(t == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i += 2){
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int x,y,z;

    scanf("%d %d %d", &x, &y, &z);

    if ((x + y + z) == 17){
        if (x == 7 || y == 7 || z == 7){
            if (x == y || y == z || z == x){
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        } else {
            printf("NO\n");
        }
    } else {
        printf("NO\n");
    }

    return 0;

}

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

vector<ll> primeVec(ll max)
{
	vector<ll> v(max, 1);
	v[0] = 0, v[1] = 0;

	for (ll i = 2; i < max; ++i)
	{
		for (ll j = 2*i; j < max; j+=i)
			v[j] = 0;
	}
	return v;
}

int main(int argc, char **argv)
{
	ll q;
	cin >> q;
	vector<ll> l(q), r(q);

	for (int i = 0; i < q; ++i)
		cin >> l[i] >> r[i];

	ll MAX = 100100;
	vector<ll> prime = primeVec(MAX);

	vector<ll> near_2017(MAX, 0);
	for (ll i = 0; i < MAX; ++i)
	{
		if (prime[i] && prime[(i+1)/2])
			near_2017[i] = 1;
	}

	vector<ll> com(MAX+1, 0);
	for (ll i = 0; i < MAX; ++i)
		com[i+1] = com[i] + near_2017[i];

	for (int i = 0; i < q; ++i)
	{
		int left = l[i];
		int right = r[i] + 1;
		std::cout << com[right] - com[left] << std::endl;
	}
}


Measured memory_bytes: 4608
#define pi 3.14159265358979323846
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip>
using namespace std;

struct Sdata{
	long long int n;
	string c;
};

string S;
long long int K;
vector<Sdata> datas;

int main() {
	string tmpChar;
	string pastChar = "";
	int nData = 0;
	long long int ans = 0;
	bool isLoop = false;

	cin >> S;
	cin >> K;
	
	for (int i = 0;i < S.length();i++) {
		tmpChar = S[i];
		if (pastChar != tmpChar) {
			nData++;
			datas.emplace_back();
			datas[nData - 1].c = tmpChar;
			pastChar = tmpChar;
		}
		datas[nData - 1].n++;
	}

	if (K > 1) {
		isLoop = (datas[nData - 1].c == datas[0].c);
	}
	
	if (nData == 1) {
		ans = ((long long int)(S.length()) * K) / 2 ;
	}
	else if (isLoop) {
		for (int i = 1;i < nData - 1; i++) {
			ans += (long long int)(datas[i].n / 2) * K;
		}
		ans+= ((datas[0].n + datas[nData-1].n) / 2) * (K - 1);
		ans += datas[0].n / 2;
		ans += datas[nData - 1].n / 2;
	} else {
		for (int i = 0;i < nData; i++) {
			ans += (long long int)(datas[i].n / 2) * K;
		}
	}
	cout << ans;
	return 0;
}

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

int main(){
	int m;
	string s;
	int h;
	while(1){
		cin >> s;
		if(s == "-") break;
		cin >> m;
		for(int k = 0; k < m; k++){
			cin >> h;
			s += s.substr(0,h);
			s.erase(0,h);
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, P = map(int, input().split())
S = list(map(int, list(input())))
# print(S)
S.reverse()

ans = 0
if P == 2 or P == 5:
    cnt = 0
    for i in range(N):
        if S[i] % P == 0:
            ans += N - i

else:
    cummod = [0] * P

    d = 1
    prev = 0
    for i in range(N):
        m = (S[i] * d) % P
        m += prev
        m %= P
        cummod[m] += 1
        d *= 10
        d %= P
        prev = m

    cummod[0] += 1

    for n in cummod:
        if n <= 1:
            continue
        ans += n * (n - 1) // 2

    #ans += cummod[0]

print(ans)


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




int main()
{
   string s,t;
   cin>>s>>t;
   int a,b;
   cin>>a>>b;
   string u;
   cin>>u;
   if(u==s)a--;
   else if(u==t)b--;

   cout<<a<<" "<<b<<endl;

return 0;

}

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	bs := make([]int, n-1)
	for i := range bs {
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}
	var ans = bs[0] + bs[n-2]
	for i := 0; i < n-2; i++ {
		ans += min(bs[i], bs[i+1])
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int n,aa;
	cin>>n;
	int a[n];
	map<int,int> me;
	map<int,int> mo;
	for(int i=0;i<n;i++){
		cin>>aa;
		if(i%2==0){
			me[aa]++;
		}
		else{
			mo[aa]++;
		}
	}
	int maxo=-1,maxe=-1,val1,val2;
	//cout<<mo.size()<<endl;
	for(auto x: mo){
		if(x.second>=maxo){
			maxo=x.second;
			val1=x.first;
		}
	}
	for(auto x: me){
		if(x.second>=maxe){
			maxe=x.second;
			val2=x.first;
		}
	}
	if(val1==val2){
		int maxoo=0,maxee=0;
		mo[val1]=0; me[val1]=0;
		for(auto x: mo){
		if(x.second>=maxoo ){
			maxoo=x.second;
			val1=x.first;
			}
		}
		for(auto x: me){
		if(x.second>=maxee ){
			maxee=x.second;
			val2=x.first;
			}
		}
		//cout<<maxoo<<" "<<maxee<<endl;
		if(maxoo>=maxee){
			cout<<n/2+n%2-maxe+n/2-maxoo<<endl;
		}
		else{
			cout<<n/2-maxo+n/2+n%2-maxee<<endl;
		}
		return 0;
	}
	int ans=n-maxe-maxo;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8340
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

const int MOD = 1e9+7;

int modpow(ll x, int n) {
    int ret = 1;
    while (n) {
        if (n%2) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

vector<int> get_divisors(int n) {
    vector<int> v1, v2;
    int i;
    for (int i = 1; i * i <= n; i++) if (n % i == 0) {
        v1.push_back(i);
        if (i * i != n) v2.push_back(n/i);
    }
    reverse(v2.begin(),v2.end());
    for (auto x: v2) v1.push_back(x);
    return v1;
}

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> divs = get_divisors(n);
    map<int,int> num;
    int ans = 0;
    for (auto x: divs) {
        num[x] = modpow(k,(x+1)/2);
        for (auto y: divs) if (x > y && x % y == 0) num[x] = (num[x] - num[y] + MOD) % MOD;
        if (x % 2 == 0) ans = (ans + (ll) num[x] * x / 2) % MOD;
        else ans = (ans + (ll) num[x] * x) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

//Numeral System
public class Main {

	static int f(char[] s){
		int r = 0;
		int x = 1;
		for(int i=0;i<s.length;i++){
			if(Character.isDigit(s[i]))x = s[i]-'0';
			else {
				switch(s[i]){
				case 'm': r+=x*1000;break;
				case 'c': r+=x*100;break;
				case 'x': r+=x*10;break;
				case 'i': r+=x;
				}
				x = 1;
			}
		}
		return r;
	}

	static String g(int r){
		String s = "";
		if(r/1000>0){
			if(r/1000>1)s+=r/1000;
			s+='m';
		}
		r%=1000;
		if(r/100>0){
			if(r/100>1)s+=r/100;
			s+='c';
		}
		r%=100;
		if(r/10>0){
			if(r/10>1)s+=r/10;
			s+='x';
		}
		r%=10;
		if(r>=2)s+=r+"i";
		else if(r==1)s+='i';
		return s;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			System.out.println(g(f(sc.next().toCharArray()) + f(sc.next().toCharArray())));
		}
	}
}


Measured memory_bytes: 38756
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

ll a,b,n,x;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b >> n;
    if( n < b ) x = n;
    if( n >= b ) x = max( 1LL , b-1 );

    cout << ((a*x)/b)-a*(x/b);

    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
using namespace std;
int abs(int a) {
  if (a < 0)
    return -a;
  return a;
}
int main() {
  int N, t, a;
  cin >> N >> t >> a;
  int max_score = __INT_MAX__, max_index;
  int H_i, score;
  for (int i = 0; i < N; i++) {
    cin >> H_i;
    score = abs(t * 1000 - 6 * H_i - 1000 * a);
    if (score < max_score) {
      max_index = i;
      max_score = score;
    }
  }
  cout << max_index + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int K,a,b,i;
	scanf("%d",&K);
	scanf("%d",&a);
	scanf("%d",&b);
	for(i=K;;i+=K){
		if(i>=a&&i<=b){
			printf("OK");
			break;
		}
		if(i>b){
			printf("NG");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1732
n,m = map(int,input().split())
a = list(map(int,input().split()))
l = []
for i in range(m):
    bc = list(map(int,input().split()))
    l.append(bc)
l.sort(key=lambda x:x[1],reverse=True)
a.sort()
b = 0
for i in range(m):
    count = 0
    while a[b] < l[i][1] and count < l[i][0]:
        a[b] = l[i][1]
        b = b + 1
        count = count + 1
        if b == n:
            break
    if b == n:
        break
    else:
        if i < m-1:
            if a[b] >= l[i+1][1]:
                break
print(sum(a))

Measured memory_bytes: 32980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
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;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}


bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

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

    // solution comes here

    ll N;
    cin >> N;
    vector<matrix> F(N, matrix(5, vl(2)));
    matrix P(N, vl(15));
    rep(i, N){
        rep(j, 5){
            rep(k, 2) cin >> F[i][j][k];
        }
    }
    rep(i, N) {
        rep(j, 11) cin >> P[i][j];//1-indexed
    }

    ll ALL = 1<<5, ans=-INF;
    rep(am, ALL) {
        rep(pm, ALL) {
            if(am or pm) {
                ll profit=0;
                rep(i, N) {
                    ll cnt=0;
                    rep(j, 5) cnt += (bit(am, j) and F[i][j][0]);
                    rep(j, 5) cnt += (bit(pm, j) and F[i][j][1]);
                    profit += P[i][cnt];
                }
                chmax(ans, profit);
            }
        }
    }

    cout << ans << nl;
}

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

using namespace std;

const int maxn=5e3+5;

typedef long long ll;

char s[maxn];


//inline int read(){
//    int x=0; bool f=0; char ch=getchar();
//    while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
//    while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
//    return f?-x:x;
//}
//
//void out(int a)///????
//{
//    if(a>9)
//        out(a/10);
//    putchar(a%10+'0');
//}

int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int ans=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			if(s[j]!=s[i]) continue;
			if(j-i<ans||n-j<ans) continue;
			int tmp=1;
			int k=i+1;int kk=j+1;
			while(k<j&&kk<n){
				if(s[k]==s[kk]) ++tmp;
				else break;
				++k;++kk;
			}
			ans=max(ans,tmp);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<functional>
#include<iomanip>
#include<climits>

using namespace std;
typedef unsigned long long int ll;
////  ll gcd(ll a, ll b)
////  {
////      if(b%a == 0) return a;
////      else return gcd(b%a, a);
////  }

int main()
{
    int arr[200000+2];
    int n ;
    cin >> n;

    int t;
    for(ll i = 1; i <=n; i++)
    {
       cin >> arr[i];
    }

  t= 1;
  int c = 0;
    for(ll i = 1; i <=n; i++)
    {
      if(arr[i] == t) t++;
      else c++;
    }
    if(t==1)
        cout << -1 ;
    else
        cout <<c;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,k=0,j=1,p=0;
    char s[100];
    cin>>s;
    m = strlen(s);
    if(m%2!=0)
    {
        cout<<"No";
        return 0;
    }
    for(i=0; i<m-1; i+=2)
    {
       if(s[i]=='h' && s[i+1]=='i')
       {
           p++;
       }
       else
       {
           cout<<"No";
           return 0;
       }
    }
    cout<<"Yes";

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int n, s, a, mod = 998244353;
long long dp[3005][3005];
 
int main() {
    cin >> n >> s;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++){
        cin >> a;
        for (int j = 0; j <= s; j++){
            dp[i][j] = dp[i-1][j]*2;
            dp[i][j] %= mod;
            if (j >= a){
                dp[i][j] += dp[i-1][j-a];
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][s] << "\n";
}

Measured memory_bytes: 74048
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
	int N,M;
	int I,J,K;
	scanf("%d%d",&N,&M);
	if((N+M)%2==1)
		printf("%d",(N+M+1)/2);
	else
		printf("%d",(N+M)/2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector <long long int> v;
vector <double> vd;
 
vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
set <int> st;
#define For(n) for(int i=0; i<n; i++)
//#define sort(v) sort(v.begin(),v.end());
#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i];}
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
 
//int cnt =0;
 
void SieveOfEratosthenes(int n=20000000)
{
   // v.push_back(1);
 
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
 
    vector <bool>prime(n+1,true);
 
    for (int p=2; p*p<=n; p++)
    {
 
        if (prime[p] == true)
        {
 
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
 
 
    for (int p=2; p<=n; p++)
       if (prime[p])
          mp[p]++;
}
 
 
//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}
 
//vector <int> arr(100,-1);
//
//int fib(int n)
//{
//    if(n<=1)return 1;
//
//    if(arr[n]==-1)
//    {
//        arr[n] = fib(n-1)+fib(n-2);
//    }
//    //else return arr[n];
//
//   return arr[n];
//}
 
 
//int arr[1050][1050];
//
//int mx=0;
//int LCS(string s, string p)
//{
//    for(int i=1; i<=s.size(); i++)
//    {
//        for(int j=1; j<=p.size(); j++)
//        {
//
//            if(s[i-1]==p[j-1])
//                arr[i][j]=1+arr[i-1][j-1];
//            else
//                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
//
//        }
//    }
//    return arr[s.size()][p.size()];
//}
//
//
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        x++;
//        n /= 2;
//    }
//    h+=x;
//    x=0;
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            x++;
//            n /= i;
//        }
//        h+=x;
//        x=0;
//
//    }
//
//    if(n>2){
//        h++;
//    }
//
//}
 
int main()
{

    long long int a,b,c,n;
    
    cin >> a >> b;
    
    
    if((a==1&&b==2) || (a==2&&b==1))cout << 3 << endl;
    
    else if((a==3&&b==2) || (a==2&&b==3))cout << 1 << endl;
    
    else cout << 2 << endl;
    
    
  
    return 0;
}
 


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

int main(){
    int h,w;
    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                bool i_parity = i%2==0;
                if((i+j)%2 == 0){
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  rep(i,k) ans+=l[i];

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll h, w, d; cin >> h >> w >> d;
    vvll a(h, vll(w));
    map<ll, P> m;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
            m[a[i][j]] = mp(i, j);
        }
    }
    vvll cs(d, vll(0));
    rep(i, 0, d){
        ll x = 0+i, s = 0;
        cs[i].emplace_back(0);
        while(x <= h*w-d){
            ll o = m[x].fst, p = m[x].snd, q = m[x+d].fst, r = m[x+d].snd;
            s += abs(q-o) + abs(r-p);
            cs[i].emplace_back(s);
            x += d;
        }
    }
    ll Q; cin >> Q;
    rep(i, 0, Q){
        ll L, R; cin >> L >> R;
        ll g = L%d;
        ll e = (L-g)/d, f = (R-g)/d;
        prtl(cs[g][f] - cs[g][e]);
    }
}


Measured memory_bytes: 14508
import java.util.*;

public class Main {
	public static void main(String[] args) {
		java.util.Scanner in = new java.util.Scanner(System.in);
		
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int [] arr = new int [3];
		arr[0] = a ; arr[1]=b;arr[2]=c;
		int c5=0, c7 =0;
		
		for (int i =0;i<arr.length;i++) {
			if(arr[i]== 5) {
				c5++;}
			else if (arr[i] == 7) {
				c7++;}
		}
		
		
		
		if (c5 ==2 && c7==1) {
			System.out.println("YES");}
		else {
			System.out.println("NO");
		}
		
		
		
    }
}


Measured memory_bytes: 26984
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <time.h>
#include <vector>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    double x;
    string u;
    cin >> n;
    
    double sum = 0.0;
    for (int i = 0; i < n; i++) {
        cin >> x >> u;
        if (u == "JPY") sum += x;
        else sum += x * 380000.0;
        
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define all(c) (c).begin(), (c).end()
#define sz(x) ((int)(x).size())
 
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
const ll MOD = 1e9 + 7; //998244353
constexpr ll INF = 1e18;
const int MX = 3010;

bool a[101];
int n, x, pi;

int main(){
    ios::sync_with_stdio(false);
    cin >> x >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> pi;
        a[pi] = 1;
    }
    for(int i = 0; ; i++){
        if(!a[x - i])
            return cout << x - i << endl, 0;
        if(!a[x + i])
            return cout << x + i << endl, 0;

    }


    return 0;
}

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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = -1;
	for (int i = 0; i + 1 < s.length(); i++) {
		bool cont[2][26] = {false};
		for (int j = 0; j <= i; j++) {
			cont[0][s[j]-'a'] = true;
		}
		for (int j = i + 1; j < s.length(); j++) {
			cont[1][s[j]-'a'] = true;
		}
		int cnt = 0;
		for (int j = 0; j < 26; j++) {
			cnt += cont[0][j] && cont[1][j];
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

namespace zyt
{
	const int N = 5e5 * 5 + 10;
	string s, t;
	bool vis[N], cnt;
	int n, m;
	namespace KMP
	{
		int fail[N];
		void getfail(const string &s)
		{
			fail[0] = fail[1] = 0;
			for (int i = 1; i < s.size(); i++)
			{
				int tmp = fail[i];
				while (tmp && s[i] != s[tmp])
					tmp = fail[tmp];
				fail[i + 1] = (s[i] == s[tmp] ? tmp + 1 : 0);
			}
		}
		void query(const string &s, const string &t)
		{
			getfail(t);
			int now = 0;
			for (int i = 0; i < s.size(); i++)
			{
				while (now && (now == t.size() || s[i] != t[now]))
					now = fail[now];
				if (s[i] == t[now])
					++now;
				if (now == t.size())
					vis[i] = true;
			}
		}
	}
	bool check()
	{
		for (int i = 0; i < s.size(); i++)
			if (s[i] != s[0])
				return false;
		for (int i = 0; i < t.size(); i++)
			if (t[i] != t[0])
				return false;
		return s[0] == t[0];
	}
	int work()
	{
		cin >> s >> t;
		if (check())
		{
			printf("-1");
			return 0;
		}
		static string buf;
		buf = s;
		while (s.size() < t.size())
			s += buf;
		s += s;
		s += s.substr(0, t.size() - 1);
		KMP::query(s, t);
		n = s.size(), m = t.size();
		int ans = 0;
		for (int i = 0; i < n; i++)
		{
			if (vis[i] && (i < m || !vis[i - m]))
			{
				int num = 0, tmp = i;
				while (tmp < n && vis[tmp])
					++num, tmp += m;
				ans = max(ans, num);
			}
		}
		if (ans >= n / m)
		{
			printf("-1");
			return 0;
		}
		printf("%d", ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 11556
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int N, X;
	cin >> N >>X;
	int A[110];
	int sum = 0;
	for(int n=0; n<N; n++){
		cin >> A[n];
		sum += A[n];
	}
	int nokori;
	nokori = X - sum;
	sort(A, A+N);
	int b=0;
	while(nokori-A[0]>=0){
		b++;
		nokori -= A[0];
	}
	cout << N+b <<endl;
	return 0;
}

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

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

    int l=0, r=0;
    int s=a[l];
    long long ans=0;
    for(; l<n; l++){
        if(l<=r) ans+=r-l+1;
        else{
            ans++;
            r=l;
            s=a[l];
        }
        for(; !(r+1>n-1 || s&a[r+1]); r++){
            s=s|a[r+1];
            ans++;
        }
        s=s&~a[l];
    }
    cout<<ans<<endl;

    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int h1,m1;
    int h2,m2;
    int k;

    cin >> h1 >> m1;
    cin >> h2 >> m2;
    cin >> k;

    int tot = 60*(h2-h1);
    tot -= m1;
    tot += m2;

    tot -= k;

    out(tot);
    
    
    
    return 0;
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  REP(i,N) cin >> S[i];

  int ret = 0;
  for(int k = -N + 1; k <= N - 1; ++k) {
    bool flag = true;
    REP(i,N){
      REP(j,N) if(S[i][j] != S[(j - k + N) % N][(i + k + N) % N]) {
        flag = false;
        break;
      }
      if(!flag) break;
    }
    if(flag) {
      REP(B, N) {
        int A = k + B;
        if((A >= 0) && (A < N)) ++ret;
      }
    }
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    ll n, L;
    cin >> n >> L;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    ll dis = 0, init_idx = 0;
    for(int i = 1; i < n; i++) {
        if (arr[i]+arr[i-1] >= L) {
            init_idx = i;
        }
    }
    // cout << "init_idx " << init_idx << endl;
    if (init_idx == 0) {
        cout << "Impossible" << endl;
    } else {
        vector<ll> ans;
        cout << "Possible" << endl;
        for(int i = init_idx; i < n; i++)
            ans.push_back(i);
        for(int i = init_idx-1; i > 0; i--)
            ans.push_back(i);
        reverse(ans.begin(), ans.end());
        for(int val: ans)
            cout << val<< endl;
    }
    return 0;
}




Measured memory_bytes: 2548
def merge(A, left, mid, right):
    global cnt
    inf = 100000000001
    n1, n2 = mid - left, right - mid
    L, R = A[left:left+n1]+[inf], A[mid:mid+n2]+[inf]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        cnt += 1

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

cnt = 0
n = int(input())
A = list(map(int, input().strip().split()))
mergeSort(A, 0, n)
print(*A)
print(cnt)


Measured memory_bytes: 63688
import * as fs from 'fs';

export class Reader {
    lines: string[];
    currentLine: number;

    constructor() {
        this.lines = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        this.currentLine = 0;
    }

    readLine(): string {
        return this.lines[this.currentLine++];
    }

    readInt(): number {
        return Number(this.readLine());
    }

    readInts(): number[] {
        return this.readLine().split(" ").map(Number);
    }
}

let reader = new Reader();

let N = reader.readInt();
let A: number[] = [];
for(let i=0; i<N; i++) {
    A.push(reader.readInt());
}

let B = new Array(2*N).fill(-1);
let start = N, end = N;

for(let a of A) {
    if (start == end && B[start] == -1) {
        B[start] = a;
        continue
    }
    if (a <= B[start]) {
        B[--start] = a;
        continue
    }
    if (a > B[end]) {
        B[end] = a;
        continue
    }
    let low = start-1, high = end+1;
    while (high-low > 1) {
        let mid = Math.floor((low+high)/2);
        if (a > B[mid]) {
            low = mid;
        } else {
            high = mid;
        }
    }
    if (B[low] == -1)
        B[--start] = a;
    else
        B[low] = a;
}

let count = B.reduce((prev, current) => prev+((current >= 0)?1:0), 0);
console.log(count);


Measured memory_bytes: 46524
=begin
N
B1 B2 ... Bn-1
=end

n = gets.chomp.to_i
bs = gets.chomp.split(" ").map(&:to_i)

bs = [10**6] + bs + [10**6]

sum = 0

for i in (0...n) do
  sum += [bs[i], bs[i+1]].min
end

puts sum


Measured memory_bytes: 2044
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

struct union_find {
    int uf[100000];
    long long sum[100000];
    
    int id_[200000];
    int uf_[200000];
    long long sum_[200000];
    int k;

    int find(int x) {
        while (uf[x] >= 0) x = uf[x];
        return x;
    }

    void store(int x) {
        id_[k] = x;
        uf_[k] = uf[x];
        sum_[k] = sum[x];
        k++;
    }

    void restore() {
        k--;
        int x = id_[k];
        uf[x] = uf_[k];
        sum[x] = sum_[k];
    }

    void skip() {
        k--;
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (-uf[x] < -uf[y]) swap(x, y);
        store(x);
        store(y);
        uf[x] += uf[y];
        sum[x] += sum[y];
        uf[y] = x;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
} uf;


int N, M;
int X[100000];
int A[100000], B[100000], Y[100000], P[100000];
int used[100000];

int main() {
    scanf("%d %d", &N, &M);
    for (int i = 0; i < N; i++) {
        scanf("%d", &X[i]);
        uf.uf[i] = -1;
        uf.sum[i] = X[i];
    }
    for (int i = 0; i < M; i++) {
        scanf("%d %d %d", &A[i], &B[i], &Y[i]);
        A[i]--;
        B[i]--;
        P[i] = i;
    }
    sort(P, P + M, [&](int i, int j) { return Y[i] < Y[j]; });
    for (int i = 0; i < M; i++) {
        int j = P[i];
        if (!uf.same(A[j], B[j])) {
            uf.unite(A[j], B[j]);
            used[j] = 1;
        }
    }
    int ans = 0;
    for (int i = M - 1; i >= 0; i--) {
        int j = P[i];
        long long sum = uf.sum[uf.find(A[j])];
        if (used[j]) {
            if (sum < Y[j]) {
                ans++;
                uf.restore();
                uf.restore();
            } else {
                uf.skip();
                uf.skip();
            }
        } else {
            if (sum < Y[j]) {
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}




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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    unordered_map<int, int> ma;
    unordered_map<int, int> mb;
    unordered_map<int, int> mc;

    int a, b, c;
    cin >> a >> b >> c;
    int times = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        if (ma.find(a) != ma.end() && mb.find(b) != mb.end() && mc.find(c) != mc.end() && ma[a] == mb[b] && mb[b] == mc[c]) {
            cout << -1 << endl;
            return 0;
        }
        ma[a] = times;
        mb[b] = times;
        mc[c] = times;
        times++;
        int oa = a;
        int ob = b;
        a = b / 2 + c / 2;
        b = oa / 2 + c / 2;
        c = oa / 2 + ob / 2;
    }
    cout << times << endl;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

// 桁数
int cKeta(i64 v) {
  int r = 0;
  while (v) {
    v /= 10;
    r++;
  }
  return r;
}

void calc(int K) {
  if ((K & 1) == 0 || (K % 5) == 0) {
    cout << -1;
  }
  else {
    int k = cKeta(K);
    i64 d = 7;

    int res = 0;
    while (d) {
      res++;
      i64 r = d % K;
      if (!r) {
        break;
      }
      //debug(res);
      //cout << d << ' ' << r << newl;
      d = r * 10 + 7;
    }
    cout << res;
  }
  cout << newl;
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

#if 1
  int K;
  cin >> K;
  calc(K);

#else
  FOR(i, 1, 1000001) {
    debug(i);
    calc(i);
  }
#endif
}
#endif


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

long long gcd (long long a, long long b) {
  if(a%b==0) return b;
  else return gcd(b, a%b);
}

int main() {
  long long n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  long long GCD = gcd(n, m);
  long long lim = min(n, m);
  bool yes = true;
  int alpha = n / GCD;
  int beta = m / GCD;
  for(int k=0;(alpha*k<n && beta*k<m);k++) {
    if(s[alpha*k] != t[beta*k]) {
      yes = false;
      break;
    }
  }

  if(yes) cout << n * m / GCD << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    if(c-a-b < 0) {
        cout << "No\n";
        return 0;
    }
    ll d = (c-a-b);
    d = d * d;
    if(4 * a * b < d) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1010, mod = 1e9 + 7;
int n;
bool isprime[maxn];
vector<int> v;
int main() {
	cin>>n;
	for(int i = 2; i <= n; i++) {
		if(!isprime[i]) {
			v.push_back(i);
			for(int j = i + i; j <= n; j += i) {
				isprime[j] = true; 
			}
		}
	}
	long long ans = 1ll;
	for(int i = 0; i < v.size(); i++) {
		int nn = n;
		long long cnt = 0ll;
		while(nn) {
			nn /= v[i];
			cnt += (long long)nn;
		}
		cnt++;
		ans = (ans * cnt) % (long long)mod;
	}
	cout<<ans<<endl;
	return 0;
}
/*
3
Output:4

6
Output:30

1000
Output:972926972
*/


Measured memory_bytes: 256
n = int(input())
ls = list(map(int, input().split(' ')))

ls = sorted(ls)
f = 1
ans = 1
inf = 1000000000000000000
for x in ls:
    ans *= x
    if ans > inf:
        f = 0
        break

if f == 1:
    print(ans)
else:
    print("-1")



Measured memory_bytes: 21656
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i/ 60 - h*60 );
   s = i % 60;
   
   
  
   cout << h<< ":" <<  m << ":" << s << endl;

 

   
   return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x; cin>>n>>x;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int ans = 0;
    for(int i=0; i<n; i++){
        if(x >= a[i]){ans++;x-=a[i];}
        else{x=0;break;}

    }
    if(x)ans--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
C = [int(input()) for _ in range(N)]
C = [x for x,y in zip(C[:-1],C[1:]) if x!=y] + [C[-1]]

DP = [1]
dic = {}

for i in range(len(C)):   
    DP.append((DP[-1]+dic.get(C[i],0))%(10**9+7))    
    dic[C[i]] = DP[-1]
print(DP[-1])          

Measured memory_bytes: 32420
#-*-coding:utf-8-*-

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

    i = 1
    j = 0
    ans = 0
    while True:
        ans += 1
        j += i
        i += 1
        if j >= x:
            print(ans)
            break



if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, A, B;
	cin >> N >> A >> B;

	cout << min(N * A, B);

	return 0;
}


Measured memory_bytes: 3608