akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  long long int n,m;
  cin >> n >> m;
  vector<pair<long long int,long long int>> shop(n);
  for(int i=0;i<n;i++)
    cin >> shop.at(i).first >> shop.at(i).second;
  
  sort(shop.begin(),shop.end());
  
  long long int k=0; long long int money=0;
  
  for(int i=0;i<n;i++){
    if(m-k<=shop.at(i).second){
      money+=shop.at(i).first*(m-k);
      break;
    }
    else{
      k+=shop.at(i).second;
      money+=shop.at(i).first*shop.at(i).second;
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 1920
n, k = map(int, input().split(" "))
h = [int(i) for i in input().split(" ")]

dp = [0] * n

for i in range(1, n, 1):
  candidate = []
  for j in range(min(i, k)) :
    candidate.append(dp[i - j - 1] + abs(h[i - j -1] - h[i]))
  dp[i] = min(candidate)

print(dp[n-1])

Measured memory_bytes: 53584
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int main(){
    int n,q;
    std::cin >> n;
    VEC(int,s,n);
    //int q;
    std::cin >> q;
    VEC(int,t,q);
    int ans=0;
    rep(i,q){
        if(lb(all(s),t[i])!=ub(all(s),t[i]))ans++;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    ll mi = a[0], ma = a[a.size()-1];
    ll misum = inf;
    for (ll cand = mi; cand <= ma; cand++) {
        ll _sum = 0;
        for (auto elem : a) {
            _sum += pow(elem - cand, 2);
        }
        misum = min(misum, _sum);
    }
    cout << misum << endl;
    return 0;
}

Measured memory_bytes: 256
/*
   ,##.                   ,==.
 ,#    #.                 \ o ',
#        #     _     _     \    \
#        #    (_)   (_)    /    ; 
 `#    #'                 /   .'  
   `##'                   "=="
*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#define ll long long
#define null NULL
#define all(a) a.begin(), a.end()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)

using namespace std;

const ll MOD = 1e9 + 7;

ll a, b, c, k;

int main() {
	cin >> a >> b >> c >> k;
	if (k % 2 == 0)
		cout << a - b << endl;
	else
		cout << b - a << endl;
}

Measured memory_bytes: 256
s = list(input())
a = int("".join(s[:2]))
b = int("".join(s[2:]))

a_YY = 0
a_MM = 0
b_YY = 0
b_MM = 0

if a <= 12 and a >= 1:
    a_MM = 1
elif a == 0 or (a > 12 and a <= 99):
    a_YY = 1

if b <= 12 and b >= 1:
    b_MM = 1
elif b == 0 or (b > 12 and b <= 99):
    b_YY = 1

if a_MM == 1 and b_MM == 1:
    print("AMBIGUOUS")
elif a_MM == 1 and b_YY == 1:
    print("MMYY")
elif b_MM == 1 and a_YY == 1:
    print("YYMM")
else:
    print("NA")

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

using namespace std;
typedef long long ll;

void setmin(ll& a, ll b){
    if(a > b){ a = b; }
}

void setmax(ll& a, ll b){
    if(a < b){ a = b; }
}

int main(){
    string s, t;
    cin >> s >> t;
    vector<vector<ll>> dp(s.size(), vector<ll>(t.size(), 0));
    for(int i = 0; i < s.size(); ++i){
        for(int j = 0; j < t.size(); ++j){
            if(i > 0){
                setmax(dp.at(i).at(j), dp.at(i - 1).at(j));
            }
            if(j > 0){
                setmax(dp.at(i).at(j), dp.at(i).at(j - 1));
            }
            if(i > 0 && j > 0){
                setmax(
                    dp.at(i).at(j),
                    dp.at(i - 1).at(j - 1) + (s.at(i) == t.at(j)));
            }else{
                setmax(dp.at(i).at(j), (s.at(i) == t.at(j)));
            }
        }
    }

    string ans;
    int i = s.size() - 1, j = t.size() - 1;
    while(i >= 0 && j >= 0 && dp.at(i).at(j) > 0){
        if(i > 0 && j > 0 &&
           dp.at(i).at(j) == dp.at(i - 1).at(j - 1) + (s.at(i) == t.at(j))){
            if(s.at(i) == t.at(j)){
                ans.push_back(s.at(i));
            }
            i--; j--;
        }else if(dp.at(i).at(j) == (s.at(i) == t.at(j))){
            if(s.at(i) == t.at(j)){
                ans.push_back(s.at(i));
            }
            i--; j--;
        }else if(i > 0 && dp.at(i).at(j) == dp.at(i - 1).at(j)){
            i--;
        }else if(j > 0 && dp.at(i).at(j) == dp.at(i).at(j - 1)){
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,j,k;
  string s;
  s="Z";
  k=s[0];
  cin>>n>>s;
  for(int i=0;i<s.length();i++){
    j=s[i]+n;
    if(j>k){j-=26;}
    s[i]=j;
  }
  cout<<s<<"\n";
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    vint a = in(n);
    int tmp = 1;
    int cnt = 0;
    rep(i, n)
    {
        if (a[i] != tmp)
            ++cnt;
        else
            ++tmp;
    }
    if (cnt == n)
        cnt = -1;
    cout << cnt << endl;
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   
   ll cnt = 0;
   
   while(b<=a)
        b*=2, cnt++;
   while(c<=b)
        c*=2, cnt++;
   
   if(cnt<=k)
        cout<<"Yes\n";
   else cout<<"No\n";        
   
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>
int main(){
  int N,L,i; scanf("%d %d",&N,&L);
  int apple[N];
  for(i=0;i<N;++i)apple[i]=L+i;
  int sum=0;
  for(i=0;i<N;++i)sum+=apple[i];

  int MIN=1000;
  for(i=0;i<N;++i){
    if(abs(apple[i])<abs(MIN))MIN=apple[i];
  }

  printf("%d\n",sum-MIN);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void QuickSort(int arr[],int l,int h)

{

         if(!(l<h))

                   return;

         int m,tmp=arr[l];

         int low=l,high=h;

         while(low<high)

         {

                   while(arr[high]>=tmp&&high>low)high--;

                   if(high>low)

                            arr[low++]=arr[high];

                   while(arr[low]<=tmp&&high>low) low++;

                   if(high>low)

                            arr[high--]=arr[low];

         }

         m=low;

         arr[m]=tmp;

         QuickSort(arr,l,m-1);

         QuickSort(arr,m+1,h);

}
int main()
{
	int n,i,count=1;
	int a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	QuickSort(a,0,n-1);
	for(i=n-2;i>=0;i--)
	{
		if(a[i]<a[i+1])	
			count++;
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
bool cmp(int a,int b){
    return a>b;
}
int main(){
    int n, k, x;
    cin>>n>>k;
    
    int a[200000+5]={0};
    
    for (int i=0;i<n;i++)
	{
        cin>>x;
        a[x]++;
    }
    
	sort(a+1,a+200000+1,cmp);
    
	int count=0;
    
	for(int i=k+1;i<=200000;i++)count+=a[i];
    
	cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10,maxh=1e4+10;
int h,n;
int a[maxn],b[maxn];
int dp[maxn][maxh];
int main()
{
	cin>>h>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
	}
	memset(dp,1e9,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		for(int v=h-1;v>=0;v--)
		{
			dp[i][v]=(i==0?1e9:dp[i-1][v]);
			int tmp=(v+a[i]>=h?0:dp[i][v+a[i]]);
			int tmp2=tmp+b[i];
			dp[i][v]=min(dp[i][v],tmp2);
		}
	}
	cout<<dp[n-1][0]<<endl;
	return 0;
}

Measured memory_bytes: 39808
N = int(input())

li = [[0 for j in range(9)] for i in range(9)]


for i in range(1,N+1):
    start = str(i)[0]
    end = str(i)[-1]
    if start != '0' and end != '0':
        li[int(start)-1][int(end)-1] += 1
ans = 0
for i in range(1,N+1):
    start = str(i)[0]
    end = str(i)[-1]
    if start != '0' and end != '0':
        ans += li[int(end)-1][int(start)-1]
print(ans)

Measured memory_bytes: 3064
from sys import stdin
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(stdin.readline().rstrip())
res = 0
if N>=2:
  c = collections.Counter(prime_factorize(N))
  for v in c.values():
    for n in range(1,10):
      if v < n:
        break
      else:
        v -= n
        res += 1
print(res)

Measured memory_bytes: 9464
import math
from fractions import Fraction
a,b,x=map(int,input().split())
if b*(a**2)<=x*2:
    print(math.degrees(math.atan(Fraction(2*(a*a*b-x),a**3))))
else:
    print(math.degrees(math.atan(Fraction(a*b*b,2*x))))

Measured memory_bytes: 10504
#include <iomanip>
#include <iostream>
#include <math.h>
using namespace std;
const int N=3e3+10;
const long double pi=acos(-1);
long double X(long double t,long double l){return cos((2*pi*t)/l);}
long double Y(long double t,long double l){return sin((2*pi*t)/l);}
long double midpoint(long double a,long double b,long double l){
	if(a<b)return (a+b)/2;
	else if(a+b<l)return (l+a+b)/2;
	else return (a+b-l)/2;
}
int main(){
	long long int n,tot;
	long double x=0,y=0,l,t[N],pos;
	cin>>n>>l;
	for(int i=1;i<=n;i++)cin>>t[i];
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		pos=midpoint(t[i],t[j],l);
		x+=X(pos,l)*(n-j+i-1);
		y+=Y(pos,l)*(n-j+i-1);
		pos=midpoint(t[j],t[i],l);
		x+=X(pos,l)*(j-i-1);
		y+=Y(pos,l)*(j-i-1);
	}
	tot=(((n*(n-1))/2)*(n-2))/3;
	cout<<fixed<<setprecision(20)<<x/tot<<' '<<fixed<<setprecision(20)<<y/tot<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();

    if (K < A) {
      System.out.println(1 + K);
      return;
    }    
    if (B - A <= 2) {
      System.out.println(K+1);
      return;
    }

    long n = 1;
    K -= A-1;
    n += A-1;
    n += (long)K/2 * (B-A);
    if (K%2 == 1) {
      n++;
    }
    
    System.out.println(n);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>


void swap(int x,int y){
    int tmp;
    
    tmp=x;
    x=y;
    y=tmp;

}

int main(int argc, const char * argv[]) {
    
    int n,m,taro[100],hana[100],card,i=0,j = 0,tsum = 0,hsum = 0,flag = 0;
    
    while (1) {
        scanf("%d %d",&n,&m);
        
        if (n==0&&m==0) {
            break;
        }
        //card??\??????
        for (i = 0; i < n; i++) {
            scanf("%d",&card);
            taro[i] = card;
        }
        //card??\??????
        for (i = 0; i < m; i++) {
            scanf("%d",&card);
            hana[i] = card;
        }
        
        //?????????sort(??????)
        
        for (i = 0; i < n-1; i++) {
            for (j = n-1; j > i; j--) {
                //taro
                if (taro[j] < taro[j-1]) {
                    swap(taro[j],taro[j-1]);
                }
                //hana
                if (hana[j] < hana[j-1]) {
                    swap(hana[j],hana[j-1]);
                }
                
            }
        }
        
        for (i=0; i<n; i++) {
            tsum += taro[i];
        }
        
        for (i=0; i<m; i++) {
            hsum += hana[i];
        }
        
        //????????????????????§??????????????????????????????????°?
        for (i = 0; i < n; i++) {
            for (j = 0; j < m; j++) {
                if (tsum-(2*taro[i]) == hsum-(2*hana[j])) {
                    printf("%d %d\n",taro[i],hana[j]);
                    flag = 1;
                    break;
                }
            }
            if (flag==1) {
                //printf("flag1\n");
                break;
            }
        }
        
        if (flag == 0) {
            printf("-1\n");
        }
        
        flag = 0;
        tsum = 0;
        hsum = 0;
    }
    return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n >> m >> l;
  ll xa = 0,xb = n;
  ll ya = 0,yb = m;
  rep(i,0,l){
    ll a,b,c;
    cin >> a >> b >> c;
    if(c == 2){
      xb = min(xb,a);
    }else if(c == 1){
      xa = max(xa,a);
    }else if(c == 4){
      yb = min(yb,b);
    }else{
      ya = max(ya,b);
    }
  }
  if(xa >= xb || ya >= yb)puts("0");
  else print((xb-xa) * (yb - ya));
  return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let mut count_r = 0u64;
    let mut count_g = 0u64;
    let mut count_b = 0u64;

    for &c in &s {
        match c {
            'R' => count_r += 1,
            'G' => count_g += 1,
            _ => count_b += 1,
        }
    }

    let mut ans: u64 = count_r * count_g * count_b;

    for d in 1..s.len() {
        for i in 0..s.len() {
            if i + 2 * d >= s.len() {
                break;
            }

            if s[i] != s[i + d] && s[i] != s[i + 2 * d] && s[i + d] != s[i + 2 * d] {
                ans -= 1;
            }
        }
    }

    println!("{}", ans);
}


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


int A[3][3];
int B[3];
int cura[3][3];

void success() {
	cout << "Yes";
	exit(0);
}

int main() {
	for (int i =0;i<3;i++) {
		for (int j=0;j<3;j++) {
			cin >> A[i][j];
		}
	}
	
	for (int x = 0; x <= A[0][0]; x++) {
		bool fail = false;
		for (int i =0;i<3;i++) {
			if (A[i][0] < x) fail = true;
			B[i] = A[i][0] - x;
		}
		for (int i =0;i<3;i++) {
			cura[i][1] = A[i][1] - B[i];
			cura[i][2] = A[i][2] - B[i];
		}
		
		for (int j=1;j<3;j++) {
			if (cura[0][j] != cura[1][j]) fail = true; 
			if (cura[1][j] != cura[2][j]) fail = true;
			if (cura[1][j] < 0) fail = true;
		}
		if (!fail) success();
	}
	cout << "No";
}




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

int main(){
  int a, b, k;
  
  cin >> a >> b >> k;
  
  int ans=0;
  
  for(int i=min(a,b); i>=1 && k>0; i--){
  	if((a%i==0) &&  (b%i==0)){
      ans=i;
      k--;
    }
  }
  cout << ans;
  return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, x, y;
    cin >> n >> x >> y;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    ll ans = abs(a[n-1] - y);
    if(n >= 2) ans = max(ans, abs(a[n-1]-a[n-2]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import heapq

N, M = [int(x) for x in input().split()]
A = [-int(x) for x in input().split()]

heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, -((-a)//2))

ans = -sum(A)

print(ans)

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

int main() {
  int X, a;
  int sum = 0;
  cin >> X;
  
  for (int i = 0; i<9; i++) {
    a = pow(10,i);
    sum += (X % (a*10)) / a;
  }
  
  
  if (X % sum == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
  
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: [usize; n], mut b: [usize; n]);
    let d = (0..n).map(|i| a[i] ^ a[(i + 1) % n]).collect::<Vec<_>>();
    let c = (0..n).map(|i| b[i] ^ b[(i + 1) % n]).collect::<Vec<_>>();
    let mut table = vec![0; n + 1];

    table[0] = !0;
    let mut j = !0usize;
    for i in 0..n {
        while j < c.len() && c[i] != c[j] {
            j = table[j]
        }
        j = j.wrapping_add(1);
        table[i + 1] = j;
    }

    let mut i = 0;
    let mut j = 0;
    let mut pos = vec![];
    while i < n {
        while j < n && c[j] == d[(i + j) % n] {
            j += 1;
        }
        if j == n {
            pos.push(i);
        }
        if j == 0 {
            i += 1;
        } else {
            i += j - table[j];
            j = table[j];
        }
    }
    for i in pos {
        println!("{} {}", i, a[i] ^ b[0]);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll x,y,a,b,c;
vll p,q,r;


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  cin >> x >> y >> a >> b >>c;
  p.resize(a);
  q.resize(b);
  r.resize(c);
  rep(i,0,a) cin >> p[i];
   rep(i,0,b) cin >> q[i];
   rep(i,0,c) cin >> r[i];
  
  ll res=0;
  sort(p.begin(),p.end(),greater<ll>());
  sort(q.begin(),q.end(),greater<ll>());
  sort(r.begin(),r.end(),greater<ll>());
 
  priority_queue<ll> que;
  rep(i,0,x) que.push(p[i]);
  rep(i,0,y) que.push(q[i]);
  rep(i,0,c) que.push(r[i]);
  

  rep(i,0,x+y) {
    res+=que.top();
    que.pop();
  }
  cout << res << endl;
  
}

Measured memory_bytes: 8944
/*
  Name:
  Author: Homo_sapiens
  Date:   2020/6/13 20:03:05
  Source:
  Description:
  
*/

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define IL inline
using namespace std;

char s[25];

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	scanf("%s",s+1);
	string str="";
	for(int i=1;i<=3;i++)
		str+=(tolower(s[i]));
	cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main
{
	
	static int[] dp;
	static ArrayList<Integer>[] graph;
	public static int dfs(int u) {
		if(dp[u]!=-1) {
			return dp[u];
		}
		int ans = 0;
		for(int v: graph[u]) {
			ans = Math.max(ans, dfs(v)+1);
		}
		dp[u] = ans;
		return ans;
	}
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int N = Integer.parseInt(st.nextToken()); int M = Integer.parseInt(st.nextToken());
		
		graph = new ArrayList[N+1];
		for(int i=1; i<=N; i++) {
			graph[i] = new ArrayList<Integer>();
		}
		
		for(int i=0; i<M; i++) {
			st = new StringTokenizer(br.readLine());
			graph[Integer.parseInt(st.nextToken())].add(Integer.parseInt(st.nextToken()));
		}
		
		dp = new int[N+1];
		Arrays.fill(dp, -1);
		
		int ans = 0;
		for(int i=1; i<=N; i++) {
			ans = Math.max(ans, dfs(i));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 73088
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'



int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);
	
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if (ceil((double)a/d) >= ceil((double)c/b))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	//system("pause");
	return 0;
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
const int mod = (int)1e9 + 7;

vector<int> g[MX];
int dp[MX][2];

void mul(int &x, int y){
    x = (x * 1LL * y) % mod;
}

void dfs(int x, int par){
    dp[x][0] = dp[x][1] = 1;
    for(auto y : g[x]){
        if(y == par) continue;
        dfs(y, x);
    }

    for(auto y : g[x]){
        if(y == par) continue;
        mul(dp[x][0], dp[y][1]); // to be black, all children must be white
        mul(dp[x][1], dp[y][0] + dp[y][1]); // if you're white, you children can be anything
    }
}

int main(){

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

    int n;
    cin >> n;

    for(int i = 0; i < n - 1; ++i){
        int x, y;
        cin >> x >> y;
        --x, --y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    dfs(0, -1);

    cout << (dp[0][0] + dp[0][1]) % mod << endl;

    return 0;
}

Measured memory_bytes: 13440
N=int(input())
Time_Table=[[int(i) for i in input().split()] for i in range(N)]
Price=[[int(i) for i in input().split()] for i in range(N)]
S=-10000000000000
for i in range(1,1024):
  List_kari=[]
  List=[0]*10
  List_kari=list(str(bin(i))) 
  S_kari=0
  del List_kari[0:2]
  for j in range(len(List_kari)):
    List[9-j]=int(List_kari[len(List_kari)-j-1])
  for k in range(N):
    m=0
    for n in range(10):
      if Time_Table[k][n]==1 and List[n]==1:
        m+=1
    S_kari+=Price[k][m]    
  if S<S_kari:
    S=S_kari
print(S)  



Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
tof = True
ans = 0
for i in range(n):
    if a[i]%2 == 1: tof = False
while tof:
    for i in range(n):
        a[i] //=2
    ans += 1
    for i in range(n):
        if a[i]%2 == 1: tof = False
print(ans)


Measured memory_bytes: 3060
prilen = 123456 * 2 + 1
prime = [True] * prilen
prime[0] = prime[1] = False
for i in range(2, int(prilen ** 0.5)):
    if prime[i]:
        for j in range(i * 2, prilen, i):
            prime[j] = False
            
prinum = [0] * prilen
for i in range(1, prilen):
    prinum[i] = prinum[i - 1] + prime[i]

while True:
    n = int(input())
    if n == 0:
        break
    print(prinum[2 * n] - prinum[n])

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
using System;

public class Test
{
    public static void Main()
    {
        int a, b,c;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);

        if (a < b && b < c)
        {
            Console.WriteLine("Yes");
        }

        else
        {
            Console.WriteLine("No");
        }

    }
}


Measured memory_bytes: 17928
#include <iostream>

using namespace std;

int main(){
    int N,Y;
    cin >> N >> Y;
    Y /= 1000;
    for(int i=0; i<=N;i++){
        if(10*i>Y) break;
        for(int j=0; j<=N-i;j++){
            int k = N-i-j;
            int yen = 10*i + 5*j + k;
            if(yen == Y){
                cout << i <<  " " << j << " " << k << endl;
                return 0;
            }else if(yen > Y) break;
        }
    }
    cout << -1 <<  " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s=="Sunny")cout<<"Cloudy";
  if(s=="Cloudy")cout<<"Rainy";
  if(s=="Rainy")cout<<"Sunny";
  return 0;
}


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

int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  long long happiness = 0;
  for (int i = 0; i < n-1; i++) {
    if (s[i] == s[i+1]) happiness++;
  }
  //cerr << happiness << endl;
  
  long long l = 0;
  long long r = n-1;
  
  for (int i = 0; i < k; i++) {
    if (happiness >= n-1) break;
    for (int i = l; i < r; i++) {
      if (s[i] != s[i+1]) {l = i+1; break;}
    }
    for (int i = r; i >= l; i--) {
      if (s[i-1] != s[i]) {r = i-1; break;}
    }
    //cerr << l << ' ' << r << endl;
    if (l > r) { happiness++; }
    else { happiness += 2; }
  }
  
  cout << happiness << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define clr clear()
#define pb push_back
#define sz size()
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int INF = 1e8;

int n,m,c;
int f,t,cost;
vector<P> g[101];
int d[101][100001];

int main(){
  while(cin >> n >> m >> c,n){
    rep(i,n){
      g[i].clr;
      rep(j,c+1)d[i][j] = INF;
    }

    rep(i,m){
      cin >> f >> t >> cost;
      f--; t--;
      g[f].pb(P(cost,t));
    }

    priority_queue<P2,vector<P2>,greater<P2> > q;
    q.push(P2(0,P(0,0)));
    d[0][0] = 0;

    while(q.sz){
      P2 p=q.top(); q.pop();
      int change = p.fs, v = p.sc.fs, dis = p.sc.sc;
      if(change > d[v][dis])continue;
      if(v == n-1)break;

      rep(i,g[v].sz){
	int nd = dis+g[v][i].fs, nv = g[v][i].sc;
	if(d[nv][dis] > change + 1){
	  d[nv][dis] = change + 1;
	  q.push(P2(d[nv][dis],P(nv,dis)));
	}

	if(nd>c)continue;
	if(d[nv][nd] > change){
	  d[nv][nd] = change;
	  q.push(P2(d[nv][nd],P(nv,nd)));
	}
      }
    }

    int ans = INF;
    rep(i,c+1)ans = min(ans,d[n-1][i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 49872
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  int V[N]; rep(i, N) cin >> V[i];

  int result = 0;
  rep(i, min(N+1, K+1)) {
    rep(x, i+1) {
      vector<int> tmp={}; 
      rep(j, x) tmp.push_back(V[j]);
      rep(j, i-x) tmp.push_back(V[(N-1)-j]);
      int sum=0; for(auto x: tmp) sum+=x;
      sort(tmp.begin(), tmp.end());
      rep(j, min(K-i, (int)tmp.size())) {
        if (tmp[j]>=0) break;
        else sum -= tmp[j];
      }
      // cout << i << " " << x << " " << sum << endl;
      result = max(result, sum);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.awt.Polygon;
import java.awt.geom.Line2D;
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			for (int i = 0; i < n; i++) {
				int m = scanner.nextInt();
				Polygon[] tetragon = new Polygon[m];
				Line2D[][] lines = new Line2D[m][4];
				for (int j = 0; j < m; j++) {
					int[] xs = new int[4];
					int[] ys = new int[4];
					for (int j1 = 0; j1 < 4; j1++) {
						xs[j1] = scanner.nextInt();
						ys[j1] = scanner.nextInt();
					}
					tetragon[j] = new Polygon(xs, ys, 4);
					for (int k = 0; k < 4; k++) {
						lines[j][k] = new Line2D.Double(xs[k], ys[k],
								xs[(k + 1) % 4], ys[(k + 1) % 4]);
					}
				}
				UnionFin unionFin = new UnionFin(m);
				for (int j = 0; j < m; j++) {
					for (int k = j + 1; k < m; k++) {
						if (unionFin.isSame(j, k))
							continue;
						boolean flag = false;
						if (tetragon[j].contains(tetragon[k].xpoints[0],
								tetragon[k].ypoints[0])
								|| tetragon[k].contains(tetragon[j].xpoints[0],
										tetragon[j].ypoints[0])) {
							flag = true;
						} else {
							for (int l = 0; l < 4; l++) {
								for (int p = 0; p < 4; p++) {
									if (lines[j][l].intersectsLine(lines[k][p])) {
										flag = true;
										break;
									}
								}
							}
						}
						if (flag)
							unionFin.unite(j, k);
					}
				}
				System.out.println(unionFin.num);
			}
		}
	}

	class UnionFin {
		int[] par, rank;
		int num;

		public UnionFin(int size) {
			num = size;
			par = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++)
				par[i] = i;
		}

		int root(int x) {
			if (par[x] == x)
				return x;
			else
				return par[x] = root(par[x]);
		}

		void unite(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (rank[x] < rank[y])
				par[x] = y;
			else {
				par[y] = x;
				if (rank[x] == rank[y])
					rank[x]++;
			}
			num--;
		}

		boolean isSame(int x, int y) {
			return root(x) == root(y);
		}
	}
}

Measured memory_bytes: 33328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[] cs, ss, fs;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        cs = new int[n - 1];
        ss = new int[n - 1];
        fs = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            cs[i] = sc.nextInt();
            ss[i] = sc.nextInt();
            fs[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int[] times = new int[n];
        for (int j = 0; j < n - 1; j++) {
            int time = 0;
            for (int i = j; i < n - 1; i++) {
                if (time < ss[i]) {
                    time = ss[i];
                }
                if (time % fs[i] != 0) {
                    time = (time / fs[i] + 1) * fs[i];
                }
                time += cs[i];
            }
            times[j] = time;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(times[i]);
        }
    }

    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: 22100
#include <bits/stdc++.h>
using namespace std;

int main(){
  vector<int> x(5);
  for(int i=0;i<5;i++){
    cin>>x.at(i);
  }
  for(int i=0;i<5;i++){
    if(x.at(i)==0){
      cout<<i+1<<endl;
      break;
    }
  }

}

Measured memory_bytes: 3600
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    /*第一种方法：用数组 
    long long n,i,a[100];
    cin>>n;
    a[1]=1;
    a[2]=3;
    for(i=3;i<=n;i++) a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
    */
    //第二种方法：不用数组 
    long long n,i,x,ans;
    cin>>n;
    x=2;
    ans=1;
    for(i=2;i<=n;i++)
    {
        ans+=x;
        x=ans-x;
    }
    cout<<ans<<endl;
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
///====================== TEMPLATE STARTS HERE =====================///
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define MP make_pair
#define ff first
#define ss second
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define POPCOUNT __builtin_popcountll
#define Set(N,p) ((N)|((1LL)<<(p)))
#define Reset(N,p) ((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)

#define LL long long
#define LLU long long unsigned int
typedef pair < int, int > pii;
typedef pair < LL, LL > pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pll> vll;

#ifdef s_da_sailor
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif // s_da_sailor

inline LL gcd ( LL a, LL b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}

LL ext_gcd ( LL A, LL B, LL *X, LL *Y ){
    LL x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1; y2 = 0;
    x1 = 0; y1 = 1;
    for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1;
        r = r2 % r1;
        x = x2 - (q * x1);
        y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}

inline LL modInv ( LL a, LL m ) {
    LL x, y;
    ext_gcd( a, m, &x, &y );
    x %= m;
    if ( x < 0 ) x += m;
    return x;
}

inline LL bigmod ( LL a, LL p, LL m ) {
    LL res = 1 % m, x = a % m;
    while ( p ) {
        if ( p & 1 ) res = ( res * x ) % m;
        x = ( x * x ) % m; p >>= 1; /// For bigmod2 multiply here using mulmod
    }
    return res;
}


//int knightDir[8][2] = { {-2,1},{-1,2},{1,2},{2,1},{2,-1},{-1,-2},{1,-2},{-2,-1} };
//int dir4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
//int dir8[8][2] = {{-1,0},{0,1},{1,0},{0,-1},{-1,-1},{1,1},{1,-1},{-1,1}};
const LL inf = 2147383647;
const LL mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-11;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// For generating random numbers

///======================  TEMPLATE ENDS HERE  =====================///

void solve() {
    LL x;
    cin >> x;
    if(x>=30) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

int main () {
    #ifdef s_da_sailor
    freopen ( "input.txt", "r", stdin );
    //freopen ( "output.txt", "w", stdout );
    #endif // s_da_sailor

    fast_cin;

    solve();

    return 0;
}


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

int main(){

    int n;
    cin >> n;
    int S[n];
    for(int i=0;i<n;i++){
        cin >> S[i];
    }
    int m;
    cin >> m;
    int T[m];
    for(int i=0;i<m;i++){
        cin >> T[i];
    }
    int cnt=0;
    for(int i=0;i<m;i++){
        for(int k=0;k<n;k++){
            if(T[i] == S[k]){
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3120
#include "bits/stdc++.h"  
  
using namespace std;  
  
#define ll          long long int   
#define inf         (ll)1e17  
  
static const int maxn = 100 + 5;  
static const int Max = 1e5 + 5;  
  
ll dp[maxn][Max];  
bool memoize[maxn][Max];  
  
int w[maxn], val[maxn];  
  
int N, W;  
  
ll solve(int pos, int make)  
{  
  if (pos >= N)   
  {  
      if (make == 0) return 0;  
      return inf;  
  }  
  ll &ret = dp[pos][make];  
  bool &mem = memoize[pos][make];  
  if (mem) return ret;  
  mem = 1;  
  ret = inf;  
  if (make - val[pos] >= 0) ret = min(ret, w[pos] + solve(pos+1, make - val[pos]));  
  ret = min(ret, solve(pos+1, make));  
  return ret;  
}  
                                        
int main()  
{  
    scanf("%d %d", &N, &W);  
    for (int i = 0; i < N; i++) scanf("%d %d", &w[i], &val[i]);  
    for (int make = 100000; make >= 0; make--)  
    {  
        ll ans = solve(0, make);  
        if (ans <= W)   
        {  
            printf("%d\n", make);  
            break;  
        }  
    }  
}

Measured memory_bytes: 90368
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する


int main() {
    string s, t;
    cin >> s >> t;

    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    bool result = false;
    ll ans_i = 0;

    rep(i,s.size()-t.size()+1){
        bool flag = true;
        rep(j,t.size()){
            if(s.at(s.size()-i-j-1) == t.at(t.size()-j-1)){
                continue;
            }else if(s.at(s.size()-i-j-1) == '?'){
                continue;
            }else{
                flag = false;
            }
        }
        if(flag){
            result = true;
            ans_i = i;
            break;
        }
    }

    if(result){
        rep(i,t.size()){
            s.at(s.size() - ans_i - t.size() + i) = t.at(i);
        }
        rep(i,s.size()){
            if(s.at(i) == '?'){
                s.at(i) = 'a';
            }
        }
        cout << s << endl;

    }else{
        cout << "UNRESTORABLE" << endl;
    }
    
}


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

int main(void){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }else if(a>b&&b!=1||a==1){
        cout<<"Alice"<<endl;
    }else{
        cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Vec  =vector<int>;

int		main(void)
{
	int n;
	cin >> n;
	Vec height(n);
	for (auto i = height.begin(); i != height.end(); i++)
		cin >> *i;
	int max = 0;
	int count = 0;

	for (auto i = height.begin(); i + 1 != height.end(); i++)
	{
		if (*i >= *(i + 1))
			count++;
		else
		{
			if (max < count)
				max = count;
			count = 0;
		}
	}
	if (max < count)
		max = count;
	cout << max << endl;
}


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

int main(){
    char b;
    cin >> b;
    if(b=='A') cout << "T" << endl;
    else if(b=='T') cout << "A" << endl;
    else if(b=='G') cout << "C" << endl;
    else cout << "G" << endl;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        Integer a1 = scan.nextInt();
        Integer a2 = scan.nextInt();
        Integer a3 = scan.nextInt();
        System.out.println(hantei(a1,a2,a3));
    }
    public static String hantei(int n,int m,int j){
        
    return (n+m+j)<=21? "win":"bust";
    }
}


Measured memory_bytes: 21844
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: September 9
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  if (n % 10 == 9 || n / 10 == 9) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
def partition(A, p, r):
    # print(p, r)
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1

n = int(input())
A = list(map(int, input().split()))
q = partition(A, 0, n-1)
# print(A)
for i, a in enumerate(A):
    if i == q:
        print('[', end='')
    print(a, end='')
    if i == q:
        print(']', end='')
    if i < len(A)-1:
        print(' ', end='')
print('')


Measured memory_bytes: 16384
def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)

K = int(input()) + 1
gcDP = [[0] * K for _ in range(K)]

for i in range(1, K):
  for j in range(1, K):
    gcDP[i][j] = gcd(i, j)

ans = 0
for i in range(1, K):
  for j in range(1, K):
    for k in range(1, K):
      ans += gcd(gcDP[i][j], k)

print(ans)

Measured memory_bytes: 74544