akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,y,z,k=MI()
A=LI()
B=LI()
C=LI()
lis=[]
for i in range(x):
    for j in range(y):
        lis.append(A[i]+B[j])
lis.sort(reverse=True)
lisan=[]
for i in range(min(k,x*y)):
    for j in range(z):
        lisan.append(lis[i]+C[j])
lisan.sort(reverse=True)
for i in range(k):
    print(lisan[i])

    
        

    
    


Measured memory_bytes: 220640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define INF 4000000

struct obj{
    int a,b,cost;
};




int main(){
    int n,Ma,Mb;
    cin >> n >> Ma >> Mb;
    obj X[50];
    REP(i,n){
        cin >> X[i].a >> X[i].b >> X[i].cost;
    }



    int dp[2][403][403];
    REP(i,2) REP(j,403) REP(k,403) dp[i][j][k] = INF;

    dp[0][0][0] =0;
    dp[1][0][0] = 0;
    dp[0][X[0].a][X[0].b] = X[0].cost;
    FOR(i,1,n){
        FOR(j,0,401){
            FOR(k,0,401){
                dp[i%2][j][k]=dp[(i-1)%2][j][k];
                if( j - X[i].a >=0 and k - X[i].b>=0){
                    dp[i%2][j][k] = min(dp[i%2][j][k],dp[(i-1)%2][j-X[i].a][k-X[i].b] + X[i].cost);
                }
            }
        }
    }



    int ans = INF;
    int tmp_a=0,tmp_b=0;
    while(1){
        tmp_a+=Ma;
        tmp_b+=Mb;
        if(tmp_a >400 or tmp_b >400) break;
        ans=min(ans, dp[(n-1)%2][tmp_a][tmp_b]);
    }

    if(ans!=INF){
        print(ans);
    }
    else print(-1);

}

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

int main() {
    int N;
    int a[100];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    int max = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] > max) max = a[i];
    }

    int min = 1000;
    for (int i = 0; i < N; ++i) {
        if (a[i] < min) min = a[i];
    }

    cout << max - min << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int d[]=new int[n];
		for(int i=0;i<n;i++){
			d[i]=sc.nextInt();
		}
		long total=0;
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				total+=d[i]*d[j];
			}
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
int main()
{
    fio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x = a*c;
    x = max(x,b*c);
    x = max(x,a*d);
    x = max(x,b*d);
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>


int main() {
	int n = 0, k = 0, x = 1;
	scanf("%d\n%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		if (2 * x <= x + k)
		{
			x *= 2;
		}
		else
		{
			x += k;
		}
	}
	printf("%d\n", x);
}

Measured memory_bytes: 1640
#include <iostream>

#define MAXH 102
#define MAXW 102

using namespace std;

int H, W, N, a;
int i = 0, j = 0;
int grid[MAXH][MAXW];

int main() {
    cin >> H >> W >> N;
    for (int k = 1; k <= N; ++k) {
        cin >> a;
        while (a--) {
            grid[i][j] = k;
            if (i & 1) j--;
            else j++;
            if (j == -1) {
                ++i;
                j = 0;
            } else if (j == W) {
                ++i;
                j = W - 1;
            }
        }
    }
    for (int i = 0; i != H; ++i) {
        for (int j = 0; j != W - 1; ++j)
            cout << grid[i][j] << ' ';
        cout << grid[i][W - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
d=[]
out=0
for i in c.values():
    b.append(i)
for i in c.keys():
    d.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    elif b[0]!=b[1] or b[1]!=b[2]:
        out=1
    elif (d[0]^d[1]^d[2])!=0:
        out=1
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Measured memory_bytes: 18856
#include <iostream>
#include <string>
#include <queue>
#include <set>

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		if(str == "0")
		{
			break;
		}
		queue<string> Que;
		Que.push(str);
		queue<string> NextQue;
		int depth = 0;
		set<string> Valiation;
		Valiation.insert(str);
		while(true)
		{
			if(depth >= 20)
			{
				cout << "NA" << endl;
				break;
			}
			while(!Que.empty())
			{
				string worm = Que.front();
				Que.pop();
				bool same_color_flag = true;
				for(int i = 1; i < worm.size(); ++i)
				{
					if(worm[i] != worm[0])
					{
						same_color_flag = false;
					}
				}
				if(same_color_flag)
				{
					cout << depth << endl;
					goto END;
				}
				char before_color = worm[0];
				for(int i = 1; i < worm.size(); ++i)
				{
					if(before_color != worm[i])
					{
						string next = worm;
						if(before_color == 'b')
						{
							if(worm[i] == 'g')
							{
								next[i - 1] = 'r';
								next[i] = 'r';
							}
							else if(worm[i] == 'r')
							{
								next[i - 1] = 'g';
								next[i] = 'g';
							}
						}
						else if(before_color == 'g')
						{
							if(worm[i] == 'b')
							{
								next[i - 1] = 'r';
								next[i] = 'r';
							}
							else if(worm[i] == 'r')
							{
								next[i - 1] = 'b';
								next[i] = 'b';
							}
						}
						else if(before_color == 'r')
						{
							if(worm[i] == 'g')
							{
								next[i - 1] = 'b';
								next[i] = 'b';
							}
							else if(worm[i] == 'b')
							{
								next[i - 1] = 'g';
								next[i] = 'g';
							}
						}
						if(Valiation.find(next) == Valiation.end())
						{
							NextQue.push(next);
							Valiation.insert(next);
						}
					}
					before_color = worm[i];
				}
			}
			while(!NextQue.empty())
			{
				Que.push(NextQue.front());
				NextQue.pop();
			}
			++depth;
		}
END:
		;
	}
}

int main()
{
	solve();
	return(0);
}

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

typedef long long ll;
long long const md = 1000000007;

ll factorial(ll a){
  if ( a == 0 )
    return 1;
  else
    return factorial(a-1) * a % md;
}

int main() {
  long long n;
  cin >> n;
  cout << factorial(n) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 10004, MAXM = 102, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<long long> arr(n);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        arr[i] *= 2;
        if (i & 1) {
            sum -= arr[i];
        } else {
            sum += arr[i];
        }
    }
    sum /= 2;
    cout << sum << ' ';
    for (int i = 0; i < n - 1; ++i) {
        cout << arr[i] - sum << ' ';
        sum = arr[i] - sum;
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 2176
const inp = require('fs').readFileSync('/dev/stdin', 'utf8'); const l = inp.trim().split('\n'); var n = null; var ind = 0; while (li = l.shift()) { const isN = ind % 2 === 0; const nAr = li.split(' '); if(isN){ n = nAr[0]; } else { var sSc = null; for(var i = 0; i < nAr.length; i++){ for(var j = i+1; j < nAr.length; j++){ if (i!==j) { let sDi = Math.abs(nAr[i] - nAr[j]); if(sSc === null){ sSc = sDi; } else { if(sDi < sSc){ sSc = sDi; } } } } } n = null; console.log(sSc); } ind ++; } 


Measured memory_bytes: 18172
#include<stdio.h>
char str[9];
int p[8];
int b[32];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",str);
		for(int j=0;j<8;j++){
			if(str[j]>='a'&&str[j]<='z'){
				p[j]=10+(str[j]-'a');
			}
			else p[j]=str[j]-'0';
		}
		for(int j=0;j<8;j++){
			for(int k=0;k<4;k++)if(p[7-j]&(1<<k))b[j*4+k]=1;
			else b[j*4+k]=0;
		}
		if(b[31])printf("-");
		long long ret=0;
		for(int j=0;j<31;j++){
			ret*=2;
			ret+=b[30-j];
		}
		int div=1024*1024*1024;
		if(!(ret%128)){
			printf("%lld",ret/128);
			printf(".0\n");
		}else{
			printf("%lld",ret/128);
			printf(".");
			ret%=128;
			while(ret){
				ret*=10;
				printf("%d",ret/128);
				ret%=128;
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1044
from sys import exit

N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors


ans_list = make_divisors(N)

ans = []

for ans_l in ans_list:
	a = ans_l - 1
	if a == 0:
		continue
	if N // a == N % a:
		ans.append(a)

print(sum(ans))


Measured memory_bytes: 3296
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int dp[100010];
vector<int> G[100010];
int dfs(int u = 0) {
    int ret = 0;
    vector<int> v;
    for(auto &e: G[u]) {
        v.push_back(dfs(e));
    }
    if(v.size() == 0) return 0;
    sort(v.begin(), v.end(), greater<int>());
    rep(i, v.size()) {
        ret = max(ret, v[i] + i + 1);
    }
    return ret;
} 

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N - 1) {
        int e; cin >> e;
        e--;
        G[e].push_back(i + 1);
    }
    cout << dfs() << endl;

    return 0;
}


Measured memory_bytes: 18364
N,W=map(int,input().split())
value=[]
weight=[]
#suck=[]
for i in range(N):
    v_temp,w_temp=list(map(int,input().split()))
    value.append(v_temp)
    weight.append(w_temp)
#    suck.append(temp)

dp=[[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w>=weight[i]:
            dp[i+1][w]=max(dp[i][w],dp[i+1][w-weight[i]]+value[i])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N][W])


Measured memory_bytes: 16124
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, memo[100005], visited[100005];
vector<pair<ll, ll > > segs;
ll dp(int idx) {
	if(idx == n) return 0;
	if(visited[idx]) return memo[idx];

	int mx1 = 0, mx2 = 0;
	// Take
	int low = idx+1, high = n-1, store = n;
	while(low <= high) {
		int mid = low + (high-low)/2;
		if(segs[mid].first >= segs[idx].second) {
			store = mid;
			high = mid-1;
		}
		else low = mid+1;
	}
	mx1 = 1 + dp(store);
	// Don't take
	mx2 = dp(idx+1);

	visited[idx] = 1;
	return memo[idx] = max(mx1, mx2);
}
int main() {
	cin >> n;
	memset(visited, 0, sizeof(visited));
	memset(memo, 0, sizeof(memo));
	for(int i = 0; i < n; ++i) {
		ll x, l;
		cin >> x >> l;
		segs.push_back({x-l, x+l});
	} 
	sort(segs.begin(), segs.end());
	cout << dp(0);
	return 0;
}

Measured memory_bytes: 6640
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <iomanip>
#include<math.h>
#include<queue>
#include<vector>
#include<algorithm>
#define Max (int)1e5+5
#define MAX2 (int)1e5+5
#define MOD ((int)1e9+7)
using namespace std;


vector<int>vec[11];

int check(int pos,int val){
	if((val & (1<<(pos-1)))>0)
		return 1;
	return 0;
}

int main(){
	int n,m,p[15],i,j,x,val,k;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&x);
		for(j=0;j<x;j++){
			scanf("%d",&val);
			vec[i].push_back(val);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&p[i]);
	}

	x = pow(2,n);
	int light = 0,ans = 0;
	for(i=0;i<x;i++){
		light = 0;
		for(j=0;j<m;j++){
			val = 0;
			for(k=0;k<vec[j].size();k++){
				if(check(vec[j][k],i) == 1){
					val++;
				}
			}
			if(val%2 == p[j]){
				light++;
			}
		}
		if(light == m){
			ans++;
		}
	}

	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll A[N+1], B[N];
  for(int i=0;i<=N;++i) cin>>A[i];
  for(int i=0;i<N;++i) cin>>B[i];
  ll ans = 0;
  ll zero = 0;
  for(int i=0;i<N;++i) {
    if(A[i]>=B[i]) {
      ans += B[i];
      A[i] -= B[i];
      B[i] = 0;
    }
    else {
      ans += A[i];
      B[i] -= A[i];
      A[i] = 0;
      ans += min(A[i+1], B[i]);
      A[i+1] = max(A[i+1]-B[i], zero);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5132
#include <stdio.h>
using namespace std;
int main(){
  int n, i, cnt = 0, ans=1;
  scanf("%d",&n);
  int a[n];
  for (i = 0; i < n; i++) {
     scanf("%d",&a[i]);
     while(!(a[i]%2)){
       a[i] /= 2;
       cnt++;
      }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    *X, = map(int, input())

    popcount = X.count(1)

    if popcount == 1:
        ans = []
        for i, d in enumerate(X):
            if d:  # 1 -> 0
                ans.append(0)  # 元々1つしかbitが立っておらず,そのbitを反転させる
                continue
            else:  # 0 -> 1
                if i == N - 1 or X[N - 1]:
                    ans.append(2)  # 奇数 -> 1 -> 0
                else:
                    ans.append(1)  # 偶数 -> 0

        print(*ans, sep='\n')
        return

    def get_total(off: bool):
        """bit反転操作前のXを
        bit反転操作後のpopcountで割った剰余
        各桁のbit反転した整数は
        ここで求めたsに差分を加減すれば求まる
        """
        if off:  # 1 -> 0
            mod = popcount - 1
        else:  # 0 -> 1
            mod = popcount + 1

        s = 0
        for d in X:
            s = (s * 2 + d) % mod
        return s

    tot_off = get_total(off=True)
    tot_on = get_total(off=False)

    ans = []
    for i, d in enumerate(X):
        # popcount>1より少なくとも1回の操作が必要
        # %modが1回目の操作に対応
        if d:  # 1 -> 0
            mod = popcount - 1
            tot = (tot_off - pow(2, N - 1 - i, mod)) % mod
        else:  # 0 -> 1
            mod = popcount + 1
            tot = (tot_on + pow(2, N - 1 - i, mod)) % mod

        cnt = 1
        while tot:  # tot<=2*10**5, popcount(tot)<=18
            tot %= bin(tot)[2:].count('1')
            cnt += 1

        ans.append(cnt)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 15816
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def cut(a):
    w = len(a[0])
    l = []
    for row in a:
        if row != ['.']*w:
            l.append(row)
    return l

def main():
    H, W = mi()
    a = [list(input()) for _ in range(H)]
    a = cut(a)
    a = cut([list(i) for i in zip(*a)])
    [print(''.join(list(i))) for i in zip(*a)]

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include <queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main(){
    int n; cin >> n;
    int c[n-1], s[n-1], f[n-1];
    for(int i = 0; i < n-1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 0; i < n; i++){
        int t = 0;
        //t -> 次の列車に乗れるまでの時間を求めたい
        for(int j = i; j < n-1; j++){
            if(t < s[j]) t = s[j]; //駅jにいるのがs[j]未満だったらまだ発車しない
            else if(t % f[j] == 0); //ちょうど乗れた
            else t = t+f[j]-t%f[j]; //ちょうど乗れなかった

            t += c[j];
        }
        cout << t << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin() (a).end()
void solve()
{
	ll k, n ;
	cin >>n>> k;
	ll sum = 0 ;
	ll a[n];
	for(int i = 0 ; i< n ;i++){
		cin >> a[i];
	}
	sort(a, a+ n);
	
	for(int i = n-1-k ;i>=0;i--){
		sum += a[i];
	}

	cout<<sum<<endl;

return ;
}
int main()
{
	solve();
return 0;
}


Measured memory_bytes: 1792
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
  }
  int cur = 0;
  vector<int> dist(n, -1);
  dist[0] = 0;
  for (long long i = 1; i <= k; i++) {
    int to = a[cur];
    if (dist[to] == -1) {
      dist[to] = dist[cur] + 1;
      cur = to;
      continue;
    }
    int cyc = dist[cur] - dist[to] + 1;
    cur = to;
    long long remain = k - i;
    remain %= cyc;
    while (remain--) {
      cur = a[cur];
    }
    cout << cur + 1 << '\n';
    return 0;
  }
  cout << cur + 1 << '\n';
  return 0;
}

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

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

int N, A[200000], B[200000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> A[i] >> B[i];

    vector<P> w(N);
    for(int i=0;i<N;i++){
        w[i] = P(B[i], A[i]);
    }

    sort(w.begin(), w.end());

    string ans = "Yes";
    ll t = 0;
    for(int i=0;i<N;i++){
        t += w[i].second;
        if(w[i].first < t){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) printf("Yes");
    else printf("No");
    return 0;
}

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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll 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;
}
ll func(ll n)
{
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i/10==0)
                ans+=1+func(i)*func(n/i);
            else
                ans+=func(i)*func(n/i);
        }
    }
    return ans;
}
ll dp[2001][2001];
ll check(vector<pair<ll,ll> >v,ll l,ll r,ll i)
{ 
   //cout<<l<<" "<<r<<endl;
   if(l>r)
    return 0; 
   if(dp[l][r]!=-1)
    return dp[l][r]; 
   ll ans=0;
   ll p1=v[i].first;
   ll p2=v[i].second;
   ans=max(p1*(p2-l)+check(v,l+1,r,i+1),p1*(r-p2)+check(v,l,r-1,i+1));
   return dp[l][r]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
      string s;
      cin>>s;
      if(s[0]==s[1]&&s[1]==s[2])
       cout<<"No";
      else
       cout<<"Yes"; 
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
int main(){
 int a,b,C;
 double c;
 double S,L,h;

 scanf("%d %d %d",&a,&b,&C);

 S=a*b*sin(C*M_PI/180)/2;
 
 c=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*M_PI/180));

 L=a+b+c;

 h=2*S/a;

 printf("%lf\n",S);
 printf("%lf\n",L);
 printf("%lf\n",h);

return 0;
}


Measured memory_bytes: 2112
h, w = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
d = gets.split.map(&:to_i)
s = []
s << [-1] * (w + 4)
s << [-1] * (w + 4)
h.times do
  s << [-1] * 2 + gets.chomp.chars.map { _1 == '#' ? -1 : 0 } + [-1] * 2
end
s << [-1] * (w + 4)
s << [-1] * (w + 4)
que = []
que << [c[0] + 1, c[1] + 1]
s[c[0] + 1][c[1] + 1] = 1
while que.size > 0
  h = {}
  while que.size > 0
    y, x = que.shift
    cnt = s[y][x]
    if s[y + 1][x] == 0
      s[y + 1][x] = cnt
      que << [y + 1, x]
    elsif s[y + 1][x] == -1
      h[[y, x]] = 1
    end
    if s[y - 1][x] == 0
      s[y - 1][x] = cnt
      que << [y - 1, x]
    elsif s[y - 1][x] == -1
      h[[y, x]] = 1
    end
    if s[y][x + 1] == 0
      s[y][x + 1] = cnt
      que << [y, x + 1]
    elsif s[y][x + 1] == -1
      h[[y, x]] = 1
    end
    if s[y][x - 1] == 0
      s[y][x - 1] = cnt
      que << [y, x - 1]
    elsif s[y][x - 1] == -1
      h[[y, x]] = 1
    end
  end
  h.keys.each do |y, x|
    cnt = s[y][x]
    (y - 2).upto(y + 2) do |j|
      (x - 2).upto(x + 2) do |i|
        if s[j][i] == 0
          s[j][i] = cnt + 1
          que << [j, i]
        end
      end
    end
  end
end
puts s[d[0] + 1][d[1] + 1] - 1

Measured memory_bytes: 27224
<?php
  	$count = fgets(STDIN);
	$array = explode(' ', fgets(STDIN));
	$answer = 0;

	for ($j = 0; $j < 100; $j ++) {
    	$hantei = 0;
        for ($i = 0; $i < $count; $i ++) {
            if ($array[$i] % 2 == 0) {
                $hantei += 1;
            }
        }
        if ($hantei == $count) {
            for ($k = 0; $k < $count; $k ++) {
                $array[$k] = $array[$k] / 2;
            }
        } else {
          	break 1;
        }
     	$answer += 1;
    }

	echo $answer;
?>

Measured memory_bytes: 4604
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int n,m;

int main(){
  scanf("%d %d",&n,&m);
  int a=1;
  int tmp = m;
  int answer;
  while(true){
    a *= 10;
    tmp /= 10;
    if(tmp ==0) break;
  }
  a = m + n*a;
  REP(i,100000){
    if(i*i==a){
      printf("Yes\n");
      return 0;

    }
  }
  printf("No\n");
  return 0;
}



Measured memory_bytes: 128
N,K=map(int,input().split())
A=list(map(int,input().split()))
from collections import defaultdict
d = defaultdict(int)
n=0
d[0]=1
i=2
while d[A[n]-1]==0:
  d[A[n]-1]+=i
  if i-1==K:
    print(A[n])
    exit(0)
  i+=1
  n=A[n]-1
K-=d[A[n]-1]-1
X=d[n]-d[A[n]-1]+1
n=A[n]-1
for i in range(K%X):
  n=A[n]-1
print(n+1)

Measured memory_bytes: 33744
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

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

    int ans = 0;
    int val;
    for(int i = 0; i < n; ++i){
        std::cin >> val;
        while(0 == val % 2){
            val /= 2;
            ++ans;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(){
  int a;
  scanf("%d",&a);
  char s[a+1];
  scanf("%s",s);
  int b=0,c=0;
  for(int i=0; i<a; i++){
    if(s[i]=='I'){
      b++;
    }else{
      b--;
    }
    if(c<b){c=b;}
  }
  printf("%d",c);
  return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100100];
int main() {
    scanf("%d",&n);
    for (int i=0; i<n ;i++) scanf("%d",&a[i]);
	sort(a,a+n);
  	int l = a[n/2-1], r=a[n/2];
  	printf("%d",r-l);
}


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

int main(){
    
    int num;    // ドーナツの種類
    int x;      // お菓子の素のグラム
    int m[1000];
    int max_donut;    // ドーナツの最大数
    int min;    // mの最小値 

    cin >> num;
    cin >> x;
    
    max_donut = num;

    for(int i=0;i<num;i++){
        cin >> m[i];
        x -= m[i];
    }

    min = m[0];
    for(int i=1;i<num;i++){
        if(min>m[i]){
            min = m[i];
        }
    }

    max_donut += x/min;

    cout << max_donut;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;
    int w; cin >> w;

    string ans;
    for(int i = 0; i < s.size(); i++) {
        if(i % w == 0) ans.push_back(s[i]);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    int a,b,c;

    scanf("%d %d %d", &a,&b,&c);

    if(a*c<=b){
        cout << c;
    }else{
        cout << floor(b/a);
    }

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Input
	var h, w int
	fmt.Scan(&h, &w)
	a := make([]string, 0)
	for i := 0; i < h; i++ {
		var v string
		fmt.Scan(&v)
		if includeChar(v, '#') {
			a = append(a, v)
		}
	}

	// Solve
	ng := make([]int, 0)
	for i := 0; i < w; i++ {
		var vertical string
		for _, v := range a {
			vertical += string(v[i])
		}
		if !includeChar(vertical, '#') {
			ng = append(ng, i)
		}
	}

	for i := range a {
		for j, s := range a[i] {
			if !includeInt(ng, j) {
				fmt.Print(string(s))
			}
		}
		fmt.Println()
	}
}

func includeChar(src string, char rune) bool {
	for _, s := range src {
		if s == char {
			return true
		}
	}
	return false
}

func includeInt(src []int, n int) bool {
	for _, v := range src {
		if v == n {
			return true
		}
	}
	return false
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int count = 0;
	cin >> count;
	vector<int> array(count);
	for (int i = 0; i < count; ++i)
	{
		cin >> array[i];
	}

	int minVal = array[0];
	int maxVal = -1000000000;
	for (int i = 1; i < count; ++i)
	{
		maxVal = max(maxVal, array[i] - minVal);
		minVal = min(array[i], minVal);
	}

	cout << maxVal << endl;

	return 0;
}


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

n = int(input())

m = 1046527

H = [None]*m

table = str.maketrans({
'A':'1',
'C':'2',
'G':'3',
'T':'4',
})

# 文字から数値に変換
# https://qiita.com/tag1216/items/df6c93bdb823dd48af6c参照
def getChar(string):
    return int(string.translate(table))

# pythonでは12桁でもメモリを考えず動くのでgetKeyを実装していません。

def h1(key):
    return key % m

def h2(key):
    return 1 + (key % (m-1))

def find(string):
    i = 0
    key = getChar(string)
    while True:
        h = (h1(key) + i*h2(key))%m
        if H[h] == string:
            return 1
        elif H[h] is None:
            return 0
        else:
            i += 1

def insert(string):
    i = 0
    key = getChar(string)
    while True:
        h = (h1(key) + i*h2(key))%m
        if H[h] is None:
            H[h] = string
            break
        else:
            i += 1

for _ in range(n):
    com, string = input().split()
    if com[0] == 'i':
        insert(string)
    else:
        if find(string):
            print('yes')
        else:
            print('no')



Measured memory_bytes: 48584
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main()
{
    string s;
    cin >>s;
    ll n=s.length();
    char c=s[n-1];
    if(c=='2' || c=='4'|| c=='5' || c=='7' || c=='9'){
        cout << "hon" << endl;
        return 0;
    }
    if(c=='3'){
        cout << "bon" << endl;
        return 0;
    }
    cout << "pon" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<ll, pii>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{  
    FAST;
    ll n,m,x,y;
    cin>>n>>m;

    ve<ll> v[n+1];
    ll in[n+1];
    memset(in, 0, sizeof(in));

    while(m--){
        cin>>x>>y;
        v[x].pb(y);
        in[y]++;
    }

    queue<pii> q;

    ll ans=0;
    fre(i,n) if(in[i]==0) q.push(mp(i,0));

    while(!q.empty()){
        pii p  = q.front();
        q.pop();

        ans = max(ans, p.se);
        for(auto c: v[p.fi]){
            in[c]--;
            if(in[c]==0) q.push(mp(c, p.se+1));
        }
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 6528
#include<iostream>

using namespace std;

int main()
{
	int w,ans;
	
	for(;;)
	{
		cin >> w ;
		if(w==-1)
			break;
		ans=3130;
		
		if(w>30)
		{
			ans-=1250+1400;
			ans-=(w-30)*160;
		}
		else if(w>20)
		{
			ans-=1250;
			ans-=(w-20)*140;
		}
		else if(w>10)
			ans-=(w-10)*125;
		
		cout << ans << endl;
	}
}

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

using namespace std;

vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main(void)
{
    string s;

    cin >> s;
    int n   = days.size();
    int pos = distance(days.begin(), find(days.begin(), days.end(), s));

    cout << n - pos << endl;

    return 0;
}


Measured memory_bytes: 3604
/* ex 7_1
   riverstone */

#include <stdio.h>

//頂点を表す構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//関数shift_pointの定義
//ある基点point_baseから指定された移動方向に移動させたポイントを返す
point shift_point(point point_base,point point_shift){
    point point_ret;
    point_ret.x_elem = point_base.x_elem + point_shift.y_elem;
    point_ret.y_elem = point_base.y_elem + point_shift.x_elem; 
    return point_ret;
}

int main(void){
    point point1, point2, point3, point4,point_dif;
    //入力を受け取る
    scanf("%d %d %d %d", &point1.x_elem, &point1.y_elem, &point2.x_elem, &point2.y_elem);

    //残り2点の座標を求める
    //頂点1から頂点4へのベクトル(=頂点2から頂点3へのベクトル)を定義
    point_dif.x_elem = point2.x_elem - point1.x_elem;
    point_dif.y_elem = -point2.y_elem + point1.y_elem;
 
    //頂点2を基点にして頂点3を求める
    point3 = shift_point(point2,point_dif);
    //頂点1を基点にして頂点4を求める
    point4 = shift_point(point1,point_dif);

    //出力
    printf("%d %d %d %d\n", point3.x_elem, point3.y_elem, point4.x_elem, point4.y_elem);
    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int N,K;cin>>N>>K;
    vector<int> A;
    for(int i = 0;i < N;i++){
        int _a;cin>>_a;
        A.push_back(_a);
    }  
    // int N = 100000,K = 100000;
    // vector<int> A(N,0);
    for(int i = 0;i < K;i++){
        vector<int> accum(N+1,0);
        for(int j = 0;j < N;j++){
            accum[max(0,j - A[j])]++;
            accum[min(N,j + A[j]+1)]--;
        }
        A[0] = accum[0];
        bool flag = true;
        for(int j = 1;j < N;j++){
            accum[j] += accum[j-1];
            A[j] = accum[j];
            if(A[j] != N)flag = false;
        }
        if(flag)break;
        // for(int i = 0;i < N-1;i++){
        //     cout<<A[i]<<" ";
        // }cout<<A[N-1]<<endl;
    }
    for(int i = 0;i < N-1;i++){
        cout<<A[i]<<" ";
    }cout<<A[N-1]<<endl;
}

Measured memory_bytes: 4820
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> P(3);
    vector<int> J(2);
    
    for(int i = 0; i < 3; i++)
        cin >> P[i];
    
    for(int i = 0; i < 2; i++)
        cin >> J[i];
    
    sort(P.begin(), P.end());
    sort(J.begin(), J.end());
    
    cout << P[0] + J[0] - 50 << endl;
    
    return 0;
}

Measured memory_bytes: 1212
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> p(n,0);
    rep(i,n) cin>>p.at(i);
    vector<int> q(n,0);
    rep(i,n) cin>>q.at(i);
    vector<int> x(n);
    rep(i,n) x[i]=i+1;
    int a=0,b=0;
    int cnt=0;
    do{
        if(x==p) a=cnt;
        if(x==q) b=cnt;
        cnt ++;
        if(a*b>0) break; 
    } while (next_permutation(all(x)));
    cout<<abs(a-b)<<'\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>
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); }

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 a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
    {
        Yes;
        return;
    }
    No;
}

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: 256
// Problem : A - AC or WA
// Contest : AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cmath>
#include <cstdio>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <map>
#include <set>
#include <vector>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;
int m;

void input() {
  cin >> n >> m;
}

void solve1() {
  if (n == m) {
    cout << "Yes";
    
    exit(0);
  }
  
  cout << "No";
}

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

  preambule();
  input();
  solve1();
}


Measured memory_bytes: 764
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/rational.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static constexpr ll flip(ll K, ll i) {
  ll res = i, count = 0;
  while (res < K) {
    res <<= 1;
    count++;
  }
  return count;
}

int main() {
  ll N, K;
  cin >> N >> K;

  boost::rational<ll> res;
  REP1(i, N) {
    boost::rational<ll> a(1, N * static_cast<ll>(pow(2, flip(K, i))));
    res += a;
  }
  cout << boost::rational_cast<double>(res) << endl;
  return 0;
}


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

int main()
{
	int N;
	string s = "No";
	cin >> N;

	for (int donut = 0; donut < 14; donut++) {
		for (int cake = 0; cake < 25; cake++) {
			if (N == cake * 4 + donut * 7)
				s = "Yes";
		}
	}
	
	cout << s << endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define F first
#define S second
typedef pair<int, int> pii;
typedef long long ll;

void C(){
	/**int pass(int m, int k){
		int cnt=0;
		while(m<k){
			m*=2;
			cnt++;
		}
		return cnt;
	}
	int n,k; cin>>n>>k;
	double ans=0;
	for(int i=1; i<=n; i++){
		int x = 1<<pass(i, k);
		double prob = 1.0/(x*1.0);
		ans+=((1.0/n*1.0)*prob);
	}
	cout<<fixed<<setprecision(12)<<ans<<endl;*/
}
const int MAX = 1e5+1;
vector<pii> g[MAX];
bool vis[MAX];
int color[MAX];

void bfs(pii u){
	memset(color, -1, sizeof(color));
	queue<pii> q;
	q.push(u);
	while(!q.empty()){
		pii v = q.front();
		q.pop();
		vis[v.F]=true;
		for(auto&x: g[v.F]){
			if(!vis[x.F]){
				vis[x.F]=true;
				if(x.S%2==0){
					if(color[v.F]!=-1)color[x.F]=color[v.F];
					else color[v.F]=color[x.F]=0;
				}
				else{
					if(color[v.F]!=-1)color[x.F]=!color[v.F];
					else {color[v.F]=1; color[x.F]=0;}
				}
				q.push(x);
			}
		}
	}
}

int main(){
	int n; cin>>n;
	int u, v, w;
	for(int i=0; i<n-1; i++){
		cin>>u>>v>>w;
		u--; v--;
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
	bfs({0,0});
	for(int i=0; i<n; i++){
		cout<<color[i]<<endl;
	}
	return 0;   
}


Measured memory_bytes: 10052
import java.util.Calendar;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			boolean flag = true;
			int[] num = new int[6];
			for (int i = 0; i < 6; i++) {
				num[i] = scanner.nextInt();
				if (num[i] < 0)
					flag = false;
			}
			if (!flag)
				break;
			Calendar date = Calendar.getInstance();
			date.set(num[0], num[1] - 1, num[2]);
			long a = date.getTimeInMillis();
			Calendar date2 = Calendar.getInstance();
			date2.set(num[3], num[4] - 1, num[5]);
			long b = date2.getTimeInMillis();
			long c = (b - a) / (1000 * 60 * 60 * 24);
			System.out.println(c);
		}

	}
}

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

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int len1,len2;
    len1 = s1.size();
    len2 = s2.size();
    int dp[1001][1001];//dp[i][j] iまで、jまでの編集距離
    rep(i,len1+1){
        dp[i][0] = i;
    }
    rep(j,len2+1){
        dp[0][j] = j;
    }
    rep(i,len1)rep(j,len2){
        if(s1[i] == s2[j]){
            dp[i+1][j+1] = dp[i][j];
        }
        else{
            dp[i+1][j+1] = min(dp[i][j+1]+1,min(dp[i][j]+1,dp[i+1][j]+1));
        }
    }
    cout << dp[len1][len2] << endl;
}


Measured memory_bytes: 7128
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b;
   cin >> a >> b;
   cout << max(a+b,max(a-b,a*b)) << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long X,A,B;
  cin>>X>>A>>B;
  long long C=B-A;
  if(C<=0){
    cout<<"delicious"<<endl;
  }
  else if(C>0&&C<=X){
    cout<<"safe"<<endl;
  }
  else{
    cout<<"dangerous"<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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

        Double x1 = Double.parseDouble(sc.next());
        Double y1 = Double.parseDouble(sc.next());
        Double x2 = Double.parseDouble(sc.next());
        Double y2 = Double.parseDouble(sc.next());

        Double H = y2 - y1;
        Double W = x2 - x1;
        Double dist2 = H * H + W * W;
        out.printf("%.10f\n", Math.sqrt(dist2));
        out.flush();
    }
}


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

inline void fastRead_int(int &x) {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;

    for(; ((c<48 || c>57) && c != '-'); c = getchar_unlocked());

    if(c=='-') {
      neg = 1;
      c = getchar_unlocked();
    }

    for(; c>47 && c<58 ; c = getchar_unlocked()) {
      x = (x<<1) + (x<<3) + c - 48;
    }

    if(neg)
      x = -x;
}

int main(){

	int n;
	fastRead_int(n);

	int arr[n], cost[n];
	for (int i = 0; i < n; ++i)	{
		fastRead_int(arr[i]);
	}

	cost[n-1] = 0;
	cost[n-2] = abs(arr[n-2]- arr[n-1]);

	for(int i = n-3; i >= 0; i--){
		cost[i] = min( abs(arr[i]- arr[i+1]) + cost[i+1],
						abs(arr[i]- arr[i+2]) + cost[i+2]);
	}
		
	printf("%d\n", cost[0]);
	
	return 0;
}

Measured memory_bytes: 1024
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    ans = 0
    count = 0

    for c in s:
        if c == "R":
            count += 1
        else:
            if ans < count:
                ans = count
            count = 0

    if ans < count:
        ans = count
    print(ans)


if __name__ == "__main__":
    resolve()


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

int main(){
  int N, T;
  
  cin >> N >> T;
  
  int min_cost = 1001;
  for(int i = 0;i < N;i++){
    int c, t;
    
    cin >> c >> t;
    if(t <= T) min_cost = min(min_cost, c);
  }
  
  if(min_cost < 1001) cout << min_cost << endl;
  else cout << "TLE" << endl;
  
  return 0;
}

Measured memory_bytes: 3564