akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int l = -1;
        int r = -1;
        for (int i = 0; i < s.length-1; i++) {
            if(s[i] == s[i+1]){
                l = i+1;
                r = i+2;
                break;
            }
            if(i < s.length-2 && s[i] == s[i+2]){
                l = i+1;
                r = i+3;
                break;
            }
        }
        System.out.println(l + " " + r);
        sc.close();

    }

}


Measured memory_bytes: 27244
n = input()
li = []
m = {}
x = set([])
for i in range(int(n)):
      s,p = [z for z in input().split()]
      x.add(s)
      m[str([s,int(p)])] = i
      li.append([s,int(p)])
new = sorted(li, reverse=True)
for i in sorted(list(x)):
      for j in range(int(n)):
            if (new[j][0]==i):
                  print(m[str(new[j])]+1)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    int n;
    std::cin >> n;
    string s;
    std::cin >> s;
    vvector(r,int,n+1,10,0);
    vvector(rr,int,n+2,10,0);
    rep(i,n){
        rep(j,10){
            r[i+1][j]=r[i][j];
        }
        r[i+1][s[i]-'0']++;
    }
    irep(i,n){
        rep(j,10){
            rr[i][j]=rr[i+1][j];
        }
        rr[i][s[i]-'0']++;
    }
    std::set<int> ans;
    rrep(ii,1,n-1){
        rep(i,10)rep(j,10){
            if(r[ii][i]&&rr[ii+1][j]){
               // std::cout << i*100+(s[ii]-'0')*10+j << std::endl;
                ans.insert(i*100+(s[ii]-'0')*10+j);
            }
        }
    }
    std::cout << ans.size() << std::endl;
    
}

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

int main(){
  	int n,m;
  	cin >> n >> m;
  	int a[n],b[n],c[m],d[m],check[m],memo = 0,memo_n = 2147483647;
  
  	rep(i,0,n){
      cin >> a[i] >> b[i];
    }
  	
  	rep(i,0,m){
      check[i] = 0;
      cin >> c[i] >> d[i];
    }
  
  	rep(i,0,n){
      memo = 0;
      memo_n = 2147483647;
      rep(j,0,m){
        if(memo_n > (abs(a[i]-c[j])+abs(b[i]-d[j]))){
          memo = j+1;
          memo_n = (abs(a[i]-c[j])+abs(b[i]-d[j]));
        }
      }
      cout << memo << endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll k,x;
	cin >> k >> x;
	if (k*500 >= x){
		cout <<"Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    rep(i,0,s.size()){
        if(s[i] == 'C'){
            ans = 1;
        }else if(s[i] == 'F'){
            if(ans == 1){
                ans = 2;
            }
        }
    }
    if(ans == 2){
        print("Yes");
    }else{
        print("No");
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn divide_ceil(a: usize, b: usize) -> usize {
    (a + b - 1) / b
}

fn main() {
    let (n, d) = parse_pair::<usize, usize>();

    let range_length = 2 * d + 1;

    println(divide_ceil(n, range_length));
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

ModInt func[200001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 1;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}
lint H, W, A, B;
int main() {
	cin >> H >> W >> A >> B;
	funcinit(200000);
	ModInt ans = 0;
	REP(i, H - A) {
		ModInt a = comb(B + i - 1, i), b = comb(W - B + H - i - 2, H - i - 1);
		ans += a * b;
	}
	cout << ans.a << endl;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b; cin >> n >> a >> b;
    string ans = ((a-b+1)%2==0 ? "Borys" : "Alice");
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var hmhmk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var min = (int)(new DateTime(2000, 1, 1, hmhmk[2], hmhmk[3], 0) - new DateTime(2000, 1, 1, hmhmk[0], hmhmk[1], 0)).TotalMinutes;
        Console.WriteLine(min - hmhmk[4]);
    }
}


Measured memory_bytes: 28312
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int n;
int m;

struct Coord {
    double l;
    double a;
    double b;
};

double d_abs(double target) {
    if (target < 0) {
        target *= (-1);
    }
    return target;
}

double act(int temp, Vec<Vec<double> > &dist, Vec<double > &dp, Vec<int> &edge) {
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        dp[1 << i] = 0;
        edge[1 << i] = 1;
    }

    for (int i = 0; i < pow(2, n); i++) {
        dp[i] = 0;
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) != 0) {
                edge[i] = edge[i - (1 << j)] + 1;
            }
        }
        for (int j = 0; j < n; j++) {
            if ((i & (1 << j)) != 0) {
                double add_dist = 0;
                for (int k = 0; k < n; k++) {
                    if ((i & (1 << k)) != 0) {
                        add_dist += dist[j][k];
                    }
                }
                dp[i] = max(dp[i], dp[i - (1 << j)] + add_dist);
            }
        }
    }

    double max_ans = 0;
    for (int i = 0; i < pow(2, n); i++) {
        if (edge[i] == m) {
            max_ans = max(max_ans, dp[i]);
        }
    }
    return max_ans;
}

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

    Vec<Coord> list(n);
    for (int i = 0; i < n; i++) {
        cin >> list[i].l >> list[i].a >> list[i].b;
    }
    Vec<Vec<double> > dist(n, Vec<double>(n));
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            double dl = d_abs(list[i].l - list[j].l);
            double da = d_abs(list[i].a - list[j].a);
            double db = d_abs(list[i].b - list[j].b);
            dist[i][j] = dl * dl + da * da + db * db;
            dist[j][i] = dist[i][j];
        }
    }

    Vec<double> dp((pow(2, n)));
    Vec<int> edge_num((pow(2, n)));
    cout << fixed << setprecision(6) << act(n, dist, dp, edge_num) << endl;

    return 0;
}

Measured memory_bytes: 15556
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s,ans;
    int x;
    cin>>s;
    x=s.size();
    ans=s.substr(1,x-2);
    cout<<s[0]<<ans.size()<<s.at(x-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
#define LL long long
const int N = 2000;
LL xi[N], yi[N];
int m;
int xd[] = {-1, 0, 1, 0};
int yd[] = {0, -1, 0, 1};
char dd[] = {'L', 'D', 'R', 'U'};
char now[N];
LL di[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i)
        scanf("%lld%lld", &xi[i], &yi[i]);
    for (int i = 1; i < n; ++ i)
        if ((xi[i] + yi[i] + xi[i + 1] + yi[i + 1]) & 1)
        {
            puts("-1");
            return 0;
        }
    di[++ m] = 1; di[++ m] = 1;
    if (((xi[1] + yi[1]) & 1)) di[++ m] = 1;
    while (m < 40) ++ m, di[m] = di[m - 1] * 2;
    printf("%d\n", m);
    for (int i = 1; i <= m; ++ i) printf("%lld ", di[i]); puts("");
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = m; j >= 1; -- j)
        {
            for (int d = 0; d < 4; ++ d)
            {
                if (abs(xi[i] - xd[d] * di[j]) + abs(yi[i] - yd[d] * di[j]) <= di[j - 1] * 2)
                {
                    xi[i] -= xd[d] * di[j];
                    yi[i] -= yd[d] * di[j];
                    now[j] = dd[d];
                    break;
                }
            }
        }
        fprintf(stderr, "%lld %lld\n", xi[i], yi[i]);
        printf("%s\n", now + 1);
    }
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(){
	char A[101]={0};
	char B[101]={0};
	char C[101]={0};
	char turn;
	int i=0,j=0,k=0;

	scanf("%s %s %s",A,B,C);
	turn=A[i];
	i++;

	while(1){

		if(turn=='a'){
			if(i==strlen(A)){
				printf("A");
				break;
			}

			turn=A[i];
			i++;

		}
		if(turn=='b'){
			if(j==strlen(B)){
				printf("B");
				break;
			}
			turn=B[j];
			j++;

		}
		if(turn=='c'){
			if(k==strlen(C)){
				printf("C");
				break;
			}
			turn=C[k];
			k++;
	
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc160/abc160_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string s;
  cin >> s;
  
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}

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

int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);	
	#endif*/

    int n,i;
    cin>>n;
    int a[n+1]={0},b[n+1]={0},c[n]={0},pts=0,k;
    for(i=1;i<n+1;i++){
    	cin>>a[i];
    }
    for(i=1;i<n+1;i++){
    	cin>>b[i];
    }
    for(i=1;i<n;i++){
    	cin>>c[i];
    }
    for(i=1;i<n+1;i++){
    	
    	k=a[i];
    	pts+=b[k];if(a[i+1]==k+1)pts+=c[k];
    	
    }
    cout<<pts<<"\n";
    return 0; 
} 




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#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 repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  map<char,ll>ma;
  rep(i,4)ma[s[i]]++;
  ll f=1;
  for(auto tp:ma){
    if(tp.second!=2)f=0;
  }
  if(f){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }

  return 0;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

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

	vector<int> h(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> h[i];

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

	int ans = 0;

	for(int u = 1; u <= n; u++){
		int mx = -1;
		for(auto &v : g[u])
			mx = max(mx, h[v]);

		if(h[u] > mx)
			++ans;
	}

	cout << ans << endl;

	return 0;
}


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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    int n; cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    vi b;
    rep(i,1,n+1) {
      b.pb(abs(n-i - (i-1)));
    }
    sort(all(b));
    debug(b);
    int flag = 0;
    sort(all(a));
    rep(i,0,n) {
      if(a[i] != b[i]) flag = 1;
    }
    if(!flag) {
      lli ans = 1;
      rep(i,0,n/2) ans = (ans * 2) % MOD;
      cout<<ans<<endl;
    }
    else cout<<0<<endl;
}



Measured memory_bytes: 1276
A, B = map(int, input().split())

A_min = 12.5 * A
A_max = 12.5 * (A + 1)

B_min = 10 * B
B_max = 10 * (B + 1)


if A % 2 == 0:
    myList1 = list(range(int(A_min), int(A_max + 1)))
else:
    myList1 = list(range(int(A_min + 1), int(A_max)))

myList2 = list(range(int(B_min), int(B_max)))

mySet = list(set(myList1) & set(myList2))

mySet = [item for item in mySet if item >= 1]

if len(mySet) == 0:
    print(-1)
else:
    print(sorted(mySet)[0])

Measured memory_bytes: 3064
n = gets.to_i
a = gets.split.map(&:to_i)
mod = 10 ** 9 + 7

def power(x, n, m)
    n == 0 ? 1 : ((n.odd? ? x : 1) * power(x ** 2 % m, n / 2, m) % m)
end

h = Hash.new(0)
a.each do |e|
    h[e] += 1
    if n.odd? ^ e.even?
        puts 0
        exit
    end
end

if n.odd?
    if h[0] != 1
        puts 0
        exit
    end
    h[0] = 2
    puts h.values.all?{|e| e == 2} ? power(2, n / 2, mod) : 0
else
    puts h.values.all?{|e| e == 2} ? power(2, n / 2, mod) : 0
end

Measured memory_bytes: 11788
#include<stdio.h>

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

int main(){
  int N, minval, ans=-1e9;
  scanf("%d",&N);
  scanf("%d",&minval);
  N--;
  while(N--){
    int num;
    scanf("%d",&num);
    ans = MAX(ans, num-minval);
    minval = MIN(minval, num);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 596
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    A, B, C, D = [int(x) for x in input().strip().split()]
    t = 0
    while A > 0 and B > 0:
        if t == 0:
            C -= B
        else:
            A -= D
        if A <= 0:
            print('No')
            exit()
        elif C <= 0:
            print('Yes')
            exit()
        t ^= 1


if __name__ == '__main__':
    main()

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

int main(){
	int E,Y;
	cin>>E>>Y;
	if(E==0){
		if(1868<=Y && Y<=1911)         cout<<'M'<<Y-1867<<endl;
		else if (1912<=Y && Y<=1925)   cout<<'T'<<Y-1911<<endl;
		else if (1926<=Y && Y<=1988)   cout<<'S'<<Y-1925<<endl;
		else if (1989<=Y && Y<=2016)   cout<<'H'<<Y-1988<<endl;
	}
	else if(E==1){
		cout<<Y+1867<<endl;
	}
	else if(E==2){
		cout<<Y+1911<<endl;
	}
	else if(E==3){
		cout<<Y+1925<<endl;
	}
	else if(E==4){
		cout<<Y+1988<<endl;
	}
	return 0;
}


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

//---------------------------------------------------------------------------------------------------------
#define error( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) {
    vector<string> v;
    stringstream ss( s);
    string x;
    while ( getline( ss, x, c))
        v.emplace_back( x);
    return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
    err( ++it, args...);
}
//----------------------------------------------------------------------------------------------------------

#define pb push_back
#define pfr push_front
#define eb emplace_back
#define ef emplace_front
#define fi first
#define se second
#define mp make_pair
#define fr(i,j,k) for(i = j; i < (k); i++)
#define bck(i,j,k) for(i = j; i > (k); i--)
#define all(x) x.begin(), x.end()
#define el '\n'

typedef long long int ll;
typedef long double DO;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
//---------------------------  TEMPLATE ENDS, MAKE CHANGES FROM HERE ----------------------------------------

const int mod = 1e9+7;
const ll inf = 2e18;
const DO eps = 1e-9;
const int NN = 1e5 + 2;

int ar[NN];

void solve(){
    int i = 0, j = 0, k = 0, n = 0, m = 0;
    cin >> i >> j >> k;
    int a1 = i*10 + j; a1 += k;
    int a2 = j*10+k; a2 += i;
    int a3 = j*10 + i; a3 += k;
    int a4 = i*10 + k; a4 += j;
    int a5 = k*10 + i; a5 += j;
    int a6 = k*10 + j; a6 += i;
    a6 = max(a6 ,a5); a6 = max(a6, a4);
    a6 = max(a6, a3);
    a2 = max(a2, a6);
    cout << (max(a1, a2));
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T = 1, tc;
    fr(tc, 1, T+1){
        solve();
    }
    return 0;
}
/* The judge is never wrong! Your code is buggy 😈
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */



Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
string S;

int main() {
    cin >> N >> S;

    int ans = 0;
    for (int j = 1; j < N; ++j) {
        if (S[j] == 'E') { ++ans; }
    }

    int c = ans;
    for (int j = 1; j < N; ++j) {
        if (S[j] == 'E') {
            --c;
        }
        if (S[j-1] == 'W') {
            ++c;
        }
        ans = min(ans, c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
n = int(input())
a = list(map(int,input().split()))

ans = 0
while 1:
    for i in range(len(a)):
        if a[i]%2 == 0:
            a[i] = a[i]/2
            ans += 1
    cnt = 0
    for i in range(len(a)):
        if a[i]%2 != 0:
            cnt += 1
    if cnt == len(a): break
print(ans)

Measured memory_bytes: 4152
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;

int main(){
    int n;
    int min = 1000;
    cin>>n;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin>>w.at(i);
    }
    for(int i=1;i<n;i++){
        int s1,s2;
        s1 = accumulate(w.begin(),w.begin()+i,0);
        s2 = accumulate(w.begin()+i,w.end(),0);
        if(min>abs(s1-s2)){
            min = abs(s1-s2);
        }
    }
    cout<<min<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s1,s2,x,y;
int len1,len2,f1[27],f2[27];
int main() {
	cin>>s1;len1=s1.length();
	cin>>s2;len2=s2.length();
	x="";y="";
	for(int i=0;i<len1;i++)f1[s1[i]-'a'+1]++;
	for(int i=0;i<len2;i++)f2[s2[i]-'a'+1]++;
	for(int i=1;i<=26;i++){
		for(int j=1;j<=f1[i];j++)
			x=x+(char)(i-1+'a');
	}
	for(int i=26;i>=1;i--){
		for(int j=1;j<=f2[i];j++)
			y=y+(char)(i-1+'a');
	}
	if(x<y)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int N,K;
	cin >> N >> K;
	if(2*K-1<=N){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}



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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int A, B, C, X, Y;

  while (cin >> A >> B >> C >> X >> Y) {
    int ans = INT_MAX;
    int mxC = max(X * 2, Y * 2);
    for (int c = 0; c <= mxC; c++) {
      int m = c * C;

      int remX = max(0, X - c / 2);
      int remY = max(0, Y - c / 2);

      m += remX * A + remY * B;
      ans = min(ans, m);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int r = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());

        int[][] M = new int[r+1][c+1];

        for (int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                M[i][j] = Integer.parseInt(sc.next());
            }
        }

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                M[r][j] += M[i][j];
                M[i][c] += M[i][j];
            }
            M[r][c] += M[i][c];
        }

        for (int i = 0; i < r + 1; i++) {
            for (int j = 0; j < c + 1; j++) {
                if (j == c ) {
                    System.out.printf("%d\n", M[i][j]);
                } else {
                    System.out.printf("%d ", M[i][j]);
                }
            }
        }
    }
}

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

using namespace std;

int main() {
    string s;
    vector<char> dst;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'B') {
            if (dst.size() > 0) {
                dst.pop_back();
            }
        }
        else {
            dst.push_back(s[i]);
        }
    }

    for (auto it = dst.begin(); it != dst.end(); ++it) {
        cout << *it;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

N,K = list(map(int, input().split()))
LRs = [list(map(int, input().split())) for _ in range(K)]

dp = np.zeros(N+2, dtype = int)
dp[1] = 1
dp[2] = -1

atai = 0
for i in range(1, N+2):
    atai += dp[i]
    for LR in LRs:
        if(i+LR[0] <= N):
            dp[i+LR[0]] = (dp[i+LR[0]] + atai) % 998244353
        if(i+LR[1] <= N):
            dp[i+LR[1]+1] = (dp[i+LR[1]+1] -atai) % 998244353

#    print(dp)

#復元
ruisekiwa = [0]

for hoge in dp:
    ruisekiwa.append(ruisekiwa[-1]+hoge)
print(ruisekiwa[N+1] % 998244353)

Measured memory_bytes: 36412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
const ll mod = 1e9+7;
const int N = 1e6+6;
int a[N];
bool vis[N];
bool p[N];
int lst[N];
void solve(){
    memset(p,true,sizeof p);
    p[0] = p[1] = false;
    for(int i=2;i<N;i++){
        if(p[i]){
            lst[i]=  i;
            for(int j=i+i;j<N;j+=i){
                p[j] = false;
                lst[j]=i;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int g = a[1];
    for(int i=1;i<=n;i++)g = __gcd(a[i],g);
    bool cp = true;
    for(int i=n;i>=1;i--){
        if(!cp)break;
        int trt = a[i];
        while(trt>1){
            if(vis[lst[trt]]){
                cp = false;
                break;
            }
            trt/=lst[trt];
        }
        trt = a[i];
        while(trt>1){
            vis[lst[trt]] = true;
            trt/=lst[trt];
        }
    }
    if(cp==true){
        cout<<"pairwise coprime"<<endl;
        return ;
    }
    if(g==1){
        cout<<"setwise coprime"<<endl;
        return ;
    }
    cout<<"not coprime"<<endl;

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


Measured memory_bytes: 12328
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()

	if N%K == 0 {
		fmt.Fprintln(wtr, 0)
	} else {
		fmt.Fprintln(wtr, 1)
	}
	wtr.Flush()
}


Measured memory_bytes: 640
s = [i  for i in input()]
left = ["k", "e", "y", "e", "n", "c", "e"]
right = ["e", "c", "n", "e", "y", "e", "k"]
num = 0
for i in range(7):
    if(s[i] == left[i]):
        num += 1
s = list(reversed(s))
for i in range(7):
    if(s[i] == right[i]):
        num += 1
if(num>=7):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=105*105+2*105;//1~n 为颜色点 n+1~2*n为行点 所有没到过的格子给行->颜色连一条边 跑完后，每个颜色新增的哪个行，标记打上，然后在B里放入这个。 
const int inf=1e9;
struct Flow{
	int s,t,head[maxn],cur[maxn],cnt,q[maxn],rk[maxn];
	struct gg{
		int u,v,w,next;
	}side[maxn*2];
	Flow(){s=maxn-3,t=maxn-2,cnt=1;}
	void reset(){
		cnt=1;memset(head,0,sizeof(head));	
	}
	void ins(int u,int v){
		side[++cnt]=(gg){u,v,1,head[u]};head[u]=cnt;
		side[++cnt]=(gg){v,u,0,head[v]};head[v]=cnt;
	}
	bool bfs(){
		memset(rk,0,sizeof(rk));int hd=1,tl=1;q[tl]=s;rk[s]=1;
		while(hd<=tl){
			int u=q[hd++];
			for(int i=head[u];i;i=side[i].next){
				int v=side[i].v;if(rk[v]||!side[i].w)continue;
				rk[v]=rk[u]+1;q[++tl]=v;
			}
		}
		return rk[t];
	}
	int dfs(int u,int flow){
		if(u==t)return flow;
		int tot=0;
		for(int &i=cur[u];i;i=side[i].next){
			int v=side[i].v;if(rk[u]+1!=rk[v]||!side[i].w)continue;
			int sent=dfs(v,min(flow,side[i].w));flow-=sent;tot+=sent;
			side[i].w-=sent;side[i^1].w+=sent;
		}
		return tot;
	}
	void dinic(){
		int maxflow=0;
		while(bfs()){
			memcpy(cur,head,sizeof(head));
			maxflow+=dfs(s,inf);
		}
	}
}f;
int A[105][105],B[105][105],C[105][105],col[105][105];//col=属于哪一行 
bool used[105][105];
int n,m;
int get_col(int num){
	int tmp=num%m;if(!tmp)tmp=m;
	return (num-tmp)/m+1;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)rep(j,1,m)scanf("%d",&A[i][j]),col[i][j]=get_col(A[i][j]);
	rep(floor,1,m){
		f.reset();
		rep(i,1,n)f.ins(f.s,i),f.ins(i+n,f.t);
		rep(i,1,n)rep(j,1,m)if(!used[i][j])f.ins(col[i][j],i+n);
		f.dinic();
		rep(i,n+1,2*n){//枚举每一行 
			for(int j=f.head[i];j;j=f.side[j].next){
				int v=f.side[j].v;
				if(v<=n&&f.side[j].w){//颜色v->行i-n的匹配被点亮 
					rep(k,1,m){//寻找这一行中符合这一颜色的 
						if(col[i-n][k]==v&&!used[i-n][k]){
							used[i-n][k]=1;
							B[i-n][floor]=A[i-n][k];//填过来 
							break;
						}
					}
					break;
				}
			}
		}
	}
	//现在B中每一列的任意一种颜色只有一个
	rep(i,1,n)rep(j,1,m)C[get_col(B[i][j])][j]=B[i][j];
	rep(i,1,n){rep(j,1,m)printf("%d ",B[i][j]);printf("\n");}
	rep(i,1,n){rep(j,1,m)printf("%d ",C[i][j]);printf("\n");}
	return 0;
}

Measured memory_bytes: 4460
#include <stdio.h>

int main(void)
{
  int tako[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int i;
  
  scanf("%d", &i);
  printf("%d", tako[i - 1]);
  return (0);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

#define MAX 500000

void ins(int);
void Pre(int);
void Ino(int);


typedef struct{
  int key;
  int p;
  int l[2];
} Node;

Node t[MAX];

int main(){
  int i, n;
  char s[7];

      scanf("%d", &n);

      for(i = 0; i < n; i++){
        t[i].key = -1;
        t[i].l[0] = -1;
        t[i].l[1] = -1;
      }


      for(i = 0; i < n; i++){
        scanf("%s", s);
        if(strcmp(s, "insert") == 0){
          scanf("%d", &t[i].key);
          ins(i);
        }
        else if(strcmp(s, "print") == 0){
          Ino(0);
          printf("\n");
          Pre(0);
          printf("\n");
        }
      }

      return 0;
}

void ins(z){
  int x, y;

    y = -1;
  x = 0;

      while(1){
    if(x == -1 || z == 0) break;
    y = x;
    if(t[z].key < t[x].key) x = t[x].l[0];
    else x = t[x].l[1];
    }

          t[z].p = y;
              if(y != -1){
    if(t[z].key < t[y].key) t[y].l[0] = z;
    else t[y].l[1] = z;
    }
}


void Pre(int a){
  printf(" %d", t[a].key);

    if(t[a].l[0] != -1) Pre(t[a].l[0]);
  if(t[a].l[1] != -1) Pre(t[a].l[1]);
}


void Ino(int a){
  if(t[a].l[0] == -1){
    printf(" %d", t[a].key);
    if(t[a].l[1] != -1) Ino(t[a].l[1]);
    }
  else{
    Ino(t[a].l[0]);
    printf(" %d", t[a].key);
    if(t[a].l[1] != -1) Ino(t[a].l[1]);
    }
}

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

int main() {
  int N,sum=0;
  double ave;
  cin >> N;
  vector<int> man(N);
  
  for(int i = 0; i<N; i++){
    cin >> man.at(i);
    sum += man.at(i);
  }
  
  ave = (double)sum/N;
  ave = round(ave);
  
  int output=0;
  for(int i = 0; i<N; i++){
    output += (man.at(i) - ave)*(man.at(i) - ave);
  }
  
  cout << output << endl;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a <= 8 && b<= 8){
            System.out.println("Yay!");
        }else{
        System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21844
import collections,sys
n=int(input())
v=list(map(int,input().split()))
a=[]
b=[]
for i in range(0,n,2):
  a.append(v[i-1])
  b.append(v[i])
c=collections.Counter(a)
d=collections.Counter(b)
C=sorted(c.items(), key=lambda x:-x[1])
D=sorted(d.items(), key=lambda x:-x[1])
A=int(C[0][0])
B=int(D[0][0])
cnt=0
if len(set(v))==1:
  print(n//2)
  sys.exit()
if A!=B:
  for i in range(n//2):
    if a[i]!=A:
      cnt+=1
  for j in range(n//2):
    if b[j]!=B:
      cnt+=1
  print(cnt)
  sys.exit()
if A==B:
  totla=0
  A_=int(C[1][0]) if len(set(a))!=1 else A
  for i in range(n//2):
    if a[i]!=A_:
      totla+=1
  for j in range(n//2):
    if b[j]!=B:
      totla+=1
  totlb=0
  B_=int(D[1][0]) if len(set(b))!=1 else B
  for i in range(n//2):
    if a[i]!=A:
      totlb+=1
  for j in range(n//2):
    if b[j]!=B_:
      totlb+=1
  print(min(totla,totlb))
  sys.exit()
  
  
  
  
    
    
    

    





Measured memory_bytes: 29920
#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>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll x;
	cin >> n >> x;
	vector<ll> a(2*n);
	rep(i,n){
		cin >> a[i];
		a[i+n] = a[i];
	}
	vector<vector<ll>> mi(n, vector<ll>(n, INF));
	rep(i,n){
		rep(j,n){
			mi[i][j] = min(mi[i][max(0,j-1)], a[i+n-j]);
		}
	}
	ll ans = 1e18;
	rep(i,n){
		ll cost = x * i;
		rep(j,n){
			cost += mi[j][i];
		}
		chmin(ans, cost);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31744
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ctime>
#include <set>
#include <sstream>
#include <bitset>
#define fi first
#define se second
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define MAXN 200009
using namespace std;

int main () {
    unordered_map<int, int>mp;
    int n;
    cin>>n;
    for (int i= 0; i < n - 1; i++) {
        int x;
        cin>>x;
        mp[x]++;
    }
    for (int i = 0; i < n; i++) {
        cout<<mp[i + 1]<<"\n";
    }
}


Measured memory_bytes: 11472
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in();
    ll S = 0;
    vecll a(n),sum(n);
    rep(i,n){
        a[i]=lin();
        S+=a[i];
        if(i==0)sum[0]=a[0];
        else sum[i]=sum[i-1]+a[i];
    }
    ll ans = LONG_MAX;
    rep(i,n)ans=min(ans,abs(2 * sum[i] - S));
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
void treeDelete(Node);
Node treeSearch(Node, int);

#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
    while (u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void treeDelete(Node z){
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

     while (x != NIL){
         y = x;
         if (z->key < x->key)
             x = x->left;
         else 
             x = x->right;
     }
     z->parent = y;
    if (y == NIL)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else 
        y->right = z;

}

void inorder(Node u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}

void preorder(Node u){
    if(u == NIL) return;
    printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      }
      if(com[0] == 'i'){
          scanf("%d", &x);
      insert(x);
      }
      else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
 else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
}
  return 0;
}



Measured memory_bytes: 20484
#include <iostream>
#include <vector>
#include <map>
#define rep(i, N) for(int i = 0; i < N; ++i)

typedef long long ll;

using namespace std;

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

    vector<ll> a;
    map<ll, ll> data;

    rep(i, n)
    {
        ll x;
        cin >> x;
        a.push_back(x);
        data[x]++;
    }


    ll total = 0;
    auto begin = data.begin();
    auto end = data.end();
    for (auto iter = begin; iter != end; iter++)
    {
        // cout << iter->first << "->" << iter->second << endl;
        ll value = iter->second;
        total += value * (value - 1) / 2; 
    }

    //cout << total << endl;    

    rep(i, n)
    {
        ll oldCount = data[a[i]];
        ll newCount = oldCount-1;

        ll old = oldCount * (oldCount - 1 ) / 2;
        ll n = newCount * (newCount - 1) / 2;

        cout << total - old + n  << endl;
    }
    return 0;
}


Measured memory_bytes: 11120
N = int(input())
P = [int(i) for i in input().split()]
min_ = 9999999999
ans = 0
for i in range(N):
    
    min_ = min(P[i], min_)

        
    if P[i] == min_:
        #print(P[i], i_max)
        ans += 1
    
    #if not flag:
    #    ans += 1
#print(ans.keys())
print(ans)

Measured memory_bytes: 76752
package main

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

func main() {
	var n int
	fmt.Scan(&n)
	var t, u int64
	fmt.Scan(&u)
	for i := 1; i < n; i++ {
		fmt.Scan(&t)
		u = lcm(u, t)
	}
	fmt.Println(u)
}

func lcm(a, b int64) int64 {
	return (a / gcd(a, b)) * b
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}

func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func max(i, j int) int {
	if i < j {
		return j
	}
	return i
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans1 = a*10+b*10;
  int ans = ans1/2;
  int ans_ans = ans/10;
  if(ans%10 >= 5 && ans%10 <= 9){
    ans_ans++;
  }
  cout << ans_ans << endl;
}


Measured memory_bytes: 256
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc163_c
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    int n;
    scanf("%d", &n);
    vector<int> f(n+1);
    for(int i=1; i<n; i++) {
        int x;
        scanf("%d", &x);
        f[x]++;
    }
    for(int i=1; i<=n; i++) {
        printf("%d\n", f[i]);
    }
}


Measured memory_bytes: 4068
n = int(input())

s = [""] *  n
for i in range(n):
    s[i] = input()

ans = ""
for i in range(26):
    cnt = 50
    for j in range(n):
        cnt = min(cnt, s[j].count(chr(ord("a") + i)))
    ans += chr(ord("a") + i) * cnt
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    vector<int> hist(26);
    rep(i, s.size()) { hist[s[i] - 'a']++; }
    rep(i, 26) {
        if(hist[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512