akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct {
    char state[31][31];
    int time;
    int ty, tx;
    int sw;
} DUNGEON;

DUNGEON queue[50000];

int head, tail;

void enq(DUNGEON t)
{
    queue[(tail++) % 50000] = t;
}

void deq(DUNGEON *t)
{
    *t = queue[(head++) % 50000];
}

int main(void)
{
    DUNGEON first, temp;
    int id[27];
    static signed char v[31][31][256];
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int y, x;
    int i, j, k;
    int num;
    int flag;
    
    while (1){
        scanf("%d%*c%d", &x, &y);
        getchar();
        
        if (x + y == 0){
            break;
        }
        
        memset(id, -1, sizeof(id));
        num = 0;
        for (i = 0; i < y; i++){
            for (j = 0; j < x; j++){
                scanf("%c", &first.state[i][j]);
                if (first.state[i][j] == '@'){
                    first.tx = j;
                    first.ty = i;
                    first.state[i][j] = '.';
                }
                if ('A' <= first.state[i][j] && first.state[i][j] <= 'Z' && id[first.state[i][j] - 'A'] == -1){
                    id[first.state[i][j] - 'A'] = num++;
                }
            }
            getchar();
        }
        
        memset(v, 0, sizeof(v));
        
        v[first.ty][first.tx][0] = 1;
        first.time = 0;
        first.sw = 0;
        head = tail = 0;
        enq(first);
        
        flag = 1;
        while (head != tail){
            deq(&temp);
            
            if (temp.state[temp.ty][temp.tx] == '<'){
                printf("%d\n", temp.time);
                flag = 0;
                break;
            }
            
            for (i = 0; i < 4; i++){
                first = temp;
                first.tx = temp.tx + dx[i];
                first.ty = temp.ty + dy[i];
                first.time = temp.time + 1;
                if (0 <= first.tx && first.tx < x && 0 <= first.ty && first.ty < y && (!('A' <= first.state[first.ty][first.tx] && first.state[first.ty][first.tx] <= 'Z') && first.state[first.ty][first.tx] != '#') && !v[first.ty][first.tx][first.sw]){
                    v[first.ty][first.tx][first.sw] = 1;
                    if ('a' <= first.state[first.ty][first.tx] && first.state[first.ty][first.tx] <= 'z' && id[first.state[first.ty][first.tx] - 'a'] != -1){
                        first.sw = temp.sw ^ (1 << id[first.state[first.ty][first.tx] - 'a']);
                        for (j = 0; j < y; j++){
                            for (k = 0; k < x; k++){
                                if (abs(first.state[j][k]) == first.state[first.ty][first.tx] - 'a' + 'A'){
                                first.state[j][k] *= -1;
                                }
                            }
                        }
                    }
                    enq(first);
                }
            }
        }
        
        if (flag){
            printf("-1\n");
        }
    }
    
    return (0);
}

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


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll cnt = 0;
    /*rep(i,N){
        cnt += A[i]/2;
        A[i] %= 2;
    }*/
    rep(i,N-1){
        ll n = (A[i]+A[i+1]) / 2;
        cnt += n;
        if(A[i+1] == 0){
            continue;
        }else{
            A[i+1] = (A[i]+A[i+1])%2;
            A[i] = 0;
        }
    }
    if(N==1){
        cnt = A[0]/2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{
  	public static void main(String[] args)
    {
     	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	boolean jud = false;
      	while(!jud && a > 1)
        {
         	if(a % 10 == 7)
            {
             	jud = true; 
            }
          
          	a /= 10;
        }
      
      	if(jud)
        {
          	System.out.println("Yes");
        }else{
          	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35764
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

void swapLeft(int *p, int i, int j) {
	int tmp;

	for (; i < j; j--) {
		tmp = p[j];
		p[j] = p[j - 1];
		p[j - 1] = tmp;
	}
}
void swapRight(int *p, int i, int j) {
	int tmp;

	for (; i < j; i++) {
		tmp = p[i];
		p[i] = p[i + 1];
		p[i + 1] = tmp;
	}
}

int main(void) {
#ifdef DEBUG
	printf("");
#endif
	int N;
	int p[100001] = {0};
	int tmp;
	int ans=0;
	int ansTmp;

	scanf("%d", &N);

	int i,j;
	for (i = 0; i < N; i++) {
		scanf("%d", &p[i]);
	}

	for (i = 0; i < N; i++) {
		if (p[i] == i+1) {
#ifdef DEBUG
			printf("%d\n", i+1);
#endif
			for (j = 1; j < N; j++) {
				if (N - i-j> 0) {
					if (p[i + j] != i) {
						ans += j;
						swapRight(p, i, i + j);
						break;
					}
				}
				if (i - j >= 0) {
					if (p[i - j] != i) {
						ans += j;
						swapLeft(p, i, i - j);
						break;
					}
				}
			}
		}
	}
	
	printf("%d\n", ans);
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;

int main(){
  ll n;cin>>n;
  vvll d(n,vll(2));
  bool ok=false;
  rep(i,0,n){cin>>d[i][0]>>d[i][1];}
  rep(i,0,n-2){
    if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
      ok=true;
    }
  }
  cout<<(ok?"Yes":"No")<<endl;
}






Measured memory_bytes: 3600
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  pair<int,int> p[100000];
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    p[i]=make_pair(b,a);
  }
  sort(p,p+M);
  int broken=0;
  int answer=0;
  for(int i=0;i<M;i++){
    if(broken<p[i].second){
      answer++;
      broken=p[i].first-1;
    }
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3936
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	int H, h, W, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
		
	return 0;
}

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

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
  ll res=1;
  while(b)
  {
    if(b&1LL)
      res=(res*a)%c;
    a=(a*a)%c;
    b>>=1;
  }
  return res;
}

int main()
{
  FASTIO;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  

  ll n;
   cin>>n;

   vector<ll>vect(n);

   f(i,0,n)
      cin>>vect[i];

      ll ans=0;
      for(int i=1;i<n;i++)
      {
        if(vect[i]<vect[i-1])
        {
            ans+=(vect[i-1]-vect[i]);
            vect[i]=vect[i-1];
        }
      }
      cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            if ((n | m) == 0) {
                break;
            }
            int[] a = new int[n];
            int[] b = new int[m];
            int as = 0, bs = 0;
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
                as += a[i];
            }
            for (int i = 0; i < m; i++) {
                b[i] = sc.nextInt();
                bs += b[i];
            }

            int ar = 1000;
            int br = 1000;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    int d = a[i] - b[j];
                    if (as - d == bs + d && ar + br > a[i] + b[j]) {
                        ar = a[i];
                        br = b[j];
                    }
                }
            }
            System.out.println(ar + br == 2000 ? -1 : (ar + " " + br));
        }

    }
}

Measured memory_bytes: 29672
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    string s;cin >> s;
    int n = s.size();
    int res=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            if(s[i]=='p')res--;
        }else{
            if(s[i]=='g')res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,x,y,GA[2010][2010],ans[2010];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n>>x>>y;
    
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++) 
            GA[i][j]=j-i;
    }
    
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            int xx=abs(j-y)+1+abs(i-x);
            int yy=abs(j-x)+1+abs(i-y);
            GA[i][j]=min(GA[i][j],min(xx,yy));
        }
    }
    
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++)
            ans[GA[i][j]]++;
    }
    
    for(int i=1;i<n;i++)
        cout<<ans[i]<<endl;
        
    return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

long long gcd(long long x,long long y)
{
	return y ? gcd(y,x % y) : x;
}

long long lcm(long long x,long long y)
{
	return x / gcd(x,y) * y;
}

ll A,B;

int main()
{
	while(~scanf("%lld%lld",&A,&B)){
		printf("%lld %lld\n",gcd(A,B),lcm(A,B));
	}

	return 0;
}

Measured memory_bytes: 3172
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

def solve(N,A,B):
    if sum(A) < sum(B):
        return(-1)
    shortage = 0
    satisfyedSubjetSurpasses = []
    numChangedSubject = 0
    for i in range(N):
        if A[i] < B[i]:
            shortage += B[i] - A[i]
            numChangedSubject += 1
        else:
            satisfyedSubjetSurpasses.append(A[i]-B[i])
    satisfyedSubjetSurpasses.sort(reverse = True)
    index = 0
    while shortage > 0:
        numChangedSubject += 1
        shortage -= satisfyedSubjetSurpasses[index]
        index += 1
    return(numChangedSubject)

print(solve(N,A,B))

Measured memory_bytes: 19508
def main():
    s = input()

    for i in range(len(s)):
        if (i+1)&1 == 1:
            if (s[i] == "R") + (s[i] == "U") + (s[i] == "D"):
                pass
            else:
                print("No")
                return
        elif (i+1)&1 == 0:
            if (s[i] == "L") + (s[i] == "U") + (s[i] == "D"):
                pass
            else:
                print("No")
                return

    print("Yes")

main()





Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int H, W, dp[1010][1010];
char fld[1010][1010];

signed main()
{
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> fld[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(fld[i + 1][j] == '.'){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
            if(fld[i][j + 1] == '.'){
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= mod;
            }
        }
    }
    cout << dp[H - 1][W - 1] << endl;


    return 0;
}
/*



*/



Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class T> struct ConvexHullTrick {
  struct Line { T a, b; };
  deque<Line> deq;
  bool monotone_query;
  bool need(const Line& l, const Line& m, const Line& r) const {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
  ConvexHullTrick(bool monotone_query = false) : monotone_query(monotone_query) {}
  void add(T a, T b) {
    if (deq.empty() or a < deq[0].a) {
      while (deq.size() >= 2 and !need({a, b}, deq[0], deq[1])) {
        deq.pop_front();
      }
      deq.emplace_front(Line{a, b});
    } else if (a > deq.back().a) {
      while (deq.size() >= 2 and !need(deq[deq.size() - 2], deq.back(), {a, b})) {
        deq.pop_back();
      }
      deq.emplace_back(Line{a, b});
    } else assert(false);
  }
  T max(T x) {
    if (deq.empty()) return numeric_limits<T>::min(); // オーバーフローに注意
    if (monotone_query) {
      while (deq.size() >= 2 and deq[0].a * x + deq[0].b <= deq[1].a * x + deq[1].b) {
        deq.pop_front();
      }
      return deq[0].a * x + deq[0].b;
    }
    int ok = 0, ng = deq.size();
    while (ng - ok > 1) {
      int m = ok + ng >> 1;
      (deq[m - 1].a * x + deq[m - 1].b <= deq[m].a * x + deq[m].b ? ok : ng) = m;
    }
    return deq[ok].a * x + deq[ok].b;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n, a; cin >> n >> a;
  if (a < 2e6) {
    V<lint> dp;
    ConvexHullTrick<__int128> cht(true);
    for (int x = 0; ; ++x) {
      dp.push_back(x);
      if (a + 2 < x) {
        cht.add(dp[x - 1 - a], (1 - x) * dp[x - 1 - a]);
        dp[x] = max<lint>(dp[x], cht.max(x));
      }
      if (dp[x] >= n) {
        cout << x << '\n';
        return 0;
      }
    }
  }
  lint res = n;
  for (lint x = sqrt(n) - 2; x <= sqrt(n) + 2; ++x) {
    if (x < 2 or x >= n) continue;
    res = min(res, x + a + (n + x - 1) / x);
  }
  cout << res << '\n';
}

Measured memory_bytes: 64736
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

ll h,w,n;
map<pair<ll, ll>, ll> mp;

ll ans[11];

bool check(ll a, ll b){
  return (2 <= a && a <= h-1 && 2 <= b && b <= w-1);
}

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

  cin >> h >> w >> n;
  REP(i, n){
    ll a, b;
    cin >> a >> b;
    FOR(j,-1,2){
      FOR(k,-1,2){    
	if(check(a+j, b+k)) mp[make_pair(a+j,b+k)]++;
      }
    }
  }
  for(auto &e: mp) ans[e.second]++;
  ll num = (h-2)*(w-2);
  for(auto &e: ans) num -= e;
  ans[0] = num;
  REP(i, 10) cout << ans[i] << endl;
  
  return 0;
}


Measured memory_bytes: 56576
#include<bits/stdc++.h>
 #include<vector>
 #include<math.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 // #include<chrono>
 using namespace std;
 // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define int         long long 
 #define vii        vector<int>
 #define big        2e18


  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}


void solve()
{
 
 int a,b;
 cin >> a >> b;

 cout<<a*b;
}

int32_t main()
{
  pr_init();
  fastio;
  
  
  solve();
  
 }


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector




void solve()
{
    int n;
    map<string,int>m;
    cin>>n;
    int ans = 0;
    forn(i,1,n)
    {
        string s;
        cin>>s;
        sort(all(s));
        ans+=m[s];
        m[s]++;
    }
        cout<<ans;
}   


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 11264
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;

void solve(){
    cin >> n;
    if (n%2==1){
        cout << (n*(n-1))/2-n/2 << endl;
        Rep(i,1,n+1){
            Rep(j,1,i){
                if (i+j!=n) cout << i << " " << j << endl;
            }
        }
    }else{
        cout << (n*(n-1))/2-n/2 << endl;
        Rep(i,1,n+1){
            Rep(j,1,i){
                if (i+j!=n+1) cout << i << " " << j << endl;
            }
        }
    }
}

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

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


#define int long long int
int a[100001];
int dp[100001];

int solve(int n,int k)
{
	if(dp[n]!=-1)
		return dp[n];
	else
	{
		int k1=1;
		dp[n]=abs(a[n]-a[n-k1])+solve(n-k1,k);
		k1++;
		while(true)
		{
			if(k1>k)
				break;
			int check;
			check=n-k1;
			if(check>=1)
			{
				dp[n]=min(dp[n],abs(a[n]-a[check])+solve(check,k));
			}	
			else
				break;			
			k1++;
			
		}
		return dp[n];
	}
}
int32_t main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<=100001;i++)
		dp[i]=-1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[1]=0;
	int ans;
	ans=solve(n,k);
	cout<<ans<<endl;
	return 0;
}	

Measured memory_bytes: 6528
def solve(n):
    if "7" in list(str(n)):
        return "Yes"
    else:
        return "No"


def main():
    n = int(input())
    res = solve(n)
    print(res)


def test():
    assert solve(117) == "Yes"
    assert solve(123) == "No"
    assert solve(777) == "Yes"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9176
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var K = ReadText().ToCharArray();
            var klast = K.Last();
            if (klast % 2 == 0 || klast == 5) { return -1; }
            var klong = long.Parse(K);
            long count = 1;
            long current = 7;
            while (current % klong != 0)
            {
                current = (current % klong) * 10 + 7;
                count++;
                if(count > klong)
                {
                    return -1;
                }
            }
            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27884
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin >> a >> b;
    cout << a * b << '\n';
    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define vi vector<int>
#define mod 10000000
using namespace std;
ll dp[100001];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
ll n,k;
cin>>n>>k;

ll temp=n%k;
ll p=k-temp;
ll ans= min(p,temp);
cout<<ans<<endl;
 return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var A = Scanner.ScanEnumerable<int>().ToArray();
            var ok = true;
            foreach (var a in A.Where(x => x % 2 == 0))
            {
                if(a % 3 != 0 && a % 5 != 0) ok = false;
            }
            Console.WriteLine(ok ? "APPROVED" : "DENIED");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28452
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int m;  // |S_i|
    int A = 0;  // n = m*(m+1)/2 となるmが存在するかチェックする変数
    int flag = 0;  // 条件を満たす部分集合の組が存在するとき1
    for(m = 1; m <= 500; m++) {
        A += m;
        if(A == n) {
            flag = 1;
            break;
        }
    }

    if(flag) {

        cout << "Yes" << "\n";
        cout << m+1 << "\n";
        
        vector<vector<int>> v(m+1, vector<int>(m));
        rep(j, m) {
            v[0][j] = j+1;
        }
        for(int i = 1; i <= m; i++) {

            for(int j = 0; j < i; j++) {
                v[i][j] = v[j][i-1];
            }

            int u = (2*m+1-i)*i/2 + 1;
            for(int j = i; j < m; j++) {
                v[i][j] = u;
                u++;
            }

        }

        rep(i, m+1) {
            cout << m << " ";
            rep(j, m) {
                cout << v[i][j] << " ";
            }
            cout << "\n";
        }

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

    return 0;
}

Measured memory_bytes: 2176
Q,H,S,D = list(map(int,input().split(" ")))
N = int(input())
min05 = min(Q*2,H)
min1 = min(min05*2 ,S)
min2 = min(min1 * 2 , D)

if N %2 == 0:
    print(N//2 * min2)

else:
    print((N-1)//2 * min2 + min1 )

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

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

    cout << n * n << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
t_ = input()
t_ = t_.split(" ")
t_ = list(map(int, t_))
a_d = t_[0]
t_d = t_[1]

s = input()
s = s.split(" ")
s = list(map(int, s))


ans_list = []

for v in range(n):
    ans = a_d - s[v] * 0.006 - t_d
    ans = abs(ans)
    ans_list.append(ans)
ans_ = ans_list.index(min(ans_list))

print(ans_+1)

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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_in_out;
    string s,t;
    cin >> s >> t;
    cout << t << s;
}


Measured memory_bytes: 3628
from subprocess import*
call(('pypy3','-c',"""
def main():
    n,k,*a=map(int,open(0).read().split())
    a,f=sorted(a[:n]),sorted(a[n:])[::-1]
    ok=10**12
    ng=-1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        l=k
        for b,g in zip(a,f):
            if b*g>mid:
                l-=b-mid//g
                if l<0:
                    ng=mid
                    break
        else:ok=mid
    print(ok)
main()
"""))

Measured memory_bytes: 132116
#include <iostream>
#include <string>

using namespace std;

int main(){
  string N;
  cin >> N;
  int sum = 0;
  for (int i=0; i<N.size(); i++){
    sum += atoi(N.substr(i, 1).c_str());
  }
  cout << (sum % 9 == 0 ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll n, count = 0, s, k = 1;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll flag = 0;
	for (ll i = 0; i < n; i++) {
		if (a[i] != 1) {
			flag++;
		}
	}
	if (flag == n) {
		cout << -1 << endl;
		exit(0);
	}

	for (ll i = 0; i <n; i++) {
		if (a[i] == 1) {
			count += i;
			s = i;
			k++;
			break;
		}
	}
	for (ll i = s; i<n; i++) {
		if (a[i] == k) {
			count += i - s - 1;
			s = i;
			k++;
		}
		else if (i == n - 1) {
			count += n - 1 - s;
		}
	}
	cout << count << endl;


}



Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
#define LL long long

#define Inf 0x7fffffff
int main()
{
    ios::sync_with_stdio(false);
    int N ,i;
	while(cin>>N>>i)
	cout<<N-i+1<<endl; 
    return 0;
}


Measured memory_bytes: 256
// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
set<int> s[(int)3e5+5];
void solve()
{
	int n,m,k;
	cin >> n >> m>> k;
	map<int,int> row,column,check;
	map<pair<int,int>,int> mp;
	int ans1=0,ans2=0;
	for(int i=0;i<k;++i)
	{
		int x,y;
		cin >> x >> y;
		row[x]++;
		column[y]++;
		mp[{x,y}]=1;
		ans1=max(ans1,row[x]);
		ans2=max(ans2,column[y]);
		s[x].insert(y);
	}
	vector<pair<int,int>> mxrow,mxcolumn;
	for(auto i=row.begin();i!=row.end();++i)
	{
		pair<int,int> a=*i;
		if(a.second==ans1)
		{
			mxrow.push_back({a.second,a.first});
		}
	}
	for(auto i=column.begin();i!=column.end();++i)
	{
		pair<int,int> a=*i;
		if(a.second==ans2)
		{
			mxcolumn.push_back({a.second,a.first});
			check[a.first]=1;
		}
	}
	int ans=ans1+ans2;
	int f=0;
	for(int i=0;i<(int)mxrow.size();++i)
	{
		if((int)s[mxrow[i].second].size()<(int)mxcolumn.size())
		{
			break;
		}
		int cnt=0;
		for(auto j:s[mxrow[i].second])
		{
			//int temp=*j;
			if(check[j])
			cnt++;
		}
		if(cnt==(int)mxcolumn.size())
		{
			f++;
		}
	}
	if(f==(int)mxrow.size())
	ans--;
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

#define ll long long
//~ #define endl '\n'

void solve(){
	cout<<fixed<<setprecision(10);
	double n; cin>>n;
	vector< int > v;
	vector< pair< double, double > > pa(n);
	double ans = 0, divide = 0;
	for(int i = 0; i<n; i++){
		v.push_back(i);
		cin>>pa[i].first>>pa[i].second;
	}
	do{
		for(int i = 1; i<n; i++){
			ans += sqrt(((pa[v[i]].first - pa[v[i - 1]].first) * (pa[v[i]].first - pa[v[i - 1]].first)) + ((pa[v[i]].second - pa[v[i - 1]].second) * (pa[v[i]].second - pa[v[i - 1]].second)));
		}
		divide += 1;
	}while(next_permutation(v.begin(), v.end()));
	cout<<(ans / divide)<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	cin >> n;
	int ans = Inf;
	for (int i = 1; i < n; i++) {
		string a = to_string(i);
		string b = to_string(n - i);
		int sum = 0;
		for (int i = 0; i < a.size(); i++) {
			sum += (int)(a[i] - '0');
		}
		for (int i = 0; i < b.size(); i++) {
			sum += (int)(b[i] - '0');
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi; 
typedef pair<int,int> pi;
#define F first;
#define S second;
#define pb push_back;
#define mp make_pair;
#define rep(i, a, b) for (int i=a; i<=b; i++)

int main(){
    ll t; cin>>t;
    ll x=t%10;
    if(x==3) cout<<"bon";
    else if(x==0 || x==1 || x==6 || x==8) cout<<"pon";
    else cout<<"hon";
    return 0;
}

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

using namespace std;

int main()
{
    int a[5];
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    int min=10,count=0,m;
    for(int i=0;i<5;i++)
    {
        if(min>a[i]%10&&a[i]%10!=0)
            {min=a[i]%10;m=i;}
    }
    for(int i=0;i<5;i++)
    {
        if(a[i]<10&&m!=i&&a[i]%10!=0)
            a[i]=10;
    }
    for(int i=0;i<5;i++)
    {
        if(a[i]>10&&i!=m&&a[i]%10!=0)
            a[i]=(a[i]/10+1)*10;
    }
    for(int i=0;i<5;i++)
        count+=a[i];
        cout<<count;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int k;
  cin >> k;
  vector<int> a(k), b(k);
  for (int i = 0; i < k; i++)
    cin >> a[i] >> b[i];
  vector<int> row(n);
  vector<int> col(m);
  map<pair<int, int>, bool> mp;
  for (int i = 0; i < k; i++) {
    --a[i];
    --b[i];
    mp[{a[i], b[i]}] = true;
    ++row[a[i]];
    ++col[b[i]];
  }
  int r = 0;
  for (int i = 0; i < n; i++)
    if (row[i] > row[r])
      r = i;
  int c = 0;
  for (int i = 0; i < m; i++)
    if (col[i] > col[c])
      c = i;
  vector<int> candRows, candCols;
  for (int i = 0; i < n; i++)
    if (row[i] == row[r])
      candRows.push_back(i);
  for (int i = 0; i < m; i++)
    if (col[i] == col[c])
      candCols.push_back(i);
  int res = 0;
  int itr = 0;
  for (int r : candRows) {
    for (int c : candCols) {
      res = max(res, row[r] + col[c] - (int) mp.count({r, c}));
      ++itr;
      if (itr > (int) 1e6)
        break;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 30788
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			TreeMap<String, Integer> m1 = new TreeMap<String, Integer>();
			TreeMap<String, Integer> m2 = new TreeMap<String, Integer>();
			TreeMap<String, Integer> m3 = new TreeMap<String, Integer>();
			TreeMap<String, Integer> m4 = new TreeMap<String, Integer>();
			TreeMap<String, Integer> m5 = new TreeMap<String, Integer>();
			for(int i=0;i<n;i++)
			{
				String s=in.next();
				int cnt=in.nextInt();

				if(s.length()==1)
				{
					if(m1.containsKey(s))
						cnt+= m1.get(s);
					m1.put(s,cnt);
				}
				else if(s.length()==2)
				{
					if(m2.containsKey(s))
						cnt+=m2.get(s);
					m2.put(s,cnt);
				}
				else if(s.length()==3)
				{
					if(m3.containsKey(s))
						cnt+=m3.get(s);
					m3.put(s,cnt);
				}
				else if(s.length()==4)
				{
					if(m4.containsKey(s))
						cnt+=m4.get(s);
					m4.put(s,cnt);
				}
				else if(s.length()==5)
				{
					if(m5.containsKey(s))
						cnt+=m5.get(s);
					m5.put(s,cnt);
				}
			}

			for (Map.Entry<String, Integer>   entry : m1.entrySet()) {
				System.out.println(entry.getKey()+" "+entry.getValue());
			}
			for (Map.Entry<String, Integer>   entry : m2.entrySet()) {
				System.out.println(entry.getKey()+" "+entry.getValue());
			}
			for (Map.Entry<String, Integer>   entry : m3.entrySet()) {
				System.out.println(entry.getKey()+" "+entry.getValue());
			}
			for (Map.Entry<String, Integer>   entry : m4.entrySet()) {
				System.out.println(entry.getKey()+" "+entry.getValue());
			}
			for (Map.Entry<String, Integer>   entry : m5.entrySet()) {
				System.out.println(entry.getKey()+" "+entry.getValue());
			}
		}
	}
}

Measured memory_bytes: 38296
#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int l,r;    // child
}node;
int sibling(int);
int degree(int);
int depth(int);
int height(int);
node *T;
int h_count;
int main(){
  int n, x, i;
  scanf("%d",&n);
  T = (node *)malloc(sizeof(node) * n);
  for(i=0; i<n; i++) T[i].parent = -1;
  for(i=0; i<n; i++){
    scanf("%d",&x);
    scanf("%d%d",&T[x].l,&T[x].r);
    T[T[x].l].parent = x;
    T[T[x].r].parent = x;
  }
  for(i=0; i<n; i++){
    h_count = 0;
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i,T[i].parent,sibling(i),degree(i),depth(i),height(i));
    if(T[i].parent == -1) printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1) printf("leaf\n");
    else printf("internal node\n");
  }
  free(T);
  return 0;
}

int sibling(int x){
  if(T[x].parent == -1) return -1;
  if(T[T[x].parent].l == x) return (T[T[x].parent].r);
  else return (T[T[x].parent].l);
}

int degree(int x){
  int count=2;
  if(T[x].l == -1) count--;
  if(T[x].r == -1) count--;
  return count;
}

int depth(int x){
  int d_count = 0;
  while(T[x].parent != -1){
    x = T[x].parent;
    d_count++;
  }
  return d_count;
}

int height(int x){
  int y,z;
  if(T[x].l != -1) y = height(T[x].l) + 1;
  else y = 0;
  if(T[x].r != -1) z = height(T[x].r) + 1;
  else z = 0;
  if(y < z) return z;
  else return y;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(h.rbegin(),h.rend());
  ll ans = 0;
  for(int i=k; i<=n-1; i++) ans += h[i];
  cout << ans << endl;
}


Measured memory_bytes: 4768
#include <iostream>

using namespace std;

int main()
{
    int n, k, x, y;

    cin >> n >> k >> x >> y;
    if(n <= k)
    {
        cout << n * x;
        return 0;
    }
    int s = x * k + (n - k) * y;
    cout << s;


    return 0;
}


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

int main()
{
    int n,i,sum=0;
    int x[205];
    cin>>n;
    for(i=0;i<2*n;i++)
    {
        cin>>x[i];
    }
    sort(x,x+2*n);
    for(i=0;i<2*n;i++)
    {
        if(i%2==0)
        {
            sum+=x[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
A=list(map(int,input().split()))
A=A[1:]
for i in range(n-1):
    sub=A
    temp=list(map(int,input().split()))
    A=[]
    for j in range(0,len(sub)):
        if sub[j] in temp[1:]:
            A.append(sub[j])
print(len(A))


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

int main() {
  using tsii = tuple<string, int, int>;
  using vtsii = vector<tsii>;
  
  using pii = pair<int, int>;
  using vpii = vector<pii>;
  
  int N;
  cin >> N;
  
  vtsii restaurant(N);
  
  for( int i=0; i<N; i++ ){
    tsii elem;
    cin >> get<0>(elem);
    cin >> get<1>(elem);
    get<2>(elem) = i;
    restaurant.at(i) = elem;
  }
  
  sort(restaurant.begin(), restaurant.end());
  
  for( int i=1; i<N; i++ ){
    for( int j=(i-1); j>=0; j-- ){
      if( get<0>(restaurant.at(j)) == get<0>(restaurant.at(j+1)) ){
        if( get<1>(restaurant.at(j)) < get<1>(restaurant.at(j+1)) ){
          tsii tmp = restaurant.at(j);
          restaurant.at(j) = restaurant.at(j+1);
          restaurant.at(j+1) = tmp;
        }
      }
      else{
        break;
      }
    }
  }
  
  for( int i=0; i<N; i++ ){
    cout << (get<2>(restaurant.at(i)) + 1) << endl;
  }
}


Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(ans>m)
		ans+=m;
		else
		ans*=2;
	}
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int i,j,c[130]={0},p;
char D[1005],R[1005];

int main()
{
	gets(D);
	strcpy(R,D);
	for(i=0;i<strlen(D);i++)
	{
		if(i>=8&&p>7)c[D[i-8]]--;
		c[D[i]]++;p++;
		if(c['A']==2&&c['I']==1&&c['D']==1&&c['U']==1&&c['N']==2&&c['Y']==1)
		{
			char t=R[i+1];
			strcpy(R+i-7,"AIZUNYAN");
			R[i+1]=t;
			p=0;
			memset(c,0,sizeof(c));
		}
	}
	puts(R);
	return 0;
}

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


int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 10000000001
#define MOD 1000000007
using namespace std;

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

  ll n;
  cin>>n;
  long double p[n];
  for(ll i=0;i<n;i++)
  {
    cin>>p[i];
  }
  long double dp[n][n];
  dp[0][0]=1-p[0];
  dp[0][1]=p[0];
  for(ll i=1;i<n;i++)
  {
    for(ll j=1;j<i+1;j++)
    {
      dp[i][j]=dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
    }
    dp[i][0]=dp[i-1][0]*(1-p[i]);
    dp[i][i+1]=dp[i-1][i]*p[i];
  }

  ll z=n/2+1;
  long double ans=0;
  for(ll i=z;i<=n;i++)
  {
    ans+=dp[n-1][i];
  }
  cout<<setprecision(10)<<ans;

}


Measured memory_bytes: 140160
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int v = int.Parse(str[0]);
        int e = int.Parse(str[1]);
        int r = int.Parse(str[2]);
        int[] f = new int[e];
        int[] t = new int[e];
        long[] cost = new long[e];
        for(int i=0;i<e;i++){
            str = Console.ReadLine().Split(' ');
            f[i] = int.Parse(str[0]);
            t[i] = int.Parse(str[1]);
            cost[i] = int.Parse(str[2]);
        }
        BellmanFord B = new BellmanFord(f,t,cost,v,r,10000000000);
        if(B.NegativeCycle()){
            sb.Append("NEGATIVE CYCLE\n");
        }
        else{
            for(int i=0;i<v;i++){
                if(B.GetCost(i) == 10000000000){
                    sb.Append("INF\n");
                }
                else{
                    sb.Append(B.GetCost(i)+"\n");
                }
            }
        }
    }
}
class BellmanFord{
    bool NEGATIVECYCLE;
    long[] cost;
    public BellmanFord(int[] f,int[] t,long[] c,int n,int s,long INF){
        cost = new long[n];
        int e = f.Length;
        for(int i=0;i<n;i++){
            cost[i] = INF;
        }
        cost[s] = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<e;j++){
                if(cost[f[j]] != INF){
                    cost[t[j]] = Math.Min(cost[t[j]],cost[f[j]]+c[j]);
                }
            }
        }
        NEGATIVECYCLE = false;
        for(int i=0;i<e;i++){
            if(cost[f[i]] != INF && cost[f[i]]+c[i] < cost[t[i]]){
                NEGATIVECYCLE = true;
            }
        }
    }
    public bool NegativeCycle(){
        return NEGATIVECYCLE;
    }
    public long GetCost(int v){
        return cost[v];
    }
}

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

int a, b;
int main() {
	cin >> a >> b;
	if(a==1) a = 14;
	if(b==1) b = 14;
	if(a>b) puts("Alice");
	else if(a<b) puts("Bob");
	else puts("Draw");
	return 0;
}


Measured memory_bytes: 3604