akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int n;
vector<vi> g(200010);
int parent[200010];
int vis[200010];
int st[200010];
void dfs(int u) {
	vis[u]=1;
	int ss=0;
	for(int i = 0; i < sz(g[u]); i++) {
		int v=g[u][i];
		if(!vis[v]) {
			parent[v]=u;
			dfs(v);
			ss += st[v];
		}
	}
	st[u]=ss+1;
}
signed main(void)
{
	IOS;
	// cin>>n;
	// vii edge;
	// for(int i = 0; i < n-1; i++) {
	// 	int u,v;
	// 	cin>>u>>v; u--; v--;
	// 	edge.pb({u,v});
	// 	g[u].pb(v);
	// 	g[v].pb(u);
	// }
	// parent[0]=0;
	// dfs(0);
	// long double ad=n/2.0;
	// long double sub=0.0;
	// for(int i = 0; i < n-1; i++) {
	// 	if(parent[edge[i].ff]==edge[i].ss) {
	// 		int s1=st[edge[i].ff],s2=n-s1;
	// 		sub += ();
	// 	} else {

	// 	}
	// }
	int n,a,b;
	cin>>n>>a>>b;
	if(a>b) swap(a,b);
	if((b-a)%2==0) {
		cout<<(b-a)/2<<endl;
	} else {
		int l1=a+(n-b)+1;
		int mn=inf;
		// if(l1==n) {
		// 	mn=min(mn,n-b+1);
		// 	// cout<<n-b+1<<endl;
		// } else
			mn=min(mn,n-b+1+(n-l1)/2);
		int l2=b-(a-1)-1;
		// if(l2==1) {
		// 	mn=min(mn,a);
		// } else
		mn=min(mn,a+(l2-1)/2);
		cout<<mn<<endl;
	}
	time();
	return 0;
}

Measured memory_bytes: 4992
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Double r,length,area,pi;
        NumberFormat nf = new DecimalFormat("0.000000");
        Scanner sc = new Scanner(System.in);
        pi = Math.PI;
        r = sc.nextDouble();
        length = 2*r*pi;
        area = r*r*pi;
        System.out.println(nf.format(area) + " " + nf.format(length) );
    }
}

Measured memory_bytes: 28180
n=int(input())
if 100<=n<=111:
	print(111)
if 112<=n<=221:
	print(222)	
if 222<=n<=333:
	print(333)	
if 334<=n<=444:
	print(444)
if 445<=n<=555:
	print(555)
if 556<=n<=666:
	print(666)
if 667<=n<=777:
	print(777)
if 778<=n<=888:
	print(888)
if 889<=n<=999:
	print(999)						

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e=1,f,i;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	for(i=0;i<d;i++){
		e=e*2;
	}
	f=a;
	if(f<b){
		f=b;
	}
	if(f<c){
		f=c;
	}
	printf("%d",a+b+c-f+f*e);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(void)
{
  int m,f,b;
  cin>>m>>f>>b;
  if(b<=m)
    cout<<0<<endl;
  else{
    if(m+f<b)
      cout<<"NA"<<endl;
    else
      cout<<b-m<<endl;
  }
  return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5 + 5;
int N;
long long arr[MAX_N];
long long dp[MAX_N][2];
void solve(){
    int i = 0;
    priority_queue<long long, vector<long long>, greater<long long>> pq1;
    priority_queue<long long> pq2;
    long long sum1 = 0, sum2 = 0;
    for(i = 0; i < 3 * N; i++){
        if(i < N){
            pq1.push(arr[i]);
            sum1 += arr[i];
        }
        else if(pq1.top() < arr[i]){
            sum1 -= pq1.top();
            pq1.pop();
            pq1.push(arr[i]);
            sum1 += arr[i];
        }
        dp[i][0] = sum1;
    }
    for(i = 3 * N - 1; i >= 0; i--){
        if(i >= 2 * N){
            pq2.push(arr[i]);
            sum2 += arr[i];
        }
        else if(pq2.top() > arr[i]){
            sum2 -= pq2.top();
            pq2.pop();
            pq2.push(arr[i]);
            sum2 += arr[i];
        }
        dp[i][1] = sum2;
    }
    long long ans = -1e18;
    for(i = N - 1; i < 2 * N; i++)
        ans = max(ans, dp[i][0] - dp[i + 1][1]);
    cout << ans << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i = 0;
    cin >> N;
    for(i = 0; i < 3 * N; i++)
        cin >> arr[i];
    solve();
    return 0;
}

Measured memory_bytes: 9588
#include <stdio.h>
#include <iostream>
#include <set>

int a[100000 + 1];

int main() {

	int n, m;
	std::multiset<int> s;

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; ++i) {

		scanf("%d", &a[i]);
		s.insert(a[i]);

	}

	for (int i = 0; i < m; ++i) {

		auto sit = s.end();
		sit--;
		int temp = *sit / 2;
		s.erase(sit);
		s.insert(temp);

	}

	unsigned long long ans = 0;

	for (auto x : s) {

		ans += x;

	}

	/*

	X/2^Y

	*/

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 5376
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0 for i in range(N+1)]
ans=[]
for i in range(1,N+1):
    #print(i)
    n=N+1-i
    cnt=0
    for j in range(1,N+1):
        #print(n,j*n)
        if j*n>N:
            break
        if B[j*n]==1:
            cnt+=1
    if A[n]%2!=cnt%2:
        B[n]=1
        ans.append(n)
print(len(ans))
ans.sort()
print(*ans)
#print(A)

Measured memory_bytes: 14132
N, M, X, Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def check() :        
    for Z in range(max(x) + 1, min(y) + 1) :
        if X < Z <= Y :
            return 'No War'
    
    return 'War'
    
print(check())

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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; }

int main(){
    int N; cin >> N;
    vector <int> P(N);
    rep(i,N) cin >> P[i];
    
    int ans=0;
    rep(i,N){
        if (P[i]==i+1){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
    
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int n;
vector<vi> g;

vector<bool> u;
int dfs(int v, int d) {
    if (d == n-1) return 1;
    int res = 0;
    for (int i : g[v]) {
        if (u[i]) continue;
        u[i] = true;
        res += dfs(i, d + 1);
        u[i] = false;
    }
    return res;
}

int main(){
    int m;
    cin >> n >> m;
    vector<vi> gl(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        gl[a].pb(b);
        gl[b].pb(a);
    }
    g = gl;
    vector<bool> ul(n);
    u = ul;
    u[0] = true;
    cout << dfs(0, 0) << endl;
    return 0;
}


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

using namespace std;

int main(void) {
  
 int N;
 cin >> N;
 vector<long long> L(N);
 for (int i= 0; i<N; i++) {
   cin >> L.at(i);
 }

 long long count = 0;
 for(int i=0; i<N; i++) {
   for (int j=i+1; j<N; j++) {
     for (int k=j+1; k<N; k++) {
       if (L.at(i) == L.at(j) || L.at(j) == L.at(k) || L.at(k) == L.at(i)) {
         continue;
       } else {
         if ( L.at(i)+L.at(j) > L.at(k) && L.at(j) + L.at(k) > L.at(i) && L.at(k) + L.at(i) > L.at(j) ){
           //cout << "(i, j, k) = (" << i+1 << ", " << j+1 << ", " << k+1 << ")" << endl;
           count++;
         } else {
           continue;
         }
       }
     }
   }
 }

 cout << count << endl;

}


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



int main(){
  int n = 0;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  sort(v.begin(),v.end());
  rep(i,n-1){
    if(v.at(i)==v.at(i+1)){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;

}

Measured memory_bytes: 1024
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
    print(np.argmin(np.sum(np.abs(cd-x),axis=1))+1)


Measured memory_bytes: 12432
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int kotae = n%2;
      if(kotae == 0){
        System.out.println(n/2);
      }else{
        System.out.println(n/2+1);
      }
  }  
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int solve(bool b[20][20], int H, int W, std::pair<int, int> start) {
  int cost[20][20] = {};
  bool used[20][20] = {};

  std::deque<std::pair<int, int>> que;
  que.push_back(start);
  used[start.first][start.second] = true;

  while (!que.empty()) {
    auto p = que.front();
    que.pop_front();

    int h = p.first;
    int w = p.second;

    int nh = h-1, nw = w;  // up.
    if (0 <= nh && nh < H && 0 <= nw && nw < W && b[nh][nw]) {
      if (!used[nh][nw]) {
        cost[nh][nw] = cost[h][w] + 1;
        used[nh][nw] = true;
        que.push_back({nh, nw});
      } else {
        cost[nh][nw] = std::min(cost[nh][nw], cost[h][w] + 1);
      }
    }

    nh = h+1, nw = w;  // down.
    if (0 <= nh && nh < H && 0 <= nw && nw < W && b[nh][nw]) {
      if (!used[nh][nw]) {
        cost[nh][nw] = cost[h][w] + 1;
        used[nh][nw] = true;
        que.push_back({nh, nw});
      } else {
        cost[nh][nw] = std::min(cost[nh][nw], cost[h][w] + 1);
      }
    }

    nh = h, nw = w-1;  // left
    if (0 <= nh && nh < H && 0 <= nw && nw < W && b[nh][nw]) {
      if (!used[nh][nw]) {
        cost[nh][nw] = cost[h][w] + 1;
        used[nh][nw] = true;
        que.push_back({nh, nw});
      } else {
        cost[nh][nw] = std::min(cost[nh][nw], cost[h][w] + 1);
      }
    }

    nh = h, nw = w+1;  // right
    if (0 <= nh && nh < H && 0 <= nw && nw < W && b[nh][nw]) {
      if (!used[nh][nw]) {
        cost[nh][nw] = cost[h][w] + 1;
        used[nh][nw] = true;
        que.push_back({nh, nw});
      } else {
        cost[nh][nw] = std::min(cost[nh][nw], cost[h][w] + 1);
      }
    }
  }

  int vmax = 0;
  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      if (!b[h][w]) continue;
      vmax = std::max(vmax, cost[h][w]);
    }
  }
  return vmax;
}

int main() {
  int H, W; std::cin >> H >> W;
  bool b[20][20];
  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      char c; std::cin >> c;
      if (c == '.') b[h][w] = true;
      else          b[h][w] = false;
    }
  }

  int vmax = 0;
  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      if (!b[h][w]) continue;
      vmax = std::max(vmax, solve(b, H, W, {h, w}));
    }
  }

  std::cout << vmax << std::endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll gdcf(ll a, ll b)
{
    if(b > a) swap(a,b);
    while(a%b){
        ll tmp = b;
        b = a%b;
        a = tmp;
    }
    return b;
}

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<ll> b(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        b.at(i) = a.at(i)/2;
    }

    ll tmplcm = 1;
    for(i = 0;i < n;++i){
        if(tmplcm%b.at(i) == 0) continue;
        ll tmpgcd = gdcf(tmplcm, b.at(i));
        tmplcm *= b.at(i)/tmpgcd;
    }
    for(i = 0;i < n;++i){
        ll tmp = tmplcm/b.at(i);
        if(tmp%2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    ll ans = m/tmplcm;
    if(ans%2 == 0){
        cout << ans/2 << endl;
    }else{
        cout << (ans+1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main() 
{
    string tmp;
    int n;
    cin>>n;
    for (int i=0; i<n; i++) {
        getline(cin,tmp);
        while (tmp=="") getline(cin,tmp);
        while (tmp.find("Hoshino")!=string::npos) {
            tmp.replace(tmp.find("Hoshino"),7,"Hoshina");
        }
        cout<<tmp<<endl;
    }
}

Measured memory_bytes: 0
import bisect
n,w_max=map(int,input().split())
W,V=[],[]
for i in range(n):
  w,v=map(int,input().split())
  W.append(w)
  V.append(v)
DP=[[float("inf") for i in range(10**5+1)] for j in range(n+1)]
DP[0][0]=1
for i in range(1,n+1):
  for j in range(i*(10**3)+1):
    if j>V[i-1]:
      DP[i][j]=min(DP[i-1][j],DP[i-1][j-V[i-1]]+W[i-1])
    else:
      DP[i][j]=min(DP[i-1][j],W[i-1])
ans=bisect.bisect_right(DP[n],w_max)-1
print(ans)

Measured memory_bytes: 318192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
typedef vector<string> vs;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
const ll MOD=1000000007;
const ll mod=998244353;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
void solve(){
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=1000;i++){
		if(i/10==b&&i*8/100==a){
			cout<<i;
			return;
		}
	}
	cout<<-1;
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3616
n, m = map(int, input().split())
mod = 10 ** 9 + 7
pat = [0] * (n + 2)
pat[0] = 1
pat[1] = 1

for i in range(m):
    a = int(input())
    pat[a] = -1

for i in range(2, n + 1):
    if pat[i] < 0:
        continue
    if pat[i - 1] > 0:
        pat[i] = (pat[i] + pat[i - 1]) % mod
    if pat[i - 2] > 0:
        pat[i] = (pat[i] + pat[i - 2]) % mod

print(pat[n])


Measured memory_bytes: 6888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int A,B;
  cin>>A>>B;
  int ANS = 0;
  for (int i = A; i <= B; i++)
  {
    int X = i;
    string str = to_string(X);
    if(str[0] == str[4] &&str[1] == str[3]) ANS++;
  }
  cout<<ANS<<endl;
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
i = input()
l = []
while i / 10 > 0:
  l.append(i % 10)
  i = i / 10
l.append(i)
l.reverse()

min_diff=753

for x in range(len(l)-2):
  if min_diff > abs((100 * l[x] + 10 * l[x+1] + l[x+2])  - 753):
    min_diff = abs((100 * l[x] + 10 * l[x+1] + l[x+2])  - 753)

print min_diff

Measured memory_bytes: 2568
#
# panasonic2020b d
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1"""
        output = """a"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2"""
        output = """aa
ab"""
        self.assertIO(input, output)


def resolve():
    global N
    N = int(input())

    dfs("a", "a")


def dfs(mw, s):
    if len(s) == N:
        print(s)
        return

    for i in range(ord(mw)-ord("a")+2):
        mw = max(mw, chr(ord("a")+i))
        ns = s + chr(ord("a")+i)
        dfs(mw, ns)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    vvec<char> S(H,vec<char>(W));
    for(int i=0;i<H;i++) for(int j=0;j<W;j++) cin >> S[i][j];
    auto in = [&](int x,int y){
        return 0<=x && x<H && 0<=y && y<W;
    };
    vvec<int> ans(H,vec<int>(W));

    for(int i=0;i<H;i++) for(int j=0;j<W;j++) {
        int n = 0;
        for(int dx=-1;dx<=1;dx++) for(int dy=-1;dy<=1;dy++){
            int nx = i+dx,ny = j+dy;
            if(in(nx,ny) && S[nx][ny]=='#') ans[i][j]++;
        }
    }
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
        if(S[i][j]=='#') cout << '#';
        else cout << ans[i][j];
        if(j==W-1) cout << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define MN 3010

int n, mod;
int f[MN][MN], C[MN][MN], mi[MN * MN];

int qpow(int x, int p, int mod)
{
	int ans = 1;
	for(; p; p >>= 1, x = 1ll * x * x % mod) if(p & 1) ans = 1ll * ans * x % mod;
	return ans;
}

int main()
{
	scanf("%d%d", &n, &mod);
	for(int i = 0; i <= n; i++) C[i][0] = C[i][i] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	f[0][0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= i; j++)
			f[i][j] = (1ll * f[i - 1][j] * (j + 1) + f[i - 1][j - 1]) % mod; 
	mi[0] = 1; for(int i = 1; i <= n * n; i++) mi[i] = 2 * mi[i - 1] % mod;
	int ans = 0;
	for(int i = 0; i <= n; i++)
	{
		int w = 1ll * (i & 1 ? mod - 1 : 1) * C[n][i] % mod * qpow(2, qpow(2, n - i, mod - 1), mod) % mod;
		for(int j = 0; j <= i; j++) ans = (ans + 1ll * w * f[i][j] % mod * mi[(n - i) * j]) % mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 106368
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
 
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)
 
constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
 
int main(){
 
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(max(a*10+b+c,a+b*10+c),a+b+c*10)<<endl;
 
    return 0;
}

Measured memory_bytes: 256
n, m, _ = gets.split.map(&:to_i)
r = gets.split.map { |z| z.to_i - 1 }
max = 1e10
d = Array.new(n) { Array.new(n, max) }
m.times do
  a, b, c = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  d[a][b] = c
  d[b][a] = c
end
n.times do |k|
  dk = d[k]
  n.times do |i|
    #next if i == k
    di = d[i]
    dik = di[k]
    (0...n).each do |j|
      tmp = dik + dk[j]
      di[j] = tmp if tmp < di[j]
    end
  end
end

ans = r.permutation.map do |perm|
  perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] }
end.min

p ans


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

int main() {
	int n;cin >> n;
	for (int i =0; i<n;++i) {
		string s;cin >>s;
		if(s=="Y"){
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

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

int main() {
  int n,x; cin >>n >>x;
  vector<int> m(n);
  for (int i=0; i<n; i++) cin >>m.at(i);
  sort(m.begin(), m.end());
  
  for (int i=0; i<n; i++){
    x -= m.at(i);
  }
  
  cout <<n+x/m.at(0) <<endl;
}


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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int N, Q;

    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    cin >> Q;
    vector<ll> B(Q), C(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> B[i] >> C[i];
    }

    map<ll, ll> nums;
    for (int i = 0; i < N; ++i) {
        if (nums.count(A[i]) == 0) {
            nums[A[i]] = 1;
        } else {
            nums[A[i]] += 1;
        }
    }
    // print(nums);

    ll sum = 0;
    for (auto x: nums) {
        sum += x.first * x.second;
    }

    for (int i = 0; i < Q; ++i) {
        if (nums.count(B[i]) > 0)  {
            ll c = nums[B[i]];
            sum -= B[i] * c;
            sum += C[i] * c;
            nums.erase(B[i]);
            if (nums.count(C[i]) > 0) {
                nums[C[i]] += c;
            } else {
                nums[C[i]] = c;
            }
            // print(nums);
        }
        cout << sum << endl;
    }


    return 0;
}


Measured memory_bytes: 9592
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

public class Main {
    private static final long MOD = (long) 1e9 + 7;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final int[] array = new int[n];
        final Map<Integer, Integer> primeCounter = new HashMap<>();
        for (int i = 0; i < n; i++) {
            final int a = scanner.nextInt();
            array[i] = a;
            final Map<Integer, Integer> primeFactorization = primeFactorization(a);
            for (final int key : primeFactorization.keySet()) {
                primeCounter.put(key, Math.max(primeFactorization.get(key), primeCounter.getOrDefault(key, 0)));
            }
        }

        long lcm = 1;
        for (final Map.Entry<Integer, Integer> primeAndCount : primeCounter.entrySet()) {
            lcm *= bigPow(primeAndCount.getKey(), primeAndCount.getValue(), MOD);
            lcm %= MOD;
        }

        long answer = 0;
        for (final long i : array) {
            answer += lcm * modInv(i, MOD);
            answer %= MOD;
        }

        System.out.println(answer);
    }

    /**
     * 素数modを法としてaの逆元を計算する
     * modInvと一緒に使う
     *
     * @param a   逆元を計算したい値
     * @param n   a - 2
     * @param mod 法となる素数
     * @return modを法としたaの逆元
     */
    private static long modPow(long a, long n, final long mod) {
        long res = 1;
        while (n > 0) {
            if ((n & 1) != 0) {
                res = res * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    /**
     * 素数modを法としたaの逆元を計算する
     * modPowと一緒に使う
     *
     * @param a   逆元を計算したい値
     * @param mod 法となる素数
     * @return modを法としたaの逆元
     */
    private static long modInv(final long a, final long mod) {
        return modPow(a, mod - 2, mod);
    }

    private static long bigPow(final long number, final long count, final long mod) {
        long returnValue = 1;
        for (long i = 0; i < count; i++) {
            returnValue *= number;
            returnValue %= mod;
        }
        return returnValue;
    }

    private static Map<Integer, Integer> primeFactorization(long n) {
        final double sqrt = Math.sqrt(n);
        final Map<Integer, AtomicInteger> countMap = new HashMap<>();
        for (int i = 2; i <= sqrt; i++) {
            if (n % i == 0) {
                countMap.computeIfAbsent(i, v -> new AtomicInteger()).incrementAndGet();
                n /= i;
                i--;
            }
        }

        if (n != 1) {
            countMap.computeIfAbsent((int) n, v -> new AtomicInteger()).incrementAndGet();
        }

        return countMap.entrySet().stream()
                .collect(Collectors.toMap(Map.Entry::getKey, entrySet -> entrySet.getValue().get()));
    }
}


Measured memory_bytes: 42992
def digit_sum(n):
    n = str(n)
    S = list(map(int,n))
    return sum(S)

N , A, B = map(int,input().split())
ans = 0
for i in range(1 , N + 1):
    if A <= digit_sum(i) <= B:
       ans += i
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    long long n,a,b,c,d;
    scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
    long long mid = a-b;
    if(mid<0)mid *= -1ll;
    long long res1=c*(n-1),res2=d*(n-1);
    long long mid1,mid2;
    for(int i=0;2*i<=n-1;i++){
        mid1 = res1 - i*(d-c);
        mid2 = res2 + i*(d-c);
        res1 -= 2*c;
        res2 -= 2*d;
        if(mid>=mid1&&mid<=mid2){
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll 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) {
    assert(n < mod);
    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];
  }
};





 




int main(){
  int n,k;cin>>n>>k;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  combination c(n+3);
  
  sort(all(a));
  if(k==1) cout<<0<<endl;
  else{
  mint ans=0;
  
    rep(i,n){
      int l=n-1-i;
      
      ans+=((mint)a[l]-(mint)a[i])*c(n-1-i,k-1);
    }
    
    cout<<ans.x<<endl;
  }
  
}
  
  



Measured memory_bytes: 2560
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

// dinic
struct max_flow {
    struct edge { int to, cap, rev; };
    int V;
    vector<vector<edge>> G;
    vector<int> itr, level;

    max_flow(int V) : V(V) { G.assign(V,vector<edge>()); }

    void add_edge(int from, int to, int cap) {
        G[from].push_back((edge) {to, cap, (int) G[to].size()});
        G[to].push_back((edge) {from, 0, (int) G[from].size()-1});
    }

    void bfs(int s) {
        level.assign(V,-1);
        queue<int> q;
        level[s] = 0; q.push(s);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for(auto &e: G[v]){
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int& i = itr[v]; i < (int) G[v].size(); ++i) {
            edge& e = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int run(int s, int t) {
        int ret = 0, f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(V,0);
            while ((f = dfs(s, t, INT_MAX)) > 0) ret += f;
        }
        return ret;
    }
};

int n,A,B,ai,bi,val,ret;
//vector<pair<int,pi> > list;
vi lst;

int main(){
    I(n); I(A); I(B);
    REP(i,n){
        I(ai); I(bi);
        val = abs(ai-bi);
        if (val <= A || (B <= val && val <= 2*A) ){
            ret++;
        } else {
            //list.pb( mp (ai-bi, mp(ai,bi) ) ) ;
            lst.pb(ai-bi);
        }
    }
    sort(lst.begin(),lst.end());
    int ln = lst.size();
    int zero = upper_bound(lst.begin(),lst.end(),0) - lst.begin();

    max_flow pair_vanish = max_flow(ln+2);
    REP(i,zero) pair_vanish.add_edge(0,i+1,1);
    FOR(i,zero,ln) pair_vanish.add_edge(i+1,ln+1,1);

    REP(i,zero) { FOR(j,zero,ln){
        val = abs(lst[i]+lst[j]);
        if (val <= A || (B <= val && val <= 2*A) ) pair_vanish.add_edge(i+1,j+1,1);
    } }

    cout << ret + pair_vanish.run(0,ln+1) << endl;
}



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

// 整数xを素因数分解する
// (例)
// vector<int> v = f(20); // v = {2,2,5}
vector<int> factor(int x){
    int d=3, q;
    vector<int> vc;
    while( x >= 4 && (x % 2) == 0 ){
        vc.push_back( 2 );
        x /= 2;
    }
    q = x / d;
    while( q >= d ){
        if( (x % d) == 0 ){
            vc.push_back( d );
            x = q;
        }else{
            d += 2;
        }
        q = x / d;
    }
    vc.push_back( x );
    sort( vc.begin()  , vc.end() );
   	vc.erase( unique( vc.begin() , vc.end() ) , vc.end() );
    return vc;
}

int key_number(int x){
	vector<int> v = factor(x);
	int sum = 0;
	for(int i=0 ; i < v.size()-1 ; i++ ){
		sum += v[i];
	}
	return v[v.size()-1] - sum;
}

int main(){
	int a, b;
	while( cin >> a >> b , a || b ){
		bool ans = key_number(a) > key_number(b);
		cout << (ans? "a" : "b") << endl;
	}
}

Measured memory_bytes: 0
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		PriorityQueue<Integer> pq = new PriorityQueue<>();

		int n,k = 0;
		n = scanner.nextInt();
		k = scanner.nextInt(); // 買う果物

		while (n-- > 0){
			pq.add(scanner.nextInt());
		}

		int sum = 0;
		while (k-- > 0){
			sum += pq.poll();
		}
		System.out.println(sum);

	}

}


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

#define ll long long

string S, T, U;
ll A, B;


void input() {
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
}

void solve() {
  if (U == S) A--;
  else B--;
  cout << A << " " << B << endl;
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u){
        cout << a-1 << " " << b << endl;
    }
    else{
        cout << a << " " << b-1 << endl;
    }

}

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

using namespace std;

int r, g, b;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> r >> g >> b;

    if ((g + g + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char** argv) {
  int N, K;
  cin >> N >> K;
  long long h[100000];
  for (int i = 0; i < N; ++i) cin >> h[i];
  long long dp[100100];
  for (int i = 0; i < 100100; ++i) dp[i] = 1LL << 60;
  
  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      long long cost = dp[i] + abs(h[i] - h[i + j]);
      dp[i + j] = min(dp[i + j], cost);
    }
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

ll gcd(ll x, ll y) {
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

int main() {
    string s;
    string t;

    cin >> s;
    cin >> t;

    auto count = 0;
    for (auto i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) {
            ++count;
        }
    }

    cout << count;

    return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

int main(){

	int N,M;

	cin  >> N >> M;

	set<int>m;
	set<int>n;

	for(int i = 0;i < M;i++){
		int a,b;
		cin >> a >> b;
		if(a == 1){
			m.insert(b);
		}
		if(b == N){
			n.insert(a);
		}
	}

	for(auto c:m){
		if(n.count(c) != 0){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;

	return 0;

}


Measured memory_bytes: 9600
n,m = map(int,input().split())
a = list(map(int,input().split()))
M = max(a)
a = sorted(a,reverse=True)
t = 0
while M > 1:
    M = -(-M//2)
    t += 1
z = [[] for i in range(t+2)]
for i in range(n):
    s = 0
    b = a[i]
    while b > 1:
        b = -(-b//2)
        s += 1
    z[t-s].append(a[i])
count = 0
for i in range(t+1):
    z[i] = sorted(z[i])
    if count > m:
        break
    while z[i]:
        if count >= m:
            break
        c = z[i].pop()
        z[i+1].append(c//2)
        count += 1
ans = 0
for A in z:
    ans += sum(A)
print(ans)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define PI pair<int,int>

bool compare(PI p1,PI p2)
{
	return (p1.second+p1.first)<(p2.first+p2.second);
}

int32_t main()
{
		string s;
		cin>>s;
		int l=s.size();
		int l1=l/2;
		int c=0;
		for(int i=0;i<l1;i++)
		{
			if(s[i]!=s[l-i-1])
			{
				c++;
			}
		}
		cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10;
ll a[N]; ll ans[N],st[N],addtag[N],multag[N]; ll nowlen;
int n,m;
void prework(){ st[0]=0; a[0]=n; for (int i=0;i<=m;++i){ while (st[0]&&st[st[0]]>a[i]) --st[0]; st[++st[0]]=a[i]; } }
int get_pos(ll x,int r){ int l=1,mid,ret=r; while (l<=r){ mid=l+r>>1; if (st[mid]<=x) ret=mid,l=mid+1; else r=mid-1; } return ret; }
void solve(ll k,ll rest,int ed){
    if (!rest) return; if (rest<=st[1]){ addtag[1]+=k; addtag[rest+1]-=k; return; }
    int pre=get_pos(rest,ed); multag[pre]+=k*(rest/st[pre]); solve(k,rest%st[pre],pre-1);
}
int main(){
    ll rest,tmp,x; scanf("%d%d",&n,&m); nowlen=n; for (int i=1;i<=m;++i) scanf("%lld",a+i); prework(); multag[st[0]]=1;
    for (int i=st[0];i>=2;--i){ tmp=st[i]/st[i-1]; rest=st[i]%st[i-1]; multag[i-1]+=multag[i]*tmp; solve(multag[i],rest,i-1); }
    for (int i=1;i<=st[1];++i){ addtag[i]+=addtag[i-1]; printf("%lld\n",addtag[i]+multag[1]); }
    for (int i=st[1]+1;i<=n;++i) printf("0\n");
}

Measured memory_bytes: 4864
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, h[100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &h[i]);
  }
  
  int ans = 1;
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < i; j++){
      if(h[i] < h[j]){
        break;
      }
      else if(j == i - 1){
        ans += 1;
      }
    }
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n;
    cin>>n;
    int we[200001];
    int an[200001];
    an[0]=0;
    we[0]=0;
    we[1]=1;
    an[1]=1;
    for(int i=2; i<n; i++)
    {
        if(i%2)
        {
            we[i]=we[i/2]+1;
        }
        else
        {
            we[i]=we[i/2];
        }
        an[i]=an[i%we[i]]+1;
    }
    string s;
    cin>>s;
    long long int z=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='1')
            z++;
    }
    long long int a=0,b=0;
    long long int x=z-1,y=z+1;
    if(x==0)x=1;
    for(int i=0; i<n; i++)
    {
        a=(((long long int)(s[i]-'0'))+a*2)%x;
        b=(((long long int)(s[i]-'0'))+b*2)%y;
    }
    long long int wa[200001];
    long long int wb[200001];
    long long int oa=1,ob=1;
    for(int i=0; i<n; i++)
    {
        wa[n-1-i]=oa%x;
        wb[n-1-i]=ob%y;
        oa=oa*2%x;
        ob=ob*2%y;
    }
    for(int i=0; i<n; i++)
    {
        int o=(int)(s[i]-'0');
        if(o)
        {
            if(z>1)
                cout<<an[(a-wa[i]+x)%x]+1<<endl;
            else
                cout<<0<<endl;
        }
        else
        {
            cout<<an[(b+wb[i])%y]+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8420
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 2e5+5;
int n,k,val[N],ans=INF;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(k),read(n);
	for(ri i=1;i<=n;++i) read(val[i]);
	sort(val+1,val+1+n);
	for(ri i=1;i<n;++i) ans=min(ans,k-val[i+1]+val[i]);
	ans=min(ans,k-(val[1]+k-val[n]));
	print(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

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

    vector<int> a(n);
    cin >> a;

    int ans=0;

    REP(i,n)    ans+=(a[i]-1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A, B = map(int,input().split())

count=0 #初期化
for C in range(1,4):
    if A*B*C %2 ==1:
        count=count+1#Cに順番に１、２、３と代入していく中で、A×B×C が奇数になるたんびにcountに１加算していく
if count>0: #A×B×Cが奇数になるようなCが少なくとも１つ存在していたらYesと表示したい
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+10;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
int a[200005];
int n,k;
bool check(int x)
{
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>x)
		{
			sum+=(a[i]/x);
			if(a[i]%x)
			sum++;
			sum--;
			if(sum>k)
			return false;
		}
	}
	if(sum>k)
	return false;
	return true;
}
int main()
{
	sca(n);sca(k);
	for(int i=1;i<=n;i++)
	sca(a[i]);
	int minn=inf,maxn=0;
	for(int i=1;i<=n;i++)
	{
		minn=min(minn,a[i]);
		maxn=max(maxn,a[i]);
	}
	int l=1,r=maxn;
	while(l<r)
	{
		int mid=(l+r)/2;
		//cout<<mid<<"判断结果"<<check(mid)<<endl;
		if(check(mid))
		r=mid;
		else
		l=mid+1;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    string  s,s_r;
    cin >>s;
    s_r = s;
    reverse (ALL(s_r));
    int cnt = 0;
    REP(i,s.size()){
        if (s[i]!=s_r[i]) cnt ++;
    }
    
    cout << cnt/2 << endl;
    





    
}


Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

function Factorial(x: Int64): Int64;
begin
  if x = 0 then
    Result := 1
  else
    Result := x * Factorial(x - 1) mod 1000000007;
end;

var
  n:Int64;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(n);

    Writeln(Factorial(n));
    Readln;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 3328
import sys

SUITS = ('S', 'H', 'C', 'D')
cards = {suit:{i for i in range(1, 14)} for suit in SUITS}

n = input() # solo leer

for line in sys.stdin:
    suit, number = line.split()
    cards[suit].discard(int(number))

for suit in SUITS:
    for i in cards[suit]:
        print(suit, i)




Measured memory_bytes: 5608