akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int R,G; cin >> R >> G;
    cout << 2*G-R << endl;
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var WHxy = Sarray();
            var W = WHxy[0];
            var H = WHxy[1];
            var x = WHxy[2];
            var y = WHxy[3];

            var men = H * W / 2.0;
            var num = (2 * x == W && 2 * y == H) ? 1 : 0;
            WriteLine($"{men} {num}");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
N, M = map(int, input().split())
lstA = list(map(int, input().split()))

x = sorted(lstA)[-M] #大きいほうから数えてM番目(選んだ中では最も小さい)

if(x >= (sum(lstA) * 1) / (4 * M)):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	ll a,b,k,x;
	cin >> a >> b >> k;
	x = min(a,k);
	a -= x;
	k -= x;
	b -= min(b,k);
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int n,s=0;
  cin >> n;
  int n2=n;
  while(n>0)
  {
    s=s+n%10;
    n=n/10;
  }
  if (n2%s==0)
    cout << "Yes";
  else 
    cout << "No";
}

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

#define int long long
#define ct(n) cout << n << endl;
#define rep(i,n) for(int i=0;i<n;i++)

int n,ans,a;

main() {
    cin >> n;
    rep(i,n) {
        cin >> a;
        ans += a;
    }
    ct(ans-n)
}




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

int main() {
  int n,k;cin>>n>>k;
  vector<ll> xp;
  vector<ll> xm;
  rep(i,n) {
    ll x;cin>>x;
    if(x>=0) {
      xp.push_back(x);
    } else {
      xm.push_back(-x);
    }
  }
  sort(xm.begin(), xm.end());
  int pn = xp.size();
  int mn = xm.size();
  ll ans = 1e12;
  if(mn>=k) {
    ans = min(ans, xm[k-1]);
  }
  rep(i,pn) {
    if(i>=k-1) {
      ans = min(ans, xp[i]);
    } else {
      int j=k-(i+1);
      if(j<=mn) {
	ans = min(ans,min(2*xp[i]+xm[j-1],xp[i]+2*xm[j-1]));;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1656
import numpy as np

S = str(input())

import numpy as np

for i in range(1,int(np.floor(len(S)/2))):
    j = int(np.floor(len(S)/2)) - i

    first_str = S[:j]
    second_str = S[j:2*j]
    if first_str == second_str:
        num = 2*j
        break
    elif (first_str != second_str) & (j==1):
        num = 0
        break

print(num)  


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

int popcount(int64_t N)
{
    int x = 0;
    while (N > 0)
    {
        if (N % 2 == 1)
            x++;
        N /= 2;
    }
    return x;
}
int main() {
  int64_t N,mod=0; cin>>N;
  vector<int64_t> S(N);
  vector<int64_t> T(N);
  vector<int64_t> U(N);
  vector<int64_t> ANS(N);
  rep(i,N){
    char a; cin>>a;
    int64_t b= a-'0';
    if(b==1) mod++;
    S.at(i)=b;
  }
  reverse(S.begin(),S.end());
  int64_t k=1,l=1,ansa=0,ansb=0,moda=mod-1,modb=mod+1;
  if(moda>0){
  rep(i,N){
    ansa+=S.at(i)*k;
    ansa%=moda;
    T.at(i)=k;
    k*=2;
    k%=moda;
  }
  }
  rep(i,N){
    ansb+=S.at(i)*l;
    ansb%=modb;
    U.at(i)=l;
    l*=2;
    l%=modb;
  }
  rep(i,N){
    int64_t ans=1;
    if(S.at(i)==0){
      int64_t c=(ansb+U.at(i))%modb;
      while(c!=0){
        int64_t d= popcount(c);
        c%=d;
        ans++;
      }
      ANS.at(i)=ans;
    }
    else{
      if(moda==0) ANS.at(i)=0;
      else{
      int64_t c=(ansa-T.at(i)+moda)%moda;
      while(c!=0){
        int64_t d= popcount(c);
        c%=d;
        ans++;
      }
      ANS.at(i)=ans;
      }
    }
  }
  rep(i,N) cout<<ANS.at(N-1-i)<<endl;
}


Measured memory_bytes: 9576
#include<bits/stdc++.h>
using namespace std;
#define INFTY 200000000000
long long dp[310][310];
vector<long long> a(310);
int b;
long long ch(int l,int r){
    if(dp[l][r]>=0) return dp[l][r];
    if(l==r){
        return dp[l][r]=0;
    }
    for (int k = l; k < r; k++)
    {
        if(abs(a[k]-a[r])<=1 && ch(k+1,r-1) == r-k-1 &&ch(l,k-1)==ch(l,r-1)+1+k-r){
            return dp[l][r] = max(dp[l][r],ch(l,r-1)+2);
        }
    }
    for (int k = l+1; k < r+1; k++)
    {
        if(abs(a[k]-a[l])<=1 && ch(l+1,k-1) == k-l-1 && ch(k+1,r)==ch(l+1,r)+1+l-k){
            return dp[l][r] = max(dp[l][r],ch(l+1,r)+2);
        }
    }
    return dp[l][r] = max(ch(l+1,r),ch(l,r-1));
}
int main(){
    while(1){
    cin >> b;
    if(b==0) return 0;
    for (int i = 0; i < b; i++)
    {
        cin >> a[i];
    }
    
    for (int i = 0; i < 305;i++)
    {
        for(int j=0;j<305;j++){
            dp[i][j] = -1;
        }
    }
    long long ans=0;
   
   ans = ch(0,b-1);
    
    cout << ans << endl;
    }
    
}


Measured memory_bytes: 3896
#include<stdio.h>
int main()
{

    char N[5];
    scanf("%s",&N);
    if(N[0]==N[1] && N[1]==N[2] && N[2]==N[3]){
        printf("Yes");
    }
    else if(N[0]==N[1] && N[1]==N[2]){
        printf("Yes");
    }
    else if(N[1]==N[2] && N[2]==N[3]){
        printf("Yes");
    }
    else {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = [0 for _ in range(10**5 +2)]
b = [0 for _ in range(10**5 +2)]
c = [0 for _ in range(10**5 +2)]

nums = list(map(int,input().split()))

for i in nums:
    a[i-1] +=1
    b[i] +=1
    c[i+1] +=1

ans = [x+y+z for x,y,z in zip(a,b,c)]
print(max(ans))



Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll INF = 1000000000000000000;
int main(int argc, char const *argv[]) {
  ll n, A, B;std::cin >> n >> A >> B;
  vll p(n);re(i, n) scanf("%lld", &p[i]);
  vll idx(n+1); for(int i=0;i<n;i++) idx[p[i]] = i+1;
  vvl dp = VV(n+1, 2*n+2, INF, ll);

  vll prev(2*n+2, 0);
  for(int i=1;i<=n;i++){
    for(int j=1;j<2*n+2;j++){
      if(j==2*idx[i]){
        dp[i][j] = min(dp[i][j], prev[j-1]);
      }else if(j%2==0){
        dp[i][j] = min(dp[i][j], prev[j-1]+ (j<2*idx[i]?B:A));
      }else{
        dp[i][j] = min(dp[i][j], prev[j] + (j<2*idx[i]?B:A));
      }
    }
    for(int j=0;j<2*n+2;j++) prev[j] = INF;
    for(int j=1;j<2*n+2;j++) prev[j] = min(prev[j-1], dp[i][j]);
  }

  ll ans = INF;
  for(int i=1;i<2*n+2;i++) ans = min(ans, dp[n][i]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 391424
import sys

n = int(input())
a = [int(x) for x in input().split()[::-1]]

if 0 < n and a[-1] != 0:
    print(-1)
    sys.exit()

if n == 0:
    if a[0] == 1:
        print(1)
    else:
        print(-1)
    
    sys.exit()

limit = [[a[0], a[0]]]
for i in range(0, n):
    low = -(-limit[i][0] // 2) + a[i + 1]
    high = limit[i][1] + a[i + 1]
    
    limit.append([low, high])
    
limit = limit[::-1]
a = a[::-1]

if 1 < limit[0][0]:
    print(-1)
    sys.exit()

ans, leaf = 1, 2
for i in range(1, n):
    ans += min(limit[i][1], leaf)
    leaf = 2 * (leaf - a[i])
    
ans += a[n]
print(ans)

Measured memory_bytes: 30872
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
string s,a[3];
cin>>s;
int i=0,j=0;
for(int i=0;i<s.size();i++){
if(s[i]==',')
s[i]=' ';
}
cout<<s;
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n;
    string s;
    while(cin>>n>>s)
    {
        for(int i=0;i<s.size();i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(s[i]+1>'Z')
                {
                    s[i]='A';
                }
                else s[i]++;
            }
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x),end(x)

#define forn(i, n) for (int i = 0; i < n; ++i)
#define rforn(i, n) for (int i = n - 1; i >= 0; --i)

const int N = 2e5 + 5, M = 1e9 + 7; // 998244353
const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0};
const ll INF = 1e18 + 10LL;
const ld PI = 4.0 * atan((ld) 1.0), EPS = 1e-6;
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string YN(bool x) { return x ? "YES" : "NO"; }

void solve(int tcn) {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	int s = 0;
	forn(i, n) {
		cin >> a[i];
		s ^= a[i];
	}
	forn(i, n) {
		b[i] = s ^ a[i];
		if (i)
			cout << " ";
		cout << b[i];
	}
	cout << nl;
}

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

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


Measured memory_bytes: 4744
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int a[n+5];
		rep(i,1,n)
			cin >> a[i];
		int cur = 1000; 
		rep(i,1,n-1)
		{
			if(a[i]<a[i+1])
			{
				int f = cur/a[i];
				cur = cur%a[i];
				cur += a[i+1]*f;
			}
		}
		cout << cur;
	}
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,pi
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n,m=mii()
arr=limii()

if n>=sum(arr):
    print(n-sum(arr))
else:
    print(-1)






Measured memory_bytes: 72908
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;

  vector<int> A(n);
  ll sum = 0;
  rep(i, n) {
    cin >> A[i];
    sum ^= A[i];
  }

  if (0 == sum) puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 640
import fractions

a,b,c,d = map(int, input().split())

c_count = b//c - (a-1)//c
d_count = b//d - (a-1)//d
cd_count = b//(c*d//fractions.gcd(c,d)) - (a-1)//(c*d//fractions.gcd(c,d))

print(b-a+1-(c_count+d_count-cd_count))

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

typedef long long ll;
#define int ll
#define pb push_back
const int INF = 1e18, MOD = 1e9+7;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);


	int n,k;
	cin>>n>>k;
	int arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];

	vector<int> dp(k+1,1), next(k+1,0);
	for(int i=1;i<=n;i++){
		next[0]= 1;
		for(int j=1;j<=k;j++){
			int left = max(0ll, j-arr[i]);
			next[j] = (left == 0) ? dp[j]: dp[j] - dp[left-1];
			next[j] += next[j-1];
			if (next[j] > MOD	)
				next[j] -= MOD;
          	if (next[j] < 0)
              next[j] += MOD;
		}
	
		for(int j=0;j<=k;j++)
			dp[j] = next[j];
	}


	if (k!= 0) cout<<(dp[k]-dp[k-1] + MOD)%MOD;
	else cout<<1;

	return 0;
}


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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  int a[2 * n];
  for (int i = 0; i < 2 * n; i++) cin >> a[i];
  sort(a, a + 2 * n);
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += a[i * 2];
  }
  cout << res << "\n";
  return 0;
}

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

int main(int argc, char const *argv[])
{
    int h, w;
    while(1) {
        cin >> h >> w;
        if(h == 0 || w == 0) break;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#define N 100005
#define INF 2000000000
#include <stdio.h>

struct Card {
    char suit;
    int value;
};

struct Card A[N];  //快速排序
struct Card A1[N]; //归并排序
struct Card L[N / 2 + 2], R[N / 2 + 2];

void merge(struct Card C[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i] = C[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = C[mid + i];
    }
    L[n1].value = INF;
    R[n2].value = INF;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            C[k] = L[i++];
        }
        else {
            C[k] = R[j++];
        }
    }
}

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

void swap(struct Card *a, struct Card *b) {
    struct Card tmp = *a;
    *a = *b;
    *b = tmp;
}

int partition(struct Card A[], int p, int r) {
    int x = A[r].value;
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j].value <= x) {
            i = i + 1;
            swap(&A[i], &A[j]);
        }
    }
    swap(&A[i + 1], &A[r]);
    return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}

int main() {
    int flag = 1;
    int n = 0;
    scanf("%d", &n);
    getchar();
    for (int i = 0; i < n; i++) {
        scanf("%C %d", &A[i].suit, &A[i].value);
        getchar();
        A1[i] = A[i];
    }
    mergeSort(A1, 0, n);
    quickSort(A, 0, n - 1);
    for (int i = 0; i < n; i++) {
        if (A1[i].suit != A[i].suit) {
            flag = 0;
            break;
        }
    }
    if (flag) {
        printf("Stable\n");
    }
    else {
        printf("Not stable\n");
    }
    for (int i = 0; i < n; i++) {
        printf("%C %d\n", A[i].suit, A[i].value);
    }
    return 0;
}


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

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

    int s, t, c;
    vector<vector<int>> matrix(35, vector<int>(100005, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> s >> t >> c;
        for (int i = s; i <= t; i++)
        {
            matrix[c][i] |= 1;
        }
    }
    // for (int i = 0; i <= C; i++)
    // {
    //     for (int j = 0; j <= 20; j++)
    //     {
    //         cout << matrix[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    int ans[100005] = {};
    for (int i = 0; i <= 100000; i++)
    {
        for (int j = 1; j <= C; j++)
        {
            ans[i] += matrix[j][i];
        }
    }

    // for (int i = 0; i <= 20; i++)
    // {
    //     cout << ans[i] << " ";
    // }
    // cout << endl;

    cout << *max_element(ans, ans + 100005) << endl;
}


Measured memory_bytes: 14336
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

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

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 2e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int n, k;
ll arr[105], dp[maxn], sum[maxn];

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

    cin >> n >> k;

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

    dp[0] = 1;
    for (ll i = 0; i < n; i++){
        for (ll j = 0; j <= k; j++){
            sum[j + 1] = (sum[j] + dp[j]) % mod;
            dp[j] = (sum[j + 1] - sum[max(0LL, j - arr[i])] + mod) % mod;
        }
    }

    cout << dp[k] << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

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

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    char c;
	    cin>>c;
	    //cout<<c-'a'<<bn;
	    if(c-'a'>=0)
	    cout<<"a"<<bn;
	    else
	    cout<<"A"<<bn;
	   
	   
	   
	    
	}
	
	return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

int main(int argc, char const* argv[])
{
  int a, b;
  cin>>a>>b;
  if(a>b) rep(i,a) printf("%d",b);
  else rep(i,b) printf("%d",a);
  printf("\n");

  return 0;
}


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

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

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<i32>();
    if n % 2 == 0{
        println!("{}",n);
    } else {
        println!("{}", n * 2);
    }
}

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

int main(){
    string s;
    cin >> s;
    if(s.size()==2)
    cout << s << endl;
    else{
        for(int i=s.size()-1;i>=0;i--)
        cout << s[i];
        cout << endl;
    }
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif // LOCAL
#include <bits/stdc++.h>

#define sz(c) int((c).size())

using namespace std;

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    long long k;
    int n;

    while (cin >> n >> k)
    {
        cerr << "in" << endl;

        vector<int> a(n);
        for (int &x : a)
            cin >> x;

        vector<int> next(n, -1);
        map<int, int> first;
        for (int i = n - 1; i >= 0; i--)
        {
            if (first.count(a[i]))
                next[i] = first[a[i]];
            first[a[i]] = i;
        }

        vector<int> who_first (n + 1, -1);

        for (int i = n - 1; i >= 0; i--)
        {
            if (next[i] == -1)
                who_first[i] = a[i];
            else
                who_first[i] = who_first[next[i] + 1];
        }
        first[-1] = -1;

        cerr << "here" << endl;

        int v = -1;
        map<int, int> when;
        when[-1] = 0;

        for (long long i = 1; i <= k - 1; i++)
        {
            v = who_first[first.at(v) + 1];

            if (when.count(v))
            {
                const int cycle = i - when[v];
                const long long repeats = (k - 2 - i) / cycle;
                if (repeats >= 0)
                    i += repeats * cycle;
            }
            else
            {
                when[v] = i;
            }
        }

        cerr << "there" << endl;

        vector<int> stck;
        map<int, int> where;

        for (int i = first.at(v) + 1; i < n; i++)
        {
            if (!where.count(a[i]))
            {
                where[a[i]] = sz(stck);
                stck.push_back(a[i]);
            }
            else
            {
                int pos = where.at(a[i]);
                for (int i = pos; i < sz(stck); i++)
                    where.erase(stck[i]);
                stck.resize(pos);
            }
        }

        for (int x : stck)
            cout << x << ' ';
        cout << endl;
    }
}

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

#ifdef LOCAL
    ifstream in ("input.txt");
    ofstream out ("output.txt");
    solve (in, out);

    cout << setprecision (4);
    cout << "clock: " << clock () / (double) CLOCKS_PER_SEC << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


Measured memory_bytes: 29940
#include<stdio.h>

int main(){
  double d,m,n,ave,sum=0;
  scanf("%lf %lf %lf",&n,&m,&d);
  sum=2*n-2*d;
  if(d==0)
    sum/=2;
  sum/=n;
  sum/=n;
  sum*=(m-1);
  printf("%.10f\n",sum);
}

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

using namespace std;

int main() {

	int n,m;
	cin >> n >> m;

	vector<vector<int>> a(n, vector<int>(m, 0));

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

	vector<int> b(m, 0);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

	int c;
	for (int i = 0; i < n; i++) {
		c = 0;
		for (int j = 0; j < m; j++) {
			c += a[i][j] * b[j];
		}
		cout << c << endl;
	}


}


Measured memory_bytes: 3204
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


# エントリーポイント
PARA = {"R": (1, 0, 0), "G": (0, 1, 0), "B": (0, 0, 1)}
PARA2 = {"R": 0, "G": 1, "B": 2}


def main():
    N, S = input(int, str)
    count = [(0, 0, 0)]
    for s in reversed(S):
        left = count[-1]
        count.append(((left[0] + PARA[s][0]),
                      (left[1] + PARA[s][1]),
                      (left[2] + PARA[s][2])))
    count.reverse()
    ans = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            if S[i] == S[j]:
                continue
            last = ({"R", "G", "B"} - {S[i], S[j]}).pop()
            ans += count[j + 1][PARA2[last]]
            if ((j * 2 - i < N) and S[j * 2 - i] == last):
                ans -= 1
    print(ans)

    return


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 74912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    int n, m; cin >> n >> m;
    ll hw = 0;
    rep(i, m)
    {
        ll tmp;cin >> tmp;
        hw += tmp;
    }
    cout << max(n-hw, -1LL) << endl;
    return;
}

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


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n;cin>>n;
    cout<<24-n+24<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a[5],k;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
    sort(a,a+5);
    if(a[4]-a[0]<=k)
    {
        cout<<"Yay!";
        return 0;
    }
    cout<<":(";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b;
	
	while(1){
		scanf("%d %d", &a, &b);
		
		if(a == 0 && b == 0)	break;
		
		if(a >b){
			printf("%d %d\n", b, a);
		}else{
			printf("%d %d\n", a, b);
		}
	}
	
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 200005;

int n, m;
int A[SIZE], B[SIZE], C[SIZE];
int main(){
	cin>>n>>m;
	for(int i = 0; i < m; i ++)
		cin>>A[i]>>B[i];
		
	for(int i = 0; i < m; i ++)
		if(A[i] == 1)C[B[i]] = 1;
	
	bool ans = false;
	for(int i = 0; i < m; i ++){
		if(B[i] == n&&C[A[i]] == 1)ans = true;
		if(ans)break;
	}	

	if(!ans)cout<<"IM";
	cout<<"POSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 2560
def checkACGT(s):
    ss = ''.join(s)
    check = ss.replace('A', '').replace('C', '')\
    .replace('G','').replace('T', '')
    if len(check) == 0:
        return True
    else:
        return False


s = input()
ans = 0
for i in range(len(s)):
    for j in range(len(s) - i + 1):
        ss = s[i:j + i]
        # print(ss)
        if (checkACGT(ss)):
            ans = max(ans, len(ss))
print(ans)


Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std; 
#define ll long long  
#define vi  vector<int> 
#define vll vector<long long> 
#define pii pair<int,int> 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define  pb  push_back
#define fi  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end()) 
#define m_p make_pair
int main(){
ll n; ll k;
cin>>n>>k; 
vector<pll> a(n); 

for(int i=0;i<n;i++)
{
	ll x,y; 
	cin>>x>>y;
	a[i]=(make_pair(x,y)); 
}

SORT(a);  
ll pre =0;
for(int i=0; i<n;i++ )
{
	pre+=a[i].sec; 
	if(pre>=k)
	{	cout<<a[i].fi;
		return 0;}  
}



return 0; 
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
#define display(v) f(v.size())cout << v[i] << " "
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
int n,m ; cin>>n>>m;
vector<pair<int,int> > v;

f(m)
{
   int a,b;   cin>>a>>b;
   v.pb({a,b});
}
int st = pow(10,n-1);
int ed = pow(10,n) -1;
if(n==1)st = 0;
for(int val = st;val <= ed;val++)
{
   string s = to_string(val);
   int f = 1;
   for(int j =0;j<v.size();j++)
   {
      int a = v[j].ff;
      int b = v[j].ss;
      char bb = b + '0';
      //cout << bb << "\n";
      if(s[a-1] != bb)
      {
         f =0;break;
      }
   }
   if(f == 1)
   {
      cout << s; return 0;
   }
}
cout << -1;


   return 0;
}     

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;ll h,w;ll ans;
ll jisuan(ll i,ll j,ll s)
{
	ll s1,s2;
	if(!(i&1)||!(j&1)){
		s1=s2=i*j/2;
	}
	else{
		if(i<j){
			s1=i*(j>>1);
			s2=i*(j-(j>>1));
		}
		else 
		{
			s1=j*(i>>1);
			s2=j*(i-(i>>1));
		}
	}
	return max(max(s1,s2),s)-min(min(s1,s2),s);
}
int main()
{
	cin>>h>>w;
	ans=h*w;
	for(ll i=1;i<h;i++)
	{
		ll j=h-i;
		ans=min(ans,jisuan(j,w,i*w));
		ans=min(ans,jisuan(i,w,j*w));
	}
	for(ll i=1;i<w;i++)
	{
		ll j=w-i;
		ans=min(ans,jisuan(j,h,i*h));
		ans=min(ans,jisuan(i,h,j*h));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-i for i in a]
heapify(a)

for i in range(m):
    x = heappop(a)
    heappush(a, int(x/2))

ans = 0
for i in range(n):
    ans += -a[i]
print(ans)

Measured memory_bytes: 85096
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    System.out.println(lcm(A,B));
    }
    static long lcm (long a, long b) {
	long temp;
	long c = a;
	c *= b;
	while((temp = a%b)!=0) {
		a = b;
		b = temp;
	}
	return (long)(c/b);
}
 }


Measured memory_bytes: 23380
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int main() {
    ll a;
    string b;
    cin >> a >> b;

    ll B = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    ll x = a * B;
    cout << x / 100 << "\n";
    return 0;
}


Measured memory_bytes: 3624
N,M=map(int,input().split())
sc_list=[list(map(int,input().split())) for i in range(M)]

result_n = [0] * N

flag_lsit = [False] * N

for line in sc_list:
    first_n = line[0]
    second_n = line[1]

    if flag_lsit[first_n-1] == False:
        result_n[first_n-1] = second_n
        flag_lsit[first_n-1] = True
    else:
        if not(result_n[first_n-1] == second_n):
            print(-1)
            exit()
            
# 先頭が0
if result_n[0] == 0:
    if N == 1:
        print(0)
        exit()
    if flag_lsit[0] == True: # 変更があった
        print(-1)
    else:
        result_n[0] = 1
        for i in result_n:
            print(i,end="")
        print()

else:
    for i in result_n:
        print(i,end="")
    print()


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

int main() {
  int n, k;
  cin >> n >> k;
  
  string s;
  cin >> s;
  
  if (s.at(k-1) == 'A') {
    s.at(k-1) = 'a';
    cout << s << endl;
  }
  else if (s.at(k-1) == 'B') {
    s.at(k-1) = 'b';
    cout << s << endl;
  }
  else {
    s.at(k-1) = 'c';
    cout << s << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}

int main() {

	ll m, n;
	cin >> n >> m;
	vecll a(n);
	ll sum = 0;
	ll cnt = 0;
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	for (ll i = 0; i < n; i++)
	{
		if (a[i] * 4 * m >= sum) {
			cnt++;
		}
	}

	if (cnt >= m)
	{
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	cout << endl;

	return 0;
}


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

int main() {
  int n; cin >>n;
  int ans = 0;
  for (int i=1; i<=n; i+=2){
    int cnt = 0;
    for (int j=1; j*j<=i; j++){
      if (i%j==0) cnt++;
    }
    if (cnt==4) ans++;
  }
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
// ABC083_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    
    // calculation
    if (A+B > C+D) {
        cout << "Left" << "\n";
    } else if (A+B == C+D) {
        cout << "Balanced" << "\n";
    } else {
        cout << "Right" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
s = input()
no = False
if (s.count("N") == 0 and s.count("S") > 0)\
  or (s.count("N") > 0 and s.count("S") == 0)\
  or (s.count("W") == 0 and s.count("E") > 0)\
  or (s.count("W") > 0 and s.count("E") == 0):
  no = True
if no:
  print("No")
else:
  print("Yes")

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

int main(){
  
  int N; cin >> N;
  vector<pair<pair<string,int>,int>> P(N);
  for (int i=0;i<N;i++){
    string s;
    int p;
    cin >> s >> p;
    P.at(i).first = make_pair(s,-p);
    P.at(i).second = i;
  }
  
  sort(P.begin(),P.end());
  
  for (int i=0;i<N;i++){
    cout << P.at(i).second + 1 << endl;
  }
}


Measured memory_bytes: 256