akhauriyash/Code-Regression huggingface dataset:
//soale D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e4 + 20, M = 1e2 + 20;
ll h, w, n, a[N], p[M][M];
vector <int> v;
int main(){
	cin >> h >> w;
	cin >> n;
	for(int i = 1 ; i <= n ; i ++){
		cin >> a[i];
		for(int j = 0; j < a[i]; j ++){
			v.push_back(i);
		}
	}
	for(int i = 0; i < v.size(); i ++){
		if((i + 1) % w != 0){
		if((((i + 1)/w) + 1) % 2 == 1){
			if((i + 1) % w != 0){
			    p[(i + 1)/w + 1][(i + 1) % w] = v[i];
		    }
		    else{
		    	p[(i + 1)/w][w] = v[i];
			}
		}
		else{
		    p[(i + 1)/w + 1][w - ((i + 1) % w) + 1] = v[i];
		   // cout << p[2][5] << endl;
		}
	    }
	    else{
	    	if(((i + 1)/w) % 2 == 1){
			if((i + 1) % w != 0){
			    p[(i + 1)/w + 1][(i + 1) % w] = v[i];
		    }
		    else{
		    	p[(i + 1)/w][w] = v[i];
			}
		    }
		    else{
		        p[(i + 1)/w][1] = v[i];
		    }
		}
	}
	for(int i = 1; i <= h; i ++){
		for(int j = 1; j <= w; j ++){
			cout << p[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
#define cerr if(0)cout
int main(){
	// no distinct black group of squares share the a corner or side
	FAST
	ll q;
	cin>>q;
	vector<ll> p3(31, 0);
	p3[0]=1; FOR(i,1,31)p3[i]=p3[i-1]*3;
	while(q--){
		array<ll, 2> a, b;
		cin>>a[0]>>a[1]>>b[0]>>b[1];--a[0],--a[1],--b[0],--b[1];
		ll ans=0;
		FOR(i,0,30){
			if(a[0] / p3[i] == b[0] / p3[i] && a[1] / p3[i] == b[1] / p3[i]) continue;
			cerr<<"hi: "<<i<<'\n';
			// check if got p3[i] square blocking
			// belongs to p3[i+1] (if u consider whole grid)
			// check row
			if(a[0] / p3[i] == b[0] / p3[i] && 
				a[0] / p3[i] % 3 == 1 &&
				llabs(a[1]/p3[i]-b[1]/p3[i]) != 1
			) {
				cerr<<i<<"!\n";
				ans=max(ans,min(
					a[0]%p3[i+1]-p3[i]+1 + b[0]%p3[i+1]-p3[i]+1,
					p3[i]*2-a[0]%p3[i+1] + p3[i]*2-b[0]%p3[i+1]
				) - llabs(a[0]-b[0]));
			}
			if(a[1] / p3[i] == b[1] / p3[i] && 
				a[1] / p3[i] % 3 == 1 && 
				llabs(a[0]/p3[i]-b[0]/p3[i]) != 1
			) {
				cerr<<i<<"!\n";
				ans=max(ans,min(
					a[1]%p3[i+1]-p3[i]+1 + b[1]%p3[i+1]-p3[i]+1,
					p3[i]*2-a[1]%p3[i+1] + p3[i]*2-b[1]%p3[i+1]
				) - llabs(a[1] - b[1]));
			}
			// take out prev squares
		}
		cerr<<ans<<'\n';
		ans = llabs(a[0]-b[0]) + llabs(a[1]-b[1]) + ans;
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

int main() {
    int N;
    std::string s; 
    std::cin >> N >> s;
    

    /* cut文字列を分割する位置 0~cut-1, cut~N-1で分ける*/
    int res = 0;
    for (int cut = 1; cut < N; ++cut) {
      int tmp = 0;
      for (int i = 0; i < 26; ++i) {
        if (s.find('a'+i) < cut && s.find('a'+i, cut) != std::string::npos) {
          ++tmp;    
        }
      }      
      res = std::max(res, tmp);
    }

    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;

ll ksm(ll x,ll n)
{
    ll r=1;
    while(n){
        if(n%2)
            r=r*x%mod;
        x=x*x%mod;
        n/=2;
    }
    return r;
}
ll inv(ll x)
{
     return ksm(x, mod-2);
}
ll C(ll n,ll m)
{
    ll fz=1,fm=1;
    for(int i=0;i<m;i++){
        fz=fz*n%mod;
        n--;
    }
    while(m){
        fm=fm*m%mod;
        m--;
    }
    return fz * inv(fm) % mod;
}

ll Lucas(ll n, ll m)
{
     if(m == 0)return 1;
     return C(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}
int main()
{
  //  ios::sync_with_stdio(false);
    ll n ,a ,b;
    cin >> n >> a >> b;
    ll ans=ksm(2,n)-1-C(n,a)-C(n,b);
    while(ans<0)
        ans+=mod;
    cout << ans;



    return 0;
}


Measured memory_bytes: 256
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run(){
	s := next()
	t := next()
	count := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			count++
		}
	}
	Println(count)
}
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(1<<n);
  rep(i, 1<<n) cin >> a[i];
  vint x = a;
  rep(i, n) {
    rep(s, 1<<n) {
      if((s>>i)&1) {
	chmax(x[s], a[s]+a[s^(1<<i)]);
	chmax(a[s], a[s^(1<<i)]);
      }
    }
  }
  int ans = x[0];
  reps(i, 1, 1<<n) {
    chmax(ans, x[i]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	cout << (a+b)%24 << endl;
	return 0;
}

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

using namespace std;

const int N = 200020;

int a[N], b[N], A[N];
pair<int, int> X[N], Y[N];

int main()
{
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for(int i = 1; i <= n; i++)
		scanf("%d", &b[i]);
	for(int x = 0; x <= 28; x++)
	{
		int S = 1 << (x + 1), X0 = 0, Y0 = 0, cnt = 0;
		for(int i = 1; i <= n; i++)
			A[i] = a[i] % S;
		sort(A + 1, A + 1 + n);
		for(int i = n; i; i--)
			if(i == n || A[i] != A[i + 1])X[++X0] = make_pair(A[i], i);
		reverse(X + 1, X + 1 + X0);
		for(int i = 1; i <= n; i++)
			if(i == 1 || A[i] != A[i - 1])Y[++Y0] = make_pair(A[i], i);
		Y[Y0 + 1] = make_pair(A[n] + 1, n + 1);
		for(int i = 1; i <= n; i++)
		{
			int nowv = S - b[i] % S;
			int x1 = X[lower_bound(X + 1, X + 1 + X0, make_pair(nowv, 0)) - X - 1].second;
			nowv = (S >> 1) - b[i] % S;
			int x2 = Y[lower_bound(Y + 1, Y + 1 + Y0, make_pair(nowv, 0)) - Y].second;
			nowv = S + (S >> 1) - b[i] % S;
			int x3 = Y[lower_bound(Y + 1, Y + 1 + Y0, make_pair(nowv, 0)) - Y].second;
			if(x1 >= x2)cnt += x1 - x2 + 1;
			cnt += n - x3 + 1;
		}
		if(cnt & 1)ans += 1 << x;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5760
local mfl, mce = math.floor, math.ceil
local bls, brs = bit.lshift, bit.rshift
local n = io.read("*n")
local a, b, c = io.read("*n", "*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local tot = bls(1, 2 * n)
local ret = false
local mab = math.abs
for i = 0, tot - 1 do
  local ta, tb, tc = 0, 0, 0
  local ca, cb, cc = 0, 0, 0
  for j = 1, n do
    if i % 4 == 1 then
      ta = ta + t[j]
      ca = ca + 1
    elseif i % 4 == 2 then
      tb = tb + t[j]
      cb = cb + 1
    elseif i % 4 == 3 then
      tc = tc + t[j]
      cc = cc + 1
    end
    i = brs(i, 2)
  end
  if 0 < ca * cb * cc then
    local v = mab(ta - a) + mab(tb - b) + mab(tc - c)
    v = v + (ca + cb + cc - 3) * 10
    if not ret then ret = v
    elseif v < ret then ret = v
    end
  end
end
print(ret)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

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

int main()
{
  ll h;
  cin>>h;

  cout<<f(h)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
import os
# import math
# input = sys.stdin.readline

def int_array():
    return list(map(int, input().strip().split()))


def str_array():
    return input().strip().split()

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);x

def take_input():
	if os.environ.get("check"):
		sys.stdin = open('input.txt', 'r') 
		sys.stdout = open('output.txt', 'w')
		
take_input()
######################### TEMPLATE ENDS HERE #################################

n = int(input())
if n >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61916
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();   
    int b = sc.nextInt();
    if (n * a < b)
      System.out.println(n * a);
    else 
      System.out.println(b);
  }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  for (int i = 0; i < (1 << 3); i++) {
    int ans = (s[0] - '0');
    for (int j = 0; j < 3; j++) {
      if (i & (1 << j)) {
        ans += (s[j + 1] - '0');
      } else {
        ans -= (s[j + 1] - '0');
      }
    }
    if (ans == 7) {
      cout << s[0];
      for (int j = 0; j < 3; j++) {
        if (i & (1 << j)) {
          cout << "+" << s[j + 1];
        } else {
          cout << "-" << s[j + 1];
        }
      }
      cout << "=7" << '\n';
      break;
    }
  }

  return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  vector<int> A(3);
  rep(i, 3) cin >> A[i];

  std::sort(A.begin(), A.end());

  int sum = A[1] - A[0] + A[2] - A[1];
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MaxN = 1000;
using namespace std;
int cnt[MaxN + 5], n, m;
char s[MaxN + 5];
void Init() {
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1;i <= n;i++) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++) cnt[s[j]]++;
	}
}

void Solve() {
	int cnt_1 = 0, cnt_4 = 0, cnt_2 = 0;
	for (char i = 'a'; i <= 'z'; i++) {
		if(cnt[i] % 4 == 0) cnt_4++;
			else if(cnt[i] % 4 == 2) cnt_2++;
				else if(cnt[i] % 2 == 1) cnt_1++;
	}
	if((n & 1) && (m & 1)) {
		if((cnt_2 <= n / 2 + m / 2) && cnt_1 == 1) printf("Yes\n");
			else printf("No\n");
	}
	else if((n & 1) && (m % 2 == 0)) {
		if((cnt_2 <= m / 2) && (cnt_1 == 0)) printf("Yes\n");
			else printf("No\n");
	}
	else if((n % 2 == 0) && (m & 1)) {
		if((cnt_2 <= n / 2) && (cnt_1 == 0)) printf("Yes\n");
			else printf("No\n");
	}
	else {
		if(cnt_2 == 0 && cnt_1 == 0) printf("Yes\n");
			else printf("No\n");
	}
}
int main()
{
	while(~scanf("%d%d", &n, &m)) {
		Init();
		Solve();
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<vector<char>> field(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
        }
    }

    int ans = 0;
    for (int tmp = 0; tmp < (1 << H); tmp++) {
        bitset<6> l(tmp);
        for (int tmp2 = 0; tmp2 < (1 << W); tmp2++) {
            bitset<6> r(tmp2);
        
            int sum = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (l.test(i) || r.test(j)) continue;
                    if (field[i][j] == '#') sum++;
                }
            }

            if (sum == K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

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

   string s;cin >> s;
   for(int i = 0;i < s.size();i++){
        if(s[i] == '7'){
            cout << "Yes" << '\n';
            return 0;
        }
   } 
   cout << "No" << '\n';
}


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

int go(int n)
{
    if(n==0)return 0;
    return go(n%__builtin_popcount(n))+1;
}

const int MAXN=200005;
char str[MAXN];
int pw[2][MAXN];

int main()
{
    int n;
    scanf("%d%s",&n,str);
    int cnt=0;
    for(int i=0;i<n;i++)
        cnt+=(str[i]-'0');
    for(int t=0;t<2;t++)
    {
        if(cnt+1-2*t==0)continue;
        for(int i=pw[t][0]=1;i<n;i++)
            pw[t][i]=2*pw[t][i-1]%(cnt+1-2*t);
    }
    int x[2]={0,0};
    for(int t=0;t<2;t++)
    {
        if(cnt+1-2*t==0)continue;
        for(int i=0;i<n;i++)
            x[t]=(2*x[t]+str[i]-'0')%(cnt+1-2*t);
    }
    for(int i=0;i<n;i++)
    {
        int t=(str[i]-'0');
        if(cnt==1 && t==1)
        {
            printf("0\n");
            continue;
        }
        int tx=(x[t]-(2*t-1)*pw[t][n-1-i])%(cnt+1-2*t);
        tx=(tx+(cnt+1-2*t))%(cnt+1-2*t);
        printf("%d\n",1+go(tx));
    }
    return 0;
}


Measured memory_bytes: 5476
#include<iostream>
#include<string>
#include<vector>
#include<math.h>

using namespace std;

int main() {
	 long long int K;
	 long long int X = 0;
	int ans = -1;
	cin >> K;
	for (int i = 0; i < 2*K; i++) {

		X = (10*X%K+7)%K;
		X = X % K;
		//cout << X << endl;
		
		if (X == 0) {
			ans = i + 1;
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>

using namespace std;

inline int ctoi(const char c)
{
	return c >= '0'&&c <= '9' ? c - '0' : -1;
}

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

	int base = (int)pow(100, d);

	if (n == 100) {
		cout << base * 101 << endl;
	}
	else {
		cout << base * n << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i)

//v4
int cond = 1;
string to_string(char c){return'\''+string(1,c)+'\'';}
string to_string(const string&s){return'"'+s+'"';}
string to_string(const char*s){return to_string((string)s);}
string to_string(bool b){return(b?"true":"false");}
string to_string(std::vector<bool>::reference&r){return to_string((bool)r);}
template<typename A,typename B>string to_string(const pair<A,B>&p){return"("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A>string to_string(A v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x);}r+="}";return r;}
template<typename A,typename B>string to_string(map<A,B>v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x.first)+" -> "+to_string(x.second);}r+="}";return r;}
void __db(int i,const vector<string>&s){cerr<<endl;}
template<typename T,typename... A>void __db(int i,const vector<string>&s,T t,A... a){if(i)cerr<<", ";cerr<<s[i]<<" = "<<to_string(t);__db(i+1,s,a...);}
string __cl(string s){while(!s.empty()&&s[0]==' ')s.erase(0,1);while(!s.empty()&&s.back()==' ')s.pop_back();return s;}
vector<string>__vars(string s){vector<string>r;s+=",";string n="";int d=0;for(auto x:s)if(x==','&&d==0){if(!n.empty())r.push_back(__cl(n));n="";}else{n+=x;if(x=='('||x=='[')d++;else if(x==')'||x==']')d--;}return r;}
#define DB(...){if(cond){cerr<<"Line:"<<__LINE__<<" ";__db(0,__vars(#__VA_ARGS__),__VA_ARGS__);}}


vector<string> v;
int t[30][30];
int n, m;

int getscore(int x, int y) {
  REP(i, 30) REP(j, 30) t[i][j] = 1000000000;
  t[x][y] = 0;
  queue<pair<int, int>> q;
  q.push({x, y});
  while (!q.empty()) {
    auto wz1 = q.front();
    q.pop();
    int val = t[wz1.first][wz1.second];
    FOR(i, -1, 1) FOR(j, -1, 1) if (abs(i) + abs(j) == 1) {
      int xx = wz1.first + i, yy = wz1.second + j;
      if (xx < 0 || xx >= n || yy < 0 || yy >= m) {
      } else if (v[xx][yy] != '#' && t[xx][yy] > val + 1) {
        t[xx][yy] = val + 1;
        q.push({xx, yy});
      }
    }
  }
  int max_el = 0;
  REP(i, n) REP(j, m) if (t[i][j] != 1000000000) max_el = max(max_el, t[i][j]);
  return max_el;
}


int main() {
  scanf("%d%d", &n, &m);
  REP(i, n) {
    char ch[23];
    scanf("%s", ch);
    v.push_back(ch);
  }
  int result = 0;
  REP(i, n) REP(j, m) {
    if (v[i][j] == '#') continue;
    result = max(result, getscore(i, j));
  }
  printf("%d\n", result);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n, k, i;
   
    long long a = 1;
   
      
    scanf("%d %d", &n ,&k);


    if( k > 1 ){

        for( i = 1 ; i <= n ; i = i + 1 ){

             if( i == 1 ) a *= k;

             else a *= k - 1;

             }

        printf("%lld\n", a);

        return 0;

        }

    else printf("1\n");

    return 0;
                                                          
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

int main() {
    int n, m; cin >> n >> m;
    vvec<int> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;

    vec<bool> vis(n, false);
    for (int i = 0; i < n; ++i) {
        if (vis[i]) continue;

        queue<int> que;
        que.push(i);
        vis[i] = true;

        while (!que.empty()) {
            int c = que.front(); que.pop();
            for (auto v : g[c]) {
                if (vis[v]) continue;
                vis[v] = true;
                que.push(v);
            }
        }

        ++ans;
    }

    cout << ans - 1 << endl;
}



Measured memory_bytes: 8536
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        Deque<String> numDeque = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                numDeque.addFirst(sc.next());
            } else {
                numDeque.addLast(sc.next());
            }
        }
        Iterator<String> i = n % 2 == 0 ? numDeque.descendingIterator() : numDeque.iterator();
        StringBuilder sb = new StringBuilder(i.next());
        while (i.hasNext()) {
            sb.append(" ").append(i.next());
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 87780
import java.util.Scanner;


class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] budget = new int[4];
    int usedBudget_train = 0;
    int usedBudget_bus = 0;

    for (int i=0; i<4; i++) {
      budget[i] = sc.nextInt();
    }

    if (budget[0]<budget[1]) {
      usedBudget_train = budget[0];
    }else{
      usedBudget_train = budget[1];
    }

    if (budget[2]<budget[3]) {
      usedBudget_bus = budget[2];
    }else{
      usedBudget_bus = budget[3];
    }

    System.out.println(usedBudget_train + usedBudget_bus);

  }
}


Measured memory_bytes: 24916
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(b+(b-a));
  }
}

Measured memory_bytes: 23636
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

num_dic = {}
for a in a_list:
  count = num_dic.get(a, 0)
  num_dic[a] = count + 1

replace_num = len(num_dic.keys()) - K
replace_num = 0 if replace_num < 0 else replace_num
ans = 0
for i, taple in enumerate(sorted(num_dic.items(), key = lambda x:x[1])):
  if i == replace_num:
    break
  ans += taple[1]

print(ans)

Measured memory_bytes: 42788
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;

int main() {
  int m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  
  if(m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;
  
}

Measured memory_bytes: 3500
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <bitset>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int dp[110][10];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    dp[0][0] = 1;
    if(W == 1) {cout << 1 << endl; return 0;}
    rep(i, H) { 
        rep(bit, (1 << (W - 1))) {
            bool ok = true;
            rep(j, W - 2) {
                if(bit & (1 << j) && bit & (1 << (j + 1))) ok = false;
            }
            if(!ok) continue;
            //cerr << bitset<4>(bit) << endl;
            rep(j, W - 1) {
                if(bit & (1 << j)) {
                    dp[i + 1][j + 1] += dp[i][j];
                    dp[i + 1][j] += dp[i][j + 1];
                    j++;
                    if(j == W - 2) {
                        dp[i + 1][j + 1] += dp[i][j + 1];
                        //cerr << j << " " << bitset<4>(bit) << " " << dp[i + 1][j + 1] << endl;
                    }
                } else {
                    dp[i + 1][j] += dp[i][j];
                    if(j == W - 2) {
                        dp[i + 1][j + 1] += dp[i][j + 1];
                        //cerr << j << " " << bitset<4>(bit) << " " << dp[i + 1][j + 1] << endl;
                    }
                }
            }
            rep(j, W) dp[i + 1][j] %= mod;
        }
    }
    // rep(i, H + 1) {
    //     rep(j, W) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // } 
    cout << dp[H][K - 1] << endl;


    return 0;
}
// | | | |
// 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define endl "\n"
#define mset(m,v) memset(m,v,sizeof(m))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
typedef vector<int>	vi;
#define FAST_IO  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

void solve()
{
	int n,k,i,a,b,p=INT_MIN,q=INT_MAX,x=INT_MIN,y=INT_MAX;
	cin >> n ;
	for(i=0;i<n;i++){
	    cin >> a >> b;
	    x=max(x,a+b);
	    y=min(y,a+b);
	    p=max(p,a-b);
	    q=min(q,a-b);
	}
	cout << max(x-y,p-q) << endl;
}

int32_t main()
{
	FAST_IO;
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};



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

   

int n,r;
cin>>n>>r;
if(n>=10)
cout<<r<<"\n";
else cout<<r+100*(10-n)<<"\n";



}



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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int T[5];
char C[2] = {'+', '-'};

int main()
{
    string S;
    cin >> S;
    REP(i, S.length())
    {
        T[i] = (int)(S[i] - '0');
    }

    for (int i = 0; i < 8; ++i)
    {
        int sum = T[0];
        REP(j, 3)
        {
            sum += (T[j + 1] * pow(-1, (i >> j) & 1));
        }
        if (sum == 7)
        {
            cout << T[0];
            REP(j, 3)
            {
                cout << C[(i >> j) & 1] << T[j + 1];
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

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

int main(void) {
    long int n,m;
    string s;

    cin>>n;
    m=n;
    long int a=0;
    while(n>0)
    {
        a+=n%10;
        n/=10;
    }
    if(m%a==0){cout<<"Yes\n";}
    else{cout<<"No\n";}


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
bool visit[100004];
vector<int> v;
int main(){
  visit[0]=visit[1]=true;
  for(int i=2;i<=100003;i++){
    if(visit[i]) continue;
    v.push_back(i);
    for(long long j=1LL*i*i;j<=100003;j+=i) visit[j]=true;
  }
  int X;scanf("%d",&X);
  printf("%d",*lower_bound(v.begin(),v.end(),X));
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(n+1), y(m+1);
  cin >> x.at(0) >> y.at(0);
  for(int i=0; i<n; i++)
    cin >> x.at(i+1);
  for(int i=0; i<m; i++)
    cin >> y.at(i+1);
  
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  
  if(x.at(n) < y.at(0))
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}

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

def main():
    def is_prime(n):
        if n == 1: return False
        for k in range(2, int(n**(1/2)) + 1):
            if n % k == 0:
                return False
        return True
    
    prime,now = [0],0
    for i in range(1,10**5+1):
        if i%2 == 1 and is_prime(i) and is_prime((i+1)//2):
            now += 1
        prime.append(now)
    
    N = int(input())
    for _ in range(N):
        a,b = map(int,input().split())
        print(prime[b]-prime[a-1])

if __name__ == "__main__":
    main()


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

int f(vector<vector<int>> &v,vector<bool> &poseceni,int cvor)
{
    int br=1;
    poseceni[cvor]=true;
    for (auto x:v[cvor])
    {
        if(!poseceni[x])
            br+=f(v,poseceni,x);
    }
    return br;
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m,a,b,mx=0;
    cin >> n >> m;
    vector<vector<int>> v(n);
    vector<bool> poseceni(n,false);
    for (int i=0;i<m;i++)
    {
        cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for (int i=0;i<n;i++)
        if(!poseceni[i])
            mx=max(mx,f(v,poseceni,i));
    cout << mx;
}


Measured memory_bytes: 26580
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x1,x2,x3,x4,x5,res;
  cin>>x1;
  if(x1==0)
    res=1;
   cin>>x2;
  if(x2==0)
    res=2;
  cin>>x3;
  if(x3==0)
    res=3;
  cin>>x4;
  if(x4==0)
    res=4;
  cin>>x5;
  if(x5==0)
    res=5;
  cout<<res;
}

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline

import numpy as np

N,*D = map(int,input().split())

grid = np.zeros((2*N,2*N), dtype=np.int8)

for i,d in enumerate(D):
    width = 1
    while d % 4 == 0:
        d //= 4
        width *= 2
    if d%4 == 1:
        x = np.arange(2*N)
        bl = (x%(2*width) >= width)
        grid += (bl[:,None]^bl[None,:]) * (1<<i)
    elif d%4 == 2:
        x = np.arange(2*N)
        bl = (x%(2*width) >= width)
        grid += bl * (1<<i)

for i in range(4):
    X,Y = np.where(grid == i)
    if len(X) >= N*N:
        break

X,Y = X[:N*N], Y[:N*N]
for x,y in zip(X,Y):
    print(x,y)

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

int main(void) {
	int n, m, l, a[100][100], b[100][100], i, j, k;
	long int c[100][100] = {0};
	cin >> n >> m >> l;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			for (k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
			cout << c[i][j];
			if (j != l - 1)
				cout << ' ';
			else
				cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <algorithm>


int a[50];
using namespace std;


int fibonacci(int n) {
	if (a[n] > 0)
		return a[n];

	a[n] = fibonacci(n-1) + fibonacci(n-2);
	return a[n];
}


int main() {

	fill(a,a + 50, -1);

	int n;

	cin >> n;

	a[0] =  1;
	a[1] =  1;

	cout << fibonacci(n) << endl;

}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}
	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			ans += d[i] * d[j]
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
if a[-1] < k:
    print('IMPOSSIBLE')
    sys.exit(0)

seta = set(a)
if k in seta:
    print('POSSIBLE')
    sys.exit(0)
change = True
while change:
    change = False
    setb = seta.copy()
    sorteda = sorted(seta)
    mini = sorteda[0] if sorteda[0] != 0 else sorteda[1]
    for i in range(1, len(sorteda)):
        setb.add(sorteda[i] % mini)
    if len(setb) != len(seta):
        change = True
        seta = setb

mini = sorted(seta)[1]
a.reverse()

for i in a:
    if (k - i) % mini == 0:
        print('POSSIBLE')
        sys.exit(0)
print('IMPOSSIBLE')

Measured memory_bytes: 18552
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int main(){
    int a , b;
    cin >> a >> b;
    if(a * 500 >= b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N;
inline void solve(){
  IN(N);
  OUT(N/3);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

void dfs(int cur, vector<vector<int> > arr, int d[], int f[], int &time, int n, bool psd[]){
    d[cur] = time;
    time++;
    psd[cur] = true;
    for(int dst = 0; dst < n; dst++){
        if(arr[cur][dst] == 1 && !psd[dst]){
            dfs(dst,arr,d,f,time,n,psd);
        }
    }
    f[cur] = time;
    time++;
}

int main(){
    int n;
    scanf("%d",&n);
    vector<vector<int> > arr(n,vector<int>(n));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            arr[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        int u,k;
        scanf("%d %d",&u,&k);
        for(int j = 0; j < k; j++){
            int v;
            scanf("%d",&v);
            arr[u-1][v-1] = 1;
        }
    }
    int d[n],f[n],time = 1;
    bool psd[n];
    for(int i = 0; i < n; i++){
        psd[i] = false;
    }
    for(int cur = 0; cur < n; cur++){
        if(!psd[cur]){
            dfs(cur,arr,d,f,time,n,psd);
        }
    }
    for(int id = 0; id < n; id++){
        printf("%d %d %d\n", id+1, d[id], f[id]);
    }
}

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

ll func(ll a){
    ll sum=0;
    for(int i=1;i<=a-1;i++){
        sum+= i;
    }
    return sum;
}

int main() {
    int n;
    ll sum=0;
    cin >>n;
    vector<string> s(n);
    for (int i=0;i<n;i++){
        cin >> s.at(i);
        sort(s.at(i).begin(),s.at(i).end());
    }
    map<string,ll> mp;
    for (int i=0;i<n;i++){
        mp[s.at(i)] +=1;
    }

    for (auto i:mp){
        if(i.second>1){
            // cout << i.first << endl;

            // cout << i.second << endl;
            sum+=func(i.second);
            // cout << sum << endl;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 18176
#include <stdio.h>
#include <string.h>

#define MAX 1024

int main(){
    char s[MAX], t[MAX];
    int n, m, h;
    int i;
    
    while(scanf("%s", s), strcmp(s, "-") != 0){
        
        n = strlen(s);
        
        scanf("%d", &m);
        
        for(i = 0; i < m; ++i){
            scanf("%d", &h);
            
            memcpy(t + n - h, s,     h);
            memcpy(t,         s + h, n - h);
            memcpy(s,         t,     n);
        }
        
        printf("%s\n", s);
    }
    
    return 0;
}

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

int  main(){   
    int n,m;
    cin>>n>>m;
    multiset<ll> st;
    rep(i,n){
        ll tmp;cin>>tmp;
        st.insert(tmp);
    }
    rep(i,m){
        auto itr = st.end();
        itr--;
        ll tmp=*itr/2;
        st.erase(itr);
        st.insert(tmp);   
    }

    ll ans=0;
    for(auto itr=st.begin();itr!=st.end();++itr){
        ans+=*itr;
    }
    cout << ans << endl;

}

Measured memory_bytes: 4992
n = int(input())
l = list(map(int, input().split()))
l.sort()


if l[-1]%2 == 0:
  s = l[-1]//2
else:
  s = (l[-1]+1)//2

temp = float('inf')
for i in range(n-1):
  t = abs(l[i]-s)
  if t <= temp:
    p = l[-1]
    q = l[i]
    temp = t
print(p, q)

Measured memory_bytes: 14432
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func pow2(x int) int {
	return int(math.Pow(2, float64(x)))
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	ans := 0
	for i := 1; i <= n; i++ {
		ans += (n - 1) / i
	}
	fmt.Println(ans)
}


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

int main(){
  int n[6];
  int a,b,c;

  while(1){
    for(int i=0;i<6;i++)cin >> n[i];
    bool f = false;
    for(int i=0;i<6;i++){
      if(n[i])f = true;
    }
    if(!f)break;

    a = n[0] + n[3];
    b = n[1] + n[4];
    c = n[2] + n[5];

    int ans = 0;
    if(a){
      ans += (a/3);
      a -= (a/3)*3;
      if(!a){
	a += 3;
	ans -= 1;
      }
    }
    //cout << "[" << ans << "]" << endl;

    if(b){
      ans += (b/3);
      b -= (b/3)*3;
      if(!b){
	b += 3;
	ans -= 1;
      }
    }
    //cout << "[" << ans << "]" << endl;

    if(c){
      ans += (c/3);
      c -= (c/3)*3;
      if(!c){
	c += 3;
	ans -= 1;
      }
    }
    //cout << "[" << ans << "]" << endl;
    //cout << a << " " << b << " " << c << endl;

    if(a>2 && b>2 && c>2)ans += 3;
    else if(a>1 && b>1 && c>1)ans += 2;
    else if( (a==3 && b==3) || (b==3 && c==3) || (c==3 && a==3) )ans += 2;
    else if(a>0 && b>0 && c>0)ans += 1;
    else if(a==3 || b==3 || c==3)ans += 1;

    cout << ans << endl;
  }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
//datatypes
	#define ll 			long long
	#define vi 			vector<int>
	#define vll 		vector<ll>
	#define si 			set<int>
	#define vii 		vector<ii>
	#define ii 			pair<int,int>
	#define vpll		vector<pll>
	#define pii 		pair<int,int>
	#define pll 		pair<ll, ll>
	#define mii 		map<int,int>
	#define ord_set		tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
	#define M 			1000000007
	#define narak 		998244353
	#define pi 			acos(-1)
	#define inf 		2147483647
	#define infl 		9223372036854775807
	#define infd 		1.7e308
	#define invd 		1.7e-308
	#define sz(x) 		(ll)x.size()
	#define fr 			first
	#define sc 			second
	#define pb 			push_back
	#define mkp 		make_pair
	#define rep(i,a,b) 	for(int i=a; i<b; ++i)
	#define rep0(i,a)	for(int i=0; i<a; ++i)
	#define rep1(i,a)	for(int i=1; i<=a; ++i)
	#define trav(a) 	for(auto &x:a)
	#define test 		cout<<"hello\n";
	#define all(x) 		(x).begin(),(x).end()
	#define mem(x,val)	memset(x, val, sizeof(x))
	#define sa(x) 		std::sort(all(x))
	#define endl 		'\n'
	#define __lcm(m,n) 	m*(n/__gcd(m,n))
	#define fill(a,n) 	for(int xxx=0;xxx<n;++xxx) cin>>(a)[xxx]
	#define maxa(v)		*(max_element(all(v)))
	#define mina(v)		*(min_element(all(v))
	#define inputFile 	freopen("input.txt", "r", stdin); 
	#define outputFile	freopen("output.txt", "w", stdout);
	#define disp(a) 	trav(a) cout<<x<<" "; cout<<endl;
  	//#define int long long

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T,typename U> std::ostream& operator<<(std::ostream& out, std::pair<T,U> a) {out<<a.fr<<" "<<a.sc; return out;}
template<typename T,typename U> std::istream& operator>>(std::istream& in, std::pair<T,U> &a) {in>>a.fr>>a.sc; return in;}
template<typename T> static inline void sd(vector<T> &x) {sort(all(x), greater<T>()) ; }

signed solve()
{
    int n;
    cin>>n;
    if(n>=30)
    {
    	cout<<"Yes";
    }
    else cout<<"No";
	return 0;
}

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
        
		solve();
        
	}
	//cout << "\nTime : " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    int resultX, resultY;

    resultX = (N / A) * B;
    if (N % A != 0) {
        resultX += B;
    }

    resultY = (N / C) * D;
    if (N % C != 0) {
        resultY += D;
    }

    cout << min(resultX, resultY) << endl;
}



Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;


int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> v;
  REP(i,n){
    string s;
    int p;
    cin>>s>>p;
    v.push_back(make_tuple(s,-p,i));
  }
  sort(v.begin(),v.end());

  
  REP(i,n){
    int j;
    tie(ignore,ignore,j)=v.at(i);
    cout<<j+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int n) {
    auto dp = new int[n + 1];
    for (int i = 1; i <= n; i++)
        dp[i] = i;

    foreach (coin; [6, 9]) {
        int c = 1;
        while (true) {
            c *= coin;
            if (c > n) break;

            for (int i = c; i <= n; i++) {
                dp[i] = min(dp[i], dp[i - c] + 1);
            }
        }
    }
    return dp[n];
}

void main() {
    int n = readint;

    int ans = calc(n);
    writeln(ans);
}


Measured memory_bytes: 2428
# gets.to_i
# gets.split.map(&:to_i)
# N.times.map{gets.to_i}
# N.times.map{gets.split.map(&:to_i)}
# 

#N,M=gets.split.map(&:to_i)

N,A,B=gets.split.map(&:to_i)

div=N/(A+B)
mod=N%(A+B)
if mod>=A
    mod=A
end
puts div*A+mod

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++) {
		string left = "", right = "";
		left  = s.substr(0, s.size() - 1 - i);
		right  = s.substr(s.size() - 1 - i);
		if (right + left == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string str;
    cin >> str;
    str[3] = '8';
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 256