akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<ll,ll> > vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//'0'+cnt 数字cntからcharへの変換


int main(){

    ll n,m;
    cin >> n >> m;
    vpl p(n);
    rep(i,n) cin >> p.at(i).first >> p.at(i).second;
    sort(all(p));

    ll ans = 0;

    rep(i,n){
        int buy = min(p.at(i).second,m);
        ans += (ll)buy*p.at(i).first;
        m -= buy;
    }

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


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    string S;
    ll inf = 1e9+7;
    cin >> S;
    int N = S.size();
    vector<vector<ll>> dp(N+1,vector<ll>(13,0));
    dp[0][0] = 1;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=12;j++){
            if(S[i-1]!='?'){
                int c = S[i-1]-'0';
                (dp[i][(10*j+c)%13] += dp[i-1][j])%=inf;
            }else{
                for(int k=0;k<10;k++){
                    (dp[i][(10*j+k)%13] += dp[i-1][j])%=inf;
                }
            }
        }
    }
    cout << dp[N][5] << endl;
}

Measured memory_bytes: 13696
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n;
  str s;
  cin >> n >> s;
  ll white_cnt[n+1], black_cnt[n+1];
  black_cnt[0] = 0;
  REP(i,n){
    black_cnt[i+1] = black_cnt[i] + ((s[i]=='#') ? 1 : 0);
  }
  white_cnt[n] = 0;
  REP(i,n){
    white_cnt[n-1-i] = white_cnt[n-i] + ((s[n-1-i]=='.') ? 1 : 0);
  }
  ll ans = INF;
  REP(i,n+1){
    ans = min(ans, white_cnt[i]+black_cnt[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  double a, b, c;
  cin >> a >> b >> c;
  a = a / c;
  if(a > b){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

struct pos {
    int x, y;
};

using P = pair<pos, pos>;

int main() {
    int W, H;
    while(cin >> W >> H, W) {
        vector<string> v1(H), v2(H);
        for(int i=0; i<H; ++i) {
            cin >> v1[i] >> v2[i];
        }

        pos lg, rg;
        queue<P> que;
        vector<vector<vector<vector<int>>>> d(50, vector<vector<vector<int>>>(50, vector<vector<int>>(50, vector<int>(50, -1))));
        {
            pos L, R;
            for(int i=0; i<H; ++i) {
                for(int j=0; j<W; ++j) {
                    if(v1[i][j] == 'L') {
                        L.x = j; L.y = i;
                    } else if(v1[i][j] == '%') {
                        lg.x = j; lg.y = i;
                    }
                    if(v2[i][j] == 'R') {
                        R.x = j; R.y = i;
                    } else if(v2[i][j] == '%') {
                        rg.x = j; rg.y = i;
                    }
                }
            }
            auto p = make_pair(L, R);
            que.push(p);
            d[L.x][L.y][R.x][R.y] = 0;
            
        }
        while(!que.empty()) {
            P p = que.front(); que.pop();
            pos& l = p.first; pos& r = p.second;
            //cout << "l: " << l.x << " " << l.y << "     R: " << r.x << " " << r.y << endl;
            int dx[4] = {0, 1, 0, -1},
                dy[4] = {1, 0, -1, 0};
            for(int i=0; i<4; ++i) {
                pos nl{l.x - dx[i], l.y + dy[i]};
                pos nr{r.x + dx[i], r.y + dy[i]};
                if(nl.x < 0 || W <= nl.x || nl.y < 0 || H <= nl.y || v1[nl.y][nl.x] == '#') {
                    nl.x += dx[i];
                    nl.y -= dy[i];
                }
                if(nr.x < 0 || W <= nr.x || nr.y < 0 || H <= nr.y || v2[nr.y][nr.x] == '#') {
                    nr.x -= dx[i];
                    nr.y -= dy[i];
                }
                auto np = make_pair(nl, nr);
                if(d[nl.x][nl.y][nr.x][nr.y] != -1) {
                    continue;
                }
                if(v1[nl.y][nl.x] != '%' && v2[nr.y][nr.x] != '%') {
                    que.push(np);
                }
                d[nl.x][nl.y][nr.x][nr.y] = d[l.x][l.y][r.x][r.y] + 1;
                //cout << "nl: " << nl.x << " " << nl.y << "    nR: " << nr.x << " " << nr.y << endl;
            }
        }
        //cout << lg.x << " " << lg.y << " " << rg.x << " " << rg.y << endl;
        if(d[lg.x][lg.y][rg.x][rg.y] != -1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 32264
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int D;
  cin >> D;
  if(D==22)puts("Christmas Eve Eve Eve");
  else if(D==23)puts("Christmas Eve Eve");
  else if(D==24)puts("Christmas Eve");
  else puts("Christmas");

  return 0;
}


Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <boost/hana/functional/fix.hpp>
#include <boost/sort/spreadsort/spreadsort.hpp>
//#include <boost/graph/adjacency_list.hpp>
//#include <boost/graph/dijkstra_shortest_paths.hpp>
//#include <boost/graph/graph_utility.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
  
using namespace std;
//using namespace boost::multiprecision;
//using namespace boost::math;

/*
typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
        boost::no_property, boost::property<boost::edge_weight_t, int> > Graph;
*/


#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define FixPoint boost::hana::fix
#define bsort boost::sort::spreadsort::spreadsort
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    vector<int> a(n);

    rep(i,n){
        cin >> a[i];
    }

    bsort(all(a));
    a.erase(unique(all(a)), a.end());

    if(a.size() == n){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

ll n, k, c;
string s;

int main(void)
{
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	bool ok = false;
	rep(i, n) {
		ll s1 = a - i * c;
		ll s2 = a - i * d;
		ll low = s2 + (n - 1 - i) * c;
		ll up = s1 + (n - 1 - i) * d;
		if (b >= low && b <= up) {
			ok = true;
			break;
		}
	}
	if (ok) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


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

int main(){
    string s;
    int count=0;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='+'){
            count++;
        }else if(s.at(i)=='-'){
            count--;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin>>s;
  int a=100100;
  for(int i=0; i<s.size()-2; i++){
    int n=atoi(s.substr(i,3).c_str());
    a=min(a,abs(n-753));
  }
  cout<<a;
}

Measured memory_bytes: 3620
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: f64,
        b: f64,
        x: f64,
    }

    let x_area = x / a;
    if x_area > a * b / 2.0 {
        println!("{}", (2.0 * (a * b - x_area) / (a * a)).atan() * 180.0 / std::f64::consts::PI);
    } else {
        println!("{}", (b / (2.0 * x_area / b)).atan() * 180.0 / std::f64::consts::PI);
    }
}


Measured memory_bytes: 2952
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


struct Edge {
    int to, cost, nm;
    Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;

ll GCD(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

bool cmp(const pii& a, const pii& b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    return a.first < b.first;
}

int arr[6];
int main() {

    int n;cin >> n;
    for(int i=0; i<n; ++i){
        double c; cin >> c;
        if(c < 165.0) arr[0]++;
        else if(c < 170.0) arr[1]++;
        else if(c < 175.0) arr[2]++;
        else if(c < 180.0) arr[3]++;
        else if(c < 185.0) arr[4]++;
        else arr[5]++;
    }

    for(int i=0; i<6; ++i){
        cout << i+1 << ":";
        for(int j=0; j<arr[i]; ++j) cout << "*";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
import bisect as bs
N=int(input())
y=list(map(int, input().split()))
y.sort()
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bs.bisect_left(y[(j+1):],tmp)
    
print(ans)



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dp[100100][13];

signed main(){

	string s;
	cin>>s;

	if(s.at(s.size()-1)=='?'){
		REP(i,0,10)dp[0][i]=1;
		REP(i,10,13)dp[0][i]=0;
	}
	else{
		REP(i,0,13)dp[0][i]=0;
		dp[0][s.at(s.size()-1)-'0']++;
	}
	lli base = 10;
	for(lli i=s.size()-2;i>=0;i--){
		lli index = s.size()-1-i;
		if(DEBUG)cout<<"index="<<index<<endl;
		if(s.at(i)=='?'){
			REP(j,0,10){
				lli next = base*j;
				next %= 13;
				REP(k,0,13){
					dp[index][(next+k)%13] += dp[index-1][k];
					dp[index][(next+k)%13] %= MOD;
				}
			}
		}
		else{
			lli next = base*(s.at(i)-'0');
			REP(k,0,13){
				dp[index][(next+k)%13] += dp[index-1][k];
				dp[index][(next+k)%13] %= MOD;
			}
		}
		base *= 10;
		base %= 13;
	}
	if(DEBUG){
		REP(i,0,13){
			cout<<dp[s.size()-1][i]<<endl;
		}
	}
	cout<<dp[s.size()-1][5]%MOD<<endl;

	return 0;
}

Measured memory_bytes: 10624
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	while(true){
	    int h=sc.nextInt();
	    int w=sc.nextInt();
	    if(h==0&&w==0)break;
	    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)System.out.print("#");
		System.out.println();
	    }
	    System.out.println();
	}
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

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

using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	string u;
	cin>>u;
	if(u==s){
		cout<<a-1<<" "<<b;
	}
	else cout<<a<<" "<<b-1;
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc171/tasks/abc171_c

import string

numbers = string.digits                             # [0-9] をロード
abc = string.ascii_lowercase                        # [a-z] をロード
ABC = string.ascii_uppercase                        # [A-Z] をロード
characters = numbers + abc + ABC                    # [0-9] + [a-z] + [A-Z] の 62進数まで対応


def base_cvt(value, n=2, output=characters):        # n=26, output=abc で、[a-z]表示の26進数を生成可能
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)   # 整数以外はアウト

    if n < 2 or n > len(characters):                # 62進数まで対応
        raise ValueError('Invalid n:', value)

    coef = []
    while tmp >= n:
        idx = tmp % n                               #  tmp = a_k n^k + ... a_1 n^1 + a_0 n^0 の a_0 の値を取り出す
        coef.append(idx)
        tmp = tmp // n                              # a_k n^k + ... a_1 n^1 + a_0 n^0 ⇒　a_k n^k + ... a_1 n^1　:最小桁を消去してループ
    idx = tmp % n
    coef.append(idx)                                # coef = [a_0, a_1, ... , a_k]
    res = "".join(map(lambda x: output[x], reversed(coef)))
    return res


N = int(input())

k = 0
while N - 26 ** k >= 0:
    N -= 26 ** k
    k += 1

res = base_cvt(N, 26, abc)
l = len(res)
print("".join(["a"] * (k - l)) + res)

Measured memory_bytes: 71948
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=j;i<=k;i++) 
#define dec(i,j,k) for(int i=j;i>=k;i--)
#define mod 1000000007 
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll n,m,k,x,y,a,b,c,d,s,t,ans,q,r;

const int nax = 1005;

void solve()
{  string s;
 cin>>s;
   int n = s.length();
   int cnt = 0 ;
   int mx = 0;
   for(int i=0;i<n;i++)
   { if(s[i]== 'R')
      {  cnt++;
	  } 
	 else 
      {  mx = max(mx,cnt);
	     cnt  = 0;
	  }	 
   } 
   mx = max(mx,cnt);
   cout<<mx;
}
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	
 	
	int t=1;
	
 	//cin>>t; 
 
 
	int  a=0;
	while(t--)
	{ // cout<<"Case #"<<++a<<": ";
	   solve();
	   cout<<"\n"; 
	}    
	
    return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> pos, neg, zero;
    for(unsigned long i{0}; i < N; ++i){
        long k;
        cin >> k;
        if(k > 0)pos.emplace_back(k);
        else if(k < 0)neg.emplace_back(-k);
        else zero.emplace_back(0);
    }
    unsigned long ans{1};
    if(N == K){
        for(const auto& i : pos)(ans *= i) %= MOD;
        for(const auto& i : neg)(ans *= i) %= MOD;
        if(neg.size() & 1)(ans = MOD - ans) %= MOD;
        for(const auto& i : zero)ans *= i;
        cout << ans << endl;
    }else if(pos.empty()){
        copy(begin(zero), end(zero), back_inserter(neg));
        if(K & 1)sort(begin(neg), end(neg));
        else sort(begin(neg), end(neg), greater<>());
        for(unsigned long i{0}; i < K; ++i)(ans *= neg[i]) %= MOD;
        cout << (K & 1 ? (MOD - ans) % MOD : ans) << endl;
    }else{
        sort(begin(pos), end(pos));
        sort(begin(neg), end(neg));
        if(K & 1){
            --K;
            ans *= pos.back();
            pos.pop_back();
        }
        while((pos.size() > 1 || neg.size() > 1) && K){
            if(pos.size() < 2 || (neg.size() > 1 && pos.back() * pos.end()[-2] < neg.back() * neg.end()[-2])){
                (ans *= neg.back()) %= MOD;
                neg.pop_back();
                (ans *= neg.back()) %= MOD;
                neg.pop_back();
            }else{
                (ans *= pos.back()) %= MOD;
                pos.pop_back();
                (ans *= pos.back()) %= MOD;
                pos.pop_back();
            }
            K -= 2;
        }
        if(K)return 0 & puts("0");
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 7452
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int isis[8];
int pas[8][8];
int N;

int dfs(int next, int nokori){
    if(nokori==0) return 1;
    isis[next] = 1;
    int res = 0;
    FOR(i, 1, N){
        if(pas[next][i]==1 && isis[i]==0) res += dfs(i, nokori-1);
    }
    isis[next] = 0;
    return res;
}

int main(){
    int M;
    cin >> N >> M;
    //int pas[N][N];
    FOR(i, 0, M){
        int a, b;
        cin >> a >> b;
        pas[a-1][b-1] = pas[b-1][a-1] = 1;
    }

    int ans = 0;
    cout <<  dfs(0, N-1) << endl; 
}

Measured memory_bytes: 256
import Data.List

toDice :: [Int]	-> [[Int]]
toDice [a,b,c,d,e,f] = [[a,f],[b,e],[c,d]]

pattern1 :: [Int] -> [String]
pattern1 x = map show [(x !! 0),(x !! 1),(x !! 5),(x !! 4),(x !! 0)]

pattern2 :: [Int] -> [String]
pattern2 x = map show [(x !! 1),(x !! 2),(x !! 4),(x !! 3),(x !! 1)]

pattern3 :: [Int] -> [String]
pattern3 x = map show [(x !! 2),(x !! 0),(x !! 3),(x !! 5),(x !! 2)]

solve :: [Int] -> String -> Int
solve list x
  | isInfixOf x (unwords $ pattern1 list) = list !! 2
  | isInfixOf x (unwords $ pattern2 list) = list !! 0
  | isInfixOf x (unwords $ pattern3 list) = list !! 1
  | isInfixOf x (unwords $ reverse $ pattern1 list) = list !! 3
  | isInfixOf x (unwords $ reverse $ pattern2 list) = list !! 5
  | isInfixOf x (unwords $ reverse $ pattern3 list) = list !! 4

check1 :: [Int] -> [Int] -> Bool
check1 xs ys = (solve' xs) == (solve' ys)
  where solve' = sort . map sort . toDice

check2 :: [Int] -> [Int] -> String -> Bool
check2 xs ys s = (solve xs s) == (solve ys s)

main = getContents >>= putStrLn . (\x -> if and x then "Yes" else "No") . (\[a,b] -> check2 (read' a) (read' b) (mkstr a) : check1 (read' a) (read' b) : []) . lines
  where read' = map read . words
        mkstr = unwords . map show . take 2 . read'

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int N, *W, i, sum1=0, sum2=0, minim;
    cin >> N;
    W = new int[N];
    for(i=0;i<N;i++){
        cin >> W[i];
        sum2 += W[i];
    }
    sum1 += W[0];
    sum2 -= sum1;
    minim = abs(sum2 - sum1);
    for(i=1;i<N;i++){
        sum1 += W[i];
        sum2 -= W[i];
        minim = min(minim, abs(sum2 - sum1));
    }
    cout << minim << endl;
    return 0;
}

Measured memory_bytes: 256
aList = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bList = [int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if aList[i][j] in bList:
            aList[i][j] = 0
flag = False
if [0, 0, 0] in aList:
    flag = True
else:
    for i in range(3):
        if aList[0][i] == aList[1][i] == aList[2][i] == 0:
            flag = True
if not flag and aList[1][1] == 0:
    if aList[0][0] == aList[2][2] == 0 or aList[2][0] == aList[0][2] == 0:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

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

void fnInsertionSort(vector<int> &argviSort, int argiGap, int &argiSortCnt)
{
  for (int ixSorting = argiGap; ixSorting < argviSort.size() ; ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - argiGap;

    while (ixSorted >= 0              &&
           iTarget < argviSort[ixSorted])
    {
      argviSort[ixSorted + argiGap] = argviSort[ixSorted];
      ixSorted -= argiGap;

      argiSortCnt++;
    }
    argviSort[ixSorted + argiGap] = iTarget;
  }
}

void fnShellSort(vector<int> &argviSort, vector<int> &argviGap, int &argiSortCnt)
{

  for (int iGap = 1; iGap <= argviSort.size(); iGap = 3 * iGap + 1)
    argviGap.push_back(iGap);
  
  for (int i = argviGap.size() - 1; i >= 0; i--)
    fnInsertionSort(argviSort, argviGap[i], argiSortCnt);
}

void fnOutput(const vector<int> &argviSort, const vector<int> &argviGap, int argiSortCnt)
{
  cout << argviGap.size() << endl;

  for (int i = argviGap.size() - 1; i >= 0; i--)
  {
    if (i != argviGap.size() - 1) cout << " ";
    cout << argviGap[i];
  }
  cout << endl;

  cout << argiSortCnt << endl;

  for (int i = 0; i < argviSort.size(); i++)
    cout << argviSort[i] << endl;
}

int main()
{
  vector<int> viSort;
  vector<int> viGap;
  int iSortCnt = 0;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnShellSort(viSort, viGap, iSortCnt);
  fnOutput(viSort, viGap, iSortCnt);

  return 0;
}

Measured memory_bytes: 6992
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> A){
    vector<long long> B(N, 1);
    vector<long long> C(N, 0);
    long long t = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            C[i]++;
        }
    }
    for (int i = 0; i < N; i++) {
        if (C[N-1-i] <= 0) {
            t = 0;
        } else {
            C[N-1-i] += t;
            t += 1;
        }
    }

    for (int i = 0; i < N; i++) {
        long long t = A[i];
        for (int j = 1; j < N-i; j++) {
            if (A[i+j] == 0) {
                B[i] += C[i+j];
                j += C[i+j] - 1;
                continue;
            }
            if ((t + A[i+j]) == (t ^ A[i+j])) {
                B[i]++;
                t ^= A[i+j];
            } else {
                break;
            }
        }
    }
    long long ret = 0;
    for (int i = 0; i < N; i++) {
        ret += B[i];
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> A(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&A[i]);
    }
    solve(N, A);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	int a, b;
	cin >> a >> b;

	a += b;

	if (a < 10) cout << a << endl;
	else cout << "error" << endl;
	

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c, x, y) = readLine()!!.split(" ").map { it.toInt() }
    val remaining_p = if(x > y) a else b
    val remaining_c = Math.abs(x - y)
    println(Math.min( a * x + b * y, Math.min(2 * Math.max(x, y) * c, 2 * Math.min(x, y) * c + remaining_c * remaining_p)))
}

Measured memory_bytes: 37608
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  int K;
  cin >> K;

  vector<vector<int>> dp(19, vector<int>(10, 0));
  for (int i = 0; i < (int)(10); ++i) dp[0][i] = 1;

  function<void(int, int, ll)> ans = [&](int d, int k, ll n) {
    if (d == 0) {
      cout << n << endl;
      return;
    }

    int m = n % 10;
    int s = 0;
    if (m - 1 >= 0 && s + dp[d - 1][m - 1] >= k)
      return ans(d - 1, k - s, n * 10 + m - 1);
    s += dp[d - 1][m - 1];
    if (s + dp[d - 1][m] >= k) return ans(d - 1, k - s, n * 10 + m);
    s += dp[d - 1][m];
    return ans(d - 1, k - s, n * 10 + m + 1);
  };

  int s = 0;
  for (int d = 0; d < (int)(18); ++d) {
    for (int i = 0; i < (int)(10); ++i) {
      if (i - 1 >= 0) dp[d + 1][i] += dp[d][i - 1];
      dp[d + 1][i] += dp[d][i];
      if (i + 1 < 10) dp[d + 1][i] += dp[d][i + 1];
      if (i == 0) continue;
      if (s + dp[d][i] >= K) {
        ans(d, K - s, i);
        return 0;
      } else {
        s += dp[d][i];
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in).useDelimiter("[,\n]");
		boolean cups[] = new boolean[3];
		cups[0] = true;
		
		while (true)
		{
			try
			{
				int index1 = sc.next().charAt(0) - 'A';
				int index2 = sc.next().charAt(0) - 'A';
				boolean tmp = cups[index1];
				cups[index1] = cups[index2];
				cups[index2] = tmp;
			}
			catch (Exception e)
			{
				break;
			}
		}
		for (int i = 0; i < 3; i++)
		{
			if (cups[i])
			{
				System.out.println((char)(i + 'A'));
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

ll gcd(ll x,ll y){
  if(x>y)swap(x,y);
  if(y%x==0)return x;
  return gcd(y-x*(y/x),x);
}

int main(){
  string o,e;
  cin >> o >> e;
  int n=o.size()+e.size();
  rep(i,n){
    if(i%2==0)cout << o[i/2];
    else cout << e[i/2];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,T;
  cin>>N>>T;
  vector<long long>t(N);
  for(int i=0;i<N;i++){
    cin>>t.at(i);
  }
  long long sum=0;
  if(N==1){
    sum=T;
  }
  else{
    for(int i=1;i<N;i++){
      sum=sum+min(t[i]-t[i-1],T);
      if(i==N-1){
        sum=sum+T;
      }
    }
  }
  cout<<sum<<endl;
}
    
  

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI p(n), q(n);
	rep(i, n) cin >>p[i];
	rep(i, n) cin >>q[i];
	
	if(p>q) swap(p,q);
	ll ans =0;
	do {
		if(p==q){
			cout << ans <<"\n"; return 0;
		}
		ans++;
	} while ( next_permutation(all(p)) );

	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
int N,A,ct=0;
  scanf("%d",&N);
  for(int i = 1;i <= N;i++){
    scanf("%d",&A);
    ct += A != i;
  }if(ct == 0||ct == 2){printf("YES\n");}
  else{printf("NO");}
  return 0;
}

Measured memory_bytes: 128
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 2;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(string, a);
    vi A(N - 1);
    ll ans = 0;
    REP(i, N - 1)
    {
        A[i] = abs(a[i + 1] - a[i]);
        if (A[i] == 1)
        {
            ans = 1;
        }
        if (ans == 0 and A[i] == 2)
        {
            ans = 2;
        }
    }
    if (ans == 2)
    {
        REP(i, N - 1)
        {
            A[i] = min(1LL, A[i]);
        }
    }
    ll c = A[0] & 1;
    ll k = 0;
    REP1(i, N - 2)
    {
        ll x = N - 1 - i;
        while ((x & 1) == 0)
        {
            x >>= 1;
            ++k;
        }
        ll y = i;
        while ((y & 1) == 0)
        {
            y >>= 1;
            --k;
        }
        c += (A[i] & 1) and (k == 0);
    }
    OUT((c & 1) * ans);
}

Measured memory_bytes: 9220
from collections import deque
dic={}
n,m=map(int,input().split())
nod=[[]]
keep=[0]*n
for i in range(n-1):
  nod.append([])
for i in range(m):
  a,b=map(int,input().split())
  nod[a-1].append(b)
  nod[b-1].append(a)
use=deque()
use.append(1)
for i in range(0,10**100):
  if bool(use):
    sss=use.popleft()
    for j in nod[sss-1]:
      if not j in dic:
        keep[j-1]=sss
        use.append(j)
        dic[j]=1
  else:
    break

keep.pop(0)
print("Yes")
for x in keep:
  print(x)

Measured memory_bytes: 41460
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, M, ans;
    scanf("%lld %lld", &N, &M);
    vector<ll> a(M+1);
    REP(ll,i,0,M) scanf("%lld", &a.at(i));
    a.at(M) = 0;
    vector<ll> dp(N+1);
    dp.at(0) = 1;

    int j = 0;
    if ( a.at(0) == 1){
        dp.at(1) = 0;
        j++;
    }
    else{ 
        dp.at(1) = 1;
    }
    int brokenFlag;

    //cout << "dp[0] = " << dp.at(0) << endl;
    //cout << "dp[1] = " << dp.at(1) << endl;
    
    REP(ll,i,2,N+1){
        brokenFlag = 1;
        if ( i == a.at(j) ){
            brokenFlag = 0; 
            j++;
        }
        if ( brokenFlag ){
            dp.at(i) = dp.at(i-1) + dp.at(i-2);
            dp.at(i) %= MODNum;
        }
        else{
            dp.at(i) = 0;
        }
        //cout << "dp[" << i << "] = " << dp.at(i) << endl;
    }
    printf("%lld\n", dp.at(N));
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<cmath>
#define int long long
using namespace std;
pair<int,int>a[114514];
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        cin>>a[i].second;
    }
    sort(a,a+n);
    reverse(a,a+n);
    cout<<a[0].first+a[0].second<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibutan(auto a,auto b);
void print(int a,int b,int c){
    cout << a << " " << b << " " << c << endl;
}


signed main(){
    int n;
    cin >> n;
    int ans = 1;
    REP(i,n){
        ans *= i+1;
        ans %= max_int;
    }
    cout << ans << endl;
    
    
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibutan(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    return x-1;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),K=in();
	string S=in<string>();
	vector<int> C(1,0);
	char V=S[0];
	REP(i,N-1){
		if(S[i+1]!=V){
			C.push_back(i+1);
			V=S[i+1];
		}
	}
	int M=C.size();
	int maxV=0;
	REP(i,M){
		if(S[C[i]]=='1'){
			int L=C[i];
			int R=(i+2*K+1<M)?C[i+2*K+1]:N;
			maxV = max(maxV,R-L);
		}
		else{
			int L=C[i];
			int R=(i+2*K<M)?C[i+2*K]:N;
			maxV = max(maxV,R-L);
		}
	}
	out(maxV);
	return 0;
}


Measured memory_bytes: 1020
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<int> s;
    for(int i = 0, a; i < 3; ++i) {
        cin >> a;
        s.insert(a);
    }
    if(s.size() == 2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
    vector<int> n(3);
    for(int i = 0; i < n.size(); i++) cin >> n.at(i);

    for(int i = 0; i < n.size() - 1; i++){
        for(int j = i; j < n.size(); j++)
            if(n.at(i) > n.at(j)) {
                int work;
                work = n.at(i);
                n.at(i) = n.at(j);
                n.at(j) = work;
            }
    }
    cout << n.at(0) << ' ' << n.at(1) << ' ' << n.at(2) << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX=200000;
int main(){
  int R[MAX],n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>R[i];
  int maxv=-2000000000;
  int minv=R[0];
  for(int i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }
  cout<<maxv<<endl;
  return 0;
}



Measured memory_bytes: 3876
using System;
using System.Linq;

class E
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1];
		Console.WriteLine(Totients(k).Select((x, i) => i == 0 ? 0 : x * ((MInt)(k / i)).Pow(n)).Aggregate((x, y) => x + y));
	}

	static int[] Totients(int n)
	{
		var b = new bool[n + 1];
		for (int p = 2; p * p <= n; ++p) if (!b[p]) for (int x = p * p; x <= n; x += p) b[x] = true;
		var r = new int[n + 1];
		for (int x = 1; x <= n; ++x) r[x] = x;
		for (int p = 2; p <= n; ++p) if (!b[p]) for (int x = p; x <= n; x += p) r[x] = r[x] / p * (p - 1);
		return r;
	}
}

struct MInt
{
	const int M = 1000000007;
	public long V;
	public MInt(long v) { V = (v %= M) < 0 ? v + M : v; }

	public static implicit operator MInt(long v) => new MInt(v);
	public static MInt operator +(MInt x, MInt y) => x.V + y.V;
	public static MInt operator *(MInt x, MInt y) => x.V * y.V;

	public MInt Pow(int i) => MPow(V, i);
	public override string ToString() => $"{V}";

	static long MPow(long b, int i)
	{
		for (var r = 1L; ; b = b * b % M)
		{
			if (i % 2 > 0) r = r * b % M;
			if ((i /= 2) < 1) return r;
		}
	}
}


Measured memory_bytes: 19044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		string s,t;
		cin>>s>>t;
		int mi=s.size();
		for(int i=0;i<s.size();i++){
			int cnt=0;
			for(int j=0;j<t.size();j++){
				if(j+i>=s.size()){
					cnt=s.size();
					break;
				}
				if(t[j]==s[i+j])
					continue;
				cnt++;
			}
			mi=min(mi,cnt);
		}
		cout<<mi;
	}
	return 0;
}

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

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
ll C[5000][5000];

int main(){
	for(int i=0;i<5000;i++){
		for(int j=0;j<=i;j++){
			if(j==0||j==i)C[i][j]=1;
			else C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
		}
	}
	int k,n;scanf("%d%d",&k,&n);
	for(int i=2;i<=2*k;i++){
		int cnt1=0,cnt2=0;
		for(int j=1;j<=k;j++){
			if(j<i&&j<i-j&&i-j<=k)cnt1++;
			if(j>=i||i-j>k)cnt2++;
		}
		ll ans=0;
		for(int j=0;j<=cnt1;j++){
			if(j+cnt2==0)continue;
			(ans+=C[n-j+(j+cnt2-1)][j+cnt2-1]*ppow(2,j)%MOD*C[cnt1][j]%MOD)%=MOD;
			if(i%2==0)(ans+=C[n-j+(j+cnt2-1)-1][j+cnt2-1]*ppow(2,j)%MOD*C[cnt1][j]%MOD)%=MOD;
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 193792
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
using namespace std;
int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s;
	cin >> a;
	b += (a % 10);
	b += ((a % 100) - (a % 10)) / 10;
	b += ((a % 1000) - (a % 100)) / 100;
	b += ((a % 10000) - (a % 1000)) / 1000;
	b += ((a % 100000) - (a % 10000)) / 10000;
	b += ((a % 1000000) - (a % 100000)) / 100000;
	b += ((a % 10000000) - (a % 1000000)) / 1000000;
	b += ((a % 100000000) - (a % 10000000)) / 10000000;
	b += ((a % 1000000000) - (a % 100000000)) / 100000000;
	b += ((a % 10000000000) - (a % 1000000000))/1000000000;
	if (a%b==0)
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;

	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  vector<int> a(n);
  rep(i, n) a[i] = i+1;
  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  }
  while (next_permutation(a.begin(), a.end()));

  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8560
n, m =map(int,input().split())
a = [-1] * n
flg = True
for i in range(m):
    s, c = map(int,input().split())
    if a[s-1] == -1:
        a[s-1] = c
    elif a[s-1] == c:
        pass
    else:
        flg = False
        break
        
if n >= 2:
    if a[0] == 0:
        flg = False
    elif a[0] == -1:
        a[0] = 1
else:
    if a[0] == -1:
        a[0] = 0
    
if flg:
    num = 0
    for i in range(len(a)):
        if a[i] != -1:
            num += a[i] * (10**(n-i-1))
    print(num)
else:
    print(-1)

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;
	string S;
	cin >> S;
	bool ok1 = true;
	bool ok2 = true;
	bool ok3 = false;
	bool spflag = false;
	//without position switch ABCD
	if (C < D) {
		rept(i, A, D-1) {
			if (S[i] == '#' && S[i+1] == '#') {
				ok1 = false;
				break;
			}
		}
		if (ok1) ok3 = true;
	}
	//with position switch ABDC
	else {
		ok1 = ok2 = true;
		//do BD first
		rept(i, B+1, D-1) {
			if ((S[i] == '#') && (S[i+1] == '#')) {
				ok1 = false;
				break;
			}
		}
		//check if there is a hole
		rept(i, B-1, D) {
			if (S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') {
				spflag = true;
			}
		}
		if (ok1 && spflag) {
			//do AC
			rept(i, A+1, C-1) {
				if ((S[i] == '#') && (S[i+1] == '#')) {
					ok2 = false;
					break;
				}
			}
			if (ok2) ok3 = true;
		}
	}
	if (ok3) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}



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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    int N;
    cin>>N;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll ans = 0;
    rep(i,N-1) ans+=v[(i+1)/2];
    cout<<ans<<endl;
}

Measured memory_bytes: 4836
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

m=0
for i in range(n-1):
  if a[i+1]==a[i]+1:
    m=m+c[a[i]-1]

print(sum(b)+m)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>

typedef long long lli;

int n;
lli a, b;
lli arr[100000];

int main()
{
	scanf("%d %lld %lld",&n,&a, &b);
	for(int i=0;i<n;i++) 
		scanf("%lld",arr+i);

	lli res=0;
	for(int i=1;i<n;i++) {
		res+=std::min(b, a*(arr[i]-arr[i-1]));
	}
	printf("%lld\n",res);

	return 0;
}

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

int main(){
    int N;
    int arr[200004];
    cin >> N;
    int counter = 0, checkfor = 1;
    for(int i=0; i<N; i++){
        cin >> arr[i];
        if(arr[i]!=checkfor){
            counter++;
        }
        else checkfor++;
    }

    if(checkfor==1){
        cout << -1 << endl;
        return 0;
    }
    cout << counter << endl;

    

    return 0;
}

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

int main() {
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int n;
    cin >> n;
    n=2*n;
    vector<int> L(n);
    for(int i = 0; i<n; ++i)
        cin >> L[i];
    sort(L.begin(), L.end());
    int ans1 = 0, ans2 = 0;
    for(int i = 1; i<n; i += 2)
        ans1 += min(L[i-1], L[i]);
    for(int i = 1; i<n-1; i += 2)
        ans2 += min(L[i], L[i+1]);
        ans2 += L[0];
    cout << max(ans1,ans2) << endl;

    return 0;
}

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

int main(){
  ll N,K,M=0;
  int b;
  cin>>N>>K;
  ll p[N];
  for(int i=0;i<N;i++) cin>>p[i];
  
  double q[N];
  for(int i=0;i<N;i++){
    q[i]=(double)(p[i]+1)/2;
    if(i>0) q[i]+=q[i-1];
  }
double ans[N-K+1];
for(int i=0;i<N-K+1;i++){
  if(i==0) ans[i]=q[K-1];
  if(i>0) ans[i]=q[i+K-1]-q[i-1];
}
sort(ans,ans+N-K+1);
reverse(ans,ans+N-K+1);

  printf("%.12f\n",ans[0]);
}


Measured memory_bytes: 4992