akhauriyash/Code-Regression huggingface dataset:
/**         srijan_de
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/       08.04.2020     **/
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
#include    <bits/stdc++.h>  
using       namespace       std;
using       lli=            long long  int;
using       ulli=           unsigned long long int;
using       ld=             long double;
#define     mem(a,val)      memset( a,  val,  sizeof(a) )
#define     b_s             binary_search
#define     u_b             upper_bound
#define     l_b             lower_bound
#define     nl              cout<<endl
#define     pb              push_back
#define     pf              push_front
#define     ppb             pop_back
#define     ppf             pop_front
#define     in              insert
#define     fi              first
#define     se              second
#define 	pqueue			priority_queue
const lli   MOD=            (int)1e9 + 7;
const lli   MOD1=           (int)1e9 + 9;
const lli   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
lli         tests=          1;
template<class x,class y>x max(x a,y b){return (a>b)?a:b;}
template<class x,class y>x min(x a,y b){return (a<b)?a:b;}
template<class x,class y>x log(x n,y r){return (n>r-1)?1+log(n/r,r):0;}

///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main() 
{
	auto start = clock();
	ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);	
	#ifndef ONLINE_JUDGE	
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	#endif
//	cout<<fixed;
//	cout<<scientific;
//	cout<<fixed<<setprecision(12);
	//cin>>tests;
	for(lli test=1;test<=tests;test++) 
	{
//		cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
		
		lli n,sum=0;
		cin>>n;
		for(lli i=0;i<=n;i++)
		{
			if(i%3==0 || i%5==0)
			continue;
			sum+=i;
		}
		cout<<sum;
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
	}
	cerr<<endl<<endl<<endl<< "Time : " << double(clock() - start) / CLOCKS_PER_SEC <<endl;
	return 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.


Measured memory_bytes: 3804
def minor_change():
    # 入力
    S = input()
    T = input()
    # 比較処理
    char_count = len(S)
    replace_count = 0
    for i in range(char_count):
        if S[i] != T[i]:
            replace_count += 1
    return replace_count

result = minor_change()
print(result)

Measured memory_bytes: 9188
import bisect

I = lambda:[int(i) for i in input().split()]
n, q = I()
A = [0] + I() if n % 2 else I()

m = len(A)//2
L = []
S = [sum(A[m:])]

for i in range(m-1):
  l = A[2 * i + 1]
  r = A[i + m]
  L+= [(l + r)//2]
  S+= [S[-1] + l - r]

for _ in range(q):
  print(S[bisect.bisect_left(L,int(input()))])

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

ll modpow(ll a, ll b, ll p = 10){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    n %= 10;
    ll tim = modpow(n%10, m);
    bool used[10] = {};
    vector<int> v;
    ll sum = 0;
    while(true){
        if(used[n]) break;
        v.push_back(n);
        sum += n;
        used[n] = true;
        n = n*tim%10;
    }
    int siz = v.size();
    ll ans = sum*(k/siz);
    k %= siz;
    for(int i = 0; i < k; i++)  ans += v[i];
    cout << ans << endl;
    return 0;
}


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/
ll ans=0;
int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;

    VVI tab(n, VI(n));
    FOR(i,0,n-1) FOR(j,0,n-1)
    {
        cin >> tab[i][j];
        ans+=tab[i][j];
    }

    FOR(i,0,n-1) FOR(j,0,n-1) FOR(k,0,n-1)
    {
        if (tab[i][k] > tab[i][j] + tab[j][k])
        {
            cout << -1;
            return 0;
        }
    }

    ll total = 0;
    FOR(i,0,n-1) FOR(k,0,n-1)
    {
        bool found = false;

        FOR(j,0,n-1) if (j != i && j != k && tab[i][k] == tab[i][j] + tab[j][k])
        {
            found = true;
            break;
        }

        if (found)
        {
            total += tab[i][k];
        }
    }

    cout << ans/2-total / 2;

    return 0;
}


Measured memory_bytes: 640
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

class rolling_hash_l61m1 {
public:
  using size_type = size_t;
  using value_type = uintmax_t;

private:
  value_type M_b;
  std::vector<value_type> M_c, M_p;
  static size_type const S_npos = -1;
  static value_type const S_mod = (1_ju << 61) - 1;

  static value_type S_fma(value_type a, value_type b, value_type c) {
    value_type au = a >> 31;
    value_type al = a & ((1u << 31) - 1);
    value_type bu = b >> 31;
    value_type bl = b & ((1u << 31) - 1);

    value_type x = au*bl + al*bu;
    value_type xu = x >> 30;
    value_type xl = x & ((1u << 30) - 1);

    value_type y = ((au*bu) << 1) + (xu + (xl << 31)) + (al*bl);
    value_type yu = y >> 61;
    value_type yl = y & ((1_ju << 61) - 1);

    value_type z = yu + yl + c;
    if (z >= S_mod) z -= S_mod;
    return z;
  }

  void M_build() {
    for (size_type i = 1; i < M_c.size(); ++i)
      M_c[i] = S_fma(M_c[i-1], M_b, M_c[i]);
    M_c.insert(M_c.begin(), 0);

    M_p.assign(M_c.size(), 1);
    for (size_type i = 1; i < M_p.size(); ++i)
      M_p[i] = S_fma(M_p[i-1], M_b, 0);
  }

public:
  rolling_hash_l61m1() = default;

  template <typename InputIt>
  rolling_hash_l61m1(InputIt first, InputIt last, value_type base): M_b(base) {
    assign(first, last);
  }

  template <typename InputIt>
  void assign(InputIt first, InputIt last) {
    M_c.assign(first, last);
    M_build();
  }

  template <typename InputIt>
  void assign(InputIt first, InputIt last, value_type base) {
    M_b = base;
    M_c.assign(first, last);
    M_build();
  }

  value_type substr(size_type pos, size_type len = S_npos) {
    size_type n = M_c.size() - 1;
    if (len == S_npos) len = n - pos;
    size_type endpos = pos + len;
    value_type hr = M_c[endpos];
    value_type hl = M_c[pos];
    value_type hs = hr - S_fma(hl, M_p[len], 0);
    if (hs >= S_mod)  // "negative"
      hs += S_mod;
    return hs;
  }
};

#include <random>
#include <set>

int main() {
  size_t n;
  scanf("%zu", &n);

  char buf[5001];
  scanf("%s", buf);
  std::string s = buf;

  std::random_device rd;
  rolling_hash_l61m1 rh(s.begin(), s.end(), rd());

  auto f = [&](size_t len) {
    std::set<uintmax_t> seen;
    for (size_t j = len; len+j <= n; ++j) {
      uintmax_t h0 = rh.substr(j-len, len);
      seen.insert(h0);
      uintmax_t h1 = rh.substr(j, len);
      if (seen.count(h1)) return true;
    }
    return false;
  };

  size_t lb = 0;
  size_t ub = n;
  while (ub-lb > 1) {
    size_t mid = (lb+ub) >> 1;
    (f(mid)? lb: ub) = mid;
  }
  printf("%zu\n", lb);
}


Measured memory_bytes: 512
H, W, A, B = map(int, input().split())
p = 10 ** 9 + 7
F = [1 for i in range(H + W + 1)]
for i in range(1, H + W + 1):
  F[i] = F[i - 1] * i % p
Fi = [pow(f, p - 2, p) for f in F]
def fac(a, b):
  a = F[a + b] * Fi[a] * Fi[b]
  return a % p
if H - A < B:
  ans = 0
  for h in range(H - A):
    ans += fac(h, B - 1) * fac(H - h - 1, W - B - 1) % p
else:
  ans = fac(H - 1, W- 1)
  for w in range(B):
    ans -= fac(H - A - 1, w) * fac(A - 1, W - w - 1) % p
print(ans % p)

Measured memory_bytes: 18904
fun main(args: Array<String>) {
    nikkei2019QualBB()
}

fun nikkei2019QualBB() {
    val n = readLine()!!.toInt()
    val abc = (1..3).map { readLine()!! }

    val answer = (0 until n).map { i -> abc.map { it[i] }.toSet().size - 1 }.sum()

    println(answer)
}


Measured memory_bytes: 33736
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair


using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int>v;
    int a , b , k; cin>>a>>b>>k;
    int g = __gcd(a , b);
    for(int i = 1 ; i <= g; ++i){
      if(g % i== 0)v.pb(i);
    }
    sort(all(v) , greater<int>());
    cout<<v[k - 1];

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define MAX 10001
using namespace std;
bool prime[MAX];

void isPrime(){
}
int main(void){
  //isPrime();
  fill(prime,prime+MAX,true);
  prime[0] = prime[1] = false;
  for(int i = 0 ; i < MAX ; i ++)
    if(prime[i])    
      for(int j = i + i ; j < MAX ; j += i)
        prime[j] = false;
  
  
  int n;
  while(1){
  cin>>n;
  if(cin.eof())break;
  int cnt = 0;
  for(int i = 1 ; i <= n ; i ++)
    if(prime[i] * prime[n-i+1])cnt ++; 
  cout<<cnt<<endl;
  }
}

Measured memory_bytes: 1168
#include<cstdio>
#include<algorithm>
using namespace std;
int abs(int x)
{
	if(x<0)return -x;
	return x;
}
int mp[5000000];
int main()
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int ans=min(j-i,min(abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1));
			mp[ans]++;
		}
	}
	for(int i=1;i<=n-1;i++)
	{
		printf("%d\n",mp[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    rep(i,n)a[i]=0;
    string s="AC";
    int q;
    string t;
    int ac=0;
    int wa[n];
    rep(i,n)wa[i]=0;
    rep(i,m){
        cin>>q>>t;
        if(!(a[q-1])){
            if(s==t){
                ac++;
                a[q-1]=1;
            }else{
                wa[q-1]++;
            }
        }
    }
    cout<<ac<<" ";
    int  WA=0;
    rep(i,n){
        WA+=wa[i]*a[i];
    } 
    cout<<WA<<endl;
    return 0;
}

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

int main(void)
{
    using namespace std;
    int K, N;
    cin >> K >> N;

    int A[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    int N_max = 0;
    int buf = 0;
    for (int i = 0; i < N; i++) {
        if (i == (N - 1)) {
            buf = K - A[i] + A[0];
            if (N_max < buf) {
                N_max = buf;
            }
        } else {
            buf = A[i+1] - A[i];
            if (N_max < buf) {
                N_max = buf;
            }
        }
    }

    printf("%d\n", K - N_max);
}

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

int main(){
  
  int K, S;
  cin >> K >> S;
  int count =0;
  for(int i=0; i<=K; i++){
  	for(int j=0; j<=K; j++){
          if(S-i-j>=0 && S-i-j<=K) {
            count++;
          }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

signed main()
{   
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a));

    vint b; 
    for(int i=N-1;i>=0;i-=2){
        REP(j,2){
            if(b.size()<a.size()) b.push_back(i);
        }
    }
    reverse(ALL(b));

    if(a!=b) cout<<0<<endl;
    else{
        int ans=1; 
        REP(i,N/2) ans=ans*2%mod;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 2168
N = int(input())
p = list(map(int, input().split()))

ans = 0
for i, num in enumerate(p):
    if i + 1 == p[i]:
        temp = p[i]
        try:
            p[i] = p[i + 1]
            p[i + 1] = temp
        except IndexError:
            pass
        ans += 1

print(ans)

Measured memory_bytes: 14004
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
 
int main(){
    IOS;
int n;
cin>>n;
ll a[n+1][4];
loop(n) for(int j=0;j<3;j++)cin>>a[i][j];
int dp[n+1][4];
for(int i=0;i<n;i++){
  for(int j=0;j<3;j++){
    if(i==0)
      dp[i][j]=a[i][j];
    else{
      dp[i][j]=a[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
    }
  }
}
int ans=0;
for(int i=0;i<3;i++)
  ans=max(ans,dp[n-1][i]);
cout<<ans<<endl;

}

 


Measured memory_bytes: 4992
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        cout << a * b << endl;
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}

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

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

    int count = 0; 
    for(int i=0; i<4; i++)
    {
      if(S[i]=='+') count++;
    }

    cout << count*2-4 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int x, a, r, i, j, min;
    char s[5];
    scanf("%s", s);
    if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1])) printf("Yes");
    else printf("No");
    
    
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int a[26];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    string s;
    while (cin >> s) {
        int size = s.length();
        FOR(i,0,size) {
            int x = s[i] - 97;
            a[x] = 1;
        }
        if (a[0] == 1 && a[1] == 1 && a[2] == 1 && a[3] == 1 && a[4] == 1 && a[5] == 1 && a[6] == 1 && a[7] == 1 && a[8] == 1 && a[9] == 1 && a[10] == 1 && a[11] == 1 && a[12] == 1 && a[13] == 1 && a[14] == 1 && a[15] == 1 && a[16] == 1 && a[17] == 1 && a[18] == 1 && a[19] == 1 && a[20] == 1 && a[21] == 1 && a[22] == 1 && a[23] == 1 && a[24] == 1 && a[25] == 1) {
            cout << "None" << endl;
        }
        else {
            FOR(j,0,26) {
                if (a[j] == 0) {
                    char c = j + 97;
                    cout << c << endl;
                    break;
                }
            }
        }
    } 
}


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

string s;
vector<pair<int, int>> v;

bool solve();

int main() {
  cin >> s;
  if(solve())
    cout << -1 << endl;
  else
    for(int i = 0; i < v.size(); ++i)
      cout << v[i].first << " " << v[i].second << endl;
  return 0;
}

bool solve() {
  int cnt = 0, now = 1;
  if(s[s.size() - 1] == '1' || s[0] == '0') return 1;
  while(cnt <= s.size() - 2 - cnt) {
    if(s[cnt] != s[s.size() - 2 - cnt]) return 1;
    ++cnt;
  }
  // v.push_back(make_pair(1, 2));
  cnt = 2;
  for(int i = 0; i < s.size() - 1; ++i) {
    if(s[i] == '1') {
      v.push_back(make_pair(now, cnt));
      now = cnt;
      ++cnt;
    }
    else {
      v.push_back(make_pair(now, cnt));
      ++cnt;
    }
  }
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    for (int i = 0; i < s.length() - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;

int main(){
  char s[4];
  int cnt=0;
  scanf("%s",s);
  for(int i=1;i<4;i++){
    if(s[i]==s[i-1]){
        cnt++;
    }
  }
  
  if(cnt==0){
    printf("Good");
  }else if(cnt>0){
    printf("Bad");
  }

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    rep(i,n){
        if(s[i]=='R'){
            cnt++;
        }
    }
    n-=cnt;
    if(cnt>n){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		ArrayList<ArrayList<Integer>> s = new ArrayList<>();
		for (int i = 0; i < M; i++) {
			int k = in.nextInt();
			ArrayList<Integer> si = new ArrayList<>();
			for (int j = 0; j < k; j++) {
				si.add(in.nextInt() - 1);
			}
			s.add(si);
		}
		int[] p = new int[M];
		for (int i = 0; i < M; i++) {
			p[i] = in.nextInt();

		}
		int ans = 0;
		for (int i = 0; i < (1 << N); i++) {
			boolean isOk = true;
			for (int j = 0; j < M; j++) {
				int count = 0;
				for (Integer sw : s.get(j)) {
					if ((i & (1 << sw)) != 0) {
						count++;
					}
				}
				count %= 2;
				if (count != p[j]) {
					isOk = false;
				}
			}
			if (isOk) {
				++ans;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 22356
#include<stdio.h>

int main(void){
int h = 0, m = 0, s = 0;
scanf("%d", &s);
if(0 <= s && s <= 86400){
h = s / 3600;
s = s - h * 3600;

m = s / 60;
s = s - m * 60;
}
printf("%d:%d:%d\n", h, m, s);
}


Measured memory_bytes: 2756
// https://atcoder.jp/contests/abc176/tasks/abc176_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll cur = 0;
  ll res = 0;

  rep(i, N) {
    res += max(0ll, cur - as[i]);
    chmax(cur, as[i]);
  }

  cout << res << "\n";
}


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

using namespace std;

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

bool clear(vi &data, int x)
{
    return data[0] < x+1;
}

bool check(vi &data, int m, int x)
{
    int lv = 1, step;
    for (step = 1; step < m-1; step++) {
        int p = lower_bound(data.begin(), data.end(), lv) - data.begin();
        if (p) {
            if (data[p] < lv+x) {
                int tmp = max({1, x - abs(lv - data[p]), x - abs(lv - data[p-1])});
                lv += tmp;
            } else {
                lv += max(1, x - abs(lv - data[p-1]));
            }
        } else {
            if (data[p] < lv+x) {
                lv += max(1, x - abs(lv - data[p]));
            } else {
                assert(0);
            }
        }
    }
    return !(data.back() < lv + x);
}

void solve(vi &data, int m)
{
    int left = 0;
    int l = 1, r = 20001000;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (clear(data, mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    left = r;
    if (clear(data, 1)) {
        left = 1;
    }
    //cout << left << endl;
    
    if (!check(data, m, left)) {
        cout << -1 << endl;
        return;
    }

    int right = 20001000;
    while (right - left > 1) {
        int mid = (right+left)/2;
        if (check(data, m, mid)) {
            left = mid;
        } else {
            right = mid;
        }
    }
    cout << left << endl;
    return;
}

int main()
{
    int n, m;
    while (cin >> n >> m, n) {
        vi data(n);
        rep(i, n) {
            cin >> data[i];
        }
        solve(data, m);
    }
    return 0;
}



Measured memory_bytes: 3412
# -*- coding: utf-8 -*-

def main():

    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    sumA = sum(A)

    if sumA > N:
        ans = -1
    
    else:
        ans = N - sumA

    print(ans)


if __name__ == "__main__":
    main()

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

using ll = long long;

template <typename T> T gcd(T m, T n) {
  if(m == 0 || n == 0) {
    return max(m, n);
  }

  T temp = 0;
  while(m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> as(N + 2, 0);
  for(int i = 1; i <= N; ++i) {
    cin >> as[i];
  }
  vector<ll> lgs(N + 2, 0);
  lgs[1] = as[1];
  for(int i = 2; i <= N; ++i) {
    lgs[i] = gcd(lgs[i - 1], as[i]);
  }
  vector<ll> rgs(N + 2, 0);
  rgs[N] = as[N];
  for(int i = N - 1; i >= 1; --i) {
    rgs[i] = gcd(rgs[i + 1], as[i]);
  }
  ll max = 0;
  for(int i = 1; i <= N; ++i) {
    chmax(max, gcd(lgs[i - 1], rgs[i + 1]));
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans=Integer.MAX_VALUE;
        int tmp;
        int count;
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            tmp=sc.nextInt();
            count=0;
            while(tmp%2==0){
                tmp/=2;
                count++;
            }
            ans=Math.min(ans,count);
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 21716
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n,k,i,j=0;
	scanf("%d%d",&n,&k);
	double p=0;
	double tmp;
	tmp=1/(double)n;
	
	for(i=1;i<=n;i++){
		
	while(i*pow(2,j)<k){
		tmp*=0.5;
		j++;
		}
	p+=tmp;
	tmp=1/(double)n;
	j=0;
	}
	printf("%.12lf",p);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
const int maxn = 1e5 + 5;
const int mod = 998244353;
int vis[maxn];
ll a[2 * maxn];
int main()
{
    ios::sync_with_stdio(false);
    ll n , x , m; cin >> n >> x >> m;
    a[1] = x;
    vis[a[1]] = 1;
    ll l = n + 1 , r = n;
    for (int i = 2 ; i <= n ; i++){
        a[i] = (a[i - 1] * a[i - 1]) % m;
        if (vis[a[i]]) {
            l = vis[a[i]];
            r = i - 1;
            break;
        }
        vis[a[i]] = i;
    }
  //  cout << l << " " << r << endl;
    ll ans = 0 , len = r - l + 1;
    for (int i = 1 ; i <= r ; i++){
        ans += a[i];
    }
    ll sum = 0;
    for (int i = l ; i <= r ; i++) sum += a[i];

    ll rest = n - r , cnt = (len == 0 ? 0 : rest / len);
    ans += sum * cnt;
    ll last = (len == 0 ? 0 : (rest % len));
    for(int i = 0 ; i < last ; i++) ans += a[l + i];
    cout << ans << endl;
  //  cout << 492443256176507ll - ans << endl;
    return 0;
}

Measured memory_bytes: 4388
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
n=int(I())
l=[0]*n
for i in range(n):
    a,b=MI()
    if a==b:
        l[i]=1
ans='No'
for j in range(2,n):
    if l[j]==1 and l[j-1]==1 and l[j-2]==1:
        ans='Yes'
        break
print(ans)

Measured memory_bytes: 61912
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(map(int, input().split()))
import bisect
ans = 0

for i in B:
    iA = bisect.bisect_left(A, i)
    iB = bisect.bisect_right(C, i)
    ans += (iA)*(N-iB)
print(ans)

Measured memory_bytes: 23932
def line(a)
  (a / 100) * 60 + a % 100
end
while l = gets
  n, p, q = l.split.map(&:to_i)
  p = line(p)
  q = line(q)
  break if n == 0
  m = Array.new(n){ Array.new(q-p) }
  n.times do |j|
    k = gets.to_i
    a = gets.split.map(&:to_i)
    k.times do |i| 
      (line(a[2*i])-p...line(a[2*i+1])-p).each do |r|
        m[j][r] = true
      end
    end
  end
  ret = 0
  cnt = 0
  flag = false
  m.transpose.each do |item|
    if item.any?{ |t| !t }
      cnt += 1
      if !flag
        flag = true
      end
    elsif item.all?{ |t| t }
      if flag
        ret = cnt if cnt > ret
      end
      cnt = 0
      flag = false
    end
  end
  ret = cnt if cnt > ret
  p ret
end

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 ll a,b,res=0; cin>>a>>b;
 
 if(a==b) cout<<'0'<<endl; 
 else if((a+b)%2==0)cout<<(a+b)/2<<endl; 
 else cout<<"IMPOSSIBLE"<<endl;

}

Measured memory_bytes: 256
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

long long n;
vector <int> g;

int main(){
    cin>>n;
    int q = 0;
    int sum = 0;
    while(n){
        q++;
        g.push_back(n % 10);
        sum += n % 10;
        n /= 10;
    }
    reverse(g.begin() , g.end());
    int answ = (q - 1) * 9;
    answ = max(answ , sum);
    sum = 0;
    for(int i=0;i<(int)g.size();i++){
        sum += g[i];
        if(i == 0 && g[i] == 1)continue;
        if(g[i] == 0)continue;
        sum--;
        sum += ((int)g.size() - i - 1) * 9;
        break;
    }
    cout<<max(sum , answ)<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110
#define MAX_V 100010

ll N, W;
vector< pair<ll, ll> > item;
ll dp[MAX_N][MAX_V];

signed main()
{
    cin >> N >> W;
    item.assign(N, make_pair(0, 0));
    REP(i, N) {
        cin >> item[i].first >> item[i].second;
    }

    REP(i, N) {
        REP(j, MAX_V) {
            dp[i][j] = (j == 0) ? 0 : LLINF;
        }
    }

    ll ans = 0;
    // 配る DP
    // dp[j][val] : [0,j] まで使って val を作った時の最小の重さ
    for(ll i = 0; i < N; ++i) {
        for(ll val = 0; val < MAX_V; ++val) {
            ll w = item[i].first;
            ll v = item[i].second;
            if(val == v) { dp[i][val] = min(dp[i][val], w); }
            for(ll j = 0; j < i; ++j) {
                if (dp[j][val] + w <= W) {
                    dp[i][val + v] = min(dp[i][val + v], dp[j][val] + w);
                }
            }
        }
    }
    for(ll i = 0; i < N; ++i) {
        for(ll val = 0; val < MAX_V; ++val) {
            if(dp[i][val] <= W) { ans = max(ans, val); }
        }
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
using namespace std;
int64_t rec(int64_t N, int64_t n) {
    if (n > N) return 0;
    string s = to_string(n), t = "753";
    int64_t ret = 1;
    for (char c : t) if (s.find(c) == string::npos) ret = 0;
    for (char c : t) ret += rec(N, 10 * n + c - '0');
    return ret;
}
int main() {
    int64_t N;
    cin >> N;
    cout << rec(N, 0) << endl;
}


Measured memory_bytes: 256
input = raw_input().split(" ")
a = int(input[0])
b = int(input[1])
c = int(input[2])

if a > b:
  temp = b
  b = a
  a = temp

if b > c:
  temp = c
  c = b
  b = temp

if a > b:
  temp = b
  b = a
  a = temp

print a, b, c

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

int main(){
    int n,times = 0,maxi = 0;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    for(int i = 1;i < n;i++){
        if(a[i] <= a[i - 1])times++;
        else {
             maxi = max(maxi,times);
             times = 0;
        }
    }
    maxi = max(maxi,times);
    cout << maxi << endl;
}

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

int main(){
    int K,N;
    int A[1000000];
    cin >> K >> N;
    vector<int> dis(N);
    for (int i = 1; i < N + 1; i++){
        cin >> A[i];
    }
    dis[0] = A[1] + (K - A[N]);
    for (int i = 1; i < N; i++){
        dis[i] = A[i+1] - A[i];
    }
    sort(dis.begin(), dis.end());
    cout << K - dis[N-1] << endl;
    return 0;
}

Measured memory_bytes: 3712
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############


test_case=1
while test_case:
    test_case-=1


    n, k=mi()
    a=li()
    a.sort()
    print(sum(a[:k]))

Measured memory_bytes: 62364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200;
char a[N],ans[N];
int n,qj;
char ask(vector<int> v){
	sort(v.begin(),v.end());
	cout<<"? ";
	for(auto i:v)wri(i);
	cout<<endl;
	string s; cin>>s;
	return s[0];
}
char as(int x){
	vector<int> v;
	For(i,x,x+n-1)v.pb(i);
	return ask(v);
}
void solve(int l,int r,char L,char R){
	if(l+1==r){
		qj=r; return;
	}
	int mid=(l+r)>>1;
	char t=as(mid);
	if(L!=t)solve(l,mid,L,t);
	else solve(mid,r,t,R);
}
int main(){
	#ifdef Brollan
		//freopen("1.in","r",stdin);
	#endif
	n=read();
	char L=as(1),R='R'+'B'-L;
	solve(1,n+1,L,R);
	cerr<<qj<<" "<<qj+n-2<<endl;
	For(i,1,2*n)if(i<qj||i>=qj+n-1){
		vector<int> v;
		For(j,qj,qj+n-2)v.pb(j);
		v.pb(i);
		ans[i]=ask(v);
	}
	For(i,qj,qj+n-2){
		vector<int> v;
		For(j,1,qj-2)v.pb(j);
		For(j,qj+n,2*n)v.pb(j);
		assert((int)v.size()==n-1);
		v.pb(i);
		ans[i]=ask(v);
	}
	cout<<"! "<<(ans+1)<<endl;
}


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

int main() {
  long long N; cin >> N;
  long long L[N];
  for (int i = 0; i < N; i++) cin >> L[i];
  
  long long count = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      for (int k = j + 1; k < N; k++){
        if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]){
          if (L[i] != L[j] && L[i] != L[k] && L[j] != L[k]){
            count++;
          }
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            for (int i = 1; i <= 9; i++)
            {
                if(N % i == 0 && N / i <= 9)
                {
                    Console.WriteLine("Yes");
                    return;
                }

            }
            Console.WriteLine("No");
        }
    }
}

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

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

  for (int i = 0; i < N-1; i++) {
    if (A[i] + 1 == A[i+1]) {
      ans += C[A[i]-1];
    }
  }
  
  cout << ans << endl;
  
}

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

int main(){
    int n;
    cin >> n;
    //cout << n << endl;
    if(n%2==0){
        cout << fixed << setprecision(12) << double(0.5) << endl;
        return 0;
    }else{
        n = double(n);
        //cout << n << endl;
        double j = 2*n;
        cout << fixed << setprecision(12) <<  (n+1)/j << endl;
        return 0;
    }
    
}

Measured memory_bytes: 256
// Binomial Coefficients

#define NDEBUG

#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<type_traits>
#include<cstdint>
#include<cassert>
using namespace std;

// is_differ
template<typename Iter>
bool is_differ(Iter first, Iter last)
{
        static_assert(is_base_of<forward_iterator_tag, typename iterator_traits<Iter>::iterator_category>::value,
                        "Iterは前進反復子");

        Iter mid = first;
        for (; first != last; ++first){
                mid = first;
                ++mid;
                if (last != find(mid, last, *first)){
                        return false;
                }
        }

        return true;
}

// PowerOfTen
template<uintmax_t N>
constexpr uintmax_t PowerOfTen()
{
        return 10*PowerOfTen<N-1>();
}

template<>
constexpr uintmax_t PowerOfTen<0>()
{
        return 1;
}

// comb
template<typename T>
T comb(T n, T r){
        static_assert(is_integral<T>::value, "Tは整数");
        assert(n>=r);

        r = min(r, n-r);

        T ret{1};
        for (; r>0; --r){
                if (ret%r == 0){
                        ret = ret/r * (n-(r-1));
                }
                else {
                        ret *= (n-(r-1))/r;
                }
        }

        return ret;
}

// main
int main()
{
        size_t n;
        cin >> n;
        assert(2<=n && n<=PowerOfTen<5>());

        vector<int_fast32_t> a;
        a.reserve(n);
        copy_n(istream_iterator<int_fast32_t>{cin}, n, back_inserter(a));
        assert(a.size()==n);
        assert(all_of(a.begin(), a.end(), [](int_fast32_t x){ return 0<=x && x<=PowerOfTen<9>(); }));
        assert(is_differ(a.begin(), a.end()));

        nth_element(a.begin(), a.end()-1, a.end());
        int_fast32_t ai = *(a.end()-1);

        int_fast32_t aj = *(max_element(a.begin(), a.end()-1,
                                [ai](int_fast32_t x, int_fast32_t y){ return min(x,ai-x) < min(y,ai-y); }));
        assert(ai > aj);
        /* cout << comb<int_fast64_t>(ai,aj) << endl; */
        cout << ai << ' ' << aj << endl;

        return 0;
}



Measured memory_bytes: 1024
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return float(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	A=[0]+LI()+[0]
	total=0


	for i,j in zip(A[1:],A[:-1]):
		total+=abs(i-j)


	for i in range(1,n+1):
		print(total-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))











if __name__ == "__main__":
	main()


Measured memory_bytes: 19084
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <iostream>
#include <set>
#include <string>

using namespace std;


int n;
string s;

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

    map<string,int> mp;

    for(int i=0;i<n;i++) {
        cin>>s;
        mp[s]++;
    }

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;


    
    
    return 0;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

T_split = [[] for i in range(K)]
for i in range(N):
    T_split[i%K].append(T[i])
#print(T_split)

ans = 0
flag = 0

for i in range(len(T_split)):
    for j in range(len(T_split[i])):
        if flag == 1:
            flag = 0
            continue
        if T_split[i][j] == 'r':
            point = P
        elif T_split[i][j] == 's':
            point = R
        elif T_split[i][j] == 'p':
            point = S
        ans += point
        if j != len(T_split[i]) - 1:
            if T_split[i][j] == T_split[i][j+1]:
                flag = 1
print(ans)


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

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

  if(a+b == 15){
    cout <<'+'<<endl;
  }else if(a*b == 15){
    cout <<'*'<<endl;
  }else{
    cout <<'x'<<endl;
  }




  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(void) {
	ll n, m, i, X = 0, Y = 0, ans = 0;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	for (i = 0; i < n; i++)
		scanf("%lld", &x[i]);
	for (i = 0; i < m; i++)
		scanf("%lld", &y[i]);
	for (i = 0; i < n; i++)
		X += ((i << 1) - n + 1) * x[i] % MOD;
	for (i = 0; i < m; i++)
		Y += ((i << 1) - m + 1) * y[i] % MOD;
	X %= MOD;
	Y %= MOD;
	ans = X * Y % MOD;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1920
cards = [[False for i in range(14)] for j in range(4)]
marks = ['S', 'H', 'C', 'D']

n = int(input())
for i in range(n):
    mark, num = input().split()
    num = int(num)
    cards[marks.index(mark)][num] = True

for i in range(4):
    for j in range(1, 14):
        if not cards[i][j]:
            print(marks[i], j)


Measured memory_bytes: 5600
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
da = []
db = []
for i in range(n-1):
    da.append(A[i+1] ^ A[i])
    db.append(B[i+1] ^ B[i])
da.append(A[-1]^A[0])
db.append(B[-1]^B[0])
    
import random
M = 10**9+7
b = random.choice(range(M))
def rhash(s):
    import random
    ans = 0
    v = 1
    for item in s:
        ans += item*v
        v *= b
        ans %= M
        v %= M
    return ans

h = rhash(db)
g = rhash(da)
t = pow(b, n, M)
ans = []
for i in range(n):
    if h==g:
#         if all(da[(j+i)%n]==db[j] for j in range(n)):
        ans.append((i,A[i]^B[0]))
    h *= b
    h = h - t*db[n-1-i] + db[n-1-i]
    h %= M
    
write("\n".join(" ".join(map(str, item)) for item in ans))

Measured memory_bytes: 122540
#include <bits/stdc++.h>
using namespace std;
int N,bil=1,k;
int main () {
	cin >> N >> k;
	for(int i=1;i<=N;i++) {
		if (2*bil<bil+k) {
			bil*=2;
		} else {
			bil +=k;
		}
	}
	cout << bil << endl;
}


Measured memory_bytes: 256