akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

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


Measured memory_bytes: 256
#include <stdio.h>

int main (int argc, char ** argv)
{
	int a,b,c;

	scanf("%d%d%d", &a, &b, &c);
	
	if (a == b)
	{
		printf("%d\n",c);
	}	

	else if(b == c)
	{
		printf("%d\n",a);
	}

	else
	{
		printf("%d\n",b);
	}

	return 0;

}

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

int main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> c(n);
    ll sa=0,sb=0;
    for(int i = 0;i < n;i ++){
        ll a,b;
        cin >> a >> b;
        c[i].first = a+b;
        c[i].second = b;
    }
    sort(c.begin(),c.end());
    for(int i = n-1;i >= 0;i -= 2){
        sa += c[i].first-c[i].second;
        if(i>0) sb += c[i-1].second;
    }
    cout << sa-sb << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

typedef vector<bool> vb;

int n;
vi a;
vector<vll> dp;
vector<vb> recorded;

ll rec(int l, int r) {
	if(recorded[l][r]) return dp[l][r];
	recorded[l][r] = true;
	bool first = (n - (r - l + 1)) % 2 == 0;
	if(l == r && first) return dp[l][r] = a[l];
	else if(l == r && !first) return dp[l][r] = -a[l];
	else if(first) return dp[l][r] = max(rec(l + 1, r) + a[l], rec(l, r - 1) + a[r]);
	else return dp[l][r] = min(rec(l + 1, r) - a[l], rec(l, r - 1) - a[r]);
}

int main() {
//	cout << fixed << setprecision(15);
	cin >> n;
	a = vi(n);
	rep(i, n) cin >> a[i];

	dp = vector<vll>(n, vll(n));
	recorded = vector<vb>(n, vb(n));
	ll b = (n % 2) ? 1 : -1;
	rep(i, n) {
		dp[i][i] = a[i] * b;
		recorded[i][i] = true;
	}
	cout << rec(0, n - 1) << endl;
}


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

int N,M,now[100010];
bool F[100010] = {0};

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)now[i] = 1;
    F[0] = true;

    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        a--;b--;
        if(F[a])F[b] = true;
        if(now[a] == 1)F[a] = false;
        now[a]--;
        now[b]++;
    }
    int cnt = 0;
    for(int i = 0; i < N; i++)if(F[i])cnt++;
    printf("%d\n",cnt);

    return 0;
}


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

const int MAXH = 2010;
const int MAXW = 2010;
int H, W;
char G[MAXH][MAXW];

int height[MAXH][MAXW];

int par[MAXW];
int sz[MAXW];
int getpar(int a) {
	return par[a] == -1 ? a : (par[a] = getpar(par[a]));
}
bool merge(int a, int b) {
	a = getpar(a), b = getpar(b);
	if (a == b) return false;
	if (sz[a] < sz[b]) swap(a,b);
	par[b] = a;
	sz[a] += sz[b];
	return true;
}

int go(int r) {
	for (int i = 0; i < W; i++) {
		par[i] = -1;
		sz[i] = 1;
	}

	vector<pair<int, int>> cnds(W-1);
	for (int i = 0; i+1 < W; i++) {
		cnds[i] = {height[r][i], i};
	}
	sort(cnds.rbegin(), cnds.rend());

	int res = 0;
	for (auto cnd : cnds) {
		assert(merge(cnd.second, cnd.second+1));
		res = max(res, cnd.first * sz[getpar(cnd.second)]);
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> G[i];
	}

	for (int i = H-1; i >= 0; i--) {
		for (int j = 0; j+1 < W; j++) {
			if (i == H-1) {
				height[i][j] = 1;
			} else {
				height[i][j] = (((G[i][j] == G[i][j+1]) == (G[i+1][j] == G[i+1][j+1])) ? height[i+1][j] + 1 : 1);
			}
		}
	}

	int ans = max(H, W);
	for (int i = 0; i < H; i++) {
		ans = max(ans, go(i));
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 19968
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int lcs(string X, string Y) {
	int n, m;
	int c[1001][1001] = { 0 };
	int maxlcs = 0;;

	m = X.size();
	n = Y.size();


	X = ' ' + X;
	Y = ' ' + Y;

	for (int i = 1; i <= m; i++)c[i][0] = 0;
	for (int j = 1; j <= n; j++)c[0][j] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {

			if (X[i] == Y[j])
				c[i][j] = c[i - 1][j - 1] + 1; 
			else
				c[i][j] = max(c[i][j - 1],c[i - 1][j]);

			maxlcs = max(maxlcs, c[i][j]);
		}
	}
	return maxlcs;
}

int main() {

	int n;
	string S1, S2;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S1 >> S2;
		cout << lcs(S1, S2) << endl;
	}

	return 0;
}

Measured memory_bytes: 7076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];

    ll reserve_cnt = 0;
    ll defeated_cnt = 0;
    rep(i,n){
        ll ar = max(a[i]-reserve_cnt, (ll)0);
        ll ai = max(ar-b[i], (ll)0);
        ll bi = max(b[i]-ar, (ll)0);
        defeated_cnt += a[i] - ai;
        reserve_cnt = bi;
    }
    ll an = max(a[n]-reserve_cnt, ll(0));
    defeated_cnt += a[n]-an;
    cout << defeated_cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
x, y = map(int, input().split())
grp1 = {1, 3, 5, 7, 8, 10, 12}
grp2 = {4, 6, 9, 11}
grp3 = {2}
if x in grp1 and y in grp1 or x in grp2 and y in grp2 or x in grp3 and y in grp3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    string s;
    cin >> s;
    bool ok = true;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == s[i + 1]) {
            ok = false;
        }
    }
    if (ok)
        cout << "Good"
             << "\n";
    else
        cout << "Bad"
             << "\n";
    return 0;
}

Measured memory_bytes: 764
A, B, C, D=list(map(int, list(input())))

for b in [B, -B]:
  for c in [C, -C]:
    for d in [D, -D]:
      if A+b+c+d==7:
        output=str(A)
        
        if b<0:
          output+=str(b)
        else:
          output+='+'+str(b)
          
        if c<0:
          output+=str(c)
        else:
          output+='+'+str(c)
          
        if d<0:
          output+=str(d)
        else:
          output+='+'+str(d)
          
print(output+'=7')

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define mymalloc(p,n) {p = malloc((n)*sizeof(*p));if ((p)==NULL) {printf("not enough memory?\n"); exit(1);};}

typedef struct{
	long key;
	long order;
}data;

data *readData(long n){
	long i,j;
	char c;
	data *A;
	mymalloc(A,n);
	for(i=0;i<n;i++){
		scanf("  %ld",&j);
		A[i].key=j;
		A[i].order=i;
	}
	return A;
}

void swap(data *i,data *j){
	data tmp;
	tmp=*i;
	*i=*j;
	*j=tmp;
}

long partition(data *A,long p,long r){
	long i,j,x;
	x=A[r].key;
	i=p;
	for(j=p;j<r;j++){
		if(A[j].key<=x){
			swap(&A[i],&A[j]);
			i++;
		}
	}
	swap(&A[i],&A[r]);
	return i;
}

void printData(data *A,long p,long n){
	long i;
	for(i=0;i<p;i++){
		printf("%ld ",A[i].key);
	}
	printf("[%ld] ",A[p].key);
	for(i=p+1;i<n;i++){
		printf("%ld",A[i].key);
		if(i!=n-1){
			printf(" ");
		}
	}
	printf("\n");
}

main(){
	long p,n;
	data *A;
	scanf("%ld",&n);
	A=readData(n);
	p=partition(A,0,n-1);
	printData(A,p,n);
	free(A);
	return 0;
}

Measured memory_bytes: 1944
import sys

rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, n - 1)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    H, W, A, B = map(int, rl().split())
    MOD = 10 ** 9 + 7
    
    com = Combination(H + W, MOD)
    ans = 0
    for i in range(B, W):
        tmp = com.ncr(i + H - A - 1, i)
        tmp = tmp * com.ncr(W - i - 1 + A - 1, W - i - 1) % MOD
        ans = (ans + tmp) % MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 46448
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int g[300010];
int main(){
  int n, a, b;
  while(cin>>n>>a>>b){
    int ans=0, cnt;
    if(a+b> n+1 || b < (n+a-1)/a )
      ans=-1;
    else{
      cnt=0;
      for(int i=0; i<a; ++i){
        g[i]=n-a+i+1;
        ++cnt;
      }
      --b;
      bool l=0;
      int tmp=2;
      vector <int> v;
      while(1){
        if(n-cnt>=a){
          for(int j=0; j<a; ++j){
            if(n-cnt<=b){
              l=1;
              for(int k=j; k<a; ++k)
                v.push_back(n-tmp*a+k+1);
              reverse(v.begin(), v.end());
              break;
            }
            g[cnt]=n-tmp*a+j+1;
            ++cnt;
          }
        }
        else{
          int t=n-cnt;
          for(int j=1; j<=t; ++j){
            if(n-cnt<=b){
              l=1;
              for(int k=j; k<=t; ++k)
                v.push_back(k);
              reverse(v.begin(), v.end());
              break;
            }
            g[cnt]=j;
            ++cnt;
          }
          if(l){
            if(n-cnt!=b)
              ans=-1;
            for(int j=0; j<v.size(); ++j){
              g[cnt]=v[j];
              ++cnt;
            }
          }
          break;
        }
        if(!l){
          ++tmp;
          --b;
        }
        else{
          if(n-cnt!=b)
            ans=-1;
          for(int j=0; j<v.size(); ++j){
            g[cnt]=v[j];
            ++cnt;
          }
          for(int j=cnt; j<n; ++j){
            g[j]=n-j;
          }
          break;
        }
      }
    }
    if(ans==-1){
      cout<<-1<<endl;
    }
    else{
      for(int i=0; i<n; ++i){
        cout<<g[i]<<" ";
      }
      cout<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];

    ll ans = 0;
    repd(i, 1, N) {
        if (a[i] + a[i - 1] > x) {
            ans += a[i] + a[i - 1] - x;
            a[i] = max(0LL, a[i] - (a[i] + a[i - 1] - x));
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;
#define lol long long


int main()
{
	int N;
	cin >> N;
	vector<int> V(N);
	vector<int> C(N);
	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (V[i] - C[i] >= 0) {
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int n, m, max{};
	std::string tmp;
	std::map<std::string, int> str;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		std::cin >> tmp;
		str[tmp]++;
	}
	scanf("%d\n", &m);
	for (int i = 0; i < m; i++)
	{
		std::cin >> tmp;
		str[tmp]--;
	}
	for (auto& e : str)
	{
		if (e.second > max) max = e.second;
	}
	printf("%d\n", max);


	return 0;
}

Measured memory_bytes: 256
while True:
    s = input()
    if s == '.':break
    while True:
        if s.find('+') == -1 and s.find('-') == -1:
            index = s.rfind('[')
            if index == -1:break
            e = s.find(']', index, len(s))
            s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
        else:
            index = s.find('+')
            if index == -1:
                index = s.find('-')
            if s.find('-') != -1:
                index = min(index, s.find('-'))
            e = index
            f = 0
            while s[e] == '+' or s[e] == '-':
                f += [-1, 1][s[e] == '+']
                e += 1
            r = s[e]
            if r != '?':
                r = chr((ord(r) - ord('A') + f) % 26 + ord('A'))
            s = s[:index] + r + s[e + 1:]
    print(s.replace('?', 'A'))


Measured memory_bytes: 5580
# ALDS1_1_A - Insertion Sort
def main():
    N, *A = map(int, open(0).read().split())
    print(*A)
    for i in range(1, N):
        key = A[i]
        j = i - 1
        while j >= 0 and A[j] > key:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = key
        print(*A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long max = long.MinValue;
            long min = long.MaxValue;
            for (int i = 0; i < n; i++)
            {
                if (inputLongArray[i] < min)
                {
                    min = inputLongArray[i];
                }
                if (inputLongArray[i] > max)
                {
                    max = inputLongArray[i];
                }
            }

            Console.WriteLine(max-min);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
string s;
ll arr[MAXN];
ll b[MAXN];

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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>s;
    n = s.length();
    if(s[0] == '<'){
        b[0] = 0;
    }
    if(s[n - 1] == '>'){
        b[n] = 0;
    }
    for(int i = 1; i < n; i++){
        if(s[i] == '<' && s[i - 1] == '>'){
            b[i] = 0;
        }
    }

    for(int i = 1; i < n; i++){
        if(s[i] == '<' && s[i - 1] == '<'){
            b[i] =  b[i - 1] + 1;
        }
    }
    for(int i = n - 1; i > 0; i--){
        if(s[i] == '>' && s[i - 1] == '>'){
            b[i] = b[i + 1] + 1;
        }
    }
    for(int i = 1; i < n; i++){
        if(s[i] == '>' && s[i - 1] == '<'){
            b[i] = max(b[i - 1], b[i + 1]) + 1;
        }
    }

    if(s[n - 1] == '<')
        b[n] = b[n - 1] + 1;
    if(s[0] == '>')
        b[0] = b[1] + 1;
    ll sum = 0;

    for(int i = 0; i <= n; i++)
        sum += b[i];
    cout<<sum<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n,m,k;cin>>n>>m>>k;
  bool e=false;
  // for(ll i=0;n-2*i>0;i++){
  rep(i,0,n+1){
    ll a=k-i*m;
    ll b=n-2*i;
    if(a==0)e=true;
    else{
      if(b!=0){
        if(a%b==0&&(0<=a/b&&a/b<=m))e=true;
      }

    }
  }

  if(e)out("Yes");
  else out("No");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int i;
    int m,f,r;

    for(i=0;i<50;i++){
        std::cin>>m>>f>>r;

        if(m==-1&&f==-1&&r==-1){
            break;
        }
    

        if(m!=-1&&f!=-1){
         
            if(80<=m+f){
                std::cout<<"A"<<std::endl;
            }else if(65<=m+f&&m+f<80){
                std::cout<<"B"<<std::endl;
            }else if(50<=m+f&&m+f<65){
                std::cout<<"C"<<std::endl;
            }else if(30<=m+f&&m+f<50){
                if(r>=50){
                    std::cout<<"C"<<std::endl;
                }else{
                    std::cout<<"D"<<std::endl;
                }   
            }else if(m+f<30){
                std::cout<<"F"<<std::endl;
            }
        
        }else if(m==-1||f==-1){
            std::cout<<"F"<<std::endl;
        }
    }
    return 0;
}


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


int main(){

    string S;
    cin >> S;
    int cnt=0;
    for(int i=0;i<S.size();i++){
        if((i+1)%2==0){
            if(S[i]=='R'){
                cout << "No" << endl;
                return 0;
            }
        } else{
            if(S[i]=='L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = LI()
A = list(map(lambda x: x*(-1), A))
heapify(A)

while m > 0:
    a = heappop(A)*(-1)
    b = floor(a/2)
    m -= 1
    heappush(A, b*(-1))

print(sum(A)*(-1))

Measured memory_bytes: 103148
def main():
    # 下、右、上、左
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    H, W = map(int, input().split())
    s = [["."] * (W + 2)]
    s.extend([["."] + list(input()) + ["."] for i in range(H)])
    s.append(["."] * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == "#" and s[y + dy[0]][x + dx[0]] == "."\
                    and s[y + dy[1]][x + dx[1]] == "."\
                    and s[y + dy[2]][x + dx[2]] == "."\
                    and s[y + dy[3]][x + dx[3]] == ".":
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
#undef		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<climits>			//INT_MAX

using namespace std;

#define		MAX		500000

int		S[MAX + 1];
int		L[MAX / 2 + 1];
int		R[MAX / 2 + 1];
int		Compare = 0;

void merge(int A[], int left, int mid, int right)
{
	int		n1 = mid - left;
	int		n2 = right - mid;

	for (int i = 0; i < n1; ++i)
	{
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i)
	{
		R[i] = A[mid + i];
	}
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;

	int	i = 0;
	int	j = 0;

	for (int k = left; k < right; ++k)
	{
		++Compare;
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			++i;
		}
		else
		{
			A[k] = R[j];
			++j;
		}
	}
}

void mergeSort(int A[], int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE

	int		n;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> S[i];
	}

	mergeSort(S, 0, n);

	for (int i = 0; i < n; ++i)
	{
		if (i != 0)			cout << " ";
		cout << S[i];
	}
	cout << "\n" << Compare << "\n";

	return 0;
}

Measured memory_bytes: 6936
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,m,i,c[100005],a,b,v,k,t[100005];
set<int> g[100005];
vector<int>first_half;
vector<int>second_half;
vector<int>total;
int par[209],group[209];
int arra[150000];
vector<ll>points;
map<char,ll>vis_c;
map<ll,ll>nibo;
vector<ll>req;
vector<ll>PB;
vector< pair <ll,ll> > vect;
ll PaB[10009];
int main()
{
  ll a,b,k,c,i,j;
  cin>>k>>a>>b;
  for(i=1;i<=1000;i++)
  {
     c=k*i;
     if(c>=a&&c<=b)
      {
        cout<<"OK";
        return 0;	
      }	
  }
  cout<<"NG"<<'\n';
  	
}

Measured memory_bytes: 8320
from collections import Counter
N,M = map(int,input().split())
L = list(map(int,input().split()))

A = [0]
for i in range(N) :
    a = (A[-1]+L[i])%M
    A.append(a)

B = Counter(A)
ans = 0
for i in B.values() :
    ans += i*(i-1)//2 #Combination iC2
print(ans)


Measured memory_bytes: 16556
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int n,a[]={0,1,2,4,8,16,32,64};
int main()
{
	cin>>n;
	for(int i=7;i>=1;i--)
	{
		if(a[i]<=n)
		{
			cout<<a[i];
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);

// ===

fn main() {
    let n: usize = read();
    let mut a: Vec<i32> = readnc();
    a.push(0);
    a.insert(0, 0);

    let mut sum = 0;
    for i in 1..n+2 {
      sum += (a[i]-a[i-1]).abs();
    }

    for i in 1..n+1 {
      let form_dist = (a[i-1]-a[i]).abs() + (a[i+1]-a[i]).abs();
      let to_dist = (a[i+1]-a[i-1]).abs();
      println!("{}", sum-form_dist+to_dist);
    }
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
#include<map>
#define MEM(var,val) memset(var,(val),sizeof(var))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define nitro   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define inf 10000000000
ll dp[101][100001];
bool vis[101][100001];
ll wajan[101],val[101];
ll n;

ll rec(ll i,ll v)
{
    if(v<=0)
    return 0;
    if(i>n)
    return inf;

   if(vis[i][v])
    return dp[i][v];
    vis[i][v]=1;
    dp[i][v]=rec(i+1,v);
    if(v>=val[i])
    dp[i][v]=MIN(dp[i][v],wajan[i]+rec(i+1,v-val[i]));
   return dp[i][v];
}
int main()
{
    nitro;
    ll w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
        cin>>wajan[i]>>val[i];
        //minimum weight required to buy items worth value v is denoted by rec(i,v);
       ll i;
       for(i=100000;i>=0;i--)
        if(rec(1,i)<=w)
       {cout<<i;return 0;}

}


Measured memory_bytes: 88960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int T = s.nextInt();
        Integer [] arr = new Integer[T];
        for(int i=0;i<T;i++)
            arr[i]=s.nextInt();
        Arrays.sort(arr,Collections.reverseOrder());
        long res=0;
        int t1=0;
        for(int i=0;i<T;i++){
            if(i==0){
                res+=arr[i];
                t1++;
            }
            else{
                if(t1+2<T-1){
                    res+=2*arr[i];
                    t1+=2;
                }
                else if(t1+2==T-1){
                    res+=2*arr[i];
                    break;
                }
                else if(t1+1==T-1){
                    res+=arr[i];
                    break;
                }
                else
                    break;
            }
        }
        System.out.println(res);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 54812
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>
#include<queue>

using namespace std;

int main(){

    int n, k;
    cin >> n >> k;

    if(k==1)cout << 0 << endl;
    else{
        cout << n- k << endl;;

    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size
vector<int>v;

bool palin(int x){
	v.clear();
	while(x!=0){
			v.pb(x%10);
			x/=10;
		}
	
	for(int i=0;i<v.size()/2;i++){
		if(v[i]!=v[v.size()-1-i]){
			return 0;
		}
	}
	return 1;
}

int main(){
	ll a,b;cin>>a>>b;
	int ans=0;
	
	for(ll i=a;i<=b;i++){
		if(palin(i)){
			ans++;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  int x, y;
  cin >> x >> y;
  vector<string> G(x);
  for (auto &s : G) cin >> s;
  int farest = 0;
  vector<vector<int>> dist(x,vector<int>(y,-1));
  queue<pair<int,int>> Q;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      if (G[i][j] == '#') continue;
      Q.push({i,j});
      dist[i][j] = 0;
      while (!Q.empty()) {
        pair<int,int> p = Q.front();
        Q.pop();
        int D = dist[p.first][p.second];
        for (int k = 0; k < 4; k++) {
          int X = p.first+dx[k];
          int Y = p.second+dy[k];
          if (X < 0 || X >= x) continue;
          if (Y < 0 || Y >= y) continue;
          if (G[X][Y] == '#' || dist[X][Y] != -1) continue;
          Q.push({X,Y});
          dist[X][Y] = D+1;
        }
      }
      for (auto v : dist) {
          for (auto e : v) farest = max(farest,e);
      }
      dist.assign(x,vector<int>(y,-1));
    }
  }
  cout << farest << endl;
}

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

const int maxn = 1e5 + 5;

namespace dominator {
vector<int> g[maxn], r[maxn], rdom[maxn];
int dfn[maxn], rev[maxn], fa[maxn], sdom[maxn], dom[maxn], val[maxn], rp[maxn], tk;
void init(int n) {
    // vertices are numbered from 0 to n - 1
    fill(dfn, dfn + n, -1);
    fill(rev, rev + n, -1);
    fill(fa, fa + n, -1);
    fill(val, val + n, -1);
    fill(sdom, sdom + n, -1);
    fill(rp, rp + n, -1);
    fill(dom, dom + n, -1);
    tk = 0;
    for (int i = 0; i < n; ++i)
        g[i].clear();
}
void add_edge(int x, int y) {
    g[x].push_back(y);
}
void dfs(int x) {
    rev[dfn[x] = tk] = x;
    fa[tk] = sdom[tk] = val[tk] = tk;
    tk++;
    for (int &u : g[x]) {
        if (dfn[u] == -1) dfs(u), rp[dfn[u]] = dfn[x];
        r[dfn[u]].push_back(dfn[x]);
    } 
}
void merge(int x, int y) {
    fa[x] = y;
}
int find(int x, int c = 0) {
    if (fa[x] == x) return c ? -1 : x;
    int p = find(fa[x], 1);
    if (p == -1) return c ? fa[x] : val[x];
    if (sdom[val[x]] > sdom[val[fa[x]]]) val[x] = val[fa[x]];
    fa[x] = p;
    return c ? p : val[x];
}
vector<int> build(int s, int n) {
    // return the father of each node in the dominator tree
    dfs(s);
    for (int i = tk - 1; i >= 0; --i) {
        for (int &u : r[i]) sdom[i] = min(sdom[i], sdom[find(u)]);
        if (i) rdom[sdom[i]].push_back(i);
        for (int &u : rdom[i]) {
            int p = find(u);
            if (sdom[p] == i) dom[u] = i;
            else dom[u] = p;
        }
        if (i) merge(i, rp[i]);
    }
    vector<int> p(n, -1);
    for (int i = 1; i < tk; ++i) if (sdom[i] != dom[i]) dom[i] = dom[dom[i]];
    for (int i = 1; i < tk; ++i) p[rev[i]] = rev[dom[i]];
    return p;
}}

int c[maxn], dep[maxn], fa[maxn][20];
vector<int> g[maxn];

void dfs(int x, int p) {
    fa[x][0] = p;
    dep[x] = ~p ? dep[p] + 1 : 0;
    if (p != -1) c[x] = min(c[x], c[p]);
    for (int i = 1; (1 << i) <= dep[x]; ++i)
        fa[x][i] = fa[fa[x][i - 1]][i - 1];
    for (int u : g[x]) dfs(u, x);
}

int lca(int x, int y) {
    if (dep[x] > dep[y]) swap(x, y);
    for (int i = 0; i < 20; ++i) {
        if ((dep[y] - dep[x]) >> i & 1)
            y = fa[y][i];
    }
    if (x == y) return x;
    for (int i = 19; i >= 0; --i) {
        if (fa[x][i] != fa[y][i]) {
            x = fa[x][i];
            y = fa[y][i];
        }
    }
    return fa[x][0];
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    dominator::init(n);
    for (int i = 0; i < m; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        --u, --v;
        dominator::add_edge(u, v);
    }
    for (int i = 0; i < n; ++i) scanf("%d", &c[i]);
    auto p = dominator::build(0, n);
    assert(p[0] == -1);
    for (int i = 1; i < n; ++i) g[p[i]].push_back(i);
    dfs(0, -1);
    int q; scanf("%d", &q);
    while (q--) {
        int k; scanf("%d", &k);
        int z = -1;
        for (int i = 0; i < k; ++i) {
            int w; scanf("%d", &w);
            --w;
            if (z == -1) z = w;
            else z = lca(z, w);
        }
        printf("%d\n", c[z]);
    }
    return 0;
}



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

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

  int n;
  cin >> n;

  int left = 0, right = n - 1;
  string gender = "";
  int parity = 0;
  bool first = true;
  while(true) {

    int mid = (left + right)/2;

    if(first) cout << 0 << endl;
    else if(right - left <= 1) cout << right << endl;
    else cout << mid << endl;

    string input;
    cin >> input;

    if(input == "Vacant") return 0;
    if(gender == "") gender = input;

    bool flag = false;

   if((input != gender && parity == mid%2) || (input == gender && parity != mid%2))
     flag = true;

    if(first) {
      first = false;
      continue;
    }



    if(flag) {
      right = mid;
    } else {
      left = mid;
    }

  }
}

Measured memory_bytes: 3840
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 2005;
const int mod = 1e9 + 7;
LL a[maxn], n, x, b[maxn], ans;
int main() {
    cin>>n>>x;
    for (int i=0; i<n; i++) cin>>a[i];
    ans = 1LL * maxn * 1e9;
    memset(b, 0x3f, sizeof(b));
    for (int i=0; i<n; i++) {
        LL tmp = 0;
        for (int j=0; j<n; j++)
            b[j] = min(b[j], a[(j-i+n)%n]);
        for (int j=0; j<n; j++)
            tmp += b[j];
        ans = min(ans, i * x + tmp);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    // 入力
    int N;
    cin >> N;

    double sum = 0;
    rep (i, N) {
        double a;
        cin >> a;

        sum += 1 / a;
    }

    // 出力
    printf("%lf", 1 / sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 1; i <= (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = int64_t;
using namespace std;

int main(){
  ll a,b,n;cin>>a>>b>>n;
  if(n>=b)n=b-1;
  ll c,d;
    c=floor(a*n/b);
    d=a*floor(n/b);
    cout<<c-d<<endl;
}


Measured memory_bytes: 3604
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;


int main(){
	string str;
	while(getline(cin,str)){
		if(str==".")break;
		stack<char>kakko;
		bool flag=true;
		REP(i,SZ(str)){
			if(str[i]=='['||str[i]=='(')kakko.push(str[i]);
			else if(str[i]==']'||str[i]==')'){
				if(!kakko.empty()&&((str[i]==']'&&kakko.top()=='[')||(str[i]==')'&&kakko.top()=='('))){
					kakko.pop();
				}else{
					flag=false;
					break;
				}
			}
		}
		if(flag&&kakko.empty())cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>
#include <bitset>
using namespace std;
int dp[1010][1010];
bitset<1010> went[1010];
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int dis(int n,int m,char l[],char r[]){
    if(n<0&&m<0)return 0;
    if(n<0)return m+1;
    if(m<0)return n+1;
    if(went[n][m])return dp[n][m];
    went[n][m]=true;
    return dp[n][m]=min(min(dis(n-1,m,l,r),dis(n,m-1,l,r))+1,dis(n-1,m-1,l,r)+(l[n]!=r[m]));
}
int main(){
    int n=0,m=0;
    char l[1010],r[1010];
    for(int i=0;i<1010;i++){
        l[i]=r[i]='\0';
        went[i].reset();
    }
    scanf("%s",l);
    scanf("%s",r);
    while(l[n]!='\0')n++;
    while(r[m]!='\0')m++;
    printf("%d\n",dis(n-1,m-1,l,r));
}

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

int main(){
	int n,m;
	cin >> n >> m;
	int w[100],v[100];
	for(int i=0;i<n;i++){
		cin >> v[i] >> w[i];
	}

	int DP[101][10001];

	for(int j=0;j<=m;j++)
		DP[n][j] = 0;

	for(int i=n-1;i>=0;i--){
		for(int j=0;j<=m;j++){
			if(j<w[i]){
				DP[i][j] = DP[i+1][j];
			}else{
				if(DP[i+1][j]>DP[i+1][j-w[i]]+v[i]){
					DP[i][j] = DP[i+1][j];
				}else{
					DP[i][j] = DP[i+1][j-w[i]]+v[i];
				}
			}
		}
	}
	
	cout << DP[0][m] <<endl;

	return 0;
}


Measured memory_bytes: 7028
import sys
N, M = map(int, input().split())
H = list(map(int, sys.stdin.readline().split()))
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

others_list = [[] for _ in range(N)]

for i in range(M):
    A_i = AB[i][0] - 1
    B_i = AB[i][1] - 1
    others_list[A_i].append(H[B_i])
    others_list[B_i].append(H[A_i])

count = 0
for i in range(N):
    if len(others_list[i]) == 0:
        count += 1
    else:
        others_max = max(others_list[i])
        if H[i] > others_max:
            count += 1

print(count)

Measured memory_bytes: 41276
#include <iostream>

using namespace std;

int main()
{
    while (true) {
        int r0, w0, c, r;
        cin >> r0 >> w0 >> c >> r;
        if (r0 == 0 && w0 == 0 && c == 0 && r == 0) {
            return 0;
        }

        // C = (R_0 + X * R) / (W_0 + Y)
        // Y = (R_0 + X * R - C * W_0) / C
        for (int i = 0; true; ++i) {
            if (r0 + i * r - c * w0 >= 0) {
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3080
#include<stdio.h>
int main(){
	char s[4];
	int c=0,a[26]={0};
	scanf("%s",s);
	for(int i=0;i<4;i++){
		a[s[i]-65]++;	
	}
	for(int i=0;i<26;i++){
		if(a[i]>0) c++;
	}
	if(c==2) printf("Yes");
	else printf("No");
	return 0;
} 

Measured memory_bytes: 128
#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 a,b;
    cin >> a >> b;
    cout << a * b << endl;  
    return 0;
}

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

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

  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  if(n % 2 == 1) {
    int l = a[n/2], r = b[n/2];
    cout << r - l + 1 << '\n';
  } else {
    int l = a[n/2 - 1] + a[n/2];
    int r = b[n/2 - 1] + b[n/2];
    cout << r - l + 1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 4832
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N,K,Q;
    cin >> N >> K >> Q;
    vector<llong> A(Q);
    for(int i=0; i<Q; i++){
        cin >> A[i];
    }
    vector<llong> total_acc(N, 0);
    for(int i=0; i<Q; i++){
        total_acc[A[i]-1] += 1;
    }
    for(int i=0; i<N; i++){
        if(K-(Q-total_acc[i])>0){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 4332
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const ll mod =   1e9+7;
ll n;ll ans;
int main()
{  fast
cin>>n;
vector<ll> primes;
if(n<=1){
	cout<<0;return 0;
}
for(ll i=2;i*i<=n;i++){
	if(n%i==0){
		ll cnt=0;
		while(n%i==0){
			cnt++;n/=i;
		}
	//	cout<<i<<" "<<cnt<<endl;
		ll x=0;int j=0;
		for( j=1;x+j<=cnt;j++){
			x+=j;
		}j--;
		ans+=j;
	}
}
if(n>1)ans++;
cout<<ans;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    int l,r;
    cin >> l >> r;
    int a,b;
    a=l/2019;
    b=r/2019;
    if(b-a!=0){cout << 0 << endl;return 0;}
    l%=2019;r%=2019;
    int ans=inf;
    for(int i=l;i<r;i++){
        for(int j=i+1;j<r+1;j++){
            ans = min(ans,(i*j)%2019);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> vi;
	long long sum = 0;
	int ma = -1000;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		sum+=a;
		ma = max(ma,a);
	}
	sum-=ma;
	ma = ma/2;
	cout<<sum+ma<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int n, k;

int main(){
	IOS
	int a, b, c;
	cin >> a >> b >> c;
	int cnt=0;
	if(a==b) cnt++;
	if(c==a) cnt++;
	if(b==c) cnt++;
	if(cnt==1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main () {
    long long int N;
    cin >> N;
    long long int exp=0, c, sum=26;
    for (int i=1; i<=10000; i++) {
        if (i==2) {
            exp=26*26;
        }
        else {
            exp*=26;
        }
        if (N<=sum+exp) {
            c=i;
            break;
        }
        sum+=exp;
    }
    sum=1, exp=26;
    long long int s;
    for (int i=1; i<=10000; i++) {
        if (c==i) {
            s=N-sum;
            break;
        }
        sum+=exp;
        exp*=26;
    }
    string ans;
    for (int i=0; i<c; i++) {
        ans.push_back(s%26+97);
        s/=26;
    }
    for (int i=ans.size()-1; i>=0; i--) {
        cout << ans[i];
    }
}

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

typedef long long ll;

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

    int a,b;
    cin >> a >> b;
    if((a+b)%2==1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin>>n,n){
		string str,a="rldu";
		bool leg[2]={};
		int ans=0,now=1,num[2]={0,1};
		for(;n>0;n--){
			cin>>str;
			for(int i=0;i<2;i++)if(str[0]==a[i])for(int j=0;j<2;j++)if(str[1]==a[2+j])leg[i]=num[j];
			if(now==leg[0]&&now==leg[1]){
				ans++;
				now=(now+1)%2;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N],vi[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		++vi[a[i]];
	}
	sort(a+1,a+n+1);

	int k=a[n],res=INT_MAX;
	for(int i=0;i<=k;i++){
		int d=max(k-i,i);
		res=min(res,d);
		if(!vi[d]){
			puts("Impossible");
			return 0;
		}
		else	--vi[d];
	}
	for(int i=1;i<=res;i++)
		if(vi[i]){
			puts("Impossible");
			return 0;
		}
	puts("Possible");
	return 0;
}


Measured memory_bytes: 256