akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define R 0
#define S 1
#define P 2

int main()
{
	int n, k;
	int r, s, p;
	string T;
	int **dp;
	
	cin >> n >> k;
	cin >> r >> s >> p;
	cin >> T;
	
	dp = new int*[n];
	
	for(int k = 0; k < n; ++k)
		dp[k] = new int[3] {0};

	for(int i = 0; i < k; ++i)
	{
		if(T[i] == 'r')
			dp[i][P] = p;
		
		else if(T[i] == 's')
			dp[i][R] = r;
		
		else
			dp[i][S] = s;
	}
		
	for(int i = k; i < n; ++i)
	{
		if(T[i] == 'r')
		{
			dp[i][P] = p + max(dp[i - k][R], dp[i - k][S]);
			dp[i][S] = max(dp[i - k][R], dp[i - k][P]);
			dp[i][R] = max(dp[i - k][S], dp[i - k][P]);
		}
		
		else if(T[i] == 's')
		{
			dp[i][P] = max(dp[i - k][R], dp[i - k][S]);
			dp[i][S] = max(dp[i - k][R], dp[i - k][P]);
			dp[i][R] = r + max(dp[i - k][S], dp[i - k][P]);
		}
		
		else
		{
			dp[i][P] = max(dp[i - k][R], dp[i - k][S]);
			dp[i][S] = s + max(dp[i - k][R], dp[i - k][P]);
			dp[i][R] = max(dp[i - k][S], dp[i - k][P]);
		}
	}
	
	int points = 0;
	
	for(int i = n - k; i < n; ++i)
		points += max(dp[i][P], max(dp[i][R], dp[i][S]));
	
	cout << points << '\n';
	
 	return 0; 
}

Measured memory_bytes: 4224
#include <iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>

using namespace std;

char field[22][22];
int H,W;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ans=1e9,rans=0;
bool d[22][22];
queue<pair<int,int>>q;
queue<int>qq;

int main(void){
    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>field[i][j];
        }
    }
    bool f[22][22]={0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
                    if(field[i][j]=='.'){
                        ans=0;
                        memset(d,false,sizeof(d));
                        pair<int,int>tem;
                        int c;
                        q.push(pair<int,int>(i,j));
                        qq.push(0);
                        d[i][j]=1;
                        while(!q.empty()){
                          
                            tem=q.front();
                            c=qq.front();
                            ans=max(ans,c);
                            q.pop(); 
                            qq.pop();
                            int x=tem.first;
                            int y=tem.second;
                            for(int s=0;s<4;s++){
                                int xx=x+dx[s],yy=y+dy[s];
                                if(d[xx][yy])continue;
                                if(xx>=0 && yy>=0 && xx<H && yy<W && field[xx][yy]=='.'){
                                    q.push(pair<int,int>(xx,yy));
                                    qq.push(c+1);
                                    d[xx][yy]=true;/*必須*/
                                }
                            }
                        }
                        
                        rans=max(ans,rans);
                    }
                }
        }
    
    cout<<rans<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };
/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

// 最小公約数
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}*/

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

	ll a, b, k;
	cin >> a >> b >> k;

	ll cnt = 0;
	for (int i = a; i > 0; i--) {
		if (a % i == 0 && b % i == 0) {
			cnt++;
			if (cnt == k) {
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

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

int main(void)
{
	string S, T;
	cin >> S >> T;

	for(int i=0; i<S.size(); i++){
		if(S == T){
			cout << "Yes" << endl;
			return 0;
		}

		S = S.back() + S.substr(0, S.size()-1);
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n,d,x;
  cin >> n >> d >> x;
  int ans=x;
  rep(i,n){
    int a; cin>>a;
    ans+=1+(d-1)/a;
  }

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

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

using namespace std;

int main(){
	long long int n;
	cin >> n; 
	const int MAX = 12;
	vector<long long > pref(MAX);
	vector<long long > pwr(MAX); 
	long long base = 26;
	pref[1] = base;
	pwr[1] = base;
	for(int i = 2; i < MAX; i++){
		base *= 26;
		pwr[i] = base;
		pref[i] = pref[i-1] + base;
	}
	int len = -1;
	for(int i = MAX - 1; i >= 1; i--){
		if(pref[i] < n){
			n-=pref[i];
			len = i + 1;
			break;
		}
	}
	string ans;
	for(int i = 1; i <= len; i++){
		for(char ch = 'a'; ch <='z'; ch++){
			if(pwr[len - i] >= n){
				ans += ch;
				break;
			}else{
				n -= pwr[len - i];
			}
		}
	}
	ans+=(n-1+'a'); 
	cout << ans << "\n";
	return 0;
}


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

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

int main(){
    int X, A;
    cin >> X >> A;
    
    if(X < A){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let xs = read_vec_i64();
    let (a,b,c) = (xs[0],xs[1],xs[2]);
    let max = max(a,max(b,c));
    let (da,db,dc) = (max-a, max-b, max-c);
    let z = da%2 + db%2 + dc%2;
    let res = da/2 + db/2 + dc/2 + (3-z)%3;
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
vector<int> v[100010];
int n,m,k;
int a[100010],b[100010],c[100010];
int d[100010];
int r[100010]={0};
void dfs(int x,int y,int col)
{
	//cout <<x<<" "<<y<<" "<<col<<" "<<d[x]<<"\n{\n";
	if (y<=d[x]) return;
	else d[x]=y;
	if (!r[x]) r[x]=col;
	if (!y) return;
	else
	{
		for (int i=0;i<v[x].size();i++)
		{
			int xi=v[x][i];
			dfs(xi,y-1,col);
		}
		//cout <<"}\n";
	}
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	cin >>k;
	for (int i=0;i<k;i++) cin >>a[i]>>b[i]>>c[i],a[i]--;
	fill(d,d+n,-1);
	for (int i=k-1;i>=0;i--) dfs(a[i],b[i],c[i]);
	for (int i=0;i<n;i++) cout <<r[i]<<"\n";
	return 0;
} 

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

struct S {
	int h, w;
	double d;
	S(int hh, int ww) {h = hh, w = ww, d = sqrt(h*h+w*w);}
	bool operator < (const S &e) const {return ((d < e.d) || ((d==e.d) && (h<e.h)));}
};

// 対角線が短い方(同じなら高さが短い方)を小さいとみなす
int h, w;
vector<S> s;

signed main() {
	repst(i,1,150) repst(j,i+1,150) s.pb(S(i,j));
	sort(all(s));
	int n = s.size();
	while (1) {
		cin >> h >> w;
		if (h==0) break;
		rep(i,n) if (s[i].h==h && s[i].w==w) {
			cout << s[i+1].h << ' ' << s[i+1].w << ln;
			break;
		}
	}
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define FI first
#define SE second
#define PB(a) push_back(a)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
#define SZ(x) ((int)(x).size())
#define SO(x) sizeof((x)) / sizeof((x)[0])
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void co(int a[], int n) {REP(i, n) cout << a[i] << " "; cout << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	string s;
	cin >> s;
	if (SZ(s) == 2){
		cout << s;
	}else{
		for (int i = SZ(s)-1; i>=0; i--){
			cout << s[i];
		}
	}
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        
        class Monster {
            int hp;
            int attack;

            Monster(int hp0, int attack0) {
                hp = hp0;
                attack = attack0;
            }
        }

        Monster takahashiMonster = new Monster(
            scan.nextInt(),
            scan.nextInt()
        );
        Monster aokiMonster = new Monster(
            scan.nextInt(),
            scan.nextInt()
        );

        while(takahashiMonster.hp > 0 && aokiMonster.hp > 0) {
            aokiMonster.hp -= takahashiMonster.attack;

            if(aokiMonster.hp > 0) {
                takahashiMonster.hp -= aokiMonster.attack;
            }
        }

        if(takahashiMonster.hp > 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        scan.close();
        return;
    }
}

Measured memory_bytes: 35708
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if (n == m) {
	    System.out.println("Yes");    	
    } else {
	    System.out.println("No");    	
    }
  }
}



Measured memory_bytes: 22868
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i=0; i < n; i++){
      p[i] = sc.nextInt();
    }
    
    int c = 0;
    for(int i=0; i<n-2; i++){
      if(p[i] <= p[i+1] && p[i+1] <= p[i+2]) c++;
      if(p[i] >= p[i+1] && p[i+1] >= p[i+2]) c++;
    }
    
    System.out.println(c);
  }
}

Measured memory_bytes: 23636
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, K);
  print(N % K);
  return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
# list(map(int, input().split()))
N, K = getNM()
intlist = [i for i in range(10)]
D = getList()
for i in D:
    if i in D:
        intlist.pop(intlist.index(i))

anslist = []
def dfs(i, num):
    anslist.append(num)
    if i < 5:
        for j in intlist:
            newnum = int(str(num) + str(j))
            dfs(i + 1, newnum)

for i in intlist:
    if i != 0:
        dfs(1, i)

anslist.sort()

for i in anslist:
    if i >= N:
        ans = i
        break
print(ans)

Measured memory_bytes: 44636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll maxim=INT64_MIN;
    maxim = max(a*c, maxim);
    maxim = max(a*d, maxim);
    maxim = max(b*c, maxim);
    maxim = max(b*d, maxim);
    cout << maxim << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	char b;
	cin >> b;
	if (b == 'A')cout<<'T'<<endl;
	if (b == 'C')cout << 'G' << endl;
	if (b == 'G')cout << 'C' << endl;
	if (b == 'T')cout << 'A' << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

int main()
{
	int a, b;
	cin >> a >> b;
	b--;
	cout << ((b % (a - 1) == 0 ? b / (a - 1) : b / (a - 1) + 1));
}


Measured memory_bytes: 31488
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=10**9
while r>l+1:
    mid=(l+r)//2
    res=0
    for i in range(n):
        res+=(math.ceil(a[i]/mid)-1)
    if res<=k:
        r=mid
    else:
        l=mid
print(r)

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N,X;
int h[55],p[55];
int f(int n,int x){
    if(n==0)return x;
    if(x<=1)return 0;
    if(x>=h[n]-1)return p[n];
    if(x>=h[n-1]+2) return p[n-1]+f(n-1,x-h[n-1]-2)+1;
    return f(n-1,x-1);
}
signed main() {
    cin>>N>>X;
    h[0]=1;
    for(int i=1;i<55;i++)h[i]=h[i-1]*2+3;
    p[0]=1;
    for(int i=1;i<55;i++)p[i]=p[i-1]*2+1;
    cout<<f(N,X)<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

#define int long long

using namespace std;

void Main()
{
	int32_t x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a);
	vector<int> q(b);
	vector<int> r(c);
	for (int32_t i = 0; i < a; i++) {
		cin >> p[i];
	}
	for (int32_t i = 0; i < b; i++) {
		cin >> q[i];
	}
	for (int32_t i = 0; i < c; i++) {
		cin >> r[i];
	}
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());

	for (int32_t i = 0; i < x; i++) {
		r.push_back(p[i]);
	}
	for (int32_t i = 0; i < y; i++) {
		r.push_back(q[i]);
	}
	sort(r.begin(), r.end(), greater<int>());

	int ans = 0;
	for (int32_t i = 0; i < x + y; i++) {
		ans += r[i];
	}

	cout << ans << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 6384
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    cin >> n;
    vector<int>L(n);
    for(int i=0;i<n;i++)cin >> L[i];
    sort(L.begin(),L.end());
    int x=L[n-1];
    int y=0;
    for(int i=0;i<n-1;i++)y+=L[i];
    if(y>x)cout << "Yes";
    else cout << "No";
    cout << endl;
}

int main(){
    solve();
    return 0;
}




Measured memory_bytes: 3600
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long a, long long b){
    string s, t;
    for(int i = 0; i < b; ++i)
        s += char('0' + a);
    for(int i = 0; i < a; ++i)
        t += char('0' + b);
    cout << min(s, t) << endl;
}


signed main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=1000005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 
 
ll int power(ll int a,ll int b)
{
	ll int ans=1,f=a;
	while(b)
	{
		 if(b&1)
		 ans=(ans*f)%mod;
		 b=b>>1;
		 f=(f*f)%mod;
	}
	return ans%mod;
}

int main()
{
	int n;
	cin>>n;
	ll int a[n];
	fo(i,0,n)
	cin>>a[i];
	sort(a,a+n);
	int j=n-1;
	ll int ans=0;
	if(j)
	{ans+=a[n-1];
	j--;
	}
	
	rfo(i,n-2,0)
	{
		ans+=(min(j,2)*a[i]);
		j-=2;
		if(j<=0) break;
	}
	cout<<ans<<endl;



}

	
	
 



Measured memory_bytes: 5184
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N;
  pair<string, int> st[60];
  string X;
  int music = 0;
  bool sleep = false;

  cin >> N;
  for(int i=0; i<N; ++i) {
    cin >> st[i].first >> st[i].second;
  }
  cin >> X;

  for(int i=0; i<N; ++i) {
    if(sleep) {
      music += st[i].second;
    }
    if(X == st[i].first) {
      sleep = true;
    }
  }

  cout << music << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
struct node{
    int u,v,nxt;
}edge[N*2];
int mcnt,head[N];
void add_edge(int u,int v){
    mcnt++;
    edge[mcnt].u=u;
    edge[mcnt].v=v;
    edge[mcnt].nxt=head[u];
    head[u]=mcnt;
}
bool vis[N];
int spx,spy,clen;
int deep[N];
int f[N],sum[N];
void dfs(int u,int fa){
    vis[u]=1;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(v==fa)
            continue;
        if(vis[v]){
            spx=u,spy=v;
            clen=deep[u]-deep[v]+1;
        }
        else{
            deep[v]=deep[u]+1;
            dfs(v,u);
        }
    }
}
void get(int u,int fa){
    vis[u]=1;
    for(int i=head[u];i;i=edge[i].nxt){
        int v=edge[i].v;
        if(v==fa||vis[v])
            continue;
        get(v,u);
        f[u]+=f[v],sum[u]+=sum[v];
    }
}
int n,m;
int z[N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    dfs(1,0);
    int ans=0,tot=0;
    for(int i=1;i<=n;i++){
        if(deep[i]&1)
            sum[i]=-1;
        else
            sum[i]=1;
        tot+=sum[i];
    }
    if(m==n-1){
        if(tot){
            puts("-1");
            return 0;
        }
    }
    else{
        if(clen&1){
            if(tot&1){
                puts("-1");
                return 0;
            }
            sum[spx]-=tot/2,sum[spy]-=tot/2;
            ans+=abs(tot)/2;
        }
        else{
            if(tot){
                puts("-1");
                return 0;
            }
            f[spx]=1,f[spy]=-1;
        }
    }
    memset(vis,0,sizeof vis);
    get(1,0);
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(!f[i])
            ans+=abs(sum[i]);
        else{
            if(f[i]==1)
                sum[i]=-sum[i];
            z[++cnt]=sum[i];
        }
    }
    z[++cnt]=0;
    sort(z+1,z+1+cnt);
    int k=z[(cnt+1)/2];
    for(int i=1;i<=cnt;i++)
        ans+=abs(z[i]-k);
    printf("%d\n",ans);
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int n,l;
    cin>>n>>l;
    int sum = 0;
    int MIN=1e6,aa=1e6;
    rep(i,n){
        sum += (l+i);
        if(MIN>abs(l+i)) aa=i;
        MIN = min(MIN,abs(l-1+i));
    }
    // cout<<MIN<<" "<<sum<<endl;
    cout<<sum-(l+aa)<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(50)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  string s;
  cin>>n>>s;
  string t="ABC";
  ll c=0;
  for(ll i=0;i<n;i++)
  {
  	if(i+2>=n)
  		break;
  	string p=s.substr(i,3);
  	if(p==t)
  		c++;
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  char N;
  cin>>N;
  if(N-'A'>=32)cout<<'a'<<endl;
  else cout<<'A'<<endl;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  //cout << N << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, A, B; cin >> N >> A >> B;
	vector<ll> X(N + 1,0);
	for (int i = 1; i <= N; i++) cin >> X[i];

	ll ans = 0;
	for (int i = 1; i < N;i++) {
		int diff = X[i + 1] - X[i];
		ans += min(A*diff, B);
	}
	cout << ans << endl;
}

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

int main(void) {
  int n, p[12], ans = 0, kari = -1, kari2;

  if(scanf("%d", &n) != 0);

  for(int i = 0; i < n; i++) {
    if(scanf("%d", &p[i]) != 0);
  }

  for(int i = 0; i < n; i++) {
    if(p[i] > kari) {
      kari = p[i];
      kari2 = i;
    }
  }

  for(int i = 0; i < n; i++) {
    if(i != kari2) {
      ans += p[i];
    }
  }
  ans += (kari / 2);

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 5001
#define MOD 1000000007

typedef long long int lli;

int cmp_str(const void *a, const void *b){
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */

int main(void) {
  char s[MAX];
  int k;
  scanf("%s %d", s, &k);

  int cnt = 0;
  char *sub[MAX * 5];
  int n = strlen(s);
  for (int b = 0; b < n; b++) {
    for (int e = b; e < n && e < b + k; e++) {
      int len = e - b + 1;
      sub[cnt++] = strndup(s + b, len);
    }
  }

  qsort(sub, cnt, sizeof(char **), cmp_str);

  int ki = 1;
  for (int ci = 0; ci < cnt; ci++) {
    if ( ki == k ) {
      printf("%s\n", sub[ci]);
      break;
    }
    if ( strcmp(sub[ci], sub[ci + 1]) == 0 ) continue;
    ki++;
  }
  return 0;
}


Measured memory_bytes: 1276
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n; cin >> n; 
  vector<ll> v(n); input(v);
  ll totxor = 0;
  for(auto x : v) totxor ^= x;
  for(int b = 61; b >= 0; --b){
    ll shift = (1LL<<b);
    if( totxor & shift ){
      for(auto & x : v) if( x & shift ) x -= shift; 
    }
  }
  
  ll ans = 0;
  while(1){
    auto y = *max_element(all(v));
  //  auto cnt = count_if(all(v), [](auto x){return x != 0; } );
   // if( cnt == 1 ) break;
    if( y == 0 ) break;
    debug("find max", y, bitset<7>(y));
    if( (ans^y) > ans ){
      debug("updating ans",ans, ans^y);
    }
    ans = max(ans, ans^y);
    for(auto & x : v){ x = min(x, x^y); }
    debug("---");
    for(auto x : v){ debug(bitset<7>(x)); }
    debug("---");
  }
  debug("ans",ans,bitset<7>(ans));
  ans += (totxor^ans);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
def omit(s):
    """
    @param: 元の文字列
    @return: 最初の文字 + 最初の文字と最後の文字にはさまれた文字列の流さ
    + 最後の文字

    >>> omit("internationalization")
    'i18n'

    >>> omit("smiles")
    's4s'

    >>> omit("xyz")
    'x1z'
    """

    s2 = list(s)

    (first,last) = (s2.pop(0), s2.pop(-1))
    return first + str(len(s2)) + last

print(omit(input()))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const N=1e6+500;
ll INF=0x3f3f3f3f;
map<string,ll>mp;
int main()
{
    string str,str1[N];
    ll n,a[N],b,c,cnt=0,ans=0,vis[N];
    cin>>str;
    n=str.length();
    for(int i=0;i<n;i++)
        a[i]=ll(str[i]-'0');
    for(int i=0;i<=n;i++)
    {
        if(a[i]>=10)
        {
            a[i]-=10;
            a[i+1]+=1;
        }
        b=a[i];
        if(b<5)
            ans+=b;
        else
        {
            if(b==5&&a[i+1]<5)
            {
                ans+=b;
                //continue;
            }
            else
            {
                a[i+1]+=1;
                ans+=10-b;
            }
           /* int j=i;
            while(a[j+1]>=5|| ( a[j+1]==4 && (a[j+2]>=6||(a[j+2]>=5&&a[j+3]>=5) ) )        )
            {
                j++;
            }
            for(int k=i;k<=j;k++)
            {
                ans=ans+(10-a[k]-1);
            }
            i=j;
                cout<<j<<endl;
            ans+=2;
            //cout<<ans<<endl;*/
        }
       // cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 17028
def solve(a, b):
    for i in range(1, 1001):
        res_a = int(i * 0.08)
        res_b = int(i * 0.10)
        if res_a == a and res_b == b:
            return i
    return -1


def main():
    a, b = map(int, input().split())
    res = solve(a, b)
    print(res)


def test():
    assert solve(2, 2) == 25
    assert solve(8, 10) == 100
    assert solve(19, 99) == -1


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define vpair(d) vector<pair<d, d> >

using namespace std;



int main()
{
	int k;
	cin >> k;
	
	int e,o;
	
	if(k%2 != 0){
		o = k/2+1;
		e = k/2;
	}else{
		o = k/2;
		e = k/2;
	}
	
	cout << o*e<< endl;
	
	return 0;
}

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

p_collect = sorted(p)

no = 0

for i in range(N):
    if p[i] != p_collect[i]:
        no += 1

if no == 1:
    print("NO")
elif no >= 3:
    print("NO")
else:
    print("YES")
 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl;
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<endl;
#define pi M_PI
int main()
{
    fastio();
    int a,b,c;cin>>a>>b>>c;
    int x = a-b;
    int y = max(0,c-x);
    cout<<y<<endl;

    return 0;
}    

Measured memory_bytes: 256
i=int(input())
n=list(map(int,input().split()))
print(' '.join(map(str, n)))
for k in range(1,i):
	target=n[k]
	hh=k-1
	while hh>=0 and n[hh]>target:
		n[hh+1]=n[hh]
		hh-=1
	n[hh+1]=target
	print(' '.join(map(str, n)))




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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main() 
{
    int n;
    cin>>n;
    cout<<2*3.1459*n<<endl;
   return 0;
}

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

int main() {
    string s[3];
    rep(i, 3) cin >> s[i];

    cout << 'A' << s[1][0] << 'C' << endl;
    return 0;
}


Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
typedef long long ll;
int n,m,p[N];
ll k;
ll a[N];
ll dist[N];
bool vis[N];
ll ans[N];
int st[N],top;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        p[i]=i;
        dist[i]=a[i]-a[i-1];
    }
    scanf("%d%lld",&m,&k);
    for(int i=1;i<=m;i++){
        int x;
        scanf("%d",&x);
        swap(p[x],p[x+1]);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i]){
            top=0;
            for(int j=i;!vis[j];j=p[j])
                st[++top]=j,vis[j]=1;
            for(int j=1;j<=top;j++)
                ans[st[j]]=dist[st[(k+j-1)%top+1]];
        }
    for(int i=1;i<=n;i++)
        ans[i]+=ans[i-1];
    for(int i=1;i<=n;i++)
        printf("%lld\n",ans[i]);
}


Measured memory_bytes: 4352
// from a scalar

#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define moder 1000000007

ll moding( ll x , ll y ){
   
    ll ans = x % y;

    if(ans < 0)ans = ans + y ;

    return ans ;

}


bool isprime(ll n){
    if(n==2) return true;
    if(n==3) return true;
    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    ll i = 5,w=2;

    while(i*i <= n){
        if(n%i == 0)return false;

        i += w;
        w = 6 - w;
    }

    return true;
}




int main(){

    string s; cin >> s;

    if(s[0] == 'S'){
        if(s[1] =='U')cout << "7";
        else cout << "1";
    }else if(s[0] == 'M')cout << "6";
    else if(s[0]== 'T'){
        if(s[1] == 'U')cout << "5";
        else cout << "3";
    }
    else if(s[0]=='W')cout << "4";
    else cout << "2";

           
     cout << endl;
     
        
    return 0;
}
      
       

Measured memory_bytes: 256
s = input()
d = int((len(s)-1) / 2)
e = int((len(s)+3) / 2)
if s == s[::-1] and s[0:d] == s[d-1::-1] and s[e-1:] == s[int(len(s)):e-2:-1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9056
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int max = 0;

        int i = 2;
        int j = 2;
        int y = (int)Math.pow(i, j);
        
        while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        }

        if(max == 0)
            max = x;
        
        System.out.println(max);
    }
}

Measured memory_bytes: 23124
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int num = sc.nextInt();

        long answer = 1;

        for(int i = 1; i <= num; i++){
            answer = answer * i;
        }

        System.out.println(answer);

    }
}

Measured memory_bytes: 17160
#include <stdio.h>
#define INFTY 1000000000
#define N 500000

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int count=0;

int main(){
  int n,i,A[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
}

void merge(int A[],int left,int mid,int right){
  int i,j,k,n1,n2;
  int L[N/2+2],R[N/2+2];
  
  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i=i+1;
    }
    else {
      A[k] = R[j];
      j=j+1;
    }
  }
}
void  mergeSort(int A[],int left,int right){
  int mid;
  if(left+1<right){
    mid = (left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 2e9
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;

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

  ll x;
  if (n < b)
  {
    x = n;
  }
  else
  {
    x = b - 1;
  }

  cout << (a * (x % b) / b) << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string n;cin >> n;
    if ( n[0] == '7'||n[1] == '7'||n[2] == '7'){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include<stdio.h>

int main (void) {
  int a, b, c, hantei, temp;
  scanf("%d %d %d", &a, &b, &c);

  do {
    hantei = 1;
    if (a > b) {
      temp = a;
      a = b;
      b = temp;
      hantei = 0;
    }
    
    if (b > c) {
      temp = b;
      b = c;
      c = temp;
      hantei = 0;
    }
  } while (hantei == 0);

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 2728
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


struct UnionFind{
    ll par[200010];
    ll r[200010];

    UnionFind(ll n){
        rep(i,n){
            par[i]=i;
            r[i]=0;
        }
    }

    ll find(ll x){
        if(par[x]==x)
        return x;
        else return par[x] =find(par[x]);
    }

    void unite(ll x,ll y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(r[x] <r[y]){
            par[x] =y;
        }
        else{
            par[y] =x;
            if(r[x] ==r[y]) r[x]++;
        }
    }

    bool same(ll x,ll y){
        return find(x) ==find(y);
    }
};

struct edge{  
    ll u,v,cost;
};

bool comp(const edge& e1,const edge& e2){
    return  e1.cost <e2.cost;
}

vector<edge> es;
ll n,E;

ll  kruskal(){
    sort(all(es),comp);
    UnionFind uf(n);
    ll res=0;
    rep(i,es.size()){
        edge e=es[i];
        if(!uf.same(e.u,e.v)){
            uf.unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    vector<ll> x(n),y(n);
    vector<pii> xi(n),yi(n);
    rep(i,n){
        cin>>x[i]>>y[i];
        xi[i]=pii(x[i],i);
        yi[i]=pii(y[i],i);
    }
    sort(xi.begin(),xi.end());
    sort(yi.begin(),yi.end());
    rep(i,n-1){
        es.pb({xi[i].second,xi[i+1].second,xi[i+1].first-xi[i].first});
    }
    rep(i,n-1){
        es.pb({yi[i].second,yi[i+1].second,yi[i+1].first-yi[i].first});
    }
    /*
    rep(i,es.size()){
        cout<<es[i].u<<" "<<es[i].v<<" "<<es[i].cost<<endl;
    }
    cout<<endl;
    */
    ll ans=kruskal();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11884