akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int check(const vector<string>& v, int S, int T){
  int H = v.size();
  int W = v[0].size();

  int ret = 0;
  rep(i,H){
    if((S>>i)&1) continue;
    rep(j,W){
      if((T>>j)&1) continue;

      if(v[i][j] == '#') ret++;
    }
  }
  return ret;
}

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> v;
  rep(i,H){
    string s;
    cin >> s;
    v.push_back(s);
  }

  int ret = 0;
  
  for(int S=0; S<(1<<H); S++){
    for(int T=0; T<(1<<W); T++){
      if(check(v, S, T) == K) ret++;
    }
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3624
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

x,y = inpl()
for i in range(101):
    for j in range(101):
        if i+j == x and 2*i+4*j == y:
            print('Yes')
            quit()
print('No')

Measured memory_bytes: 10268
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char const *argv[]) {
  int abc[3];
  int k;
  for (int i = 0; i < 3; i++) cin >> abc[i];
  cin >> k;

  sort(abc, abc+3, greater<int>());

  int sum = 0;

  for (int i = 0; i < k; i++) abc[0] *= 2;

  for (int i = 0; i < 3; i++) sum += abc[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    while (true) {
      int d = sc.nextInt();
      int w = sc.nextInt();
      if (d == 0) return;

      int map[][] = new int[d][w];
      for (int i = 0; i < d; i++)
        for (int j = 0; j < w; j++)
          map[i][j] = sc.nextInt();

          /*  -i1-      -n-
            j1    j2   w   e
              -i2-      -s-  */

      int max = 0;
      for (int i1 = 0; i1 < d - 2; i1++) {
        for (int j1 = 0; j1 < w - 2; j1++) {
          for (int i2 = i1 + 2; i2 < d; i2++) {
            for (int j2 = j1 + 2; j2 < w; j2++) {

              int out = 10;
              for (int ew = i1; ew <= i2; ew++) {
                if (map[ew][j1] < out) out = map[ew][j1];
                if (map[ew][j2] < out) out = map[ew][j2];
              }
              for (int ns = j1+1; ns <= j2-1; ns++) {
                if (map[i1][ns] < out) out = map[i1][ns];
                if (map[i2][ns] < out) out = map[i2][ns];
              }

              int in = 0;
              for (int a = i1+1; a <= i2-1; a++)
                for (int b = j1+1; b <= j2-1; b++)
                  if (map[a][b] > in) in = map[a][b];

              //System.out.println("in: "+in+", out:"+out);
              if (in < out) {
                //printMap(i1, j1, i2, j2, d, w);
                int count = 0;
                for (int a = i1+1; a <= i2-1; a++)
                  for (int b = j1+1; b <= j2-1; b++)
                    if (map[a][b] < out) count += out - map[a][b];
                if (count > max) max = count;
              }
            }
          }
        }
      }

      System.out.println(max);
    }
  }

  static void printMap(int a, int b, int c, int d, int h, int w) {

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i >= a && i <= c && (j == b || j == d) || j >= b && j <= d && (i == a || i == c))
          System.out.print(" *");
        else System.out.print(" .");
      }
      System.out.println();
    }
    System.out.println();
  }
}



Measured memory_bytes: 37844
n,y=list(map(int, input().strip().split()))
a=-1
b=-1
c=-1
for i in range(n+1):
    for j in range(n-i+1):
        s=(y-10000*i-5000*j)
        if s==1000*(n-i-j):
            a=i
            b=j
            c=s//1000
            break
print(a,b,c)

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	int cnt_pair = 0;
	rep(i,n-1) {
		if (a[i] == a[i+1]) {
			cnt_pair++;
			i++;
		}
	}
	cout << n-2*cnt_pair << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}
 
int main(){
  int n;
  string s, ans;
  cin >> n >> s;
  s += '.';
  rep(i, 1, n+1){
    while(s[i]==s[i-1]){
      i++;
    }
    ans += s[i-1];
  }
  cout << (int)ans.size() << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int v[4]={};
  for(int i=0;i<3;i++) {
    int a,b; cin>>a>>b; a--; b--;
    v[a]++; v[b]++;
  }
  int o=0,t=0;
  for(int i=0;i<4;i++) {
    if (v[i]==1) o++;
    if (v[i]==2) t++;
  }
  if (o==2&&t==2) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
}

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

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int A, B;
    io.read(A, B);
    string ans = "Impossible";
    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
        ans = "Possible";
    }
    cout << ans;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    set<P> ab,ba;
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        ab.insert(P(a,b));
        ba.insert(P(b,a));
    }
    int ans = 0;
    
    while(!ab.empty()){
        auto it = ab.end();
        it--;
        P x = *it;
        ab.erase(it);
        ans++;
        auto it2 = ba.upper_bound(P(x.first+1, -1));
        while(it2 != ba.end()){
            x = *it2;
            it2 = ba.erase(it2);
            ab.erase(P(x.second,x.first));
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16076
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  if(s[0] != 'A'){
    cout << "WA\n";
    return 0;
  }
  int n = s.length();
  int c = 0;
  int index = 0;
  for(int i = 2; i <= n - 2; i++) {
    if(s[i] == 'C'){
      c++;
      index = i;
    }
  }
  if(c != 1){
    cout << "WA\n";
    return 0;
  }
  
  for(int i = 1; i < n; i++) {
    if(s[i] <= 'z' && s[i] >= 'a' || s[i] == 'C' && i == index){
      continue;
    }else{
      cout << "WA\n";
      return 0;
    }
  }
  cout << "AC\n";
  return 0;
}

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


int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    REP(i, h){
        cin >> s.at(i);
    }

    ll ans = h * w;
    REP(i, (1 << (h - 1))){
        vector<bool> cut(h - 1, false);
        REP(j, h - 1){
            if((i >> j) & 1){
                cut.at(j) = true;
            }
        }
        const ll numcut = accumulate(cut.begin(), cut.end(), 0);
        const ll numseg = numcut + 1;

        vector<vector<ll>> numwhite(numseg, vector<ll>(w, 0));
        ll idx = 0;
        REP(u, h){
            REP(j, w){
                if(s.at(u).at(j) == '1'){
                    numwhite.at(idx).at(j)++;
                }
            }
            if(u < h - 1 && cut.at(u)){ idx++; }
        }

        bool fail = false;
        REP(u, numseg){
            REP(j, w){
                if(numwhite.at(u).at(j) > k){
                    fail = true;
                    break;
                }
            }
            if(fail){ break; }
        }
        if(fail){ continue; }

        ll tmp = 0;
        vector<ll> cs(numseg, 0);
        REP(j, w){
            bool should_cut = false;
            REP(u, numseg){
                if(cs.at(u) + numwhite.at(u).at(j) > k){
                    should_cut = true;
                    break;
                }
            }
            if(should_cut){
                tmp++;
                fill(cs.begin(), cs.end(), 0);
            }
            REP(u, numcut + 1){
                cs.at(u) += numwhite.at(u).at(j);
            }
        }
        ans = min(ans, tmp + numcut);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n";
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;
// typedef vector<ll> p;



// エラストテネスの篩
const int N = 1e7+1;
bool is_prime[N];
void build_sieve(){
    fill(is_prime, is_prime + N, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < N; ++i)if(is_prime[i]){
        for(int j = 2*i; j < N; j+=i)is_prime[j] = false;
    }
}


int main(){
    ll q; cin >> q;
    ll n = 1e5+10;
    vector<vl> lr(q,vl(2,0));
    rep(i,q){
        cin >> lr[i][0] >> lr[i][1];
    }
    build_sieve();
    vector<ll> sum(n+1,0);
    rep(i,n){
        if(i%2 == 0)sum[i+1] = sum[i];
        else{
            if(is_prime[i] && is_prime[(i+1)/2]){
                sum[i+1] = sum[i] + 1;
            }
            else sum[i+1] = sum[i];
        }
    }

    // rep(i,20){
    //     print(i,sum[i]);
    // }
    debug(sum[10]);
    rep(i,q){
        cout << sum[lr[i][1]+1] - sum[lr[i][0]] << endl;
    }

}

Measured memory_bytes: 16640
#!/usr/bin/env python
import sys
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j, n in enumerate(A[:-1]):
        if n <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1

_ = int(raw_input())
nums = map(int, raw_input().split(" "))
p = partition(nums, 0, len(nums)-1)
nums[p] = "[{}]".format(nums[p])
sys.stdout.write(str(nums[0]))
for n in nums[1:]:
    sys.stdout.write(" {}".format(n))
sys.stdout.write("\n")



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n;
    ll a[100005];
    ll ans = 1;
    cin >> n;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    for(ll i = 0; i < n; i++) {
        if(a[i] == 0) {
            cout << "0" << endl;
            exit(0);
        }
    }

    for(ll i = 0; i < n; i++) {
        if(ans < LLONG_MAX / a[i]) {
            ans *= a[i];
        } else {
            cout << "-1" << endl;
            exit(0);
        }
        if(ans > 1000000000000000000 || ans < 0) {
            cout << "-1" << endl;
            exit(0);
        }
    }

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

Measured memory_bytes: 4412
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int[] B = new int[M];
		for (int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}
		int[][] A = new int[N][M];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		debug(A);

		long result = 0;
		for (int i = 0; i < N; i++) {
			long sum = C;
			for (int j = 0; j < M; j++) {
				sum += A[i][j] * B[j];
			}
			if (sum > 0) {
				result++;
			}
		}

		System.out.println(result);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll k,i;
	string s;
	cin >> k >> s;

	for(i=0;i<s.length();i++)
	{
		if(i<k)
		{
			cout << s[i];
		}
		else
		{
			cout << "...";
			break;
		}
	}
}

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

int chk_dig(int n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

int main(){
	int a,b; cin >> a >> b;
	a*=pow(10,chk_dig(b));

	for(int i=1;i<=1000;++i){
		if( i * i == a + b ) { cout << "Yes" << endl; return 0;}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
ll a[300000];
int main()
{
    ll n,m,i,j,k,l;
    cin >> n;
    for(i=1; i<n; i++)
    {
        cin >> m;
        a[m]++;
    }
    for(i=1; i<=n; i++)
    {
        cout << a[i] << endl;
    }
    return 0;
}


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

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

	long long nowT, nowA;
	std::cin >> nowT >> nowA;
	for (int i = 1; i < n; ++i) {
		long long t, a;
		std::cin >> t >> a;

		long long scale = std::max(
			(nowT + t - 1) / t,
			(nowA + a - 1) / a
		);

		nowT = t * scale;
		nowA = a * scale;
	}

	std::cout << nowT + nowA << std::endl;
}

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

n, a, b, c = map(int, input().split())
s = []
ans = []
for i in range(n):
    s.append(input().rstrip("\n"))
def check(x, y):
    if x + y == 0:
        print("No")
        sys.exit()

for i, si in enumerate(s):
    if si == "AB":
        check(a, b)
        if a == 1 and b == 1 and i < n - 1:
            if s[i+1] == "BC":
                ans.append('B')
                a -= 1
                b += 1
                continue
            if s[i+1] == "AC":
                ans.append('A')
                b -= 1
                a += 1
                continue
        if a > b:
            ans.append('B')
            a -= 1
            b += 1
        else:
            ans.append('A')
            b -= 1
            a += 1
    if si == "AC":
        check(a, c)
        if a == 1 and c == 1 and i < n - 1:
            if s[i+1] == "BC":
                ans.append('C') 
                a -= 1
                c += 1
                continue
            if s[i+1] == "AB":
                ans.append('A')
                c -= 1
                a += 1
                continue
        if a > c:
            ans.append('C')
            a -= 1
            c += 1
        else:
            ans.append('A')
            c -= 1
            a += 1
    if si == "BC":
        check(b, c)
        if b == 1 and c == 1 and i < n - 1:
            if s[i+1] == "AB":
                ans.append('B') 
                c -= 1
                b += 1
                continue
            if s[i+1] == "AC":
                ans.append('C')
                b -= 1
                c += 1
                continue
        if b > c:
            ans.append('C')
            b -= 1
            c += 1
        else:
            ans.append('B')
            c -= 1
            b += 1
print("Yes")
for item in ans:
    print(item)


Measured memory_bytes: 16920
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INFINT = numeric_limits<int>::max();
const ll INFLL = numeric_limits<long long>::max();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;


int main() {

	ll n, k;

	cin >> n >> k;

	ll r = n / k;
	ll ans = r * r * r;

	if (!(k & 1)) {
		r = n / k;
		if (n % k >= k / 2) r++;
		ans += r * r * r;
	}

	cout << ans NL;
	

	return 0;

}

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

using namespace std;

int main() {
    int n;
    int k = 0;
    cin >> n;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            if(i * j == n)k++;
        }
    }
    if(k == 0)cout << "No" << endl;
    else cout << "Yes" << endl;
}


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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> cnt(M);
	for (int i = 0; i < N; ++i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++j){
			int A;
			cin >> A;
			A--;
			cnt[A]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < M; ++i) {
		if (cnt[i] == N) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    map<ll, int> mp;
    priority_queue<ll> que;
    rep(i, 0, n) {
        mp[a[i]]++;
    }
    a.erase(unique(a.begin(), a.end()), a.end());
    rep(i, 0, a.size()) {
        que.push(a[i]);
    }
    vector<ll> b;
    ll ans = 0;
    while(!que.empty()) {
        ll tmp = que.top(); que.pop();
        if(mp[tmp] >= 4 && b.size() == 0) {
            cout << tmp*tmp << endl;
            return 0;
        }
        else if(mp[tmp] >= 4) {
            ans = tmp*tmp;
            b.push_back(tmp);
        }
        else if(mp[tmp] >= 2) {
            b.push_back(tmp);
        }
        if(b.size() == 2) {
            cout << max(ans, b[0]*b[1]) << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

using namespace std;

void insertionSort(vector<int> a) {
    for(int i=1; i<a.size(); i++) {
        int v = a[i];
        int j = i-1;
        while (j>=0 && a[j]>v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for(auto e : a) {
            if(a.back() == e) cout << e << endl;
            else cout << e << " ";
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0; i<n; i++) {
        int e;
        cin >> e;
        a.push_back(e);
    }
    for(auto e : a) {
        if(a.back() == e) cout << e << endl;
        else cout << e << " ";
    }
    insertionSort(a);
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

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

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

mint comb(int n, int a)
{
  mint x = 1, y = 1;
  rep(i, a)
  {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  mint ans = mint(2).pow(n);
  ans -= 1;
  ans -= comb(n, a);
  ans -= comb(n, b);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            b[i] = x;
            a[x]++;
        }
        long[] s = new long[n+1];
        long sum = 0L;
        for (int i = 0; i < n; i++) {
            if(a[b[i]] < 2 || 0 < s[b[i]])continue;
            long x = (long)a[b[i]]*(a[b[i]]-1L)/2L;
            long y = (long)(a[b[i]]-1L)*(a[b[i]]-2L)/2L;
            sum += x;
            s[b[i]] = x-y;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            long t = sum - s[b[i]];
            sb.append(t + "\n");
        }
        System.out.print(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 96684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  ull a; double b;
  cin >> a >> b;

  int B = b * 100 + 0.1;
  ull res = a * B;
  res /= 100;
  cout << res << endl;
}


Measured memory_bytes: 3728
#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()
{
    int N;
    cin >> N;
    vector<string> result(N);
    int cAC = 0;
    int cWA = 0;
    int cTLE = 0;
    int cRE = 0; 
    rep(i,N){
        cin >> result[i];
        if(result[i]== "AC") cAC += 1;
        if(result[i]== "WA") cWA += 1;
        if(result[i]== "TLE") cTLE += 1;
        if(result[i]== "RE") cRE += 1;
    }
    cout << "AC x " << cAC << endl;
    cout << "WA x " << cWA << endl;
    cout << "TLE x " << cTLE << endl;
    cout << "RE x " << cRE << endl;
    return 0;
}

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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18;

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

    string s;
    cin >> s;
    int sum = 0;
    for(char ch : s) sum += (int)(ch - '0');
    cout << (sum % 9 == 0 ? "Yes" : "No");
}


Measured memory_bytes: 3768
using System;

namespace ABC136_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ans = 0;
            for (int i = 1; i <= N; i++)
            {
                if ((i.ToString()).Length % 2 == 1)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <locale>
using ll = long long;
using namespace std;

int main() {
    char a[20], b[20], c[20];
    cin >> a >> b >> c;
    char d[3]= {a[0], b[0], c[0]};
    for (char i : d) cout << toupper(i, locale::classic());
    cout << "\n";
    return 0;
}

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

int N;
vector<pair<int,int>> R, B;
vector<vector<int>> G;
vector<int> match;
vector<bool> vis;

bool findM(int cur){
  vis[cur] = true;
  for(int x : G[cur]){
    if(match[x] == -1 || (!vis[match[x]] && findM(match[x]))){
      match[x] = cur;
      match[cur] = x;
      return true;
    }
  }
  return false;
}

int main(){
  cin >> N;
  R.resize(N);
  B.resize(N);
  for(int i=0; i<N; i++){
    cin >> R[i].first >> R[i].second;
  }
  for(int i=0; i<N; i++){
    cin >> B[i].first >> B[i].second;
  }
  G.resize(2*N);
  vis.resize(2*N);
  match.resize(2*N);
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(R[i].first < B[j].first && R[i].second < B[j].second){
        G[i].push_back(N+j);
        G[N+j].push_back(i);
      }
    }
  }

  fill(match.begin(), match.end(), -1);
  int res = 0;
  for(int i=0; i<N; i++){
    fill(vis.begin(), vis.end(), false);
    res += findM(i);
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m,k;
	while(cin>>n>>m>>k,n){
		vvi in(n,vi(m)),dp(n+1,vi(m+1));
		rep(i,n)rep(j,m)cin>>in[i][j];
		dp[0][0]=k-1;
		rep(i,n)rep(j,m)if(dp[i][j]){
			dp[i+1][j]+=dp[i][j]/2;
			dp[i][j+1]+=dp[i][j]/2;
			if(dp[i][j]%2){
				if(in[i][j])dp[i][j+1]++;
				else dp[i+1][j]++;
			}
			if(dp[i][j]%2)in[i][j]^=1;
		}
		int x=0,y=0;
		while(x!=n&&y!=m){
			if(in[x][y])y++;
			else x++;
		}
		cout<<x+1<<" "<<y+1<<endl;
	}
}

Measured memory_bytes: 8992
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

int main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > cost(n,std::vector<int>(n));
	rep(i,n) {
		rep(j,n) {
			cost[i][j]=std::min({i,j,n-i-1,n-j-1});
		}
	}
	debug(cost);
	std::vector<int> p(n*n);
	rep(i,n*n) std::cin >> p[i];
	rep(i,n*n) p[i]--;
	std::vector<std::vector<int> > alive(n,std::vector<int>(n,true));
	lnt sum=0;
	// probably n^3
	for(auto q:p) {
		int x = q/n, y=q%n;
		sum+=cost[x][y];
		debug(sum);
		std::queue<std::pair<int,std::pair<int,int> > > que;
		alive[x][y]=false;
		for(int dx=-1;dx<=1;dx++) {
			for(int dy=-1;dy<=1;dy++) {
				if(dx*dy!=0 || (dx==0&&dy==0)) continue;
				if(x+dx<0||x+dx>=n) {
					cost[x][y]=-1;
					continue;
				}
				if(y+dy<0||y+dy>=n) {
					cost[x][y]=-1;
					continue;
				}
				cost[x][y] = std::min(cost[x][y],cost[x+dx][y+dy]);
			}
		}
		debug(cost[x][y]);
		que.emplace(n-cost[x][y],std::make_pair(x,y));
		while(!que.empty()) {
			auto xx = que.front(); que.pop();
			int i=xx.second.first, j=xx.second.second;
			for(int dx=-1;dx<=1;dx++) {
				for(int dy=-1;dy<=1;dy++) {
					if(i+dx<0||i+dx>=n) continue;
					if(j+dy<0||j+dy>=n) continue;
					if(dx*dy!=0 || (dx==0&&dy==0)) continue;
					// either alive and over +2 or dead and over +1
					if(alive[i+dx][j+dy] && cost[i+dx][j+dy]>cost[i][j]+1) {
						cost[i+dx][j+dy]=cost[i][j]+1;
						que.emplace(n-cost[i+dx][j+dy],std::make_pair(i+dx,j+dy));
					}
					if(!alive[i+dx][j+dy] && cost[i+dx][j+dy]>cost[i][j]) {
						cost[i+dx][j+dy]=cost[i][j];
						que.emplace(n-cost[i+dx][j+dy],std::make_pair(i+dx,j+dy));
					}
				}
			}
		}
		debug(x,y);
		debug(cost);
		debug(alive);
	}
	print(sum);
}


Measured memory_bytes: 6164
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
    ll n;
    string s;
    cin>>n>>s;
    for(ll i=0;i<s.size();i++){
        ll a;
        a=s[i]+n;
        if(a>90)a=a-26;
        s[i]=a;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 998244353;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<vector<int>> children;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for(int i=0;i<m;i++){
    int k;
    cin >> k;
    s.at(i) = vector<int>(k);
    for(int j=0;j<k;j++){
      cin >> s.at(i).at(j);
      s.at(i).at(j)--;
    }
  }
  vector<int> p(m);
  for(int i=0;i<m;i++)cin >> p.at(i);
  int ans = 0;
  for(int i=0;i<(1<<n);i++){
    bool flag = true;
    for(int j=0;j<m;j++){
      int tmp = 0;
      for(int k=0;k<s.at(j).size();k++){
        if(i & (1<<s.at(j).at(k)))tmp++;
      }
      if(tmp %2 != p.at(j))flag = false;
    }
    if(flag)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n;
int h[100005];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&h[i]);
		if(h[i]>h[i-1])h[i]--;
		else if(h[i]<h[i-1])return !puts("No");
	}
	puts("Yes");
	return 0;

}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		
		if((S.length())<=K) {
			System.out.println(S);
		}
		else {
			System.out.println(S.substring(0,K)+"...");
		}

	}

}


Measured memory_bytes: 38544
n,p = gets.split.map &:to_i
a = gets.split.map &:to_i

dp = Array.new(n+1){Array.new(2,0)}
dp[0][0] = 1

n.times do |i|
  2.times do |mod|
    2.times do |eat|
      mod_next = eat == 1 ? (mod + a[i]) % 2 : mod
      dp[i+1][mod_next] += dp[i][mod]
    end
  end
end

puts dp[n][p]


Measured memory_bytes: 1788
from collections import deque

N = int(input())
G = [[] for _ in range(N)]
for i in range(N-1):
  a, b, c = map(int, input().split())
  G[a-1].append((b-1, c))
  G[b-1].append((a-1, c))
  
Q, K = map(int, input().split())
K -= 1
costs = [0] * N
stack = deque([K])
visited = [False]*N
visited[K] = True

while stack:
  now = stack.pop()
  for nxt, c in G[now]:
    if visited[nxt]:
      continue
    visited[nxt] = True
    costs[nxt] = costs[now] + c
    stack.append(nxt)
    
for i in range(Q):
  x, y = map(int, input().split())
  print(costs[x-1] + costs[y-1])

Measured memory_bytes: 45716
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  i64 ans = 0;
  for (i64 i = 1; i <= sqrt(n); i++)
  {
    i64 p = n / i - 1;
    if (n % i == 0 && i < p)
      ans += p;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define MAX 1000007
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
 	int s;
 	cin >> s;
 	vector <int> v(s);
 	
 	for(int i=0;i<s;i++)
 		cin >> v[i];

 		int c = 0;
 		int p = 0;
 		for(int i=0;i<s;i++) {
 			if(v[i] == c+1) {
 				p++;
 				c++;
 			}
 		}
 		if(p == 0)
 			cout << "-1";
 		else
 			cout << s-p;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }
  string S;
  cin >> S;
  
  long r_cnt = 0;
  long g_cnt = 0;
  long b_cnt = 0;
  long result = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') { r_cnt++; result += g_cnt * b_cnt; }
    if (S[i] == 'G') { g_cnt++; result += r_cnt * b_cnt; }
    if (S[i] == 'B') { b_cnt++; result += r_cnt * g_cnt; }

    for (int j = 1; j < N; j++) {
      int pos1 = i;
      int pos2 = i - j;
      int pos3 = i - 2*j;
      if (pos3 < 0) break;
      if (S[pos1] != S[pos2] && S[pos2] != S[pos3] && S[pos3] != S[pos1]) result -= 1;
    }
  }
  //cout << r_cnt << ' ' << g_cnt << ' ' << b_cnt << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3640
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

multiset<int>q;

int main()
{
    int n,m,a;
    cin>>n>>m;
    rep(i,n)
    {
        cin>>a;
        q.insert(a);
    }
    while(m--)
    {
        auto it=q.end();
        --it;
        int x=*it;
        q.erase(it);
        q.insert(x/2);
    }
    LL ans=0;
    for(auto It=q.begin();It!=q.end();It++)
    {
        ans+=*It;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
  
int main(){
  int a, b;
  cin >> a >> b;
  if(1<=a && a<=9 && 1<=b && b<=9){
    printf("%d\n", a*b);
  }
  else printf("-1");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 30;
int a[maxn],b[maxn];
int main()
{
    string s,t;
    cin>>s>>t;
    int len = s.size();
    for(int i=0;i<len;i++)
    a[s[i]-'a']++,b[t[i]-'a']++;
    sort(a,a+26);
    sort(b,b+26);
    int flag=1;
    for(int i=0;i<26;i++)
    if(a[i]!=b[i])
    {
        flag=0;
        break;
    }
    if(flag)
    cout<<"Yes\n";
    else
    cout<<"No\n";
}


Measured memory_bytes: 1020
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int a, b, x; cin >> a >> b >> x;
	int m500mL = min(a, b);
	int m1L = min(a, b * 2);

	Cout(min((x + 999) / 1000 * m1L, x / 1000 * m1L + (x % 1000 + 499) / 500 * m500mL));
}


Measured memory_bytes: 3084
#include <stdio.h>

int	main()
{
	int	dish[5];
	int	rest;
	int	min = 10;
	int	sum = 0;

	scanf("%d\n%d\n%d\n%d\n%d\n", &dish[0],&dish[1],&dish[2],&dish[3],&dish[4]);
	for (int i = 0; i < 5;i++)
	{
		rest = dish[i] % 10;
		if (rest == 0)
			sum += dish[i];
		else
		{
			if (rest < min)
				min = rest;
			sum += dish[i] + (10 - rest);
		}
	}
	if (min != 10)
		sum -= (10 - min);
	printf("%d\n", sum);
	return (0);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

	int h, w;
	char[][] board;
	char[] directions = { 'U', 'L', 'D', 'R' };
	int[] directionX = { -1, 0, 1, 0 };
	int[] directionY = { 0, -1, 0, 1 };
	Stack<Character> solution = new Stack<Character>();
	
	int countLeaves() {
		int sum = 0;
		for (int i=0; i<board.length; i++){
			for (int j=0; j<board[0].length; j++){
				if (board[i][j] == 'o'){
					sum++;
				}
			}
		}
		return sum;
	}

	boolean dfs(int x, int y, int d) { // x: height; y: width
		int i = x, j = y;
		board[x][y] = '.';
		if (countLeaves() == 0){
			return true;
		}
		d--;
		for (int rep = 0; rep < 4; rep++) {
			i = x;
			j = y;
			d++;
			d %= 4;
			if (rep == 2)
				continue;
			while (i < board.length && i >= 0 && j < board[0].length && j >= 0) {
				i += directionX[d];
				j += directionY[d];
				if (!(i < board.length && i >= 0 && j < board[0].length && j >= 0)){
					break;
				}
				if (board[i][j] == 'o') {
					solution.push(directions[d]);
					if (dfs(i, j, d))
						return true;
					else
						break;
					
				}
			}
		}

		board[x][y] = 'o';
		solution.pop();
		return false;
	}

	public void solve() {
		Scanner in = new Scanner(System.in);
		h = in.nextInt();
		w = in.nextInt();
		String[] sBoard = new String[h];
		board = new char[h][w];
		for (int i = 0; i < h; i++) {
			sBoard[i] = in.next();
			board[i] = sBoard[i].toCharArray();
		}
		int d = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (board[i][j] == 'U' || board[i][j] == 'L'
						|| board[i][j] == 'D' || board[i][j] == 'R') {
					if (board[i][j] == 'U')
						d = 0;
					else if (board[i][j] == 'L')
						d = 1;
					else if (board[i][j] == 'D')
						d = 2;
					else
						d = 3;
					board[i][j] = '.';
					dfs(i, j, d);
				}
			}
		}

		in.close();
		
		Object res[] = solution.toArray();
		for (Object c : res){
			System.out.print(c);
		}
		System.out.println();
		
	}

	public static void main(String[] args) {
		new Main().solve();
	}

}

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
int N;
bool inrange(int i, int j) { return 0 <= i&&i < N && 0 <= j&&j < N; }

signed main() {
	int d; cin >> d;
	int a[120][120] = {};
	int di[] = { -1,0,1,0 };
	int dj[] = { 0,1,0,-1 };
	rep(h, 0, d) {
		if (h != 0)cout << endl;
		memset(a, 0, sizeof(a));
		cin >> N;

		if (N == 1) { cout << "#" << endl; continue; }
		if (N == 2) { cout << "##" << endl << "# " << endl; continue; }

		int ci = N - 1, cj = 0;
		int dir = 0;
		int cnt = 1;
		while (true) {
			a[ci][cj] = cnt;
			int ni = ci + di[dir], nj = cj + dj[dir];
			if (!inrange(ni, nj)) {
				dir = (dir + 1) % 4;
				ni = ci + di[dir], nj = cj + dj[dir];
			}
			else if (inrange(ni + di[dir], nj + dj[dir]) && a[ni + di[dir]][nj + dj[dir]] != 0) {
				dir = (dir + 1) % 4;
				ni = ci + di[dir], nj = cj + dj[dir];
			}
			dump(ci)dumpl(cj);
			dump(ni + dj[dir])dumpl(nj + dj[dir]);
			if (inrange(ni + di[dir], nj + dj[dir]) && (a[ni + di[dir]][nj + dj[dir]] != 0 || a[ni + di[(dir + 1) % 4]][nj + dj[(dir + 1) % 4]] != 0)) {
				break;
			}
			ci += di[dir];
			cj += dj[dir];

		}
		rep(i, 0, N) {
			rep(j, 0, N) {
				cout << (a[i][j] ? '#' : ' ');
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3112