akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    vector<int> v(n);
    rep(i,n)cin >> v[i];
    sort(ALL(v));
    double ans = (v[0] + v[1]) / 2.0;
    for(int i=2;i<n;i++){
        ans = (ans + v[i]) / 2.0;
    }
    cout << fixed << setprecision(6);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    m = list(map(int, input().split()))
    mean = sum(m) / len(m)
    std = (sum([(i - mean) ** 2 for i in m]) / len(m)) ** 0.5
    print("{:4f}".format(std))


Measured memory_bytes: 5680
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

string ans = "";

void solve(){
	//26の1乗からi乗までの和をaccum[i]とおく
	//ただしaccum[0] = 0;
	LL accum[14];
	accum[0] = 0;
	for(int i=1;i<14;i++){
		LL p = 1;
		for(int _=0;_<i;_++)p*=26LL;
		accum[i] = accum[i-1] + p;
	}

	for(int i=0;;i++){
		N--;
		char ch = char('a' + N%26LL);
		ans = ch + ans;
		N /= 26LL;
		if(N==0) break;
	}
	// if(ans.size()>=2){
	// 	for(int i=0;i<ans.size()-1;i++) ans[i];
	// }
}

int main(){
    cin >> N;

    solve();

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

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		List<Integer> l = new ArrayList<>();
		List<Integer> r = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int x = in.nextInt();
			if(x<0) l.add(-x);
			else r.add(x);
		}
		l.sort(Comparator.naturalOrder());
		int lsize = l.size();
		int rsize = r.size();
		
		int ans = Integer.MAX_VALUE;
		if(lsize>=k) ans = Math.min(ans, l.get(k-1));
		if(rsize>=k) ans = Math.min(ans, r.get(k-1));
		for(int i=0;i<lsize;i++) {
			if(i+1+rsize<k) continue;
			if(k-i-2<0) break;
			int distance = 2*l.get(i)+r.get(k-i-2);
			if(distance<ans) ans = distance;
		}
		for(int i=0;i<rsize;i++) {
			if(i+1+lsize<k) continue;
			if(k-i-2<0) break;
			int distance = 2*r.get(i)+l.get(k-i-2);
			if(distance<ans) ans = distance;
		}
		System.out.println(ans);
		in.close();
	}

}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    if(n<1200)cout << "ABC"<<endl;
    else if(n<2800)cout << "ARC"<<endl;
    else cout << "AGC"<<endl;
    return 0;
}


Measured memory_bytes: 256
import collections

N=int(input())
li=list(map(int,input().split()))

li_count=collections.Counter(li)
a=0
b=0
for k in li_count.keys():
    if li_count[k]>=4:
        if k>a:
            a=k
        if k>b:
            b=k
    elif li_count[k]>=2 and (k>a or k>b):
        if a>=b:
            b=k
        else:
            a=k
print(a*b)


Measured memory_bytes: 18600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int x; cin >> x;
    cout << ((x<1200) ? "ABC" : "ARC" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, q, m;
int a[20], flgs[2001];

int solve(int i, int remain) {
    if (remain == 0) return 1;
    else if (i >= n) return 0;
    
    return solve(i+1, remain-a[i]) || solve(i+1, remain);
}

int main(void){
    scanf("%d", &n);
    for (int i=0; i<n; i++) scanf("%d", &a[i]);
    scanf("%d", &q);
    for (int i=0; i<q; i++) {
        scanf("%d", &m);
        if (solve(0, m)) printf("yes\n");
        else printf("no\n");
    }
}



Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  int n = (int) s.size();
  if (s == string(n, s[0])) {
    cout << n * k / 2 << '\n';
  } else {
    int ans1 = 0;
    for (int i = 0; i + 1 < n; i++) {
      if (s[i % n] == s[(i + 1) % n]) {
        ++ans1;
        ++i;
      }
    }
    int ans2 = 0;
    for (int i = 0; i + 1 < 2 * n; i++) {
      if (s[i % n] == s[(i + 1) % n]) {
        ++ans2;
        ++i;
      }
    }
    cout << ans1 + (ans2 - ans1) * (k - 1) << '\n';
  }
  return 0;
}

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

avg = sum(W) / 2
total = 0

for i in range(N):
    total += W[i]
    if total >= avg:
        a = total
        b = total - W[i]
        break

print(min(2 * a - sum(W), sum(W) - 2 * b))


Measured memory_bytes: 9164
#include <stdio.h>

#define OUT1 0
#define OUT2 10

int main()
{
    int x, a;
    char buf[4];

    fgets(buf, 4, stdin);
    sscanf(buf, "%d %d", &x, &a);

    if (x < a)
    {
        printf("%d\n", OUT1);
    } else {
        printf("%d\n", OUT2);
    }

    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int x,a;
	cin >> x  >> a;
	cout << (x < a ? 0 : 10) << endl;
	return 0;
}


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

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

  int c = b-a-1;

  int ans=0;
  while(c>=0){
    ans+=c;
    c--;
  }
  ans-=a;
  
  cout << ans << endl;
  
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

const int MAX_N=10e2+5;
int n,m,dp[MAX_N][MAX_N];
char mat[MAX_N][MAX_N];

int main(){
  cin >> n >> m;
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
        cin >> mat[i][j];
    }
  }
  for(int i=0;i<MAX_N;++i){
    dp[i][0]=dp[0][i]=100000;
    mat[i][0]=mat[0][i]='.';
  }
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
        if(i==1 && j==1){
            dp[i][j]=(mat[i][j]=='#');
            continue;
        }
        int a=0,b=0;
        if(mat[i][j]=='#'){
            a=(mat[i][j]=='#')-(mat[i-1][j]=='#');
            b=(mat[i][j]=='#')-(mat[i][j-1]=='#');
        }
        dp[i][j]=min(dp[i-1][j]+a,dp[i][j-1]+b);
    }
  }
  cout << dp[n][m];
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main(){
    int target=0, max=9, sum=0, first_place;
    vector<int> s(5);
    
    for (int i=0; i< 5; i++ ) cin >> s[i];
    
    for (int i=0; i< 5; i++ ) {
        first_place = 0;
        if (100<s[i]){
            first_place = s[i] % 100 % 10;
        } else if (10<s[i]){
            first_place = s[i] % 10;
        } else {
            first_place = s[i];
        }
        
        if( 0 < first_place && first_place < max ) {
            max = first_place;
            target = i;
        }
    }
    
    for (int i=0; i< 5; i++ ) {
        if(i != target) {
          
          if (s[i] % 10 != 0 ){
              sum += (s[i] / 10 + 1) * 10;
          } else if(s[i] < 10) {
              sum += 10;
          } else {
              sum += s[i];
          }
          //cout << s[i] << endl;
        }
    }
    sum += s[target];
    
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int a, b, c, c1, c2;
  c1 = c2 = 0;
  while (scanf("%d,%d,%d", &a, &b, &c) != EOF){
    if (c * c - (a * a + b * b) == 0){
      c1++;
    }
    if (a == b){
      c2++;
    }
  }
  printf("%d\n%d\n", c1, c2);

  return 0;
}

Measured memory_bytes: 1020
N = int(input())
S = [None]*N
P = [None]*N
I = [None]*N
for i in range(N):
    tmp = input().split()
    S[i] = tmp[0]
    P[i] = int(tmp[1])
    I[i] = i+1


def less(a, b):
    if a[0] == b[0]:
        if a[1] == b[1]:
            return a[2] < b[2]
        return a[1] > b[1]
    return a[0] < b[0]


for i in range(N):
    for j in range(i+1, N):
        if not less([S[i], P[i], I[i]], [S[j], P[j], I[j]]):
            S[i], S[j] = S[j], S[i]
            P[i], P[j] = P[j], P[i]
            I[i], I[j] = I[j], I[i]

for i in range(N):
    print(I[i])


Measured memory_bytes: 39920
#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,k;cin>>n>>k;
    int a[n];
    memset(a,0,sizeof(a));
    
    rep(i,k){
        int d;cin>>d;
        rep(j,d){
            int c;cin>>c;
            --c;
            ++a[c];
        }
    }
    sort(a, a+n);
    int ans = 0;
    rep(i,n){
        if(a[i]==0)++ans;
        else break;
    }
    cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n,tt,mn=10000000,mx=-10000000; long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>tt;
        sum+=tt;
        if(mn>tt) mn=tt;
        if(mx<tt) mx=tt;
    }
    cout<<mn<<' '<<mx<<' '<<sum<<'\n';
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  vector<int> p,ne;
  vector<P> res;
  rep(i,n){
    int x;cin >> x;
    if(x >= 0)p.push_back(x);
    else ne.push_back(x);
  }
  if(p.size() >= 2 && ne.size() >= 1){
    int o = ne[0];
    for(int i = 0;i < p.size()-1;i++){
      res.push_back(make_pair(o,p[i]));
      o = o-p[i];
    }
    res.push_back(make_pair(p.back(),o));
    o = p.back()-o;
    for(int j = 1;j < ne.size();j++){
      res.push_back(make_pair(o,ne[j]));
      o = o-ne[j];
    }
    cout << o << endl;
    for(P k : res)cout << k.first << " " << k.second << endl;
  }else if(p.size() == 1){
    int o = p[0];
    for(auto au : ne){
      res.push_back(make_pair(o,au));
      o = o-au;
    }
    cout << o << endl;
    for(P k : res)cout << k.first << " " << k.second << endl;
  }else if(p.size() >= 2 && ne.size() == 0){
    sort(ALL(p));
    int o = p[0];
    for(int i = 1;i < p.size()-1;i++){
      res.push_back(make_pair(o,p[i]));
      o = o-p[i];
    }
    res.push_back(make_pair(p.back(),o));
    o = p.back()-o;
    cout << o << endl;
    for(P k : res)cout << k.first << " " << k.second << endl;
  }else if(p.size() == 0){
    sort(ALL(ne),greater<int>());
    int o = ne[0];
    for(int i = 1;i < ne.size();i++){
      res.push_back(make_pair(o,ne[i]));
      o = o-ne[i];
    }
    cout << o << endl;
    for(P k : res)cout << k.first << " " << k.second << endl;
  }




  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int k, x;
  	cin >> k >> x;
	rep3(i,x-k+1,x+k-1) {
      	cout << i;
      	if(i!=x+k-1) cout << " ";
  		else cout << endl;
    }  
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	char a,b;
  	cin>>a>>b;
  
  	if((a=='H' && b=='H')||(a=='D' && b=='D')){
    	cout<<'H'<<endl;
    }else{
    	cout<<'D'<<endl;
    }
       
       
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, k = 0, minn = 99999;
string s, a;
int main()
{
	cin >> s >> a;
	int ls = s.size(), la = a.size();
	minn = la;
	for(int i = 0; i < ls - la + 1; i ++)
	{
		int p = i, sum = 0;
		for(int j = 0; j < la; j ++)
		{
			if(s[p] != a[j])
			{
				sum ++;
			}
			p ++;
		}
		minn = min(minn, sum);
	 } 
	 printf("%d", minn);
 	return 0;
}
//abcdefg
//cdefgh

Measured memory_bytes: 3756
#include "bits/stdc++.h"
using namespace std;
int main() {
  int N, M, a, b; cin >> N >> M;
  vector<vector<int>> V(100001);
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    V[a].push_back(b);
  }
  long long ans = 0;
  priority_queue<int> pq;
  for (int i = M - 1; i >= 0; i--) {
    for (auto j: V[M - i])
      pq.push(j);
    if (pq.size()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  string s; cin >> s;

  reverse(s.begin(),s.end());
  s += '0';
  int n = s.size();
  vector<vector<int>> dp(n+1, vector<int>(2, INF));
  dp[0][0] = 0;
  for(int i = 0; i < n; i++){
    int d = s[i]-'0';
    dp[i+1][0] = min(dp[i][0] + d, dp[i][1] + d+1);
    if(d+1 == 10) dp[i+1][0] = min(dp[i+1][0], dp[i][1] + 1);
    dp[i+1][1] = min(dp[i][0] + 10 - d, dp[i][1] + 10 - d - 1);
  }
  int ans = dp[n][0];
  cout << ans << endl;

  return 0;
}


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

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

int main() {
  
  string s ;
  cin >> s;
  cout << s.at(0) << s.size()-2 << s.at(s.size()-1);


}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

bool check(ll x) {
  ll res = 0;
  rep(i, n) {
    res += a[i] / x;
    if (a[i] % x == 0) res--;
  }
  if (res <= k)
    return true;
  else
    return false;
}

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

  cin >> n >> k;
  rep(i, n) cin >> a[i];
  ll le = 1, ri = 10000000000, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (check(mid))
      ri = mid;
    else
      le = mid;
  }
  if (check(le))
    Cout(le);
  else
    Cout(ri);
  return 0;
}

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

using namespace std;

int main(void) {
    int n, l;
    cin>>n>>l;
    vector<string> ss(n);
    for (int i=0; i<n; ++i) {
        cin>>ss[i];
    }
    sort(ss.begin(), ss.end());
    for (string s : ss) {
        cout<<s;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <set>
#include <stdlib.h>
#include <algorithm>
using namespace std;

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

    set<int>s;

    for(int i=-10; i<=110; i++){
        s.insert(i);
    }

    int t;
    for(int i=0; i<n; i++){
        cin >> t;
        s.erase(t);
    }

    vector<int>a;
    for(auto r : s){
        a.push_back(r);
    }

    n = a.size();
    int tmp=10000, ans=0;

    for(int i=0; i<n; i++){
        if(tmp > abs(a[i]-x)) tmp = abs(a[i]-x), ans = a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a;
  Cout(a + a * a + a * a * a);
  return 0;
}

Measured memory_bytes: 3560
def main():
    a,b,c,k=list(map(int,input().split()))
    if(k%2==0):
        ans=a-b
    else:
        ans=b-a
    if(ans>10**18):
        print("Infinity")
        return;
    print(ans)

if __name__=="__main__":
    main()

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

struct dice {
    int d[6], f[6];

    void rotation(char com){
        if(com == 'E'){
            int tmp = d[0];
            d[0] = d[3];
            d[3] = d[5];
            d[5] = d[2];
            d[2] = tmp;
        }
        else if(com == 'S'){
            int tmp = d[4];
            d[4] = d[5];
            d[5] = d[1];
            d[1] = d[0];
            d[0] = tmp;
        }
        else if(com == 'N'){        
            int tmp = d[0];
            d[0] = d[1];
            d[1] = d[5];
            d[5] = d[4];
            d[4] = tmp;
        }
        else if(com == 'W'){
            int tmp = d[0];
            d[0] = d[2];
            d[2] = d[5];
            d[5] = d[3];
            d[3] = tmp;        
        }
        else if(com == 'R'){
            int tmp = d[3];
            d[3] = d[1];
            d[1] = d[2];
            d[2] = d[4];
            d[4] = tmp;
        }
    }

    int guess(int U, int F){
        int cnt = 0;
        while(U != d[0]){
            if(cnt % 2)rotation('N');
            else rotation('W');

            if(cnt > 10)return -1;
            cnt++;
        }

        while(F != d[1]){
            rotation('R');
            cnt++;
            if(cnt > 20)return -1;
        }

        return d[2];
    }

    bool same_dice(){
        rep(i,6){
            if(i%2)rotation('N');
            else rotation('W');

            rep(j,4){
                rotation('R');
                bool same = true;
                rep(k,6)if(d[k] != f[k])same = false;
                if(same)return true;
            }
        }
        return false;
    }
};

int main(){
    int n;
    cin >> n;
    dice D;
    rep(i,6)cin >> D.d[i];
    rep(i,n-1){
        rep(j,6)cin >> D.f[j];
        if(D.same_dice()){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(){
    int a,b,c;

    cin >> a >> b >> c;

    int max = a*10+b+c;
    if(max < b*10+a+c) max = b*10+a+c;
    if(max < c*10+a+b) max = c*10+a+b;
    cout << max << endl;
}

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

int main() {

    int N;
    cin >> N;
    N *= 3;
    ll a[N];
    rep(i, N) cin >> a[i];

    sort(a, a+N);
    ll sum = 0;

    for (int i = N/3; i < N; i += 2) {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5992
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def main():
    r = solve()
    print(r)

def solve():
    N = iip(False)
    S = input()

    dp = [[0]*(N+1) for _ in range(N+1)]
    for i in reversed(range(N)):
        for j in reversed(range(N)):
            if S[j] == S[i]:
                dp[i][j] = dp[i+1][j+1]+1

    ans = 0
    for i in range(N):
        for j in range(N):
            if i >= j:
                continue

            cnt = dp[i][j]
            if cnt+i > j:
                continue
            ans = max(ans, cnt)

    return ans


#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Measured memory_bytes: 231432
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn solve(i: usize, a: usize, b: usize, n: usize, ma: usize, mb: usize, arr: &Vec<(usize, usize, i32)>, dp: &mut Vec<Vec<Vec<i32>>>) -> i32 {
    if i == n { return if a != 0 && b != 0 && a * mb == b * ma { 0 } else { 5000 } }
    if dp[i][a][b] == 0 {
        let mut r = solve(i+1, a, b, n, ma, mb, arr, dp);
        let (aa, bb, c) = arr[i];
        r = cmp::min(r, solve(i+1, a + aa, b + bb, n, ma, mb, arr, dp) + c);
        dp[i][a][b] = r;
    }
    return dp[i][a][b];
}

fn main() {
    let (n, ma, mb) = get!(usize, usize, usize);
    let mut arr = Vec::new();
    for _ in 0..n {
        arr.push(get!(usize, usize, i32));
    }
    let mut dp = vec![vec![vec![0; 401]; 401]; n];
    let r = solve(0, 0, 0, n, ma, mb, &arr, &mut dp);
    println!("{}", if r <= 4000 { r } else { -1 });
}

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

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

    vector<int> m;
    int input;
    for (int i = 0; i < N; i++)
    {
        cin >> input;
        m.push_back(input);
        X -= input;
    }

    sort(m.begin(), m.end());

    cout << (X / m.at(0)) + N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int n, m;
	cin >> n >> m;
	int wa = 0;
	int ac = 0;
	vector<pair<int, string>> ss(m);
	vector<bool> aow(n);
	vector<int> wwa(n);
	rep(i, n) {
		aow[i] = false;
	}
	rep(i, m) {
		int ff;
		cin >> ff;
		string sa;
		cin >> sa;
		if (aow[ff - 1] == false) {
			if (sa == "WA")
				wwa[ff - 1]++;
			if (sa == "AC") {
				aow[ff - 1] = true;
			}
		}
	}
	rep(i, n) {
		if (aow[i]) {
			wa += wwa[i];
			ac++;
		}
	}
	cout << ac << " " << wa;
}



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

int main() {
  set<char> s;
  rep(i,3){
    char a; cin >> a;
    s.insert(a);
  }
  if(s.size() == 3){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int r, c, num, ssum = 0,total=0;
		int i, j;
		Scanner scan = new Scanner(System.in);
		r = scan.nextInt();
		c = scan.nextInt();
		int[] vsum=new int[c];
		for (i = 0; i < r; i++) {
			for (j = 0; j < c; j++) {
				num = scan.nextInt();
				ssum += num;
				vsum[j]+=num;
				System.out.print(num+" ");
			}
			System.out.println(ssum);
			total+=ssum;
			ssum=0;
		}
		for(i=0;i<c;i++) {
			System.out.print(vsum[i]+" ");
		}
		System.out.println(total);

	}

}

Measured memory_bytes: 39156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  cout << (N - 1) / 2 << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	string s;
	cin >> s;
	ll n = s.length();
	ll ans = INF;
	rep(i, 26) {
		char target = 'a' + i;
		ll res = 0;
		ll res2 = 0;
		rep(i, n) {
			if (s[i] == target) {
				res = max(res, res2);
				res2 = 0;
			}
			else {
				res2++;
			}
		}
		res = max(res, res2);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector <int> a(100,0);
    int alice = 0,bob = 0;
    REP(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    REP(i,n){
        if(i%2){
            bob+=a[i];
        }
        else{
            alice+=a[i];
        }
    }

    cout << alice - bob << endl;
    return 0;
}

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

void call(int n){
	int i, x;
	for(i = 1; i <= n; i++){
		x = i;
		if(x % 3 == 0){
			cout << " " << i;
		}else{
			while(x){
				if (x % 10 == 3){
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	call(n);
    return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N, K, R, S, P;
    string T;

    cin >> N >> K >> R >> S >> P >> T;

    int count = 0;

    for(int i = 0; i < K; i++) {
        int pos = 0;
        int re = -1;
        while(i + pos * K < N) {
            if(T[i + pos * K] == 'r') {
                if(re != 2) {
                    count += P;
                    re = 2;
                } else {
                    if(i + (pos + 1) * K < N) {
                        if(T[i + (pos + 1) * K] == 's') {
                            re = 1;
                        } else {
                            re = 0;
                        }
                    }
                }
            } else if(T[i + pos * K] == 's') {
                if(re != 0) {
                    count += R;
                    re = 0;
                } else {
                    if(i + (pos + 1) * K < N) {
                        if(T[i + (pos + 1) * K] == 'p') {
                            re = 2;
                        } else {
                            re = 1;
                        }
                    }
                }
            } else {
                if(re != 1) {
                    count += S;
                    re = 1;
                } else {
                    if(i + (pos + 1) * K < N) {
                        if(T[i + (pos + 1) * K] == 'r') {
                            re = 0;
                        } else {
                            re = 2;
                        }
                    }
                }
            }
            pos++;
        }
    }

    cout << count << endl;
}


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

int main() {
int ans=0;
string s,s2;
cin>>s;
s2=s;
reverse(s2.begin(),s2.end());
rep(i,s.size()/2)
  if(s.at(i)!=s2.at(i)) ans++;
cout<<ans<<endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 


const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int cost[1010][1010];
int main() {
    int H, W; scanf("%d%d", &H, &W);
    int sx, sy, gx, gy; scanf("%d%d%d%d", &sx, &sy, &gx, &gy);
    sx--, sy--, gx--, gy--;
    
    vector<string> board(H);
    for(int i=0; i<H; i++) cin >> board[i];

    fill(cost[0], cost[H], INF);
    deque< pair<int, int> > que;
    cost[sx][sy] = 0;
    que.emplace_back(sx, sy);
    while(que.size()) {
        int x, y; tie(x, y) = que.front(); que.pop_front();
        for(int dx=-2; dx<=2; dx++) {
            for(int dy=-2; dy<=2; dy++) {
                int nx = x + dx, ny = y + dy;
                int delta = abs(nx - x) + abs(ny - y);
                int c = (delta == 1 ? 0 : 1);
                if(nx < 0 or nx >= H or ny < 0 or ny >= W) continue;
                if(board[nx][ny] == '#') continue;
                if(cost[nx][ny] > cost[x][y] + c) {
                    cost[nx][ny] = cost[x][y] + c;
                    if(c == 0) que.emplace_front(nx, ny);
                    else que.emplace_back(nx, ny);
                }
            }
        }
    }

    if(cost[gx][gy] == INF) cout << -1 << endl;
    else cout << cost[gx][gy] << endl;
    return 0;
}


Measured memory_bytes: 9604
H,W = gets.split.map(&:to_i)
a = []
H.times do
  a << gets.split.map(&:to_i)
end

ans = []

(H-1).times do |h|
  W.times do |w|
    if a[h][w].odd?
      a[h+1][w] += 1
      ans << [h+1,w+1, h+1+1, w+1] * ' '
    end
  end
end

(W-1).times do |w|
  if a[H-1][w].odd?
    a[H-1][w+1] += 1
    ans << [H, w+1, H, w+1+1] * ' '
  end
end

puts ans.size
puts ans


Measured memory_bytes: 35196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    //周期をcとする
    ll c = a+b;
    //はみ出してない部分
    ll ans = a * (n/c);
    //はみ出している部分に青玉がA個あるかどうか
    ans += min(n%c, a);
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = n - 1; i > 0; i--) {
        if (h[i - 1] - h[i] > 1) {
            cout << "No" << endl;
            return 0;
        }
        if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; scanf("%d", &n);
    printf("%d\n", (n + 1) / 2);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;

namespace AOJ_Hello_World {
	class Program {
		static void Main (string[] args) {
			var sab = Console.ReadLine();
			long[] a = new long[3];
			for (int i = 0;i < 3;i++) {
				a[i] = long.Parse( sab.Split(' ')[i]);
			}

			long tmp = 0;
			int minIndex = 0;

			for (int i = 0;i < a.Length;i++) {
				tmp = a[i];
				minIndex = i;
				for (int j = i+1;j < a.Length;j++) {
					if (a[j] < tmp) {
						tmp = a[j];
						minIndex = j;
					}
				}
				if (minIndex != i) {
					a[minIndex] = a[i];
					a[i] = tmp;
				}
			}

			Console.WriteLine("{0} {1} {2}",a[0],a[1],a[2]);

			Console.Read();
		}
	}
}

Measured memory_bytes: 5632
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long h = Integer.parseInt(sc.next());
		long[] a = new long[n];
		long[] b = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
			b[i] = Long.parseLong(sc.next());
		}
		Arrays.sort(a);
		Arrays.sort(b);
		int ans = 0;
		for (int i = n - 1; i >= 0 && a[n - 1] <= b[i]; i--) {
			h -= b[i];
			ans++;
			if (h <= 0)
				break;
		}
		while (h > 0) {
			h -= a[n - 1];
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 50640
N = int(input())
A = list(map(int, input().split()))
B = 1
ans = 0
for i in range(N):
    for j in range(32, 0, -1):
        if A[i] % (2**j) == 0:
            ans += j
            A[i] = A[i] / (2**j)
print(ans)


Measured memory_bytes: 4148
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>
#include<numeric>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main() {
	long long N, K, cnt = 0, tmp, ans = 0;

	long long A, P;
	cin >> A >> P;
	long long nop = 3*A + P;
	cout << nop / 2;

	char qq;
	cin >> qq;
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll modPow(int a, int n, int mod){
  if(n == 0)
    return 1;
  if(n%2 == 0){
    ll t = modPow(a, n/2, mod);
    return t*t%mod;
  }
  ll t = modPow(a, n-1, mod);
  return a*t%mod;
}

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  int p = 998244353;
  
  ll ans = 0;
  n--;
  
  ll com[200010];
  ll fac[200010], inv[200010], finv[200010];
  fac[0] = 1;
  fac[1] = n;
  inv[1] = 1;
  finv[0] = finv[1] = 1;
  com[0] = 1;
  com[1] = n;
  rep(i, 2, 200010){
    fac[i] = fac[i-1] * (n-i+1) %p;
    inv[i] = p-inv[p%i]*(p/i) %p;
    finv[i] = finv[i-1] * inv[i] %p;
    com[i] = fac[i]*finv[i] %p;
  }
  
  rep(i, 0, k+1){
    ll t = m;
    t = t*com[i]%p;
    t = t*modPow(m-1, n-i, p)%p;
    ans = (ans + t)%p;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 9892
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int a, b;
        a = input.nextInt();
        b = input.nextInt();
        System.out.printf("%d %d %.7f", a / b, a % b,(double)a / b);
    }         
}

Measured memory_bytes: 17372
#include <iostream>

#include <algorithm>

int main()
{
	long long int K;
	int N;
	std::cin >> K >> N;


	long long int sum = 0;
	int maxx = -1;
	int prev;
	std::cin >> prev;
	int first = prev;
	for (int i = 1; i < N; ++i) {
		int x;
		std::cin >> x;
		sum += x - prev;
		maxx = std::max(maxx, x - prev);
		prev = x;
	}
		
	int x = K - prev + first;
	sum += x;
	maxx = std::max(maxx, x);

	std::cout << sum - maxx;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
//#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[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;
}
signed main() {
    vector<int> V(5);
    rep(i, 5) cin >> V[i];
    sort(all(V));
    int ans = INF;
    do {
        int now = 0;
        rep(i, 5) {
            now = (now + 9) / 10 * 10;
            now += V[i];
        }
        chmin(ans, now);
    } while(next_permutation(all(V)));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char moji[200],moji2[100], ao[100];

	int a,b,c;
	scanf("%s",&moji);
	scanf("%s",&ao);
	strcpy(moji2, moji);
	strcat(moji,moji2);

	if(strstr(moji,ao) != NULL)
	{printf("Yes\n");
	}else{
		printf("No\n");
	}

	//scanf("%d",&a);
 return 0;
} 

Measured memory_bytes: 540
#include <stdio.h>

int main(void){
    int n, i, j;
    int a;
    int ans;
    scanf("%d", &n);
    int x[n];
    for(i = 0; i < n; i++){
        scanf("%d", &x[i]);
    }

    for(i = 0; i <= 100; i++){
        a = 0;
        for(j = 0; j < n; j++){
            a += (i - x[j]) * (i - x[j]);
        }
        if(i == 0 || ans > a){
            ans = a;
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
vector<int>g[maxn];
string code;
int n, k;
int x[maxn];

bool valid() {
    if(code[0] == '0' || code[n-1] == '1') return false;
    for(int i=1;i<n;i++) {
        if(code[i-1] != code[n-i-1]) return false;
    }
    return true;
}

vector<int>free_nodes;

int main() {
    cin>>code;
    n = code.length();

    if(!valid()) {
        cout<<-1;
        return 0;
    }

    for(int i=0;i<n;i++) {
        if(code[i]=='1') {
            k++;
            x[k] = i+1;
        }
    }

    for(int i=1;i<=n;i++) {
        if(i>k) free_nodes.pb(i);
    }

    for(int i=1;i<=k;i++) {
        g[i].pb(i+1);
    }

    for(int i=1;i<=k;i++) {
        int extra = x[i] - x[i-1] - 1;
        if(free_nodes.size() < extra) {
            cout<<-1;
            return 0;
        }

        int br=0;
        while(br < extra) {
            g[i].pb(free_nodes.back());
            free_nodes.pop_back();
            br++;
        }
    }

    for(int i=1;i<=n;i++) {
        for(int j:g[i]) {
            cout<<i<<" "<<j<<"\n";
        }
    }


    return 0;
}


Measured memory_bytes: 7296