akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

ll f(ll x){
    if(x == 1) return 1;
    else {
        return 2*f(x/2)+1;
    }
}

void solve(){
    ll h; cin>>h;
    ll ans = f(h);
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	const int KIND = 26;
	string str;
	cin >> str;
	int N = str.size();
	vector<int> dp(N+2,0);
	vector< vector<int> > next(N+2,vector<int>(KIND,N+1) );
	for(int i=N;i>=0;--i){
		int res = N+1;
		for(int j=0;j<KIND; ++j){
			res = min(res,dp[ next[i][j] ] + 1 );
		}
		dp[i] = res;
		if( i ){
			next[i-1] = next[i];
			next[i-1][ str[i-1]-'a' ] = i;
		}
	}
	
	int pos = 0;
	string ans = "";
	while(pos<=N){
		//次のdpの値
		int now = dp[pos] -1;

		//辞書順最小でヒットしたら選ぶ
		for(int i=0; i<KIND; ++i){
			int to = next[pos][i];
			if( dp[to] == now ){//値を見つけた
				ans += 'a'+i;//文字を後ろにつける
				pos = to;
				break;
			}
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 27796
from collections import deque


def get_arounds(point, grid, max_x, max_y):
    x = point[0]
    y = point[1]
    arounds = [(x + dx, y + dy) for dx, dy in ((0, -1), (1, 0), (0, 1), (-1, 0))]
    return list(filter(lambda a: 0 <= a[0] < max_x and
                                 0 <= a[1] < max_y and
                                 grid[a[0]][a[1]], arounds))


H, W = tuple(map(int, input().split()))

grid = []
for i in range(0, H):
    grid.append(list(map(lambda x: True if x == '.' else False, list(input()))))

black = sum(map(lambda l: l.count(False), grid))

grid[0][0] = False
p_grid = {(0, 0): 0}
queue = deque([(0, 0)])
while not len(queue) == 0:
    here = queue.popleft()
    if here == (H - 1, W - 1):
        break;
    arounds = get_arounds(here, grid, H, W)
    for a in arounds:
        grid[a[0]][a[1]] = False
        p_grid[a] = p_grid[here] + 1
    if not arounds:
        continue
    queue.extend(arounds)

if (H-1, W-1) in p_grid:
    print(H * W - (p_grid[H-1, W-1] + 1) - black)
else:
    print(-1)


Measured memory_bytes: 3700
buildings =  [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
    b, f, r, v = map(int, input().split())

    buildings[b-1][f-1][r-1] += v
sep = 1
for b in buildings:
    for f in b:
        print(" ",end="")
        print(*f)
    if sep != len(buildings):
        print("#" * 20)
        sep +=1



Measured memory_bytes: 5628
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  M1,D1=LI()
  M2,D2=LI()

  if D2==1:
    return 1
  return 0

# main()
print(main())


Measured memory_bytes: 8232
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
ll d[100010];
vector<ll> edgeList[100010];
int main(){
    cin>>N>>M;
    for(ll i=0;i<M;i++){
        ll a,b;
        cin>>a>>b;a--;b--;
        edgeList[a].push_back(b);
        edgeList[b].push_back(a);
    }
    for(ll i=1;i<N;i++)d[i]=INF;
    priority_queue<P,vector<P>,greater<P>> pq;
    d[0]=0;
    pq.push(P(0,0));
    while(!pq.empty()){
        ll now=pq.top().second;
        ll nowC=pq.top().first;
        pq.pop();
        if(nowC>d[now])continue;
        for(auto v:edgeList[now]){
            ll newC=nowC+1;
            if(d[v]>newC){
                d[v]=newC;
                pq.push(P(newC,v));
            }
        }
    }
    cout<<"Yes"<<endl;
    for(ll i=1;i<N;i++){
        ll minCost=INF,minPos;
        for(auto v:edgeList[i]){
            if(d[v]<minCost){
                minCost=d[v];
                minPos=v;
            }
        }
        cout<<minPos+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 14196
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,a,b,c,d,e,q;

ll x[100005], y[100005], z[100005];
ll k;

vector<ll> G[500005];

void solve(){
    cin >> n >> m;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        cin >> x[i];
    }
    for(ll i=0;i<m;i++){
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    for(ll i=1;i<=n;i++){
        ll maxi = 0;
        for(ll j=0;j<G[i].size();j++){
            maxi = max(maxi, x[G[i][j]]);
        }
        if(maxi < x[i])ans ++;
    }
    p(ans);
    return;
}

int main(){

    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 19656
N,K = map(int, input().split())

l_2 = []
x = 1
while 1:
    l_2.append(2 ** x)
    if 2 ** x > K:
        break
    x += 1

ans = 0
for i in range(N):
    if i + 1 >= K:
        ans += 1 / N
        continue
    for idx, val in enumerate(l_2):
        if (i + 1) * val >= K:
            ans += 1 / N * 0.5 ** (idx + 1)
            break

print("%.20f" % ans)




Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
B=[]
ans=0
for i in range(N-1,-1,-1):
  if i%2==0:
    ans=A[i]-ans
  else:
    ans=A[i]-ans
B.append(ans)
for i in range(N-1):
  B.append(A[i]*2-ans)
  ans=A[i]*2-ans
print(*B)

Measured memory_bytes: 20532
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[100];
int main() {
  int n, sum = 0;
  cin >> n;
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a+n);
    int b =0;
   for(int i = 0; i < n; i+=2){
     b+=a[i];
   }
   int c = sum -b;
   cout << abs(b - c) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 100000001
#define inf 1000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define int ll
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

signed main() {
	fast;
	ll a,b;
	cin>>a>>b;
	if(a>=13) cout<<b;
	else if(a<=5) cout<<0;
	else cout<<b/2;
}

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

int main(void){
  int N;
  char n[128];
  fgets(n,128,stdin);
  sscanf(n,"%d",&N);

  char a[128];
  fgets(a,128,stdin);
  sscanf(a,"%d",&N);

  int left=0;
  int l=0;
  for(int i=0;i<N;i++){
    char s=*(a+i);
    if(s=='('){
      left--;
    }else if(s==')'){
      left++;
      if(left>l){l=left;}
    }
  }
  if(left<l){left=l;}
  int right=0;
  int r=0;
  for(int i=N-1;i>=0;i--){
    char s=*(a+i);
    if(s=='('){
      right++;
      if(right>r){r=right;}
    }else if(s==')'){
      right--;
    }
  }
  if(right<r){right=r;}

  for(int i=0;i<left;i++){
    printf("(");
  }
  for(int i=0;i<N;i++){
    printf("%c",*(a+i));
  }
  for(int i=0;i<right;i++){
    printf(")");
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll labs(ll a, ll b){
  if(a<b) return b-a;
  else return a-b;
}

int
main(void){  
  ll x;
  cin >> x;

  ll ans = 0LL;
  ll i=0LL;
  for(i=1; i+ans<x; ++i){
    ans += i;
  }

  cout << i << endl;;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,i;
cin>>n;
    
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        s[i]=char(65+(((s[i]-65)+n)%26));
    }cout<<s;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    string S;
    cin >> S;
    if(S.size() == 2){
        cout << S << endl;return 0;
    }
    else{
        reverse(all(S));
        cout << S << endl;
    }
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    int sum = 0;

    for(int i = 1; i <= N; i++){
        if(to_string(i).size()%2 == 1){
            sum++;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
L = gets.chomp.split(" ").map(&:to_i).sort

ans = 0
(1...(N-1)).each{|i|
  w = 0
  ((i+1)..(N-1)).each{|j|
    until L[w] > L[j] - L[i] do w += 1 end
    break if w >= i
    ans += (i - w)
  }
}

puts ans


Measured memory_bytes: 1912
n, l, t = list(map(int, input().split()))
ants = []
for i in range(n):
    ants.append(list(map(int, input().split())))
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')

Measured memory_bytes: 32312
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <set>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

#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(x) (x).begin(),(x).end()
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


using namespace std;

int main(){
	int N,A,B;
	int m[100]={0};

	cin>>N>>A>>B;
	m[A]=1;m[B]=1;
	if(N<B) {
		cout<<"Draw"<<endl;
		return 0;
	}
	for(;;){
		if((A+1)<B){
			m[A]=0;A++;m[A]=1;
		}else if(A>0){
			m[A]=0;A--;m[A]=1;
		}
		else{
			cout<<"Borys"<<endl;
			break;
		}if((B-1)>A){
			m[B]=0;B--;m[B]=1;
		}else if(B<N){
			m[B]=0;B++;m[B]=1;
		}
		else{
			cout<<"Alice"<<endl;
			break;
		}
	}
	return 0;
}

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

int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){

  int N,K,i,p[1001],ans=0;

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

  qsort(p,N,sizeof(int),compare_int);

  for(i = 0;i < K;i++) ans += p[i];

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


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s, t; cin >> s >> t;
	for (int i = 0; i < s.size(); i++)
	{
		bool ok = true;
		for (int j = 0; j < s.size(); j++)
		{
			if(t[j] != s[(i+j)%s.size()]) {
				ok = false;
				break;
			}
		}
		if(ok) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main(){
  string s,t;
  cin>>s;
  t=s;
  reverse(s.begin(),s.end());
  for(char &ch:s){
    if(ch=='b')ch='d';
    else if(ch=='d')ch='b';
    else if(ch=='p')ch='q';
    else if(ch=='q')ch='p';
  }
  cout<<(s==t?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 512
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n,k;
	while(cin >> n >> k){
		map<char,int> mp;
		REP(i,n){
			string s;
			cin >> s;
			mp[s[0]]++;
		}
		priority_queue<int> qu;
		RBP(e,mp){
			qu.push(e.S);
		}
		bool conf = true;
		int ans = 0;
		while(conf){
			vector<int> v(k,-1);
			REP(i,k){
				if(!qu.empty()){
					v[i] = qu.top();
					qu.pop();
				}else{
					conf = false;
				}
			}
			if(conf){
				ans++;
				REP(i,k) v[i]--;
				REP(i,k) if(v[i] != 0) qu.push(v[i]);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<"\n";
}

Measured memory_bytes: 256
#coding:UTF-8
def isRoot(point,A,n):
    for i in range(n):
        if A[i][1]==point or A[i][2]==point:
            return False
    return True

def isBranch(point,A,ans):
    if A[point][1]!=-1:
        ans.append(A[point][1])
        isBranch(A[point][1],A,ans)
    if A[point][2]!=-1:
        ans.append(A[point][2])
        isBranch(A[point][2],A,ans)
        
def isIn(point,A,ans):
    if A[point][1]!=-1:
        isIn(A[point][1],A,ans)
    ans.append(point)
    if A[point][2]!=-1:
        isIn(A[point][2],A,ans)

def isPost(point,A,ans):
    if A[point][1]!=-1:
        isPost(A[point][1],A,ans)
    if A[point][2]!=-1:
        isPost(A[point][2],A,ans)
    ans.append(point)
        
def Pre(A,n):
    ans=[]
    for i in range(n):
        if isRoot(A[i][0],A,n)==True:
            ans.append(A[i][0])
            if A[i][1]!=-1:
                ans.append(A[i][1])
                isBranch(A[i][1],A,ans)
            if A[i][2]!=-1:
                ans.append(A[i][2])
                isBranch(A[i][2],A,ans)
    print("Preorder")
    for i in range(n):
        ans[i]=str(ans[i])
    print(" "+" ".join(ans))

def In(A,n):
    ans=[]
    for i in range(n):
        if isRoot(A[i][0],A,n)==True:
            if A[i][1]!=-1:
                isIn(A[i][1],A,ans)
            ans.append(A[i][0])
            if A[i][2]!=-1:
                isIn(A[i][2],A,ans)
    print("Inorder")
    for i in range(n):
        ans[i]=str(ans[i])
    print(" "+" ".join(ans))

def Post(A,n):
    ans=[]
    for i in range(n):
        if isRoot(A[i][0],A,n)==True:
            if A[i][1]!=-1:
                isPost(A[i][1],A,ans)
            if A[i][2]!=-1:
                isPost(A[i][2],A,ans)
            ans.append(A[i][0])
    print("Postorder")
    for i in range(n):
        ans[i]=str(ans[i])
    print(" "+" ".join(ans))
    
def TW(A,n):
    Pre(A,n)
    In(A,n)
    Post(A,n)


if __name__=="__main__":
    n=int(input())
    A=[]
    for i in range(n):
        A.append(list(map(int,input().split(" "))))
    for i in range(n):
        minj=i
        for j in range(i,n):
            if A[j][0]<A[minj][0]:
                minj=j
        A[i],A[minj]=A[minj],A[i]
    TW(A,n)

Measured memory_bytes: 7904
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    char a,yy[5]={'a','e','i','o','u'};
    cin>>a;
    for(int i=0;i<5;i++){
        if(a==yy[i]){
            cout<<"vowel";
            return 0;
        }
    } 
    cout<<"consonant";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  double a,b,x;
  cin>>a>>b>>x;
  double s=x/a;
  double rad;
  if(s>=a*b/2){
    double h=(a*b-s)*2/a;
    rad=atan2(h,a);
  }
  else{
    double w=s*2/b;
    rad=atan2(b,w);
  }
  double PI=acos(-1);
  double deg=rad/(2*PI)*360;
  cout<<fixed<<setprecision(10)<<deg<<endl;
  return 0;
}

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

#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(false)
#define int long long

int x, y;

int32_t main() {
  FAST;
  cin>>x>>y;
  int t = x, q = 0;
  while (t <= y) {
    t *= 2;
    q++;
  }
  cout<<q<<endl;
}


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

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> dist(n);
    for (int i = 0; i < n; ++i) cin >> dist[i];
    int avoid = 0;
    for (int j = 0; j < n; ++j) {
        if (j == n - 1) avoid = max(avoid, dist[0] + k - dist[j]);
        else avoid = max(avoid, dist[j + 1] - dist[j]);
    }
    cout << k - avoid << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll a;
string s;

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

  cin>>a>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;

  return 0;
}


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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;

int n;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n;
	ll absMax = 0, ami = 0;
	vector<ll> a(n); 
	vector<pair<int, int>> ans;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (abs(a[i]) > absMax) {
			absMax = abs(a[i]);
			ami = i;
		}
	}
		
	// All 0s
	if (!absMax) {
		cout << 0;
		return 0;
	}
	
	ans.push_back({ami, ami});
	a[ami] *= 2;
	if (a[ami] > 0) {
		ans.push_back({ami, 0});
		a[0] += a[ami];
		for (int i = 1; i < n; ++i) {
			ans.push_back({i - 1, i});
			if (a[i] < 0) {
				a[i] += 2 * a[i - 1];
				ans.push_back({i - 1, i});
			} else {
				a[i] += a[i - 1];
			}
		}
	} else {
		ans.push_back({ami, n - 1});
		a[n - 1] += a[ami];
		for (int i = n - 2; i >= 0; --i) {
			ans.push_back({i + 1, i});
			if (a[i] > 0) {
				a[i] += 2 * a[i + 1];
				ans.push_back({i + 1, i});
			} else {
				a[i] += a[i + 1];
			}
		}
	}
	
	cout << sz(ans) << '\n';
	for (auto i : ans) cout << i.first + 1 << ' ' << i.second + 1 << '\n';
}


Measured memory_bytes: 3664
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let X = float N / 1.08 |> fun x -> Math.Ceiling(x) |> int
    let M = float X * 1.08 |> int
    if N <> M then printfn ":("
    else printfn "%d" X
    0


Measured memory_bytes: 14040
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >>= putStrLn . solve 

solve :: String -> String
solve "A" = "T"
solve "T" = "A"
solve "C" = "G"
solve "G" = "C"

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

using namespace std;

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

int main(){
    int n, l;
    cin >> n >> l;
    int sum = 0;
    int ans  = 1000;
    rep(i, n){
        if(abs(l+i) < abs(ans))ans = l+i;
        sum += l+i;
    }
    cout << sum - ans;

    
}

Measured memory_bytes: 256
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
import numpy as np
#from copy import deepcopy
from collections import deque
#import numba

def generate_inv(n,mod):
    """
    逆元行列
    n >= 2
    Note: mod must bwe a prime number
    """
    ret = [0, 1]
    for i in range(2,n+1):
        next = -ret[mod%i] * (mod // i)
        next %= mod
        ret.append(next)
    return ret

def generate_comb_m_i(M, N, inv, mod):
    ret = [1, M]
    for i in range(2, N+1):
        tmp = (ret[-1] * (M-(i-1)) * inv[i]) % mod
        ret.append(tmp)
    return ret
def generate_p_N_i(N, mod):
    ret = [1]
    for i in range(1, N+1):
        tmp = (ret[-1] * (N - (i-1))) % mod
        ret.append(tmp)
    return ret

def generate_p_mi_ni(M, N, mod):
    ret = deque([1])
    cache = deque([1])
    for i in range(1, N+1):
        tmp = (cache[0] * (M-N+i)) % mod
        cache.appendleft(tmp)
        ret.appendleft((tmp ** 2) % mod)
    return ret


def run():
    N, M = map(int, input().split())
    mod = 10 ** 9 + 7

    inv = generate_inv(M, mod)

    comb_m_i = generate_comb_m_i(M, N, inv, mod)
    #print(comb_m_i[0])
    p_N_i = generate_p_N_i(N, mod)
    #print(p_N_i[0])
    p_mi_ni = generate_p_mi_ni(M, N, mod)
    #print(p_mi_ni[0])

    ret = p_mi_ni[0]

    arr01 = [-1, 1] * (N//2 + 1)
    arr01 = arr01[:N+1]

    comb_m_i = np.array(comb_m_i, dtype=np.int64)
    p_N_i = np.array(p_N_i, dtype=np.int64)
    p_mi_ni = np.array(p_mi_ni, dtype=np.int64)
    arr01 = np.array(arr01, dtype=np.int64)

    tmp = (comb_m_i * p_N_i) % mod
    tmp = (tmp * p_mi_ni) % mod
    tmp = (tmp * arr01) % mod
    tmp = tmp[1:]
    sub = 0
    for val in tmp:
        sub += val
        sub %= mod

    ret -= sub
    ret %= mod

    print(ret)

if __name__ == "__main__":
    run()

Measured memory_bytes: 133916
import sys

N, K = map(int, input().split())


if(N > K):
    if(N % K == 0):
        print(0)
        sys.exit()
    else:
        tmp=N % K
        print(min(tmp,abs(K - tmp)))
        sys.exit()
else:
    tmp = abs(N - K)
    if(tmp <= N):
        print(tmp)
    else:
        print(N)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,k,m,sum,res=0,a[200000];
pair<long long int,long long int>pa[200000];
int main() {
	cout << fixed << setprecision(10);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		pa[i]={a[i],i+1};
	}
	sort(pa,pa+n);
	for(int i=0;i<n;i++){
		cout<<pa[i].second<<" ";
	}
	cout<<endl;
} 


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC135 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

s = list(input())
s = s[::-1]
l = len(s)
#dp[i][j] := 先頭i文字として考えられるもののうち、13で割ったあまりがjであるもの
dp = [[0]*13 for _ in range(l)]
remain = 1
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1,l):
    remain = (remain * 10) % 13
    if s[i] == '?':
        for k in range(10):
            for j in range(13):
                dp[i][(j + remain * k) % 13] += dp[i-1][j]
                dp[i][(j + remain * k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j + remain * int(s[i])) % 13] += dp[i-1][j]
print(dp[-1][5])


Measured memory_bytes: 65384
s=list(input())

def solve(s):
    c=1 if s[0] == 'S' else 0
    ans=1 if s[0] == 'T' else 0

    for i in range(1, len(s)):
        if s[i] == 'S':
            if s[i-1] == 'S':
                c += 1
            else:
                ans+=c
                c=1
        else:
            if c > 0:
                c -= 1
                s[i] = 'S'
            else:
                ans += 1
    return ans+c

print(solve(s))


Measured memory_bytes: 4968
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	double a;
	while (cin >> a) {
		vector<double>A(10);
		A[0] = a;
		for (lint i = 1; i < 10; i++) {
			if (i % 2 == 0) {
				A[i] = A[i - 1] / 3.0;
			}
			else {
				A[i] = A[i - 1] * 2.0;
			}
		}
		double sum = 0;
		rep(i, 10) {
			sum += A[i];
		}
		cout <<fixed<<setprecision(10)<< sum << endl;
	}
}


Measured memory_bytes: 3192
n = int(input())
l = list(map(int,input().split()))
num = 0
flg = 1

while True:
    for i in range(len(l)):
        #print(i,num)
        if l[i] % 2 == 0:
            l[i] = l[i]/2
        else:
            print(num)
            flg = 0
            break
    if flg == 0:
        break
    else:
        num += 1
        continue


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

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; 
  Node *x; 

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


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

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

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = 200003;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

vector<complex<double>> theta;

void set_theta(ll x) { theta.resize(x); double rad = 2*M_PI / x; rep(i,x) { theta[i].real(cos(rad*i)); theta[i].imag(sin(rad*i)); } }
vector<complex<double>> calc_theta(vector<complex<double>> vec) {
  ll l = vec.size(), s = theta.size();
  if (l==1) return vec;
  vector<complex<double>> odd(l/2), even(l/2); rep(i,l) { if (i%2==0) even[i/2] = vec[i]; else odd[i/2] = vec[i]; }
  vector<complex<double>> otheta = calc_theta(odd), etheta = calc_theta(even);
  vector<complex<double>> result(l); rep(i,l) result[i] = theta[s/l*i]*otheta[i%(l/2)]+etheta[i%(l/2)];
  return result;
}

vector<ll> FFT(vector<double> v1, vector<double> v2) {
  ll s = 1; while (s<v1.size()+v2.size()) s *= 2; set_theta(s);
  vector<complex<double>> vec1(s), vec2(s);
  rep(i,v1.size()) vec1[i].real(v1[i]);
  rep(i,v2.size()) vec2[i].real(v2[i]);
  vector<complex<double>> f1 = calc_theta(vec1), f2 = calc_theta(vec2);
  vector<complex<double>> fres(s); rep(i,s) fres[i] = f1[i]*f2[i];
  vector<complex<double>> rtmp = calc_theta(fres);
  vector<ll> result(s); rep(i,s) result[i] = (ll)round((rtmp[(s-i)%s].real())/s);
  return result;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  set_theta(pow(2,18));
  ll N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  vector<double> v(pow(2,18));

  ll M = 200003;
  ll pos[2*M] = {};
  ll p2[2*M] = {}; p2[0] = 1;
  rep(i,2*M-1) {
    pos[p2[i]] = i % (M-1);
    p2[i+1] = p2[i]*2 % M;
  }
  rep(i,N) if (A[i]) v[pos[A[i]]]++;
  vector<ll> r = FFT(v,v);
  // debug(r.begin(),r.begin()+10);

  ll result = 0;
  rep(i,M*2) result += p2[i]*r[i];
  rep(i,N) result -= A[i]*A[i] % M;
  cout << result/2 << endl;
  return 0;
}

Measured memory_bytes: 109808
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[200017];
void solve(){
	ll n,i,x;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		a[x]=i;
	}
	for(i=1;i<=n;i++){
		cout<<i*(n+1)<<" ";
	}
	cout<<endl;
	for(i=n;i>=1;i--){
		cout<<i*(n+1) + a[n-i+1]<<" ";
	}
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3768
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: x[2])
a, b, c = X[-1]

for px in range(101):
    for py in range(101):
      H = abs(a - px) + abs(b - py) + c
      if all(h == max(H - abs(x - px) - abs(y - py), 0) for x, y, h in X):
        print(px, py, H)
        break


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    char a[4];
    int i,flag=0;
    gets(a);
    for(i=0;i<3;i++)
    {
       if(a[i]=='a'||a[i]=='b'||a[i]=='c')
        flag=1;
    }

    if(flag==1&&a[0]!=a[1]&&a[0]!=a[2]&&a[1]!=a[2])
        printf("Yes\n");
    else
         printf("No\n");
    return 0;
}


Measured memory_bytes: 128
m=gets.to_i
H=[]
1.upto(m){|n|
  H.push(gets.chomp.to_s)
}
s=[]
h=[]
c=[]
d=[]
1.upto(13){|u|
  s.push("S "+u.to_s)
  h.push("H "+u.to_s)
  c.push("C "+u.to_s)
  d.push("D "+u.to_s)
}
deck=s+h+c+d
0.upto(H.length-1){|t|
  deck.delete(H[t])
}
puts deck

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (s[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll X; cin >> X;
    for(int a = -118; a <= 119; a++) {
        for(int b = -119; b < a; b++) {
            ll res = pow(a, 5) - pow(b, 5);
            if (res == X) {
                cout << a << " " << b << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;bool ans=true;
  char pre;map<string, int> count;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    if((i!=0&&pre!=s[0])||count[s]++>0){ans=false;}
    pre=s[s.size()-1];
  }
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int n, k, x, d[10];


int main(void) {
    scanf("%d %d", &n, &k);
    for(int i=0; i<k; i++)
        scanf("%d", d+i);

    while(1) {
        int i;
        x = n;
        while(x > 0) {
            for(i = 0; i < k; i++) {
                if(x%10 == d[i]) break;
            }

            if(i == k) x/=10;
            else break;
        }
        if(x) n++;
        else break;
    }

    printf("%d", n);
    return 0;
}

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

signed main()
{
    int N,T; cin>>N>>T;

    int ans=1e9;
    REP(i,N){
        int c,t; cin>>c>>t;
        if(t<=T) ans=min(ans,c);
    }
    if(ans==1e9)
        cout<<"TLE"<<endl;
    else
        cout<<ans<<endl;
    
}


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

int main(){
  int x;
  cin >> x;
  
  int a, b;
  
  a = x / 500;
  x -= a * 500;
  
  b = x / 5;
  
  cout << a*1000 + b*5 << endl;
  
  return 0;
}

Measured memory_bytes: 3616