akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  vector<vector<int>>retu(8,vector<int>(3));
  vector<vector<int>>card(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> card.at(i).at(j);
    }
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      retu.at(i).at(j)=card.at(i).at(j);
      retu.at(i+3).at(j)=card.at(j).at(i);
    }
    retu.at(6).at(i)=card.at(i).at(i);
    retu.at(7).at(i)=card.at(2-i).at(i);
  }
  //for(int i=0;i<8;i++)
    //cout << retu.at(i).at(0) << ","<< retu.at(i).at(1) << "," << retu.at(i).at(2) << endl;
  map<int,int>deta;
  int n,b;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> b;
    deta[b]=1;
  }
  bool ans=false;
  for(int i=0;i<8;i++){
    if(deta[retu.at(i).at(0)]==1&&deta[retu.at(i).at(1)]==1&&deta[retu.at(i).at(2)]==1)
      ans=true;
  }
  cout << (ans?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3616
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
vector<P> city[100001];
int main()
{
	int K, S;
	cin >> K >> S;

	vector<int> xy;
	REP(i, K + 1){
		REP(j, K + 1) {
			xy.emplace_back(i + j);
		}
	}

	int ans = 0;
	REP(i, xy.size()){
		int sub = S - xy[i];
		if (0 <= sub && sub <= K) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 37348
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    str s;
    cin >> s;
    if(s.at(s.size()-1) == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl; 
}


Measured memory_bytes: 3600
#include <stdio.h>
int main()
{
	int N, R, v, z, x;
	scanf("%d %d", &N, &R);
	v = R + 100*(10-N);
	if ( N >= 10 ){
		printf("%d", R);
	}
	else {
		printf("%d", v);
	}
	return 0;
}

Measured memory_bytes: 3104
import sys
from collections import deque
mapin = lambda: map(int, sys.stdin.readline().split())
listin = lambda: list(map(int, sys.stdin.readline().split()))
inp = lambda: sys.stdin.readline()

class UnionFind():
    def __init__(self,n):
        self.N = n
        self.par = [-1] * n
    
    def find(self,n):
        if self.par[n] < 0:
            return n
        else:
            self.par[n] = self.find(self.par[n])
            return self.par[n]
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        else:
            if -self.par[x] < -self.par[y]:
                x,y = y,x
            self.par[x] += self.par[y]
            self.par[y] = x
    
    def size(self,x):
        return -self.par[self.find(x)]
    
    def tree_num(self):
        res = 0
        for i in self.par:
            res += i < 0
        return res
    
    def same(self,x,y):
        return self.find(x) == self.find(y)
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = mapin()
UF = UnionFind(N)
for i in range(M):
    a,b = mapin()
    a,b = a - 1,b - 1
    UF.unite(a,b)
ans = 0
for i in UF.par:
    if i < 0:
        if ans < -i:
            ans = -i
print(ans)


Measured memory_bytes: 79968
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

vector<vector<int>> G(101, vector<int>(0));
vector<int> c(101, 0);
vector<int> d(101, 0);
vector<int> f(101, 0);

template <class T> using vec_alias = ::std::vector<T>;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int t = 0;
void dfs(int i) {
    if(c[i]) return;
    c[i] = 1;
    d[i] = ++t;
    for(auto e : G[i])
        dfs(e);
    f[i] = ++t;
}

class node {
  public:
    int dist = -1;
    vector<int> nex;
};

template <template <class> class Container> class union_find {
  protected:
    class node_type;

  public:
    using container_type = Container<node_type>;
    using size_type = typename container_type::size_type;

  protected:
    class node_type {
      public:
        typename union_find::size_type parent;
        typename union_find::size_type size;
    };

    container_type tree;

  public:
    union_find() : tree() {}
    explicit union_find(const size_type size) : tree(size, {0, 1}) {
        for(size_type i = 0; i < size; ++i)
            tree[i].parent = i;
    }

    bool empty() const { return tree.empty(); }
    size_type size() const { return tree.size(); }

    size_type find(size_type x) {
        assert(x < size());
        while(tree[x].parent != x)
            x = tree[x].parent = tree[tree[x].parent].parent;
        return x;
    }
    bool same(const size_type x, const size_type y) {
        assert(x < size());
        assert(y < size());
        return find(x) == find(y);
    }
    size_type size(const size_type x) {
        assert(x < size());
        return tree[find(x)].size;
    }

    ::std::pair<size_type, size_type> unite(size_type x, size_type y) {
        assert(x < size());
        assert(y < size());
        x = find(x);
        y = find(y);
        if(x != y) {
            if(tree[x].size < tree[y].size) ::std::swap(x, y);
            tree[x].size += tree[y].size;
            tree[y].parent = x;
        }
        return {x, y};
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q, s, t;
    cin >> n >> m;
    union_find<vec_alias> uf(n);
    rep(i, m) {
        cin >> s >> t;
        uf.unite(s, t);
    }
    cin >> q;
    rep(i, q) {
        cin >> s >> t;
        cout << (uf.same(s, t) ? "yes" : "no") << "\n";
    }
}



Measured memory_bytes: 4412
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int e,y,i,j;
scanf("%d %d",&e,&y);
if(e==0){
if(y>1988)
printf("H%d\n",y-1988);
else if(y>1925)
printf("S%d\n",y-1925);
else if(y>1911)
printf("T%d\n",y-1911);
else
printf("M%d\n",y-1867);
}
else if(e==1)
printf("%d\n",y+1867);
else if(e==2)
printf("%d\n",y+1911);
else if(e==3)
printf("%d\n",y+1925);
else
printf("%d\n",y+1988);
return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	ll x = fetch<ll>();
	ll y = fetch<ll>();

	ll answ = LL_INF;

	for(auto& a: {-x, x}) {
		for(auto& b: {-y, y}) {
			if(a <= b) {
				ll local = b - a + (a != x) + (b != y);
				answ = min(answ, local);
			}
		}
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
S = input()
C = ["maerd","remaerd","esare","resare"]
ans = ""
a = "YES"
x = len(S)
for i in range(x):
    ans = ans + S[x - 1 -i]
    if ans == C[0]:
        ans = ""
    elif ans == C[1]:
        ans = ""
    elif ans == C[2]:
        ans = ""
    elif ans == C[3]:
        ans = ""
if len(ans) != 0:
    a = "NO"
print(a)


Measured memory_bytes: 9140
def string_rotation(S: str, T: str)->bool:
    for i in range(len(S)):
        if S[i:] + S[:i] == T:
            return True
    return False


if __name__ == "__main__":
    S = input()
    T = input()
    yes = string_rotation(S, T)
    print('Yes' if yes else 'No')


Measured memory_bytes: 2940
INF=10**18
n=10
h,w=map(int,input().split())
dist=[list(map(int,input().split())) for _ in range(n)]
a=[list(map(int,input().split())) for _ in range(h)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
ans=0
for i in range(h):
  for j in range(w):
    if a[i][j]==-1:continue
    ans+=dist[a[i][j]][1]
print(ans)

Measured memory_bytes: 9420
S = input() 
N = len(S)
S += 'R'

rnl = []
tmp = 'R'
cnt = 1
for i in range(1, N+1):
    if S[i] == tmp:
        cnt += 1
    else:
        rnl.append(cnt)
        tmp = S[i]
        cnt = 1

ans = [0] * N
i = 0
for j in range(len(rnl)):
    r = rnl[j]
    # R zone
    if j % 2 == 0:
        ans[i+r-1] += (r+1) // 2
        ans[i+r] += r // 2
        i += r
    # L zone
    else:
        ans[i] += (r+1) // 2
        ans[i-1] += r // 2
        i += r

print(*ans)        

Measured memory_bytes: 7160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    rep(i, n) cin >> x[i] >> y[i] >> p[i];

    vector<vector<ll>> dx(1 << n, vector<ll>(n, LINF));
    vector<vector<ll>> dy(1 << n, vector<ll>(n, LINF));
    rep(bit, 1 << n) rep(j, n) {
        dx[bit][j] = abs(x[j]) * p[j];
        dy[bit][j] = abs(y[j]) * p[j];
    }
    rep(bit, 1 << n) {
        rep(i, n) if (bit >> i & 1) {
            rep(j, n) {
                chmin(dx[bit][j], p[j] * abs(x[i] - x[j]));
                chmin(dy[bit][j], p[j] * abs(y[i] - y[j]));
            }
        }
    }

    int MAX = 1;
    rep(i, n) MAX *= 3;
    auto num = [&](int i, int bit) {
        rep(_, i) bit /= 3;
        return bit % 3;
    };

    vector<ll> ans(n + 1, LINF);
    rep(bit, MAX) {
        int xbit = 0, ybit = 0;
        int ppcnt = 0;
        rep(i, n) {
            int kk = num(i, bit);
            if (kk == 1) xbit += 1 << i, ppcnt++;
            if (kk == 2) ybit += 1 << i, ppcnt++;
        }
        ll now = 0;
        rep(j, n) {
            now += min(dx[xbit][j], dy[ybit][j]);
        }
        chmin(ans[ppcnt], now);
    }
    rep(i, n + 1) cout << ans[i] << endl;
}

Measured memory_bytes: 12964
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	int n;
	cin >> n;
	cin >> s;
	int l = 0, r = n - 1;
	while(l < n and s[l] != 'W')l++;
	while(r > 0 and s[r] != 'R')r--;
	int ans =  0;
	while(l < r)
	{
		if(s[l] == 'W' and s[r] == 'R')
			ans++;
		l++,r--;
		while(l < n and s[l] != 'W')l++;
		while(r > 0 and s[r] != 'R')r--;
	}
	cout << ans;
}

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

int main()
{
        int N, M;
        cin >> N >> M;
        int ans = 0;
        for (int i= 1; i < N; ++i) {

                ans += N-i;

        }
        for (int i = 1; i < M; ++i) {

                ans += M-i;

        }
        cout << ans << endl;


}


Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

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

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

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

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

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

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

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

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

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

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

func main() {
	sc := NewScanner()
	A, B := sc.nextInt(), sc.nextInt()
	if A == B {
		fmt.Println(A * 2)
	} else {
		fmt.Println(max(A, B)*2 - 1)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <random>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

#define INF 1000000

ll evalNow(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d, vector<int> last) {
    ll ans = 0;
    ans += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(j, 26) {
        ans -= c[j]*(d+1 - last[j]);
    }
    return ans;
}

ll evalAll(vector<vector<int>>& s, vector<int>& c, vector<int>& t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;
    vector<int> last(26,0);

    rep(i, d) {
        ll tmpmax = - (1LL << 60);
        ll candidate = -1;
        rep(j, 26) {
            t[i] = j+1;
            if(tmpmax < evalNow(s,c,t,i,last)) {
                tmpmax = evalNow(s,c,t,i,last);
                candidate = j+1;
            }
        }
        last[t[i]-1] = i + 1;
        t[i] = candidate;
    }

    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    std::uniform_int_distribution<> randd(0, d-1);
    std::uniform_int_distribution<> rand26(0, 25);

    ll tmpmax = evalAll(s,c,t,d);

    double start,end;
    start = 50000;
    end = 0;

    int loop = 60000;

    rep(x, loop) {
        int i = rand()%d;
        int j = rand()%26;
        int original = t[i];
        t[i] = j+1;
        ll tmp = evalAll(s,c,t,d);
        if(tmpmax < tmp) {
            tmpmax = tmp;
        } else {
            double temp = start + (end - start)*x/loop;
            double prob = exp((tmpmax-tmp)/temp);
            ll diff = tmpmax - tmp;
            if (prob > (rand()%INF)/(double)INF) {
                t[i] = original;
            }
        }
    }


    rep(i, d) {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve(int ca){
    int N; cin>>N;
    ll a,b,c;
    map<pair<ll,ll>,int> mp;
    int a0=0, b0=0;
    int ab0=0;
    for (int i = 0; i < N; ++i) {
        cin>>a>>b;
        if(a<0&&b<0){
            a*=-1;
            b*=-1;
        }
        if(a==0&&b==0) {
            ab0++;
            continue;
        }
        else if(a==0) {
            a0++;
            continue;
        }
        else if(b==0) {
            b0++;
            continue;
        }
        c=gcd(abs(a),abs(b));
        a/=c; b/=c;
        mp[make_pair(a,b)]++;
    }
    vector<pair<ll,ll>> vec;
    vec.push_back(make_pair(a0,b0));
    for(auto i:mp){
        auto val=i.first;
        if((val.first>0)^(val.second>0)) {
            if(mp.find(make_pair(val.second,-val.first))!=mp.end()||
              mp.find(make_pair(-val.second,val.first))!=mp.end()) continue;
            vec.push_back(make_pair(i.second,0));
            continue;
        }
        int tui=0;
        tui+=mp[make_pair(-val.second,val.first)];
        tui+=mp[make_pair(val.second,-val.first)];
        vec.push_back(make_pair(i.second,tui));
    }

    ll ans=1ll;

    for(auto i:vec){
        //cout<<ans<<endl;
        if(i.second!=0){
            (ans*=(modpow(2ll,i.first,MOD)+modpow(2ll,i.second,MOD)+MOD-1)%MOD)%=MOD;
        }else{
            (ans*=modpow(2ll,i.first,MOD))%=MOD;
        }
    }

    (ans+=ab0-1+MOD)%=MOD;

    cout<<ans<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 31424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n,m; 
  cin >> n >> m; 
  if(n==m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;
using ll = long long;
constexpr int NMAX = 10000010;

ll divCount[NMAX];

int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		for (int j = i; j <= n; j += i) ++divCount[j];
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i) ans += i * divCount[i];
	printf("%lld\n", ans);
	return 0;
}



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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

struct Plan {
  int t, x, y;
};

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;

  vector<Plan> a(n+1);
  a[0].t = 0;
  a[0].x = 0;
  a[0].y = 0;
  FOR(i, 1, n+1) {
    cin >> a[i].t >> a[i].x >> a[i].y;
  }


  FOR(i, 1, n+1) {
    int dx = abs(a[i].x - a[i-1].x);
    int dy = abs(a[i].y - a[i-1].y);
    int dt = abs(a[i].t - a[i-1].t);
    if((dx + dy) > dt ||
       (dt % 2 != (dx + dy) % 2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = 0;
        int[][] ans;
        if(n % 2 ==0){
            m = (n - 2) * n / 2;
            ans = new int[m][2];
            int c = 0;
            for (int i = 1; i < n; i++) {
                for (int j = i+1; j <= n; j++) {
                    if(i + j == n+1) continue;
                    ans[c][0] = i;
                    ans[c][1] = j;
                    c++;
                }
            }
        }else{
            int n2 = n-1;
            m = (n2 - 2) * n2 / 2 + n2;
            ans = new int[m][2];
            int c = 0;
            for (int i = 1; i < n; i++) {
                for (int j = i+1; j <= n; j++) {
                    if(i + j == n) continue;
                    ans[c][0] = i;
                    ans[c][1] = j;
                    c++;
                }
            }
        }
        System.out.println(m);
        for (int i = 0; i < m; i++) {
            System.out.println(ans[i][0] + " " + ans[i][1]);
        }
        sc.close();
    }

}


Measured memory_bytes: 25684
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'a' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        op: [(Usize1, Usize1); m]
    }

    let mut num = vec![1; n]; // 入っているボールの数
    let mut red = vec![false; n]; // 赤が入っているか
    red[0] = true;

    for (a, b) in op {
        if red[a] {
            red[b] = true;
        }
        num[a] -= 1;
        num[b] += 1;
        if num[a] == 0 {
            red[a] = false;
        }
    }

    let ans = red.iter().filter(|x| **x).count();
    println!("{}", ans);
}


Measured memory_bytes: 5192
<?php 
fscanf(STDIN,"%d %d",$H,$K);

for($i=0;$i<$H;$i++){
    $array[] = trim(fgets(STDIN));
}

$new_arr = [];

for($row=0;$row<$H;$row++){
    for($col=0;$col<$K;$col++){
        $count = 0;
        if($array[$row][$col] === "#"){
            $new_arr[$row][$col] = $array[$row][$col];
        }else{                
            if(isset($array[$row-1][$col-1]) && $array[$row-1][$col-1] == "#") $count++;
            if(isset($array[$row-1][$col]) && $array[$row-1][$col] == "#") $count++;
            if(isset($array[$row-1][$col+1]) && $array[$row-1][$col+1] == "#") $count++;
            if(isset($array[$row][$col-1]) && $array[$row][$col-1] == "#") $count++;
            if(isset($array[$row][$col+1]) && $array[$row][$col+1] == "#") $count++;
            if(isset($array[$row+1][$col-1]) && $array[$row+1][$col-1] == "#") $count++;
            if(isset($array[$row+1][$col]) && $array[$row+1][$col] == "#") $count++;
            if(isset($array[$row+1][$col+1]) && $array[$row+1][$col+1] == "#") $count++;
            $new_arr[$row][$col] = $count;
        }
    }
    echo implode("",$new_arr[$row])."\n";
}
?>

Measured memory_bytes: 4084
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>
#include<stdlib.h>

using namespace std;

int main()
{

  string A, B, C;
  cin >> A >> B >> C;

  char flag='a';
  int A_idx=0;
  int B_idx=0;
  int C_idx=0;

  while(1){
    if(flag == 'a'){
      if(A_idx==A.length()){
        cout << "A" << endl;
        return 0;
      }
      flag = A[A_idx];
      A_idx++;
    }
    if(flag == 'b'){
      if(B_idx==B.length()){
        cout << "B" << endl;
        return 0;
      }
      flag = B[B_idx];
      B_idx++;
    }
    if(flag == 'c'){
      if(C_idx==C.length()){
        cout << "C" << endl;
        return 0;
      }
      flag = C[C_idx];
      C_idx++;
    }
  }

}


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

int main()
{
    long long n, d = 26;
    string str = "";
    cin >> n;
    while (n)
    {
        int t = n % 26;
        t -= 1;
        if (t < 0)
        {
            t += 26;
            n /= d;
            n -= 1;
        }
        else
        {
            n /= d;
        }
        str = str + char(t + 'a');
    }
    reverse(str.begin(), str.end());
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3628
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
int siz = 1e8+1;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
	int n;
	cin >> n;
	vector<ll> A(n);
	for (int i = 0; i < n; ++i)
	{
		ll a;
		cin >> a;
 
		if (a == 0LL)
		{
			cout << 0 << endl;
			return;
		}
		A[i] = a;
	}
 
	ll ans = A[0];
	ll mx = 1'000'000'000'000'000'000;
	for (int i = 1; i < n; ++i)
	{
		if (ans * A[i] > mx || ans > mx/A[i])
		{
			ans = -1;
			break ;
		}
		ans *= A[i];
	}
	cout << ans << endl;
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


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

int main(void){
    int N,Y;
    cin >> N >> Y;
    
    static long int i,j,k;
    for(i = 0; i <= (Y / 10000); i++){
        for(j = 0; j <= (Y / 5000); j++){
            k = (Y - (i*10000+j*5000));
            if((k%1000 == 0) && (N == i + j + k/1000) && (k >= 0)){
               cout << i << " " << j << " " << k/1000 << endl;
               return 0;
            }
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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

#define MAX 30
#define NIL -1

struct Node {int parent, left, right; };

Node T[MAX];
int n;

void preorder(int u){
    printf(" %d", u);
    if(T[u].left != NIL) preorder(T[u].left);
    if(T[u].right != NIL) preorder(T[u].right);
}

void inorder(int u){
    if(T[u].left != NIL) inorder(T[u].left);
    printf(" %d", u);
    if(T[u].right != NIL) inorder(T[u].right);
}

void postorder(int u){
    if(T[u].left != NIL) postorder(T[u].left);
    if(T[u].right != NIL) postorder(T[u].right);
    printf(" %d", u);
}

int main(){
    cin >> n;

    rep(i,n) T[i].parent = T[i].left = T[i].right = NIL;
    
    int v, l, r;
    rep(i,n){
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if(l != NIL) T[l].parent = v;
        if(r != NIL) T[r].parent = v;
    }

    int root;
    rep(i,n) if(T[i].parent == NIL) root = i;

    printf("Preorder\n");
    preorder(root);
    printf("\n");

    printf("Inorder\n");
    inorder(root);
    printf("\n");


    printf("Postorder\n");
    postorder(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int t = N;
	while (true) {
		if (t % 2 == 1)break;
		t /= 2;
	}
	if (t == 1) {
		cout << "No" << endl;
		return 0;
	}

	vector<pair<int, int> > vp;


	for (int i = 2; i < N; i+= 2) {
		vp.emplace_back(1, i);
		vp.emplace_back(1, i + 1);
		vp.emplace_back(i + N, i + 1);
		vp.emplace_back(i + 1 + N , i);
	}

	vp.emplace_back(1 + N, 2 + N);

	if (N % 2 == 0) {
		int bit = 1;
		while ((bit & N) == 0) {
			bit = (bit << 1);
		}

		int A = bit;
		int B = N - A;
		A++;
		vp.emplace_back(N, A);
		vp.emplace_back(N + N, B);

	}


	cout << "Yes" << endl;
	for (int i = 0; i < vp.size(); i++) {
		cout << vp[i].first << " " << vp[i].second << '\n';
	}
	return 0;

}

Measured memory_bytes: 5872
#include<stdio.h>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
using namespace std;
char str[1100];
vector<int>g[1100];
vector<int>rev[1100];
map<string,int>m;
int num;
int v[1100];
int t[1100];
void dfs(int a){
	t[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(!t[g[a][i]]){
			dfs(g[a][i]);
		}
	}
	v[num++]=a;
}
void dfs2(int a){
	t[a]=num;
	for(int i=0;i<rev[a].size();i++){
		if(!~t[rev[a][i]])dfs2(rev[a][i]);
	}
}
int cur;
struct wolf{
	int L;int R;
	int op;wolf(){}
};
wolf expr();
int sz;
wolf term(){
	if(str[cur]=='('){
		cur++;
		wolf ret=expr();
		cur++;
		return ret;
	}
	if(str[cur]=='~'){
		cur++;
		wolf ret=term();
		if(ret.op==-1){
			ret.L^=1;
			return ret;
		}
		ret.L^=1;
		ret.R^=1;
		ret.op^=1;
		return ret;
	}
	string tmp="";
	while(('a'<=str[cur]&&str[cur]<='z')||('A'<=str[cur]&&str[cur]<='Z')){
		tmp+=str[cur];
		cur++;
	}
	int at;
	if(m.count(tmp))at=m[tmp];
	else{
		at=sz;
		m[tmp]=sz++;
	}
	wolf ret;
	ret.L=at*2;
	ret.R=-1;
	ret.op=-1;
	return ret;
}
wolf expr(){
	wolf ret=term();
	while(str[cur]=='&'||str[cur]=='|'){
		char ch=str[cur];
		cur++;
		wolf tmp=term();
		if(ch=='&'){
			ret.R=tmp.L;
			ret.op=0;
		}else{
			ret.R=tmp.L;
			ret.op=1;
		}
	}
	return ret;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		cur=0;
		scanf("%s",str);
		wolf st=expr();
	//	printf("%d %d %d\n",st.L,st.R,st.op);
		if(st.op==-1){
			g[st.L^1].push_back(st.L);
			rev[st.L].push_back(st.L^1);
		}else if(st.op==1){
			g[st.L^1].push_back(st.R);
			rev[st.R].push_back(st.L^1);
			g[st.R^1].push_back(st.L);
			rev[st.L].push_back(st.R^1);
		}else {
			g[st.L^1].push_back(st.L);
			rev[st.L].push_back(st.L^1);
			g[st.R^1].push_back(st.R);
			rev[st.R].push_back(st.R^1);
		}
	}
	for(int i=0;i<2*b;i++){
		if(!t[i])dfs(i);
	}
	for(int i=0;i<2*b;i++)t[i]=-1;
	num=0;
	for(int i=2*b-1;i>=0;i--){
		if(!~t[v[i]]){
			dfs2(v[i]);
			num++;
		}
	}
	bool ok=true;
	//for(int i=0;i<b;i++)printf("%d %d\n",t[i*2],t[i*2+1]);
	for(int i=0;i<b;i++)if(t[i*2]==t[i*2+1])ok=false;
	if(ok)printf("accept\n");
	else printf("reject\n");
}

Measured memory_bytes: 1216
program number_of_amidakuji
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: h, w, k, i, j
  integer(8) :: dp(0:100,0:9) = 0_8, f(-1:9) = 0_8
  dp(0,1) = 1_8
  f(0) = 1_8
  read(*,*) h, w, k
  do i = 1, w
    f(i) = mod(f(i-1)+f(i-2),md)
  end do
  do i = 1, h
    do j = 1, w
      dp(i,j) = mod(mod(f(j-2)*f(w-j)*dp(i-1,j-1),md) &
      & +mod(f(j-1)*f(w-j)*dp(i-1,j),md)+mod(f(j-1)*f(w-j-1)*dp(i-1,j+1),md),md)
    end do
  end do
  write(*,'(i0)') dp(h,k)
end program number_of_amidakuji

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

int main()
{
  int m1, d1, m2, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  
  if (m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i) 
C = Array.new(N + 1).map{Array.new(N + 1, 10_000_000)}
L = []
M.times do
  a, b, c = gets.split.map(&:to_i)
  L.push [a, b, c]
  C[a][b] = C[b][a] = c
end

def smaller(a, b)
  a < b ? a : b 
end

dp = Array.new(N + 1) do |k|
  Array.new(N + 1) do |i|
    Hash.new do |h, j| 
      d = dp[k - 1]
      h[j] = smaller(d[i][j], d[i][k] + d[k][j])
    end
  end
end

dp[0] = C

puts L.count{|a, b, c| dp[N][a][b] != C[a][b]}


Measured memory_bytes: 52732
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt_a = Counter(a)

if n % 3 == 0:
    if cnt_a[0] == n:
        print('Yes')
    elif len(set(a)) == 2 and 0 in set(a) and cnt_a[0] == n // 3:
        print('Yes')
    elif len(set(a)) == 3:
        x, y, z = set(a)
        if cnt_a[x] == n // 3 and cnt_a[y] == n // 3 and cnt_a[z] == n // 3 and x ^ y ^ z == 0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if cnt_a[0] == n:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 20672
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}


int main(){
    int n,q,tmp1,tmp2,tmp;
    vector<set<int> > p(26);
    string s;
    cin >> n>>s>>q;
    rep(i,n){
        p[s[i]-'a'].insert(i);
    }
    
    rep(i,q){
        int type;
        cin>>type;
        if(type==1){
            int i;
            char c;
            cin>>i>>c;
            i--;
            p[s[i]-'a'].erase(i);
            s[i]=c;
            p[s[i]-'a'].insert(i);
        }else{
            int ans,l,r;
            cin>>l>>r;
            l--;
            ans=0;
            rep(i,26){
                auto it = p[i].lower_bound(l);
                if(it != p[i].end() && *it < r) ans++;
            }
            cout<<ans<<endl;
            
        }
    }

    return 0;
}

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

int main() {
  int N, K, a , b;
  int c=1;
  
  cin >> N >> K;
  
  rep(i, N){
    a = c * 2;
    b = c + K;
    if(a < b){
      c = a;
    }else{
      c = b;
    }
  }
  
  cout << c << endl;
}

Measured memory_bytes: 256
#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 PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string s,t;
    cin>>s>>t;
    ll cnt =0;
    lp(i,sz(s)){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3852
from math import pi, cos, sin
A, B, H, M = map(int, input().split())
H += M / 60

t1 = 2 * pi * H / 12
t2 = 2 * pi * H

z1 = A * complex(cos(t1), sin(t1))
z2 = B * complex(cos(t2), sin(t2))

print(abs(z1 - z2))


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

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second

const int maxn = 2e5 + 5;

const int maxv = 1e9;

int T, tc;
int n;
int a[maxn];

int main() {
//	freopen("inp.txt", "r", stdin);
    
   	cin >> n;
   	
   	int x = 0;
   	for (int i = 0; i < n; i++) {
		cin >> a[i];
		x ^= a[i];
	}
	
	for (int i = 0; i < n; i++) {
		printf("%d ", x ^ a[i]);
	}
    
    return 0;
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,t,c,a,b;
  cin>>n>>t>>a;
  c=t;
  b=a+t;
  for(int i=1;i<n;i++){
    cin>>a;
    if(b<=a){
      b=a+t;
      c+=t;
    }else{
      c+=a+t-b;
      b=a+t;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <set>
#include <string>

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

int main(){
    int n;
    cin >> n;
    set<string>  st;
    rep(i,n){
        string str;
        cin >> str;
        st.insert(str);
    }

    cout << st.size() << endl;
    

    return 0;
}

Measured memory_bytes: 19120
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

vector<pair<int, int>> A;
bool comp(pair<int, int> lhs, pair<int, int> rhs) {
  return lhs.first > rhs.first;
}
int mini(int i){
    int ans=0;
    int k=0;
    while(1){
        if(A[k].second!=i){
            ans=A[k].first;
            break;
        }
        k++;
    }
    return ans;
}
int main(void){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        A.push_back(make_pair(tmp, i));
    }
    sort(A.begin(),A.end(),comp);
    for(int i=0;i<N;i++){
        cout << mini(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 3312
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[float]", u: "List[str]"):
    d = {'JPY': 1, 'BTC':380000}
    return sum(xx * d[uu] for xx, uu in zip(x, u))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [float()] * (N)  # type: "List[float]"
    u = [str()] * (N)  # type: "List[str]"
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    print(solve(N, x, u))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int a,b;cin>>a>>b;
	if(a<b){
		for(int i=1;i<=b;i++)cout<<a;
	}
	else{
		for(int i=1;i<=a;i++)cout<<b;
	}
}


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

int main () {
  int A , B , C , D ;
  cin >> A >>B>>C>>D;
  if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  else if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

int main(){
  int t,sum,m1,m2,n;

  for(;;){
    cin >> n;
    if(!n)break;

    m1 = 0,m2 = 500;
    for(int i=0;i<n;i++){
      sum = 0;
      for(int j=0;j<5;j++){
	cin >> t;
	sum += t;
      }
      m1 = max(m1,sum);
      m2 = min(m2,sum);
    }
    cout << m1 << " " << m2 << endl;
  }
}

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

int f(int n){
  if(n%2 == 0){
    return n/2;
  }
  else{
    return 3*n + 1;
  }
}

bool hantei(int a, int b){
  return a==b;
}

int hanten(int a, int b){
  return 1 - hantei(a, b);
}

int main(){
  int s, n, doti;
  int a[1000000];
  cin >> s;
  n = 0;
  a[0] = s;
  doti = 1;
  while(doti == 1){
    n++;
    a[n] = f(a[n-1]);
    for(int j=0; j<n; j++){
      doti = doti * hanten(a[j], a[n]);
    }
  }
  cout << n+1 << endl;
  return 0;
}

Measured memory_bytes: 256
M = int(input())
keta = 0
count_sum = 0
for _ in range(M):
    d,c= map(int,input().split(' '))
    keta += c
    count_sum += d*c
additional = count_sum//10
if 9 < count_sum:
    print(keta-1 + (count_sum-1)//9)
else:
    print(keta-1)

Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	char N[1111111];
	N[0]='0';
	scanf("%s", N+1);
	int len;
	REP(i, 1111111){
		if(N[i]=='\0'){
			len=i;
			break;
		}
	}
	ll ans=0;
	bool carry=false;
	int i=len-1;
	while((i>0) or carry){
		int dig=(int)(N[i]-'0');

		if(carry)dig++;
		carry=false;

		if(dig<5){
			ans+=dig;
		}else if(dig>5){
			ans+=10-dig;
			carry=true;
		}else{
			if((int)(N[i-1]-'0')<=4){
				ans+=dig;
			}else{
				ans+=10-dig;
				carry=true;
			}
		}
		i--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1280
#include<cstdio>
#define maxn 200005
#define LL long long
using namespace std;
LL N,Ans,A[maxn],F[maxn];
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	N=read();
	for (int i=1;i<=N;++i) A[i]=read();
	if (A[1]) return puts("-1"),0;
	for (int i=1;i<N;++i) if (A[i+1]-A[i]>1){return puts("-1"),0;}
	for (int i=2;i<=N;++i) if (A[i]-A[i-1]==1) F[i]=F[i-1]+1,F[i-1]=0; else F[i]=A[i];
	for (int i=1;i<=N;++i) Ans+=F[i];
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 1123;

int n, m, k;
char s[MAXN];
char pal[MAXN];

int main (){
    scanf(" %s", s);
    scanf(" %s", pal);
    n = strlen(s);
    int np  = strlen(pal);
    int res = INT_MAX;
    for(int i=0;i<=n-np;i++){
        int ans = 0;
        for(int j=0;j<np;j++){
            ans += (s[i+j] != pal[j]);
        }
        res = min(res, ans);
    }
    printf("%d\n", res);
}



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

int main(){
	string A;
	cin >> A;
	int N=A.size();
	
	long long ans=(long long)N*(N-1)/2+1;
	for(int i=0;i<26;i++){
		char t='a'+i;
		int c=0;
		for(auto a:A)if(a==t)c++;
		ans-=(long long)c*(c-1)/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in map(int,sys.stdin):
 print((e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2)[e>3])


Measured memory_bytes: 9884
import numpy as np
w, h, n = map(int, input().split())

field = np.ones([h, w], dtype=int)

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        field[:, :x] = 0
    elif a == 2:
        field[:, x:] = 0
    elif a == 3:
        field[:y, :] = 0
    else:
        field[y:, :] = 0

print(field.sum())

Measured memory_bytes: 12532
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#define maxn 1005
#define _ 0
using namespace std;
struct nod
{
	int nex,id;
	nod(int a,int b)
	{
		nex=a;
		id=b;
	}
	nod(){}
};
int n,m,tim;
int vis[maxn];
int bel[maxn][maxn][2];
int u[maxn*maxn],v[maxn*maxn];
vector<nod> edge[maxn];
void dfs(int now,int fa,int b,int f)
{
	vis[now]=tim; bel[fa][now][f]=b;
	int len=edge[now].size();
	for(int i=0;i<len;i++)
		if(vis[edge[now][i].nex]!=tim)
			dfs(edge[now][i].nex,fa,b,f);
}
void solve(int now)
{
	tim++; vis[now]=tim;
	int len=edge[now].size();
	for(int i=0;i<len;i++)
		if(vis[edge[now][i].nex]!=tim)
			dfs(edge[now][i].nex,now,edge[now][i].id,0);

	tim++; vis[now]=tim;
	for(int i=len-1;i>=0;i--)
		if(vis[edge[now][i].nex]!=tim)
			dfs(edge[now][i].nex,now,edge[now][i].id,1);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u[i],&v[i]);
		edge[u[i]].push_back(nod(v[i],i));
	}
	for(int i=1;i<=n;i++)
		solve(i);
	for(int i=1;i<=m;i++)
	{
		if( (bel[v[i]][u[i]][0]!=0) ^ _ ^ (bel[u[i]][v[i]][0]!=i || bel[u[i]][v[i]][1]!=i) )
			printf("diff\n");
		else
			printf("same\n");
	}
}



Measured memory_bytes: 18688