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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

vector<vi> adj;
vi A, seen;

void dfs(int u) {

	if(!seen[u]) {
		seen[u] = true;
		for(int v : adj[u]) {
			dfs(v);
		}

		A.push_back(u);
	}


}

void solve(void) {

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

	adj.resize(n+1);
	seen.resize(n+1);

	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}

	for(int i = 1; i <= n; i++) {
		if(!seen[i]) {
			dfs(i);
		}
	}

	vi dp(n+1);
	int ans = 0;
	for(int u : A) {
		for(int v : adj[u]) {
			dp[u] = max(dp[u], dp[v] + 1);
		}
		ans = max(ans, dp[u]);
	}

	cout << ans << '\n';

}

int main(void) {

	solve();
	return 0;
}


Measured memory_bytes: 9080
#include <iostream>
#include <utility>
#include <cstdint>

constexpr int64_t Mod = 1000000007;

int64_t fact(int64_t n) {
	int64_t res = 1;
	for (int64_t i = 2; i <= n; ++i)
		res = (res * i) % Mod;

	return res;
}

int main() {
	int64_t n, m;
	std::cin >> n >> m;

	if (n > m)
		std::swap(n, m);

	int64_t tmp = fact(n);
	tmp = (tmp * tmp) % Mod;
	switch (m - n) {
	case 0:
		std::cout << (tmp * 2) % Mod << std::endl;
		break;
	case 1:
		std::cout << (tmp * m) % Mod << std::endl;
		break;
	default:
		std::cout << 0 << std::endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H, W;
    
    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) break;
        else {
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (j == W - 1) printf("#\n");
                    else printf("#");
                }
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1016
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
//void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
//void solve(){ll a,b,c;cin>>a>>b>>c;if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
//void solve(){char c;cin>>c;string s="aiueo";if(s.find(c)!=string::npos)cout<<"vowel"<<endl;else cout<<"consonant"<<endl;}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){ll A,B;char op;cin>>A>>op>>B;if(op=='+')cout<<A+B<<endl;else cout<<A-B<<endl;}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){string s;cin>> s;cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14)<<endl;}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
//void solve(){ll A,B,C,D;cin>>A>>B>>C>>D;cout<<max(A*B,C*D)<<endl;}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){ll x;cin>>x;cout<<(x<1200?"ABC":"ARC")<<endl;}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
//void solve(){ll A,B;cin>>A>>B;if(A==1)A=14;if(B==1)B=14;cout<<(A>B?"Alice":(A==B?"Draw":"Bob"))<<endl;}
// https://abc055.contest.atcoder.jp/tasks/abc055_a
//void solve(){ll N;cin>>N;cout<<800*N-200*(N/15)<<endl;}
// https://abc056.contest.atcoder.jp/tasks/abc056_a
void solve(){char a,b;cin>>a>>b;if(a=='H')cout<<b<<endl;else if(b=='H')cout<<'D'<<endl;else cout<<'H'<<endl;}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    int n;
    string s;

    input(n, s);

    for (char &c : s) {
        c -= 'A';
        c = (c + n) % 26;
        c += 'A';
    }

    print(s);

    return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    for(int i = 0; i < 5000000; i++)
    {
        if(a%2 == 1 || b%2 == 1 || c%2 == 1)
        {
            cout<<i<<endl;
            return 0;
        }

        int x = (b + c)/2;
        int y = (a + c)/2;
        int z = (a + b) /2;
        a = x, b = y, c = z;


    }
    cout<<-1<<endl;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	InputStream input = System.in;
      	OutputStream output = System.out;
      	Scanner sc = new Scanner(input);
      	PrintWriter out = new PrintWriter(output);
      	int X = sc.nextInt();
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	X -= A;
      	while(B <= X){
        	X -= B;
        }
      	out.println(X);
      	out.close();
    }
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

  ll n,m;
  cin >> n >> m;
  if(n==m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

struct P
{
    int x,y;

    /*bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }*/

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[222221];
int l[1];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[100333];
stack<P> s;
//set<int> s[222][22];
//priority_queue<int> q;
//queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

string r;
//char r[222253];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}

void f(int n,int m)
{
    if(n==0||(s.size()&&s.top().x==0))
    {
        s.push({0,1});
        return;
    }
    for(;s.size()&&s.top().x>n;s.pop());
        if(s.size()&&s.top().x==n)
        {
            m+=s.top().y+1;
            s.pop();
            if(m>=h)
            {
                f(n-1,0);
                f(n,m-h);
            }
            else f(n,m);
            return;
        }
        else s.push({n,m});
}

int main()
{
    scanf("%d",&a);
    i=1;
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&o[t]);
        if(o[t]<=o[t-1]) i=0;
    }
    if(i)
    {
        printf("1");
        return 0;
    }
    n=2,m=1000000000;
    for(;n<m;)
    {
        h=(n+m)/2;
        for(int t=1;t<=a;t++)
        {
            c=0;
            for(;s.size()&&s.top().x>o[t];c=1,s.pop());
            if(s.size()&&s.top().x==o[t])
            {
                c=s.top().y+1;
                s.pop();
                if(c>=h)
                {
                f(o[t]-1,0);
                f(o[t],c-h);
                }
                else f(o[t],c);
            }
            else s.push({o[t],c});
            if(s.top().x==0)
            {
                n=h+1;
                goto qwe;
            }
        }
        m=h;
        qwe:;
        for(;s.size();s.pop());
    }
    printf("%d",n);
}






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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    string s; cin >> s;
    int cnt = 0;
    REP(i, 1, s.size()){
        if(s[i] != s[i - 1]){
            continue;
        }else{
            if(s[i] == '0') s[i] = '1';
            else s[i] = '0';
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

const int mod=1e9+7;

int main()
{
    string s; cin>>s;
    int N=s.size();
    reverse(s.begin(),s.end());

    vector<int> dp(13);
    dp[0]=1;
    int r=1;
    for(int i=0;i<N;i++){
        vector<int> tmp(13);
        for(int d=0;d<10;d++){
            if(s[i]!='?' and d!=s[i]-'0') continue;
            for(int j=0;j<13;j++){
                (tmp[(j+r*d)%13]+=dp[j])%=mod;
            }
        }
        r=r*10%13;
        swap(tmp,dp);
    }
    cout<<dp[5]<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

//最大公約数を求める
long long gcd(long long a, long long b){
  if(a == 0){
    return b;
  }else if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int main() {
  long long N;
  long long ans = 0;
  long long maxv = 1;

  cin >> N;

  vector<long long > A(N, 0);
  vector<long long > L(N+1, 0);
  L[0] = 0;
  vector<long long > R(N+1, 0);
  R[N] = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  for(int i = 0; i < N; i++){
    L[i+1] = gcd(L[i], A[i]);
    // cout << "  L[" << i << "] = "<< L[i]  << endl;
  }

  for(int i = (N-1); i > 0; i--){
    R[i-1] = gcd(R[i], A[i]);
    // cout << "  R[" << i << "] = "<< R[i]  << endl;
  }
  // cout << "-----------------"  << endl;

  for(int i = 0; i < N; i++){    
    if(i == 0){
      maxv = R[i];
    }else if(i == (N-1)){
      maxv = L[N-1];
    }else{
      maxv = gcd(L[i], R[i]);
    }
    
    // cout  << "  i = " << i << ": maxv =  "<< maxv  << endl;
    if(maxv > ans){
      ans = maxv;
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N, M = LI()
    A = LI()
    total = sum(A)
    discount = []
    for a in A:
        while a > 0:
            disc = (a+1)//2
            discount.append(disc)
            a -= disc
    discount = sorted(discount)[::-1]
    discount = discount[:M]
    print(total - sum(discount))
main()



Measured memory_bytes: 146360
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
const int MOD=1000000000+7;

int a,b;

int main(){
	cin>>a>>b;
	if(a<=8&&b<=8)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;


	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans;
  if (a != 1 && b != 1) {ans = 1;}
  if (a != 2 && b != 2) {ans = 2;}
  if (a != 3&& b != 3) {ans = 3;}
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    k, n = [int(s) for s in input().strip().split()]
    A = [int(s) for s in input().strip().split()]
    A.append(A[0] + k)
    maxdiff = max(b - a for a, b in zip(A, A[1:]))
    result = k - maxdiff
    print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 91052
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll n;
  cin >> n;
  cout << 1110 - n << "\n";

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

a = [0] * n
b = [0] * m

for i in range(n):
    a[i] = list(map(int, input().split()))

for i in range(m):
    b[i] = int(input())

for i in range(n):
    ret = 0
    for j in range(m):
        ret += a[i][j] * b[j]    
    print(ret)
    



Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> vec(q);
  int i;
  for(i=0;i<q;i++){
    cin >> vec.at(i);
  }
  vector<int> tensu(n);
  for(i=0;i<n;i++){
    tensu.at(i)=k-q;
  }
  for(i=0;i<q;i++){
    tensu.at(vec.at(i)-1)++;
  }
  for(i=0;i<n;i++){
    if(tensu.at(i)>0){
      cout << "Yes" << endl;
    }else{
      cout << "No"<<endl;
    }
  }
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

int oup = 0;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  vvi lights(M, vi());
  for(int x = 0; x<M; x++){
    int k;
    cin >> k;
    for(int y = 0; y<k; y++){
      int t;
      cin >> t;
      t--;
      lights[x].push_back(t);
    }
  }
  vi p(M);
  for(int x = 0; x<M; x++)
    cin >> p[x];
  int config = 0;
  while(config < 1<<N){
    bool can = true;
    for(int x = 0; x<M; x++){
      int tot = 0;
      for(int y = 0; y<lights[x].size(); y++){
        int curr_s = lights[x][y];
        if(1 == 1 & config>>curr_s){
          tot++;
        }
      }
      if(tot%2!=p[x]){
        can = false;
        break;
      }
    }
    config++;
    if(can)
      oup++;

  }
  cout << oup << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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 (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int s,t;
    int now=0;
    vector<int> d(n,-1);
    d[0]=0;
    int cnt=0;
    while(1){
        cnt++;
        int nex=a[now];
        if(d[nex]!=-1){
            s=nex;
            t=cnt-d[nex];
            break;
        }
        d[nex]=cnt;
        now=nex;
    }
    if(k<=d[s]){
        for(int i=0;i<n;i++){
            if(d[i]==k){
                cout << i+1 << endl;
                return 0;
            }
        }
    }
    else{
        for(int i=0;i<n;i++){
            if(d[i]==d[s]+(k-d[s])%t){
                cout << i+1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4788
#include <cstdio>

int main(){
    int N;
    scanf("%d",&N);
    char CN[3];
    CN[0] = 'A';
    CN[1] = 'B';
    CN[2] = 'C' + (N + N / 1000) / 1000;
    printf("%c%c%c\n",CN[0],CN[1],CN[2]);
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
struct segtree {
    ll N;
    vl dat;
    segtree(vl A) {
        ll k = A.size();
        N = 1;
        while(N < k)
            N *= 2;
        dat = vl(N * 2 + 1);
        rep(i, k) { dat[N + i] = A[i]; }

        for(ll i = N - 1; i > -1; i--) {
            dat[i] = dat[i * 2 + 1] + dat[i * 2 + 2];
        }
    }
    // update k th element
    void add(ll k, ll a) {
        k += N - 1; // leaf
        dat[k] += a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
        }
    }
    // sum of [a, b)
    ll query(ll a, ll b) { return query(a, b, 0, 0, N); }
    ll query(ll a, ll b, ll k, ll l, ll r) {
        if(r <= a or b <= l)
            return 0;
        if(a <= l and r <= b)
            return dat[k];
        ll m = (l + r) / 2;
        return (query(a, b, k * 2 + 1, l, m) + query(a, b, k * 2 + 2, m, r));
    }
};
int main() {
    cin >> n;
    string S;
    cin>>S;
    cin>>q;

    vector<segtree> SEG(26,(vl(n,0)));

    rep(i,S.length()){
        SEG[S[i]-'a'].add(i,1);
    }

    while(q--){
        cin>>x;
        if(x==1){
            char C;
            cin>>x>>C;
            x--;
            SEG[S[x]-'a'].add(x,-1);
            SEG[C-'a'].add(x,1);
            S[x]=C;
        }
        else{
            cin>>y>>z;
            y--;
            ans=0;
            rep(i,26){
                if(SEG[i].query(y,z)>0)ans++;
            }
            cout<<ans<<endl;
        }
    }



}

Measured memory_bytes: 226052
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+6;
vector<pair<int,int>>g[N];
int ans[N],mx;

void dfs(int n,int p,int prv){
   int col=1;
   for(int i=0;i<g[n].size();i++){
    if(g[n][i].first==p)continue;
       if(col==prv)col++;
       ans[g[n][i].second]=col;
       dfs(g[n][i].first,n,col);
       col++;
       }
   }

int main()
{

   /*#ifndef ONLINE_JUDGE
   freopen("test.txt", "r", stdin);
   #endif*/
   ios_base::sync_with_stdio(0);
   cin.tie(0);

   int n,x,y;
   cin>>n;
   for(int i=0;i<n-1;i++){
    cin>>x>>y;
    g[x].push_back({y,i});
    g[y].push_back({x,i});
   }
   for(int i=1;i<=n;i++){
    mx=max(mx,(int)g[i].size());
   }
   dfs(1,-1,-1);
  cout<<mx<<'\n';
  for(int i=0;i<n-1;i++){
   cout<<ans[i]<<'\n';
  }

    return 0;
}


Measured memory_bytes: 9344
#include<stdio.h>
int main(void){
  int N,i;
  scanf("%d",&N);
  int A[N-1],B[N];
  for(i=0;i<N-1;i++){
    scanf("%d",&A[i]);
    B[i] = 0;
  }
  B[N-1] = 0;
  for(i=0;i<N-1;i++)
    B[A[i]-1]++;
  for(i=0;i<N;i++)
    printf("%d\n",B[i]);
}

Measured memory_bytes: 3248
#include<iostream>
#include<vector>
#include <cmath>
#include <stdio.h>

using namespace std;
int main()
{   
    // 整数の入力
    int a,b,c;
    string result = "bust";
    cin >> a >> b >>c;
//    vector<int> vect;

    if(a+b+c<=21){
        result = "win";
    }


        cout << result;
        return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define F first
#define S second
using namespace std;
typedef pair<int,pair<int,int> > P;
struct edge{
  int t,c;
  edge(int t,int c):t(t),c(c){}
};
vector<edge> e[111];
bool c[111];

int n,m,l,k,a,h; 

int d[111][111];
int main(void){
  while(cin >> n >> m >> l >> k >> a >> h){
    if(!n) break;
    memset(c,false,sizeof(c));
    for(int i = 0; i < 111; i++) e[i].clear();
    for(int i = 0; i < l; i++){
      int b;
      cin >> b;
      c[b] = true;
    }
    for(int i = 0; i < k; i++){
      int x,y,t;
      cin >> x >> y >> t;
      e[x].push_back(edge(y,t));
      e[y].push_back(edge(x,t));
    }

    for(int i = 0; i < 111; i++){
      fill(d[i],d[i]+111,1<<28);
      d[i][a] = 0;
    }

    //d[解けるまでの時間][今いる場所]
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,make_pair(m,a)));
    while(!que.empty()){
      P p = que.top(); que.pop();
      if(d[p.S.F][p.S.S] < p.F) continue;
      for(int j = 0; p.S.F + j <= m; j++){
	if(j && !c[p.S.S]) continue;
	for(int i = 0; i < (int)e[p.S.S].size(); i++){
	  edge v = e[p.S.S][i];
	  if(p.S.F - v.c + j >= 0 && d[p.S.F - v.c + j][v.t] > p.F + v.c + j){
	    d[p.S.F - v.c + j][v.t] = p.F + v.c + j;
	    que.push(P(p.F + v.c + j,make_pair(p.S.F - v.c + j,v.t)));
	  }
	}
      }
    }

    int res = 1<<28;
    for(int i = 0; i <= m; i++){
      res = min(res,d[i][h]);
    }
    if(res == 1<<28) cout << "Help!" << endl;
    else cout << res << endl;
  }
}

Measured memory_bytes: 1584
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u==s) cout<<a-1<<" "<<b;
    else cout<<a<<" "<<b-1;
}

Measured memory_bytes: 3452
#include <stdio.h>
#include <string.h>

typedef struct{
  char a;
  int  num;
}data;

//バブルソートと比較し安定か安定じゃないか確かめる

int main(){
  data data[36],data1[36],data2[36],tmp_data;
  char temp[2];
  int i,j,n,minj,s=0,flag=0,flag2=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    //scanf(" %c %d",&data[i].a,&data[i].num);
    scanf("%s", temp);
    data[i].a = temp[0];
    data[i].num = temp[1] - 48;
    
    data1[i]=data[i];
    data2[i]=data[i];
  }

  //バブルソート
  for(i = 0 ; i < n; i++){
    for(j = n-1; j >= i + 1; j--){
      if(data1[j].num < data1[j-1].num){
	tmp_data = data1[j-1];
	data1[j-1] = data1[j];
	data1[j] = tmp_data;
	flag = 1;
      }
    }
  }
   
  for(i=0;i<n;i++){
    printf("%c%d",data1[i].a,data1[i].num);
    if(i!=n-1)printf(" ");
      }
  printf("\nStable\n");
  

  
  //セレクションソート
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(data2[j].num < data2[minj].num){
	minj = j;
      }
    }

    tmp_data = data2[i];
    data2[i] = data2[minj];
    data2[minj] = tmp_data;
  }

  for(i=0;i<n;i++){
    printf("%c%d",data2[i].a,data2[i].num);
    if(i!=n-1)printf(" ");
    if(data1[i].a!=data2[i].a)flag2=1;
  }
  printf("\n");
  if(flag2==0)printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
int main(void){
  char n;
  scanf("%c",&n);
  switch(n){
    case 'A':
      printf("T\n");
      break;
    case 'T':
      printf("A\n");
      break;
    case 'G':
      printf("C\n");
      break;
    case 'C':
      printf("G\n");
      break;
  }
  return 0;
}


Measured memory_bytes: 128
using System;

class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		
		double m = 100000;
		double r = 0.05D;
		double w;
		
		for (int i = 0; i < n; i++)
		{
			w = Math.Ceiling((m * r) / 1000) * 1000;
			m += w;
		}
		
		Console.WriteLine(m.ToString());
	}
}



Measured memory_bytes: 15764
#include <cstdio>
#include <algorithm>

const int N = 512, INF = 1 << 27;

int n, row[N], col[N];
char a[N][N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf(" %s", a[i] + 1);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (a[i][j] == '#') ++row[i], ++col[j];
  if (*std::max_element(row + 1, row + n + 1) == 0) return puts("-1"), 0;
  int ans = INF;
  for (int i = 1; i <= n; ++i) {
    int cur = !col[i] + n - row[i];
    cur += n - std::count(col + 1, col + n + 1, n);
    ans = std::min(ans, cur);
  }
  printf("%d\n", ans == INF ? -1 : ans);
  return 0;
}


Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let v = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".to_owned();
    let v = v.chars().collect::<Vec<char>>();

    let line = read_as_vec::<usize>();
    let (h, _) = (line[0], line[1]);
    for i in 1..h+1{
        let line = read_as_string();
        if let Some(pos) = line.find("snuke"){
            println!("{}{}", v[pos/6], i);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
#include<iomanip>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a; i < b; i++)

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

	map<int, int> m, x;

	int maxi = 0;
	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		if (x[a[i]] == 0) x[a[i]]++;
		else m[a[i]]++;
		maxi = max(maxi, a[i]);
	}

	int cnt = 0;

	int l = 2;
	rep(i, 0, n) {
		int t = 1;
		while (a[i] * l <= maxi) {
			t = a[i] * l;
			m[t]++;
			l++;
		}
		l = 2;
	}

	rep(i, 0, n) {
		if (m[a[i]] == 0) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 57828
import sys
def main():
    input = sys.stdin.readline

    N, M, K=map(int, input().split())
    friend_or_block = [list() for _ in range(N)]
    friends_chain = UnionFindTree(N)

    for _ in range(M):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        friends_chain.union(a, b)
        friend_or_block[a].append(b)
        friend_or_block[b].append(a)

    for _ in range(K):
        c, d = map(int, input().split())
        c, d = c-1, d-1
        if friends_chain.same(c, d):
            friend_or_block[c].append(d)
            friend_or_block[d].append(c)

    print(*[friends_chain.size(i) - len(friend_or_block[i]) - 1 for i in range(N)])

class UnionFindTree:
    def __init__(self, n):
        self.parent = [-1] * n

    def find(self, x):
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x, y):
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x

    def same(self, x, y): return self.find(x) == self.find(y)
    def size(self, x): return -self.parent[self.find(x)]

if __name__ == '__main__':
    main()



Measured memory_bytes: 84144
n,m=map(int,input().split())
l = 1
r = n
for j in range(m):

    l_i,r_i = map(int,input().split())

    l = max(l,l_i)
    r = min (r,r_i)

if r>=l:
    print(r-l+1)
else:
    print(0)





Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=998244353LL;
const ll LINF=1LL<<60;
const ll INF=1<<30;
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; }
using namespace atcoder;
const ll n_max = 1000000;
vector<ll> ten(n_max,0LL);
vector<ll> one(n_max,0LL);
P op(P a,P b){
	return mp((a.fs * ten[b.sc]+ b.fs) % mod,a.sc + b.sc);//ten[i]=10^i（のmod)
}
P e(){
	return mp(0LL,0LL);
}
P mapping(ll f,P x){
	if(f== 0LL){
		return x;
	}
	else{
		return mp(one[x.sc] * f % mod,x.sc);//one[i] = 1をi個並べたやつ(のmod)
	}
}
ll composition(ll f,ll g){
	return ((f == 0LL)? g:f);
} 
ll id(){
	return 0LL;
}
int main(){
	ll n,q;cin>>n>>q;
	vector<P> a(n,mp(1LL,1LL));
	ten[0] = 1;
	for(ll i = 1; i < ten.size(); i++) {
		ten[i] = ten[i - 1] * 10 % mod;
	}
	one[0] = 0;
	for(ll i = 1; i < one.size(); i++) {
		one[i] = (one[i - 1] * 10 + 1) % mod;
	}
	lazy_segtree<P,op,e,ll,mapping,composition,id> seg(a);
	for(ll i = 0; i < q; i++) {
		ll l,r,d;cin>>l>>r>>d;
		seg.apply(l-1,r,d);
		ll x = seg.prod(0,n).fs;
		cout << x << endl;
	}	
	return 0;
}

Measured memory_bytes: 32304
x,n=map(int,input().split())
lis=[i-1 for i in range(103)]
flag=True
if n==0:
  flag=False
  print(x)

if flag:
  p=list(map(int,input().split()))
  for i in p:
    lis.remove(i)
  #print(lis)
  for i in range(len(lis)):
    if lis[i]>x:
      index=i
      break
  if abs(x-lis[index])<abs(x-lis[index-1]):
    print(lis[index])
  else:
    print(lis[index-1])


Measured memory_bytes: 9208
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

int main(void) {
	double r = 0;
	double PI = acos(-1);
	CI r;
	printf("%.7lf %.7lf",r * r * PI,2 * r * PI);
}

Measured memory_bytes: 1240
// https://atcoder.jp/contests/abc116/tasks/abc116_b

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashSet;
#[allow(unused)]
use std::collections::VecDeque;
use std::io;
use std::io::{BufRead, Read, Write};
use std::str::FromStr;

#[allow(unused, non_snake_case)]
pub fn solve<R: BufRead, W: Write>(mut io: Io<R, W>) {
    let s: usize = io.next();

    let mut cur = s;
    let mut used: HashSet<usize> = HashSet::new();
    used.insert(cur);

    let mut res = 1;
    loop {
        res += 1;
        cur = if cur % 2 == 0 { cur / 2 } else { 3 * cur + 1 };

        if used.contains(&cur) {
            break;
        }

        used.insert(cur);
    }

    io.println(res);
}

#[allow(dead_code)]
fn main() {
    let stdin = io::stdin();
    let stdin_lock = stdin.lock();
    let stdout = io::stdout();
    let stdout_lock = stdout.lock();

    let io = Io {
        reader: stdin_lock,
        writer: stdout_lock,
    };

    solve(io);
}

/* IO helpers */

pub struct Io<R, W>
where
    R: BufRead,
    W: Write,
{
    pub reader: R,
    pub writer: W,
}

#[allow(dead_code)]
impl<R, W> Io<R, W>
where
    R: BufRead,
    W: Write,
{
    fn println<T: std::fmt::Display>(&mut self, value: T) {
        writeln!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn print<T: std::fmt::Display>(&mut self, value: T) {
        write!(&mut self.writer, "{}", value).expect("Unable to write");
    }

    fn next<T: FromStr>(&mut self) -> T {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok().expect("Unable to parse")
    }
}

/* Structure helpers */

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int t;
	cin >> t;

	REP( ti, 0, t )
	{
		int n, k;
		cin >> n >> k;

		VI xs( n );

		EACH( x, xs )
		{
			cin >> x;
		}

		VI diff;

		REP( i, 0, n - 1 )
		{
			diff.PB( xs[ i + 1 ] - xs[i] );
		}

		sort( ALL( diff ), greater<int>() );

		cout << accumulate( ALL( diff ), 0 ) - accumulate( diff.begin(), diff.begin() + min( n, k ) - 1, 0 ) << endl;
	}

	return 0;
}

Measured memory_bytes: 2404
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

VI vi;

int main(void) {
    int n;
    cin >> n;
    vi = VI(n, 0);
    REP(i, n) cin >> vi[i];
    for(int i = n-1; i > 0; i--) {
        // cerr << "i: " << i << ", ";
        // vecprint(vi);
        if(vi[i-1] - vi[i] > 1) {
            cout << "No" << endl;
            return 0;
        }
        if(vi[i-1] - vi[i] == 1) {
            vi[i-1]--;
            continue;
        }
    }
    cout << "Yes" << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

int main() {
	int N;

	while (scanf("%d", &N), N) {		
		int ans = 1, f = 0;
		
		for_(i,0,N) {
			int k; scanf("%d", &k);
			if (k) ++ans;
			if (k > 1) f = 1;
		}
		
		if (f) printf("%d\n", ans);
		else puts("NA");
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define fast                            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int                             long long
#define ff                              first
#define ss                              second
#define max3(a,b,c)                     max(a,max(b,c))
#define min3(a,b,c)                     min(a,min(b,c))
#define setbits(x)                      __builtin_popcountll(x)
#define zerobits(x)                      __builtin_ctzll(x)
#define pb                              push_back
#define mkp                             make_pair
#define all(v)                          (v).begin(),(v).end()
#define pii                             pair<int, int>
#define vi                              vector<int>
#define vpi                             vector<pair<int,int>>
#define rev(x)                          reverse(all(x))
#define gcd(m,n)                        __gcd(m, n)
#define negmod(x,m)                     ((x)%(m)+(m))%(m)
#define fr(i, a, b)                     for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n)                       for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n)                      for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b)                    for (int i = (a), _b = (b); i >= _b; i--)
#define M                               1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ull countBits(ull n){ull count=0;while(n){count++;n>>=1;}return count;}
int updiv(int a,int b)
{
  if(a%b==0)
    return (a/b);
  else
    return (a/b)+1;
}
int mymod(int x,int m)
{
  if(x>0)
    return x%m;
  else
    return negmod(x,m);
}
int binpow(int a, int b)
{
    int res = 1;
    while(b>0)
    {
        if(b&1)
        res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.ff=lhs.ss;
    a.ss=lhs.ff;
    b.ff=rhs.ss;
    b.ss=rhs.ff;
    return a<b;
}
int32_t main()
{
fast
int t=1,n;
//cin>>t;
while(t--)
{
cin>>n;
int h[n+1]={0};
for(int i=1;i<=n;i++)
{
cin>>h[i];
}
int dp[n+1]={0};
dp[2]=abs(h[2]-h[1]);
for(int i=3;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
cout<<dp[n]<<"\n";
}
return 0;
}


Measured memory_bytes: 5176
import java.io.*;
import java.util.*;
public class Main{
	final public static int MOD = (int)1e9+7;
	public static int dp[][] = new int[1001][1001];
    public static void main(String[] args) throws IOException{
    	FastScanner sc = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    	int h = sc.nextInt();
    	int w = sc.nextInt();
    	boolean board[][] = new boolean[h][w];
    	for(int i=0; i<h; i++) {
    		String k = sc.nextToken();
    		for(int j=0; j<w; j++) {
    			board[i][j] = k.charAt(j)=='#';
    		}
    	}
    	if(board[0][0])dp[0][0] = 0;
    	else dp[0][0] = 1;
    	for(int i=1; i<h; i++) {
    		if(board[i][0]) dp[i][0] = 0;
    		else dp[i][0] = dp[i-1][0];
    	}
    	for(int i=1; i<w; i++) {
    		if(board[0][i]) dp[0][i] = 0;
    		else dp[0][i] = dp[0][i-1];
    	}
    	for(int i=1; i<h; i++) {
    		for(int j=1; j<w; j++) {
    			if(board[i][j]) dp[i][j] = 0;
    			else {
    				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
    			}
    		}
    	}
    	out.println(dp[h-1][w-1]);
    	out.close();
    }
    public static class FastScanner {
    	BufferedReader br;
    	StringTokenizer st;

    	public FastScanner(String s) {
    		try {
    			br = new BufferedReader(new FileReader(s));
    		} catch (FileNotFoundException e) {
    			e.printStackTrace();
    		}
    	}

    	public FastScanner() {
    		br = new BufferedReader(new InputStreamReader(System.in));
    	}
    	
    	String nextToken() {
    		while (st == null || !st.hasMoreElements()) {
    			try {
    				st = new StringTokenizer(br.readLine());
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}

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

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

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

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


Measured memory_bytes: 32380