akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; ++i)
#define INF (2e9)

int main() {
  int n, m; cin >> n >> m;
  int ans[n] = {};
  REP(i, n) --ans[i];
  int s, c;

  REP(i, m) {
    cin >> s >> c;
    if(ans[s-1] == -1 || ans[s-1] == c) {
      ans[s-1] = c;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  if(n != 1 && ans[0] == 0) {
    cout << -1 << endl;
    return 0;
  }

  if(n != 1 && ans[0] == -1) ans[0] = 1;
  if(n == 1 && ans[0] == -1) ans[0] = 0;
  REP(i, n-1) {
    if(ans[i+1] == -1) ans[i+1] = 0;
  }

  REP(i, n) cout << ans[i];
  cout << endl;

  return 0;
}

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

using namespace std;

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int MOD = 1e9 + 7;
const int N = 2001;

int a[200001];
int b[200001];
int dp[8001][8001];

int choose(int a, int b)
{
	if(a < b) return 0;
	if(dp[a][b] != -1) return dp[a][b];
	if(b == 0) return 1;
	if(b == 1) return a;
	dp[a][b] = (ll(choose(a - 1, b)) + ll(choose(a - 1, b - 1)))%MOD;
	return dp[a][b];
}

ll modpow(ll a, ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1) r = (r*a)%MOD;
		a = (a*a)%MOD;
		b>>=1;
	}
	return r;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < n; i++)
	{
		dp[-a[i]+N][-b[i]+N]++;
		//dp2[a[i]+N][b[i]+N]++;
	}
	
	for(int i = 1; i <= 4010; i++)
	{
		for(int j = 1; j <= 4010; j++)
		{
			dp[i][j] = (ll(dp[i][j]) + ll(dp[i - 1][j]) + ll(dp[i][j - 1]))%MOD;
		}
	}
	
	ll ans = 0;
	ll ans2 = 0;
	
	for(int i = 0; i < n; i++)
	{
		ans += dp[a[i]+N][b[i]+N];
		ans %= MOD;
	}
	
	memset(dp, -1, sizeof(dp));
	
	for(int i = 0; i < n; i++)
	{
		ans2 += choose(2*(a[i]+b[i]), 2*b[i]);
		ans2 %= MOD;
	}
	//cout << ans << ' ' << ans2 << endl;
	
	ans = (ans - ans2)%MOD;
	if(ans < 0) ans += MOD;
	ans = (ans*modpow(2, MOD - 2))%MOD;
	if(ans < 0) ans += MOD;
	cout << ans;
	return 0;
}


Measured memory_bytes: 252288
@@=1..<>;/ .* /,$_[$`][$&]=$_[$&][$`]=$' for@M=<>;for$i(@@){//,map$_[$'][$_]=($%=$_[$'][$_]||1e9)<($==($_[$'][$i]||1e9)+($_[$i][$_]||1e9))?$%:$=,@@for@@}print~~grep/ .* /*$_[$`][$&]<$',@M

Measured memory_bytes: 1408
fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(' ').map(String::toLong)
    var min = Long.MAX_VALUE
    for (i in 1..n) {
        val (c, temp) = readLine()!!.split(' ').map(String::toLong)
        if (temp <= t) min = Math.min(min, c)
    }
    if (min == Long.MAX_VALUE) {
        println("TLE")
    } else {
        println(min)
    }
}


Measured memory_bytes: 38492
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
//#define int long long
#define ll long long
#define int boost::multiprecision::cpp_int
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


int X;
int intpow(int a, int b) {
    int ans = 1;
    while (b) {
        if (b & 1)
            ans *= a;
        a *= a;
        b /= 2;
    }
    return ans;
}


void solve() {

    for (int A = 0;; A++) {
        int Y = intpow(A, 5) - X;
        if (Y == 0) {
            cout << A << " " << 0 << endl;
            return;
        }
        int minus = 1;
        if (Y < 0) {
            minus = -1;
            Y *= -1;
        }
        int ok = 0;
        int ng = Y + 1;
        auto check = [&](int x) {
            return intpow(x, 5) <= Y;
        };
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (check(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        if (intpow(ok, 5) == Y) {
            cout << A << " " << ok * minus << endl;
            return;
        }
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> X;


    solve();
    return 0;
}


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

int c()
{
    int n;
    std::cin >> n;
    
    std::vector<std::string> strings;
    for(int i = 0; i < n; i++)
    {
        std::string s;
        std::cin >> s;
        strings.push_back(s);
    }
    
    std::sort(strings.begin(), strings.end());
    
    int ans = 1;
    for(int i = 1; i < n; i++)
    {
        if(strings[i-1] != strings[i])
        {
            ans++;
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}


int main(int argc, const char * argv[])
{
    c();
    return 0;
}

Measured memory_bytes: 11660
#include<iostream>
int A, B;
int main(){
	std::cin >> A >> B;
if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
	std::cout << "Possible" << "\n";
}
else {
	std::cout << "Impossible" << "\n";
}
system("pause");
return 0;
}


Measured memory_bytes: 504
import math

a, b = map(int, input().split())  # 複数数値入力

A = list()
B = list()

if b == 0:
    B = [0]
elif b == 1:
    B = [1]
else:
    for i in range(1, int(math.log2(b))+2):
        tmp = b // (2 ** i) * 2 ** (i - 1)

        if b % (2 ** i) < (2 ** (i-1)):
            plus = 0
        else:
            plus = b % (2 ** i) - 2 ** (i-1) + 1

        B.append(tmp + plus)

if a == 0:
    A = [0]
elif a == 1:
    A = [0]
else:
    for i in range(1, int(math.log2(a-1))+2):
        tmp = (a-1) // (2 ** i) * 2 ** (i - 1)

        if (a-1) % (2 ** i) < (2 ** (i-1)):
            plus = 0
        else:
            plus = (a-1) % (2 ** i) - 2 ** (i-1) + 1

        A.append(tmp + plus)

if b == 0:
    print(0)
else:
    ans = 0
    for i in range(0, int(math.log2(b)) + 1):
        if i >= len(A):
            ans += (B[i]) % 2 * 10 ** i
        else:
            ans += (B[i] - A[i]) % 2 * 10 ** i

    print(int(str(ans), 2))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int f(int x){
  int cnt=0;
  int tmp=x;
  for(int i=1;i<sqrt(x);i++){
    if(tmp%i==0) cnt++;
  }
  cnt*=2;
  int y=sqrt(x)*1;
  if(y!=0&&y*y==x&&x%y==0) cnt++;
  return cnt;
}
int main(){
  int n; cin>>n;
  int ans=0;
  for(int i=i;i<n;i++){
    ans+=f(i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2728

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int S, N;
	int ans = -1, T = 1;
	vector<int> X, O;
	string Z;
	
	cin>>Z;
	
	// cin>>S;
	for(int i = 0; i < Z.size(); i++){
		S = S * 10 + Z[i] - '0';
	}
	
	N = Z.size();
	
	// N = to_string(S).size();

	
	for(int i = 0; i < 10; i++){
		X.push_back(i);
	}
	
	for(int i = 0; i < N; i++){
		T *= 10;
	}
	
	do {
		int num = 0;
		
		for(int i = 0; i < N; i++){
			num = num * 10 + X[i];
		}
		
		int dif1 = min(abs(S-ans),T - abs(S-ans));
		int dif2 = min(abs(S-num),T - abs(S-num));
		
		if(ans == -1) ans = num;
		else if(dif1 < dif2) ans = num;
		else if(dif1 == dif2) ans = min(ans, num);
			
	} while(next_permutation(X.begin(), X.end()));
	
	if(ans == 0) cout<<0<<endl;
	else if(to_string(ans).size() == N)cout<<ans<<endl;
	else cout<<"0"<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3272
N=int(input())
dp=[0]*(10**4+1)
for i in range(1,100+1):
  for j in range(1,100+1):
    for k in range(1,100+1):
      a=(i+j)**2+(k+j)**2+(i+k)**2
      if 10**4<a//2:
        break
      dp[a//2]+=1
for l in range(1,N+1):
  print(dp[l])

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#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__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


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

  bool isok=false;
  int mid;
  rep(i, 1, n){
    if (a[i-1] + a[i]>=l){
      mid = i; isok = true;
      break;
    }
  }
  if (!isok){
    cout << "Impossible" << endl;
    return 0;
  }
  dump(mid);

  cout << "Possible" << endl;
  vi ans;
  rep(i, 1, n){
    if (i==mid) break;
    cout << i << endl;
  }
  rrep(i, 1, n){
    if (i==mid) break;
    cout << i << endl;
  }
  cout << mid << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

int main(){
  // ここから入力受け取り
  int N;
  cin >> N;
  int X[N];
  int Y[N];
  rep(i, N){
    cin >> X[i];
    cin >> Y[i];
  }

  // 街の回り順に関するインデックス
  // next_permutationでこのインデックスを辞書順に並び変えていく
  int idx[N];
  // あらかじめ昇順にしておく
  rep(i, N) idx[i] = i;
  double ans = 0;
  int dx, dy;
  // next_permutationで並び替えられたidxを使ってその回り順における経路の長さを計算
  do {
    rep(i, N-1){
      dx = X[idx[i]] - X[idx[i+1]];
      dy = Y[idx[i]] - Y[idx[i+1]];
      ans += sqrt(dx * dx + dy * dy);
    }
  }
  // 並び替え
  while (next_permutation(idx, idx+N));
  // 平均なので階乗を計算しておく
  int F = 1;
  rep(i, N) F *= i + 1;
  // 出力
  cout << fixed << setprecision(10);
  cout << ans / F << endl;
}


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

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

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

  if(y%2 != 0)
    printf("No");
  else{
    if(y > 4 * x){
      printf("No");
      exit(0);
    }
    else{
      if((tsuru=(4*x-y)/2) >= 0 && x-tsuru >= 0)
	printf("Yes");
      else
	printf("No");
    }
  }
}

Measured memory_bytes: 1732
import math
def is_prime(n):
    if(n < 2):
        return False
    for i in range(2, int(math.sqrt(n))+1):
        if(n%i) == 0:
            return False
        
    return True

prime = []

N = int(input())
i = 1
while(len(prime) < N):
    p = 5 * i + 1
    if(is_prime(p)):
        prime.append(p)
    i += 1

s = ""
for i in prime:
    s += str(i) + " "
print(s[:len(s)-1]) 


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

const ll MOD = 1000000007;

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

int main()
{
    ll p[62];
    p[0] = 1;
    for(int i = 1; i < 62; i++) p[i] = p[i - 1] * 2 % MOD;
    int n;
    cin >> n;
    ll a[300005];
    ll c[62] {0};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ll t = a[i];
        for(int j = 0; j < 62; j++){
            c[j] += t % 2;
            t /= 2;
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 62; j++){
            if(a[i] % 2){
                ans = (ans + p[j] * (n - c[j])) % MOD;
            }
            else{
                ans = (ans + p[j] * c[j]) % MOD;
            }
            a[i] /= 2;
        }
    }
    cout << ans * modpow(2, MOD - 2) % MOD << endl;
}

Measured memory_bytes: 2560
// not finished triangles triangles triangles triangles triangles triangles 

#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n'

using namespace std;

string a, b, c;
int an, bn, cn;

int main(){

    cin >> a >> b >> c;

    an = a.length() - 1;
    bn = b.length() - 1;
    cn = c.length() - 1;

    if(a[an] == b[0] && b[bn] == c[0]){
        cout << "YES";
        return 0;
    }
    cout << "NO";
}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, m) cin >> b[i];

    int count = 0;
    rep(i, 0, n-m+1) {
        rep(j, 0, n-m+1) {
            count = 0;
            rep(k, 0, m) {
                rep(l, 0, m) {
                    if(a[i+k][j+l] == b[k][l]) {
                        count++;
                    }
                    else {
                        count = 0;
                        continue;
                    }
                }
            }
            if(count == m*m) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return  0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    x = []
    xl = {}
    tmp = []
    ans = 0
    maxtmp = 0
    for i in range(n):
        xx, ll = map(int,input().split())
        if maxtmp < xx:
            maxtmp = xx
        low = xx-ll
        high = xx+ll
        lmh = [high,xx,low]
        tmp.append(lmh)


    tmp.sort()
    high = tmp[0][0]
    ans = 1
    for i in range(1,len(tmp)):
        a = tmp[i]
        if a[2] >= high:
            high = a[0]
            ans += 1
        else:
            continue

    print(ans)
    return


if __name__=='__main__':
    main()


Measured memory_bytes: 23264
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define LL long long
#define Max +5

using namespace std;

LL Map[Max][Max],N,M,I,J,A,B,C;

int main()
{
	scanf("%lld%lld",&N,&M);
	printf("%lld",2*M-N);
	return 0;
}


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

typedef long long ll;

int main(){
  string s;
  cin>>s;
  int num1=0, num2=0, num3=0;
  bool ok=false;
  for(int i=0;i<s.size();i++){
    if(s[i]=='a') num1++;
    else if(s[i]=='b') num2++;
    else num3++;
  }
  int MAX=max(num1, max(num2, num3));
  int MIN=min(num1, min(num2, num3));
  int MID=num1+num2+num3-MAX-MIN;
  if(MAX-MID<2&&MID-MIN<2&&MAX-MIN<2){
   ok=true; 
  }
  if(ok) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 512
use proconio::input;

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

fn main() {
    input! {
        n: usize, k: usize,
        mut av: [usize; n]
    };

    av.sort();

    let res = bsearch(-1, n as i64, |x| {
        let x = x as usize;
        let mut dp = vec![vec![false; k]; n + 1];
        dp[0][0] = true;
        for i in 0..n {
            for j in 0..k {
                if i == x {
                    dp[i + 1][j] = dp[i][j];
                    continue;
                }

                dp[i + 1][j] |= dp[i][j];
                let a = av[i];
                if j + a >= k {
                    continue;
                }
                dp[i + 1][j + a] |= dp[i][j];
            }
        }
        let a = av[x];
        let l = (k as isize - a as isize).max(0) as usize;
        let is_needed = (l..k).any(|i| dp[n][i]);
        !is_needed
    });
    let res = res.map(|x| x + 1).unwrap_or(0);
    println!("{}", res);
}


Measured memory_bytes: 26624
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	vector<vector<int>> v;
	rep(i,0,n){
		vector<int> tmp(26,0);
		v.push_back(tmp);
		string s;
		cin >> s;
		rep(j,0,s.size()){
			v[i][s[j]-'a']++;
		}		
	}
	
	string ans = "";
	rep(i,0,26){
		int MIN = 0x7FFFFFFF;
		rep(j,0,n){
			MIN = min(MIN,v[j][i]);
		}
		
		rep(j,0,MIN){
			ans += 'a'+i;
		}
	}
	
	P(ans);
	ret 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
int *partition(int *first, int *last) {
    // pivot is last value
    int pivot = *(last - 1);
    // p: border 
    int *p = first - 1;
    for(int *it = first; it != last - 1; ++it) {
        if(*it <= pivot) {
            p++;
            int tmp = *p;
            *p = *it;
            *it = tmp;
        }
    }
    int tmp = *++p;
    *p = pivot;
    *(last - 1) = tmp;
    return p;
}
int main(int argc, char **argv) {
    int n = get_uint();
    int a[n];
    for(int i = 0; i < n; ++i) a[i] = get_uint();
    int *piv = partition(a, a + n);
    for(int *it = a; it != piv; ++it) put_uint(*it), putchar_unlocked(' ');
    putchar_unlocked('['), put_uint(*piv), putchar_unlocked(']'), putchar_unlocked(' ');
    for(int *it = piv + 1; it != a + n - 1; ++it) put_uint(*it), putchar_unlocked(' ');
    put_uint(a[n-1]), putchar_unlocked('\n');
    return 0;
}



Measured memory_bytes: 2104
using System;

namespace AOJ.Volume3
{
    public class SecretInvestigation
    {
        public static int Main()
        {
            int n = int.Parse(Console.ReadLine());
            var belong_a = new bool[n + 1];
            var belong_b = new bool[n + 1];
            var has_c = new bool[n + 1];
            for(int i = 1; i <= n; i++)
            {
                belong_a[i] = false;
                belong_b[i] = false;
                has_c[i] = false;
            }

            // ??????A
            var input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            for(int i = 0; i < x; i++)
            {
                int no = int.Parse(input[i + 1]);
                belong_a[no] = true;
            }

            // ??????B
            input = Console.ReadLine().Split(' ');
            int y = int.Parse(input[0]);
            for(int i = 0; i < y; i++)
            {
                int no = int.Parse(input[i + 1]);
                belong_b[no] = true;
            }

            // ??????C
            input = Console.ReadLine().Split(' ');
            int z = int.Parse(input[0]);
            for(int i = 0; i < z; i++)
            {
                int no = int.Parse(input[i + 1]);
                has_c[no] = true;
            }

            // ??????
            int output = 0;
            for(int i = 1; i <= n; i++)
            {
                if (!belong_a[i] && has_c[i]) { output++; }
                else if (belong_b[i] && has_c[i]) { output++; }
            }
            Console.WriteLine(output);

            return 0;
        }
    }
}

Measured memory_bytes: 9168
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for _ in range(0,M):
    b,c=map(int,input().split())
    B.append([c,b])
A.sort();B.sort(reverse=True)
cnt=0
fin=False
for b in B:
    for i in range(0,b[1]):
        if cnt>N-1:
            fin=True
            break
        if A[cnt]<b[0]:
            A[cnt]=b[0]
            cnt+=1
        else:
            fin=True
            break
    if fin:
        break
print(sum(A))

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

int main() {
    int N, K;
    double T, U, V, L;
    cin >> N >> K >> T >> U >> V >> L;
    vector<double> D(N);
    for (int i=0; i<N; ++i) cin >> D[i];
    
    double tm = 0;
    double r = L;
    for (int i=N-1; i>=0; --i) {
        if (i+K < N && D[i+K] < r-V*T) {
            // D[i+K]の位置から加速
            tm += T + (r-D[i+K]-V*T) / U;
            r = D[i+K];
        } else {
            // rの位置まで加速
            tm += min(V*T, r-D[i]) / V;
            r -= min(V*T, r-D[i]);
        }
    }
    tm += r / U;

    printf("%.9f\n", tm);
    return 0;
}


Measured memory_bytes: 3292
/*
ID: iCoder0020
PROG: Frog 2
LANG: C++                  
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int li;

int main()
{
	int N,K;
	cin>>N>>K;
	li H[N];
	for(int n = 0; n<N; n++)
	{
		cin>>H[n];
	}
	li dp[N+1];
	dp[0] = 0;
	dp[1] = 0;
	for(int n = 2; n<=min(N,K); n++)
	{
		dp[n] = abs(H[n-1] - H[0]);
		for(int m = 1; m<n; m++)
		{
			dp[n] = min(dp[n], dp[n-m] + abs(H[n-1]-H[n-m-1]));
		}
	}
	for(int n = K+1; n<=N; n++)
	{
		dp[n] = INT_MAX;
		for(int m = 1; m<=K; m++)
		{
			dp[n] = min(dp[n], dp[n-m] + abs(H[n-1]-H[n-m-1]));
		}
	}
	cout<<dp[N]<<endl;
	return 0;	
}

Measured memory_bytes: 1792
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N+1);
    REP(i, N+1) cin >> A[i];

    vector<ll> L(N+1);
    vector<ll> R(N+1);
    L[N] = A[N];
    R[N] = A[N];

    for (int n = N-1; n >= 0; n--) {
        ll pr = R[n+1];
        ll lr = L[n+1];
        ll r = A[n] + pr;
        ll l = A[n] + (lr+1)/2;
        R[n] = r;
        L[n] = l;
    }

    ll leaf = 1;
    bool ok = true;
    ll ret = 0;
    REP(i, N+1) {
        if (leaf < L[i] || leaf > R[i]) {
            ok = false;
            break;
        }
        if (i == N) {
            ret += leaf;
            leaf = 0;
            break;
        }
        if (A[i] == leaf) {
            ret += leaf;
            leaf = 0;
        }
        else if (A[i] > leaf) {
            ok = false;
            break;
        }
        else {
            assert(A[i] < leaf);
            ret += leaf;
            ll l = (leaf-A[i]);
            ll r = 2LL*(leaf-A[i]);
            if (r < L[i+1] || l > R[i+1]) {
                ok = false;
                break;
            }
            leaf = min(r, R[i+1]);
        }
    }
    if (ok) {
        ok = (leaf == 0);
    }
    if (!ok)
        cout << -1 << endl;
    else
        cout << ret << endl;
    return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
long long pi = 3.14159265358979323846264338327;
int a,b,c,k;
int counter=0;
int main() {
	cin >> a >> b >> c >> k;
	for(int i = 0;i<k;++i){
		if(b > a){
			break;
		}
		b *= 2;
		++counter;
	}
	k -= counter;
	for(int j = 0;j<k;++j){
		if(c>b){
			cout << "Yes" << endl;
			return 0;
		}
		c *= 2;
	}
	if(c>b){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
 	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    int N, X, T;
    cin >> N >> X >> T;

    if (N % X > 0) {
        cout << T * (N / X + 1) << endl;
    }
    else {
        cout << T * N / X << endl;
    }

}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>

using namespace std;

const int INFTY = (1<<30);

int main()
{
    int N;
    cin >> N;
    vector<int> A(N + 1);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i] >> A[i + 1];
    }

    vector< vector<int> > cost(N);
    cost[0].assign(N, 0);
    for (int l = 2; l < N + 1; l++)
    {
        cost[l - 1].assign(N - l + 1, INFTY);
        for (int num = 0; num < N - l + 1; num++)
        {
            for (int k = 1; k < l; k++)
            {
                cost[l-1][num] = min(
                    cost[l-1][num],
                    cost[k-1][num] + cost[l-1-k][num+k] + A[num]*A[num+k]*A[num+l]
                );
            }
        }
    }
    cout << cost[N-1][0] << endl;
}


Measured memory_bytes: 3152
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	ps := make([]int, 0)
	ans := 0
	ps = append(ps, as[0])
	for i := 1; i < n; i++ {
		p := ps[0]
		ps = ps[1:]
		ans += p

		a := as[i]
		ps = append(ps, a)
		ps = append(ps, a)
	}

	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 12452
#include <bits/stdc++.h>
#define INF 1.0e9
#define MOD 1.0e9+7
using namespace std;
typedef long long ll;

int N;
const int MAX_N = 100;
string W[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> W[i];
    bool f = true;
    for (int i = 1; i < N; i++) {
        if (W[i][0] != W[i-1][W[i-1].length()-1]) {
            f = false;
            break;
        }
        for (int j = i-1; j >= 0; j--) {
            if (W[i] == W[j]) {
                f = false;
                break;
            }
        }
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

int main(){
    Init();
    ll n; cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
ll a[N];
int main()
{
	int n;
	cin>>n;
	map<ll,ll>mp;
	for(int i=1;i<=n;i++) cin>>a[i];
	ll ans=0;
	for(int i=1;i<=n;i++){
		//a[i]+=i;
		ans+=mp[i-a[i]];
		mp[i+a[i]]++;
	}
//	ll ans=0;
//	for(auto x:mp){
//		ans+=x.se*(x.se-1);
//	}
	cout<<ans;
}


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

using namespace std;

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define LL long long

vector<int> vec;


int main()
{
	int n,tmp;
	cin >> n;
	bool flag = 0, check = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		vec.push_back(tmp);
	}
	sort(vec.begin(),vec.end());


	for(int i = 0; i < n; i++)
	{
		int l = 0, r = n - 1;
		while(l < r)
		{
			int mid = (l + r) / 2;
			//printf("%d %d\n", vec[mid], vec[i]);
			if(vec[mid] < vec[i])
			{
				l = mid + 1;
			}
			else if(vec[mid] == vec[i] && i != mid)
			{
				check = 1;
				break;
			}
			else
			{
				r = mid;
			}
		}
		if(check)
			break;
	}


	if(check)
	{
		printf("NO\n");
	}
	else
	{
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1e9+7;
// const ll INF = 1000000000000000000LL;
 
 
 int main() {
	 int n;
	 cin >> n;
	 vector<ll> l(n);
	 rep(i,n) cin >> l[i];
	 sort(l.begin(),l.end());
	 ll cnt=0;
	 for(ll i=0;i<l.size();i++){
		 for(ll j=i+1;j<l.size()-1;j++){
			 for(ll k=j+1;k<l.size();k++){
				 if(l[i]==l[j]||l[j]==l[k]) continue;
				 if(l[i]+l[j]>l[k]) cnt++;
				 if(l[i]+l[j]<=l[k]) break;
			 }
		 }
	 }
	 cout << cnt << endl;
	 
	 return 0;
 }

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int dp[100000][4];
int main() {
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;

	vector<int> t2;
	REP(i, n) {
		if (t[i] == 'r') t2.push_back(2);  //勝てる手
		if (t[i] == 's') t2.push_back(0);
		if (t[i] == 'p') t2.push_back(1);
	}

	int sc[3] = { r, s, p };

	int score = 0;
	REP(i, n) {
		score += sc[t2[i]];
	}

	REP(i, n - k) {
		if (t2[i] == t2[i + k]) {
			if (sc[t2[i]] < sc[t2[i + k]]) {
				score -= sc[t2[i]];
			}
			else {
				score -= sc[t2[i + k]];
				if (i + k * 2 < n) {
					t2[i + k] = 3;
				}
			}
		}
	}
	cout << score;
	return 0;
}

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

using namespace std;


#define MAXN 100001
int gcd(int a, int b) {
  while(b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, x[MAXN];
  cin >> n >> x[0];
  for (int i = 1; i <= n; ++i) {
    cin >> x[i];
  }
  sort(x, x+n+1);
  int ans = x[1]-x[0];
  for (int i = 1; i < n; ++i) {
    ans = gcd(ans, x[i+1]-x[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=998244353;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    string s;cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
int main(){
  ll a,b;cin >> a >> b;
  ll g=gcd(a,b);
  cout << a*b/g << endl;
}

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

const double PI=3.14159265358979323846;

int main () {
	int a, b, x;
	cin >> a >> b >> x;
	if (2*x <= a*a*b) {
		// aby=2x
		double y = 2.0*x / (a*b); 
		printf ("%lf\n", atan (b/y)*180/PI);
	} else {
		// aa(b-y)+aay/2 = x
		// aab - aay/2 = x
		// 2aab - aay = 2x
		// 2aab - 2x = aay
		double y = 2.0*b - 2.0*x/(a*a);
		printf ("%lf\n", atan (y/a)*180/PI);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ac fstream cin("input.txt");ofstream cout("output.txt");
#define ULL unsigned long long
int A[100005]={};
int B[100005]={};
int main()
{  
    int a;
    while(cin>>a){
        int r=1;
        for(int i=1;i<=a;i++){
            cin>>A[i];
            if(A[i]==A[i-1]){
                con;
            }
            B[r++]=A[i];
        }
        int ans=0;
        int i=1;
        while(i<=r){
            ans++;
            if(B[i]>B[i+1]){
                while(B[i]>=B[i+1]){
                    i++;
                    if(i>=r)
                        bk;
                }
                i++;
            }
            
            else if(B[i]==B[i+1]){
                while(B[i]==B[i+1]){
                    i++;
                      if(i>=r)
                        bk;
                }
                i++;            
            }
            else{
              while(B[i]<=B[i+1]){
                    i++;
                        if(i>=r)
                        bk;
                }
                i++;
            }
              if(i>=r)
                        bk;
        }
        if(ans==0)
            ans=1;
        cout<<ans<<endl;
    
    
    
    
    }
   
    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    if(n==1&&m==0){
        cout<<"0"<<endl;
        return 0;
    }
    vector<vector<int>>a(m,vector<int>(2));
    vector<int> ans(n,0);
    ans[0]=1;
    rep(i,m){
        cin>>a[i][0]>>a[i][1];
        rep(j,i){
            if(a[i][0]==a[j][0]&&a[i][1]!=a[j][1]){
                cout<<"-1"<<endl;
                return 0;
            }
        }
        ans[a[i][0]-1]=a[i][1];
    }
    if(n>1&&ans[0]==0){
        cout<<"-1"<<endl;
        return 0;
    }
    rep(i,n)cout<<ans[i];
    cout<<endl;
    return 0;

}

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

int main()
{
  int A,B ;
  cin>>A>>B ;
  
  int coin=0 ;
  for(int i=0;i<2;i++){
    if(A>B){
      coin+=A ;
      A-- ;
    }else{
      coin+=B ;
      B-- ;
    }
  }
  
  cout<<coin ;
  
  return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int count[26];
    int i;
    for (i = 0; i < 26; i++)
        count[i] = 9999;
    if (scanf("%d", &n) != 1)
        return 1;
    for (i = 0; i < n; i++)
    {
        int localCount[26] = {0};
        char S[64];
        int j;
        if (scanf("%63s", S) != 1)
            return 1;
        for (j = 0; S[j] != '\0'; j++)
        {
            int idx = S[j] - 'a';
            if (0 <= idx && idx < 26)
                localCount[idx]++;
        }
        for (j = 0; j < 26; j++)
        {
            if (localCount[j] < count[j])
                count[j] = localCount[j];
        }
    }
    for (i = 0; i < 26; i++)
    {
        int c = 'a' + i;
        int j;
        for (j = 0; j < count[i]; j++)
            putchar(c);
    }
    putchar('\n');
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n,m,use[9]={2,5,5,4,5,6,3,7,6};
	cin>>n>>m;
	int a[m],mi=10,b=-1,memo[10]={};
	for (int i = 0; i < m; ++i)
	{
		cin>>a[i];--a[i];
		memo[a[i]+1]=1;
		if (mi>=use[a[i]])
		{
			mi=use[a[i]];
			b=max(b,a[i]+1);
		}
	}
	sort(a,a+m);
	reverse(a,a+m);
	int dp[n+20];
	for (int i = 0; i < n+20; ++i)
	{
		dp[i]=-1000000;
	}
	dp[0]=0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			dp[i+use[a[j]]]=max(dp[i+use[a[j]]],dp[i]+1);
		}
	}
	string ans="";
	while (n>0)
	{
		for (int i = 0; i < m; ++i)
		{
			if (n-use[a[i]]>=0&&dp[n]-1==dp[n-use[a[i]]])
			{
				ans+='1'+a[i];
				n-=use[a[i]];
				break;
			}
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
void swap(int *, int *);
 
int main(){
  int x, y, i, r, gcd;
 
  while(1){
  scanf("%d%d",&x, &y);
  if(x >= 1 && x <= pow(10,9) && y >= 1 && y <= pow(10,9)) break;
  }
 
  if(x < y) swap(&x,&y);
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
 
  printf("%d\n",x);
  return 0;
}
 
void swap(int *x, int *y){
  int a;
  a = *x;
  *x = *y;
  *y = a;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

string s;
ll dp[100001][4];

int main(){
	cin >> s;
	dp[0][0] = 1;
	rep(i,s.size()){
		rep(j,4){
			if(s[i] == '?')dp[i+1][j] = dp[i][j]*3;
			else dp[i+1][j] = dp[i][j];
			dp[i+1][j] %= MOD;
		}
		if(s[i] == 'A' || s[i] == '?')dp[i+1][1] = (dp[i][0] + dp[i+1][1])%MOD;
		if(s[i] == 'B' || s[i] == '?')dp[i+1][2] = (dp[i][1] + dp[i+1][2])%MOD;
		if(s[i] == 'C' || s[i] == '?')dp[i+1][3] = (dp[i][2] + dp[i+1][3])%MOD;
	}
	cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

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

const ll MOD = 1e9 + 7;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) {
  return power(x, MOD - 2);
}

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  initFact(2000010);
  int N, M, K;
  while (cin >> N >> M >> K) {
    ll res = 0;
    for (int d = 1; d < N; d++) {
      ll ways = M * M % MOD * (N - d) % MOD;
      ll cost = d * ways % MOD;
      res = (res + cost) % MOD;
    }
    for (int d = 1; d < M; d++) {
      ll ways = N * N % MOD * (M - d) % MOD;
      ll cost = d * ways % MOD;
      res = (res + cost) % MOD;
    }
    res = res * choose(N * M - 2, K - 2) % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 31488
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
b=[int(input()) for _ in range(N)]
ans="No"
for i in range(N):
    if b[i] in A1:
        A1[A1.index(b[i])]=0
    elif b[i] in A2:
        A2[A2.index(b[i])]=0
    elif b[i] in A3:
        A3[A3.index(b[i])]=0
for j in range(3):
    if A1[j]==A2[j]==A3[j]==0:
        ans="Yes"
        break
if sum(A1)==0 or sum(A2)==0 or sum(A3)==0:
    ans="Yes"
elif A1[0]==A2[1]==A3[2]==0 or A3[0]==A2[1]==A3[0]==0:
    ans="Yes"
print(ans)

Measured memory_bytes: 3064
n = int(input())
nums = [int(num) for num in input().split(" ")]
result_string = ""
change_times = 0

for i in range(n):
    minj = i
    for j in range(i, n):
        if nums[j] < nums[minj]:
            minj = j
    if minj != i:
        tmp = nums[minj]
        nums[minj] = nums[i]
        nums[i] = tmp
        change_times += 1
    if result_string == "":
        result_string += str(nums[i])
    else:
        result_string += " "
        result_string += str(nums[i])
            
print(result_string)
print(change_times)


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll A, B;
  scanf("%lld %lld", &A, &B);

  cout << (A * B - A - B + 1) << endl;
}


Measured memory_bytes: 3760
#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)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {

    string S;
    cin >> S;
    string ans = (S == "ABC")?"ARC":"ABC";
    cout << ans << endl;

    return 0;
}
    

Measured memory_bytes: 3616