akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

class UnionFindTree {
public:
    vector<ll> m_parents; // 親ノードの番号を格納。-1なら自分自身が親(root)

     // 頂点数で初期化。最初は全てのノードが非連結。
    UnionFindTree(ll x) : m_parents(x, -1) {}

    // xがどのグループに属しているかを調べる。
    ll root(ll x) {
        if (m_parents[x] < 0) {
            return x;
        }
        m_parents[x] = root(m_parents[x]); // 高速化のため、親を根に繋ぎかておく。
        return m_parents[x];
    }

    // xの属するグループの頂点数を調べる。
    ll size(ll x) { return -m_parents[root(x)]; }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            return false; // すでにくっついているからくっつけない。
        }

        // ノード番号の大きい方(x)に小さい方(y)をくっつけたい。
        if (size(x) < size(y))
            swap(x, y);

        // xのサイズを更新。
        m_parents[x] += m_parents[y];
        // yの親をxにする。
        m_parents[y] = x;
        return true;
    }

    // 同じグループか？
    bool is_same_group(ll x, ll y) { return root(x) == root(y); }
};

int main()
{
    ll N, M; cin >> N >> M;
    vector<ll> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    UnionFindTree uf(N);
    ll non_unite = N * (N - 1) / 2;
    vector<ll> ans(M);
    for (int i = 0; i < M; i++) {
        ans[i] = non_unite;
        ll a = A[M-1-i], b = B[M - 1 - i]; // ケツからみていく
        if (uf.is_same_group(a, b)) {
            // 連結数が変わらない -> 非連結数もへらない
        }
        else {
            non_unite -= uf.size(a) * uf.size(b);
        }
        uf.unite(a, b);
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < M; i++) {
        cout << ans[i] << endl;
    }
}

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

signed main(){
  string ss;
  int k;cin>>ss>>k;
  for(int i=0;i<min((int)ss.size(),k);i++){
    if(ss.at(i)>'1'){cout<<ss.at(i)<<endl;return 0;}
  }
  cout<<1<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#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>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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


int main() {
	int n, m;
	cin >> n >> m;
	int l = 1, r = n;
	REP(i, m) {
		int tmp_l, tmp_r;
		cin >> tmp_l >> tmp_r;
		l = max(tmp_l, l);
		r = min(tmp_r, r);
	}
	if (r - l + 1 < 0) {
		ANS(0);
	}
	else {
		ANS(r - l + 1);
	}
	


	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
      String s = scan.next();
      int a = Integer.parseInt(s.substring(0,2));
       int b = Integer.parseInt(s.substring(2));
       if(a!=0 && a<=12) {
    	   if(b!=0 && b<=12) {
    		   System.out.println("AMBIGUOUS");
    	   }else {
    		   System.out.println("MMYY");
    	   }
       }else {
    	   if(b!=0 && b<=12) {
    		   System.out.println("YYMM");
    	   }else {
    		   System.out.println("NA");
    	   }
       }
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk; 
	cin>>n;
	if(n%2==0||n%5==0)
	{
		printf("-1\n");
	}
	else
	{
		ll s=0;
		k=7;
		while(1)
		{
			k=k%n;
			s++;
			if(k%n==0)
			break;
			else k=k*10+7;
			
		}
		cout<<s<<endl;
	}
} 

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double
#define all(x) (x).begin(), (x).end()

int mod = 1e9 + 7;

int binpow(int a, int b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a % mod;
    int c = binpow(a, b / 2);
    c = (c * c) % mod;
    if (b % 2)
        c = (c * a) % mod;
    return c;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, t;
    cin >> n >> m >> t;
    int r = __gcd(n, t);
    n /= __gcd(n, t);
    r *= __gcd(m, t);
    m /= __gcd(m, t);
    cout << binpow((binpow(2, n) + binpow(2, m) + binpow(2, __gcd(n, m)) - 3 + mod) % mod, r);
}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    s = IS()
    t = IS()
    ls = len(s)
    lt = len(t)
    for i in reversed(range(ls-lt+1)):
        ss = s[i:i+lt]
        for j in range(lt):
            if ss[j] == '?' or ss[j] == t[j]: continue
            else: break
        else:
            s = s[:i] + t + s[i+lt:]
            ans = s.replace('?', 'a')
            print(ans)
            exit(0)
    print('UNRESTORABLE')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b, c, d ,e, k; cin >> a >> b >> c >> d >> e >> k;
    
    cout << ((e-a)<=k ? "Yay!":":(") << endl;
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

struct UnionFind{
    vector<ll> par,siz;

    UnionFind(ll N):par(N+1),siz(N+1,1){
        rep1(i,N) par[i]=i; //親を自分自身として初期化
    }

    ll root(ll x){
        if(par[x]==x){
            return x;
        }
        else{
            return  par[x]=root(par[x]);
        }
    }
    void unite(ll x,ll y){
        x=root(x);
        y=root(y);
        if(x==y) return;

        if(siz[x]<siz[y]) swap(x,y);
        
		siz[x]+=siz[y];
		par[y]=x;
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    ll size(ll x){
        return siz[root(x)];
    }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct edge{
    ll from,to,cost;

    // コストの大小で順序定義
    bool operator<(const edge& o) const {
        return cost<o.cost;
    }
};

// 頂点数と辺集合の組として定義したグラフ
struct graph{
    ll n;  // 頂点数
    vector<edge> es;  // 辺集合

    graph(ll N){
        n=N;
    }

    void add_edge(ll from,ll to,ll cost){
        edge e;
        e.from=from;
        e.to=to;
        e.cost=cost;
        es.pb(e);
    }

    // クラスカル法で無向最小全域木のコストの和を計算する
    // グラフが非連結のときは最小全域森のコストの和となる
    ll kruskal() {
        // コストが小さい順にソート
        sort(all(es));

        UnionFind uf(n);
        ll res=0;

        rep(i,sz(es)){
            edge& e = es[i];
            if (!uf.same(e.from,e.to)){
                // 辺を追加しても閉路ができないなら、その辺を採用する
                res+=e.cost;
                uf.unite(e.from,e.to);
            }
        }

        return res;
    }
};

int main(){
    ll N; cin>>N;
    graph g(N); // N頂点用意

    vector<P> x(N); //x,i-1
    vector<P> y(N); //y,i-1
    vector<P> p(N); //x,y
    rep(i,N){
        ll X,Y; cin>>X>>Y;
        p[i]=P(X,Y);
        x[i]=P(X,i);
        y[i]=P(Y,i);
    }
    sort(all(x));sort(all(y));

    rep(i,N-1){
        g.add_edge(x[i].b,x[i+1].b,min(abs(p[x[i].b].a-p[x[i+1].b].a),abs(p[x[i].b].b-p[x[i+1].b].b)));
        g.add_edge(y[i].b,y[i+1].b,min(abs(p[y[i].b].a-p[y[i+1].b].a),abs(p[y[i].b].b-p[y[i+1].b].b)));
    }
    
    cout<<g.kruskal();
}

Measured memory_bytes: 13040
def change_ten_to_kisu(num, kisu):      # 10進数をkisu進数に変換 (int, int) => int
    r = 0
    syo = num
    count = 0
    while syo >= kisu:
        r += (syo % kisu) * 10 ** count
        syo = syo // kisu
        count += 1
    return r + syo * 10 ** count

def change_kisu_to_ten(num, kisu):      # kisu進数を10進数に変換 (int, int) => int
    n = str(num)
    r = 0
    for i in range(len(n)):
        r += int(n[-i - 1]) * kisu ** i
        # print(r, int(n[-i - 1]), kisu ** i)
    return r

def plus(num):                   # 3, 5, 7のみを使用しnumより大きい数を返す
    change = {"3" : "0", "5" : "1", "7" : "2"}
    change_r = {"0" : "3", "1" : "5", "2" : "7"}
    t = ""
    for i in str(num):
        t += change[i]
    r = change_ten_to_kisu(change_kisu_to_ten(int(t), 3) + 1, 3)
    if len(t) < len(str(r)):
        r = "0" + str(r)[1:]
    elif len(t) > len(str(r)):
        r = "0" * (len(t) - len(str(r))) + str(r)
    t = ""
    for i in str(r):
        t += change_r[i]
    return int(t)

N = int(input())

i = 3
count = 0
while i <= N:
    if "3" in str(i) and "5" in str(i) and "7" in str(i):
        # print(i)
        count += 1
    i = plus(i)
print(count)

Measured memory_bytes: 3572
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out ="";
    while (scanner.hasNext()) {
      double x = scanner.nextDouble();
      double h = scanner.nextDouble();
      if (x == 0 && h == 0) {
        break;
      }
      out += Math.sqrt((x / 2) * (x / 2) + h * h) * x * 2 + x * x + "\n";
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 18528
#include<iostream>
#include<stdio.h>

using namespace std;

int max(int x, int y){
        int r;

        while((r = x % y) != 0){
                x = y;
                y = r;
        }
        return y;
}

long long int small(long long int x,long long  int y, int r){
        if(x * y % r  == 0)
                return x * y / r;
        else
                return x * y;
}       

int main(){
        int x,y,r;

        while((scanf("%ld %ld",&x,&y)) != EOF){
                if(x < y){
                        int num = y;
                        y = x;
                        x = num;
                } 
                cout << max(x,y) << " " << small(x,y,max(x,y)) << endl;
        }
}

Measured memory_bytes: 1212
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]

C=[]
for i in range(n):
    line=[]
    for j in range(l):
        c=0
        for k in range(m):
            c+=A[i][k]*B[k][j]
        line.append(c)
    C.append(line)
    
for line in C:
    print(*line)


Measured memory_bytes: 7060
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}



void solve()
{
	int a, b;
	cin >> a >> b;
	cout << (b % a ? (b - a) : b + a);
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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();
        int c = sc.nextInt();
      
        int colorNum = 0;
      
        if (a == b && b == c) {
          colorNum = 1;
        } else if (a == b || b == c || a == c) {
          colorNum = 2;
        } else {
          colorNum = 3;
        }
          
        System.out.println(colorNum);
	} 
}

Measured memory_bytes: 20692
#include <iostream>
using namespace std;
using ll = long long;
int main(){
  ll n,m;
  cin >> n >> m;

  ll h = n-2 >= 0 ? n-2:0;
  ll w = m-2 >= 0 ? m-2:0;
  ll ans = h*w;
  if(n == 1 && m == 1) ans = 1;
  else if(n == 1) ans = m-2;
  else if(m == 1) ans = n-2;

  cout << ans << endl;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int solve(int n, int k) {
    if (n == 1) return 0;
    return (solve(n-1, k) + k) % n;
}

int main() {
    int n, m, k;
    while (cin >> n >> k >> m, n) {
        m = (m - k + 1 + n) % n;
        cout << (solve(n,k)+m-1+n)%n+1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3412
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

#include<bits/stdc++.h>
using namespace std;

void Main()
{
    int N;
    cin >> N;
    vector<int> A(10);
    rep(i, N){
        cin >> A[i];
    }
    int ans = 1;
    int odd = 1;
    rep(i, N){
        if(A[i] == 1 && A[i] == 100){
            ans *= 2;
            odd *= 1;
        }else{
            if(A[i] % 2 == 0){
                ans *= 3;
                odd *= 2;
            }else{
                ans *= 3;
                odd *= 1;
            }
        }
    }
    cout << ans - odd << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
import bisect

N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()


ans = 0
for i in range(N):
	ans += bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i]))

print(ans)

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

string s[50];
int res[50][50];

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

    int h, w;
    cin >> h >> w;
    rep(i, h) cin >> s[i];
    rep(i, h) rep(j, w) {
        if(s[i][j] == '#') {
            if(i > 0) ++res[i - 1][j];
            if(i < h - 1) ++res[i + 1][j];
            if(j > 0) ++res[i][j - 1];
            if(j < w - 1) ++res[i][j + 1];
            if(i > 0 && j > 0) ++res[i - 1][j - 1];
            if(i < h - 1 && j < w - 1) ++res[i + 1][j + 1];
            if(j < w - 1 && i > 0) ++res[i - 1][j + 1];
            if(i < h - 1 && j > 0) ++res[i + 1][j - 1];
        }
    }
    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '#') cout << s[i][j];
            else cout << res[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())

A=[]
B=[]
for i in range(N):
    a, b=map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2==0:
    sca=scb=N//2-1
    lca=lcb=N//2
    x=A[lca]+A[sca]
    y=B[lcb]+B[scb]
    print(y-x+1)
    
    
else:
    ca=cb=N//2
    ans=B[cb]-A[ca]+1
    print(ans)
    


Measured memory_bytes: 25544
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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+1;

bool PX[30000], PY[30000];
vector<ll> X, Y;

int main() {
    string s;
    ll x, y; cin >> s >> x >> y;
    ll isx = 1;
    
    ll k = 0, tmp = 0;
    while (s[k] == 'F') {
        x--; k++;
    }
    for (; k < s.length(); k++) {
        if (s[k] == 'T') {
            isx = isx * -1;
        } else {
            tmp = 0;
            while (k < s.length() && s[k] == 'F') {
                tmp++;
                k++;
            }
            if (isx == 1) X.push_back(tmp);
            else Y.push_back(tmp); k--;
        }
    }


    ll xsum = 0, ysum = 0;
    for (ll i = 0; i < X.size(); i++) {
        xsum += X[i];
    } 
    for (ll i = 0; i < Y.size(); i++) {
        ysum += Y[i];
    }
    if ((xsum + x) % 2 == 1 || (ysum + y) % 2 == 1) {
        cout << "No\n"; return 0;
    }

    PX[0] = true, PY[0] = true;

    for (ll i = 0; i < X.size(); i++) {
        for (ll j = 8000; j >= 0; j--) {
            if (PX[j]) PX[j+X[i]] = true;
        }
    }
    for (ll i = 0; i < Y.size(); i++) {
        for (ll j = 8000; j >= 0; j--) {
            if (PY[j]) PY[j+Y[i]] = true;
        }
    }

    if ((xsum+x)>=0 && (ysum+y)>=0 && PX[(xsum+x)/2] && PY[(ysum+y)/2]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }






}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(){
    char s[200000];
    scanf("%s",s);
    int n = strlen(s);
    int a[n];
    int k, j;
    for(int i = 0; i < n; i++)
        a[i] = 0;
    for(int i = 0; i < n; i = k){
        int x, y;
        j = i + 1;
        while(j < n && s[j] == 'R')
            j++;
        k = j + 1;
        while(k < n && s[k] == 'L')
            k++;
        x = j - i;
        y = k - j;
        a[j - 1] = (x + 1) / 2 + y / 2;
        a[j] = x / 2 + (y + 1) / 2;
    }
    for(int i = 0; i < n; i++)
        printf("%d ",a[i]);
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int main(void){
char s[200005];
  int count,fin,start,max=0;
  scanf("%s",s);
  for(count=0;;count++){
  if(s[count]=='A'){start=count;break;}
  }
    for(count=0;;count++){
  if(s[count]=='Z'){fin=count;}
      if(s[count]=='\0'){break;}
  }
  printf("%d",fin-start+1);
return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        string t;
        cin>>t;
        if(t=="print"){
            int m,n;
            cin>>m>>n;
            string pri=S.substr(m,n-m+1);
            cout<<pri<<endl;
        }
        else if(t=="reverse"){
            int m,n;
            cin>>m>>n;
            string rev=S.substr(m,n-m+1);
            reverse(rev.begin(),rev.end());
            S=S.replace(m,n-m+1,rev);
        }
        else if(t=="replace"){
            int m,n;
            cin>>m>>n;
            string p;
            cin>>p;
            S.replace(m,n-m+1,p);
        }
    }
}


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

signed main() {
	string s;
	cin >> s;
	int k = 0;
	rep(i, 3) {
		if(s[i] == '1') {
			k++;
		}
	}
	cout << k << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int r,d,x;
  scanf("%d %d %d", &r, &d, &x);
  for(int i = 0; i < 10; i ++){
    x = r*x-d;
    printf("%d", x);
    if (i < 9) printf("\n");
  }
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
A, B = map(int, input().split())
S = input()
for i in range(len(S)):
    if i<A:
        if S[i].isdigit():
            pass
        else:
            print("No")
            break
    elif i==A:
        if S[i]!="-":
            print("No")
            break
    else:
        if S[i].isdigit():
            pass
        else:
            print("No")
            break
else:
    print("Yes")


Measured memory_bytes: 8952
N = gets.to_i
H_array = gets.split.map(&:to_i)
h_bucket = [-1]
count = 0
H_array.each{|h|
  isview = true
  h_bucket.each{|b|
    if b > h
      isview = false
      break
    end
  }

  if isview
    count += 1
    h_bucket << h
  end
}

puts count


Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll n,m,k;
    cin >> n >> m >> k;

    ll flag=0;
    REP(i,n+1){
        REP(j,m+1){
            if(i*(m-j)+j*(n-i)==k){
                flag = 1;
            }
        }
    }
    if(flag==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
lli MOD=998244353;
lli powa(lli x,lli y)
{
	lli ans=1;
	lli m=MOD;
	while(y>0)
	{
		if(y%2==1)
		{
			ans*=x;
			ans%=m;
		}
		y/=2;
		x=x*x;
		x%=m;
	}
	return ans%m;
}
#define FAC 200005
lli fac[FAC+1];
lli invfac[FAC+1];
lli cnk(lli n, lli k) {
    return (fac[n] * invfac[n - k] % MOD * invfac[k] % MOD)%MOD;
}
int main()
{
    fac[0]=invfac[0]=1;
    for(int i=1;i<=FAC;i++)
    {
        fac[i]=(fac[i-1]*i)%MOD;
        invfac[i]=powa(fac[i],MOD-2);
    }
	lli n,m,k;
	cin>>n>>m>>k;
	lli ans=0;
	for(int i=0;i<=k;i++)
	{
		ans+=(cnk(n-1,i)*((m*powa(m-1,n-(i+1)))%MOD))%MOD;
		ans%=MOD;
	}
	cout<<ans;
}


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

int main()
{
    long long a,dem=0;
    for(int i=1;i<=3;i++)
    {
        cin >> a;
        if(a==5) dem++;
    }
    if(dem==2)
        cout << "YES";
    else
        cout << "NO";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int n,i,c,j;
    while(scanf("%d",&n)==1){
        string s[n];
        int a[n];
        for(i=0;i<n;i++){
            cin>>s[i];
            a[i]=0;
        }
        c=0;
        sort(s,s+n);
        for(i=0;i<n;i++){
            a[i]++;
            for(j=i+1;j<n;j++){
                if(s[i]==s[j])
                    a[i]++;
                else
                    break;
            }
            if(a[i]>c)
                c=a[i];
            i=j-1;
        }
        for(i=0;i<n;i++){
            if(a[i]==c){
                cout<<s[i]<<'\n';
                i+=c-1;
            }
        }
    }
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  while (true)
  {
    ll n, x;
    cin >> n >> x;

    if (n == 0 && x == 0)
      return 0;

    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
      for (ll j = i + 1; j <= n; j++)
      {
        ll k = x - i - j;
        if (j < k && k <= n)
          ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3076
s1, s2, s3 = input().split()
s1 = s1[0]
s2 = s2[0]
s3 = s3[0]

table1 = list("abcdefghijklmnopqrstuvwxyz")
table2 = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
def converter(st):
  n = table1.index(st)
  return table2[n]

s1 = converter(s1)
s2 = converter(s2)
s3 = converter(s3)
print(s1,end='')
print(s2,end='')
print(s3,end='')
print()


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

const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    int ans=0;
    rep(i,n){
        int tmp;
        cin >> tmp;
        int a=0;
        while(tmp%2==0){
            a++;
            tmp/=2;
        }
        ans+=a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
S1,S2=input(),input()
mod=1000000007
if S1[0]==S2[0]:
    ans=3
    i=1
else:
    ans=6
    i=2
while i<n:
    if S1[i-1]==S2[i-1] and S1[i]==S2[i]:
        ans=(ans*2)%mod
    elif S1[i-1]==S2[i-1] and S1[i]!=S2[i]:
        ans=(ans*2)%mod
    elif S1[i-1]!=S2[i-1] and S1[i]!=S2[i]:
        ans=(ans*3)%mod
    if S1[i]!=S2[i]:
        i+=1
    i+=1
print(ans)

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

int main(){
  int n; cin>>n;
  int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  num[0]--;
  for(int i=0;i<n-1;i++){
    if(num[i]<=num[i+1]){
      if(num[i]<num[i+1]) num[i+1]--;
      continue;
    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}     

Measured memory_bytes: 640
n=int(input())
s=list(map(int,input().split()))
m=int(input())
for i in range(m):
    a,b,c=map(int,input().split())
    if a==0:
        d=min(s[b:c])
    else:
        d=max(s[b:c])
    print(d)

    


Measured memory_bytes: 5624
// Sum of product of pairs

package main

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

func calcProduct(a []int64) int64 {
	const M = 1000000007
	var acc, s int64

	acc = 0
	for i := 1; i < len(a); i++ {
		acc += a[i]
	}
	acc %= M

	s = 0
	for i := 0; i < len(a)-1; i++ {
		s += a[i] * acc
		s %= M
		acc -= a[i+1]
		if acc < 0 {
			acc += M
		}
	}
	return s
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	t := sc.Text()
	return strconv.Atoi(t)
}

func nextInt64(sc *bufio.Scanner) (int64, error) {
	sc.Scan()
	t := sc.Text()
	return strconv.ParseInt(t, 10, 64)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := nextInt(sc)

	a := make([]int64, n)
	for i := 0; i < n; i++ {
		aa, _ := nextInt64(sc)
		a[i] = aa
	}

	r := calcProduct(a)
	fmt.Println(r)
}


Measured memory_bytes: 5860
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s>>t;
    if(s=="H" && t=="H") cout << "H";
    if(s=="D" && t=="H") cout <<"D";
    if(s=="D" && t=="D") cout <<"H";
    if(s=="H" && t=="D") cout <<"D";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  ld N, K;
  cin >> N >> K;

  // ll a = log2l;

  ld sum = 0;
  rep(i, N + 1) {
    if (i == 0) {
      continue;
    }

    if (i >= K) {
      sum += 1;
      continue;
    }

    ld kyoukai = K / (ld)i;

    ll num = 2;
    ll count = 1;
    while (num < kyoukai) {
      num *= 2;
      count++;
    }
    // debug(num);
    // debug(count);
    sum += powl(0.5, count);
    // debug(sum);
    // debug(a);
  }

  COUTF(sum / N);

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b;
    while(scanf("%lld %lld",&a,&b)!=EOF){
        printf("%lld %lld\n",__gcd(a,b),a/__gcd(a,b)*b);
    }
    return 0;
}

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

typedef unsigned long long llint;
#define FOR(i, a, b) for(llint i = a; i <= b; ++i)
#define REP(i, n) for(llint i = 0; i < n; ++i)

const llint maxSUM = 111'111;
const llint mod = 1'000'000'007;

llint fact[maxSUM + 1];
llint inv[maxSUM + 1];

void scale(llint &value) {
    value %= mod;
}

llint fastExp(llint a, llint n) {
    if (a == 0) {
        return 0;
    }
    llint res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void preProcess() {
    fact[0] = inv[0] = 1;
    FOR(i, 1, maxSUM) {
        fact[i] = fact[i - 1] * i;
        scale(fact[i]);
        inv[i] = fastExp(fact[i], mod - 2);
        scale(inv[i]);
    }
}

llint combination(llint N, llint K) {
    llint res = inv[K] * inv[N - K];
    scale(res);
    res *= fact[N];
    scale(res);
    return res;

}

llint double_combination(llint sum, llint nTerms) {
    llint N = sum + nTerms - 1; // <= 30 + 10^5 - 1
    llint K = nTerms - 1; // <= 10^5 - 1
    return combination(N, K);
}

void run() {
    llint ans = 1, n, m;

    preProcess();
    cin >> n >> m;

    for (llint p = 2; p * p <= m; ++p) {
        if (m % p == 0) {
            llint deg = 0;
            while (m % p == 0) {
                m /= p;
                deg += 1;
            }
            ans *= double_combination(deg, n);
            scale(ans);
        }
    }

    if (m > 1) {
        ans *= double_combination(1, n);
        scale(ans);
    }

    cout << ans << "\n";
}

static void run_with_stack_size(void (*func)(), size_t stackSize) {
    char *stack, *send;
    stack = (char*) malloc(stackSize);
    send = stack + stackSize - 16;
    send = (char*) ((uintptr_t) send / 16 * 16);
    asm volatile(
    "mov %%rsp, (%0)\n"
    "mov %0, %%rsp\n"
    :
    : "r" (send));
    func();
    asm volatile(
    "mov (%0), %%rsp\n"
    :
    : "r" (send));
    free(stack);
}

int main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#endif
    run_with_stack_size(run, 256*1024*1024);
#ifdef LOCAL
    fclose(stdin);
#endif
    return 0;
}

Measured memory_bytes: 3968
#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>;

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

  double ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    }
  }
  cout << fixed << setprecision(15) << ans * 2 / n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
long long power(long long k , long long n , long long m=1e9+7)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    vector<pair<ll,ll> > v;
    n = 5 ;
    c = 0 ;
    for(i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        if(a%10==0)
        {
        	c+=a ;
		}
		else
		{
			pll p1 ;
			p1.first = 10 - a%10 ;
			p1.second = a ;
			v.pb(p1) ;
		}
    }
    //cout<<c<<"\n" ;
    sort(all(v)) ;
    for(i=0 ; i<v.size() ; i=i+1)
    {
    	c = c + v[i].second ;
    	//cout<<v[i].second<<" " ;
    	if(i<v.size()-1)
    	{
    		c = c + v[i].first ;
		}
	}
    cout<<c ;

}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int howManyDevide(int n){
    int count = 0;
    while(n%2==0){
        count++;
        n /= 2;
    }
    return count;
}

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

    // input
    int N;
    cin >> N;

    int max_devide = 0;
    int max_number = 1;

    FOR(i, 1, N+1){
        int devideNum = howManyDevide(i);
        if(max_devide < devideNum){
            max_devide = devideNum;
            max_number = i;
        }
    }

    p(max_number);
    
    return 0;
}

Measured memory_bytes: 256
list=[int(i) for i in input().split()]

if list[0]>list[1]:
    a=list[0]
    b=list[1]
else:
    b=list[0]
    a=list[1]    


if a%b==0:
    print(b)
else:
    while b>0:
        c=a%b
        a=b
        b=c
    print(a)



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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d)
        cout << "Left" << endl;
    else if (a + b == c + d)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S,T; cin>>S>>T;

    vector<int> vS(S.size(),-1),vT(T.size(),-1);
    map<char,int> mpS,mpT;
    rep(i,0,S.size()){
        char cS=S.at(i),cT=T.at(i);

        if(mpS.count(cS)){
            vS.at(i)=mpS[cS];
        }else{
            mpS[cS]=i;
        }

        if(mpT.count(cT)){
            vT.at(i)=mpT[cT];
        }else{
            mpT[cT]=i;
        }
    }

    string ans="No";
    if(vS==vT) ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 2312
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll a[2001];
ll b[2001];
int main() {
	ll n, x; cin >> n >> x;
	rep(i, 0, n) {
		cin >> a[i];
		b[i] = a[i];
	}

	ll ans = INF;
	rep(k, 0, n) {
		ll can = k * x;
		rep(i, 0, n)b[i] = min(b[i], a[(i - k + n) % n]);
		rep(i, 0, n)can += b[i];
		ans = min(ans, can);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll N,A,B;
ll h[100000];
map<ll,int> mp; //i回で殺しきれるか

ll bsrc(ll a, ll b){
  //cout << a << " " << b << endl;
  ll p = (b + a) / 2;

  ll cnt = 0;
  for(int i=0;i<N;i++){
    ll tmp = h[i] - p * B;
    if(tmp > 0){
      cnt += (tmp + (A-B) - 1) / (A-B);
    }
  }

  if(cnt > p) mp[p] = -1;
  else mp[p] = 1;

  if(mp[p] == 1 && mp[p-1] == -1) return p;
  else if(mp[p] == -1 && mp[p+1] == 1) return p+1;
  else if(mp[p] == 1){
    return bsrc(a,p);
  }
  else if(mp[p] == -1){
    return bsrc(p,b);
  }
}

//==========================================================
int main(){
  cin >> N >> A >> B;
  for(int i=0;i<N;i++) cin >> h[i];
  sort(h,h+N);
  ll tmp = h[N-1] / B + 1;

  mp[0] = -1;
  mp[tmp] = 1;

  cout << bsrc(0,tmp) << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
ll A[300000];
ll f[100010];
ll b[100010];

int main(){
    cin >> N;
    for(int i=0;i<3*N;i++) cin >> A[i];
    priority_queue<ll,vector<ll>,greater<ll>> pqf;
    f[0] = 0;
    for(int i=0;i<N;i++){
        pqf.push(A[i]);
        f[0] += A[i];
    }
    for(int i=0;i<N;i++){
        ll m = pqf.top();
        pqf.pop();
        if(m < A[i+N]){
            pqf.push(A[i+N]);
            f[i+1] = f[i] + A[i+N] - m;
        }else{
            pqf.push(m);
            f[i+1] = f[i];
        }
    }
    priority_queue<ll> pqb;
    b[0] = 0;
    for(int i=2*N;i<3*N;i++){
        pqb.push(A[i]);
        b[0] += A[i];
    }
    for(int i=0;i<N;i++){
        ll m = pqb.top();
        pqb.pop();
        if(m > A[2*N-1-i]){
            pqb.push(A[2*N-1-i]);
            b[i+1] = b[i] + A[2*N-1-i] - m;
        }else{
            pqb.push(m);
            b[i+1] = b[i];
        }
    } 
    ll ans = -1e18;
    for(int i=0;i<=N;i++) ans = max(ans, f[i] - b[N-i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8780
#include <iostream>
#include <string>

using namespace std;

class A {
	string a, b, c;
public:
	void solve()
	{
		cin >> a >> b >> c;

		if ((a.back() == b.front()) && (b.back() == c.front())) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if (S=="ABC") cout << "ARC" << "\n";
    else cout << "ABC" << "\n";
}

Measured memory_bytes: 3652
/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long  ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
//#define mod (311111111111113)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;


   bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
   {
    if(p1.first!=p2.first)return p1.first < p2.first;
     else return p1.second < p2.second;
   }



   ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }
   ll findpower(ll a,ll b)
   {
       ll i=0;
       ll c=1;
        while(1)
        {
            c*=2;

            if(c>a)return i;
            i++;
        }
   }


vector<ll> dpfact;
   ll fact(ll a)
   { return dpfact[a];

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

  //ll n,m,k;
   //vector<ll> vans;
    //ll ans=0;

   //vector<vector<int> > v;
     vector<ll> visited;
      //vector<ll> vans;



   /* pair<ll,ll> dfs(ll p)
   { visited[p]=1;
     pair<ll,ll> p={0,0};
        for(auto x:v[p])
        {
            if(!visited[x])a+=dfs(x);
        }
       return a+1;

   }
*/

   int main()
{    ofstream fout("tcase.txt");
      ll n;cin>>n;
       vector<pair<ll,ll>> v(n);
       for(ll i=0;i<n;i++){cin>>v[i].first;v[i].second=i+1;}
       sort(all(v));
        for(auto x:v)cout<<x.second<<" ";

    return 0;
 }


Measured memory_bytes: 2432
#include <iostream>
#include <string>

using namespace std;

int main() {

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

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}
	

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

#define rep(i,n) for(int i= 0; i < n; ++i)
#define X first
#define Y second
#define all(x) x.begin(), x.end()
using namespace std;

long long dp[4][128];
int main(void){
  long long N,W;
  vector< pair<long long,long long> > wv;
  cin >> N >> W;
  wv.resize(N);
  vector<long long> v[4];

  for(auto& x: wv)cin >> x.X >> x.Y;
  long long base = wv[0].X;

  rep(i,wv.size()){
    v[wv[i].X-base].push_back(wv[i].Y);
  }

  rep(i,4){
    rep(j, v[i].size()){
      for(int k = 100; k >= 0; k--){
        dp[i][k+1] = max(dp[i][k+1], dp[i][k] + v[i][j]);
      }
    }
  }

  long long ans = 0;
  rep(i,v[0].size()+1)rep(j,v[1].size()+1)rep(k,v[2].size()+1)rep(l,v[3].size()+1){
    if( base*(i) + (base+1)*(j) + (base+2)*(k) + (base+3)*(l) <= W){
      //cout << i << " " << j << " " << k << " " << l << " " << endl;
      //cout << dp[0][i] << " " << dp[1][j] << " " << dp[2][k] << " " << dp[3][l] << " " << endl;
      ans = max(ans, dp[0][i] + dp[1][j] + dp[2][k] + dp[3][l]);
    }
  }

  cout << ans << endl;





  return 0;
}


Measured memory_bytes: 256