akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		if(n <= k){
			System.out.println(n*x);
		} else {
			System.out.println(k*x + (n-k)*y);
		}

		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
var
 a:ansistring;
 i,m:longint;
begin
 readln(a);
 for i:=1 to length(a)-2 do
  if (a[i]=a[i+1]) and (a[i]=a[i+2]) and (a[i+1]=a[i+2]) then 
   begin m:=1;
         break; end;
  if m=1 then writeln('Yes')
         else writeln('No');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int num[] = { 0,2,5,5,4,5,6,3,7,6 };
int f[10005], tmp, a[10];
map<int, int>mp;
string ans[10005];
int main()
{
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> tmp;
		mp[num[tmp]] = max(mp[num[tmp]], tmp);
	}
	m = mp.size(); tmp = 0;
	for (auto i : mp)a[tmp++] = i.second;
	sort(a, a + m);
	memset(f, -1, sizeof(f)); f[0] = 0;
	for (int i = 0; i <= n; i++)ans[i] = "";
	for (int i = 0; i < m; i++)
		for (int j = num[a[i]]; j <= n; j++)
			if (f[j - num[a[i]]] >= 0 && f[j] <= f[j - num[a[i]]] + 1)
			{
				f[j] = f[j - num[a[i]]] + 1;
				ans[j] = ans[j - num[a[i]]] + char('0' + a[i]);
			}
	sort(ans[n].begin(), ans[n].end(), greater<int>());
	cout << ans[n] << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m, k;
char planet[1005][1005];
int sum_J[1005][10005], sum_O[1005][1005], sum_I[1005][1005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> m >> n;
    cin >> k;
    rep(i, m)rep(j, n) cin >> planet[i][j];
    rep(i, m)rep(j, n) {
            if (planet[i][j] == 'J') sum_J[i + 1][j + 1] = 1;
            else if (planet[i][j] == 'O') sum_O[i + 1][j + 1] = 1;
            else sum_I[i + 1][j + 1] = 1;
            sum_J[i+ 1][j + 1] += sum_J[i + 1][j];
            sum_O[i+ 1][j + 1] += sum_O[i + 1][j];
            sum_I[i+ 1][j + 1] += sum_I[i + 1][j];
    }
    rep(_, k) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int cnt_J = 0;
        int cnt_O = 0;
        int cnt_I = 0;
        rep2(i, a, c + 1) {
            cnt_J += sum_J[i][d] - sum_J[i][b - 1];
            cnt_O += sum_O[i][d] - sum_O[i][b - 1];
            cnt_I += sum_I[i][d] - sum_I[i][b - 1];
        }
        cout << cnt_J << " " << cnt_O << " " << cnt_I << endl;
    }
}

Measured memory_bytes: 31340
#include <stdio.h>
int main(void){
    // Your code here!
    int n, a, b, c, i, x;
    scanf("%d", &n);
    
    if(n==2){
        scanf("%d %d", &a, &b);
        if(a>b){
            x=a;
            a=b;
            b=x;
        }
        for(i=1;  i<=b; i++){
            if(a%i==0 && b%i==0) printf("%d\n", i);
        }
    }
    else {
        scanf("%d %d %d", &a, &b, &c);
        if(a>b && a>c){
            x=a;
            a=c;
            c=x;
        }
        else if(b>a && b>c){
            x=b;
            b=c;
            c=x;
        }
        for(i=1; i<=c; i++){
            if(a%i==0 && b%i==0 && c%i==0) printf("%d\n", i);
        }
    }
    return 0;
    
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;

int main() {
  int N, M;
  cin >> N >> M;
  if (N % 2 == 1) {
    rrep(i, M) { cout << i << " " << 2 * M + 1 - i << endl; }
    return 0;
  }
  if (N % 4 == 0) {
    int cnt = 0;
    int n = N / 4 - 1;
    rrep(i, n) {
      cnt += 1;
      cout << i << " " << 2 * n + 2 - i << endl;
      if (cnt == M) {
        return 0;
      }
    }
    rrep(i, n + 1) {
      cnt += 1;
      cout << i + 2 * n + 1 << " " << 4 * n + 4 - i << endl;
      if (cnt == M) {
        return 0;
      }
    }
  }
  int cnt = 0;
  int n = N / 4;
  rrep(i, n) {
    cnt += 1;
    cout << i << " " << 2 * n + 2 - i << endl;
    if (cnt == M) {
      return 0;
    }
  }
  rrep(i, n) {
    cnt += 1;
    cout << i + 2 * n + 1 << " " << 4 * n + 2 - i << endl;
    if (cnt == M) {
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3596
X, Y, Z, K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

D = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            D.append(A[i] + B[j] + C[k])
D.sort(reverse=True)
D = D[:K]
for d in D:
    print(d)


Measured memory_bytes: 8708
#include<iostream>
#include<stdio.h>

using namespace std;

int main() {
	long long int a, b;
	cin >> a >> b;

	 long long int d = a/b;
	 long long int r = a%b;
	double f = (double)a / b;

	printf("%lld %lld %.5f\n", d, r, f);

	return 0;
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz1 105
#define sz2 1005

using namespace std;

int main()
{
    ll n,k,x,m=1;

    scanf("%lld %lld",&n,&k);

    ll sum=0;

    for(ll i=1; i<=n; i++)
    {
        scanf("%lld",&x);

        ll d=fabs(k-x);

        sum+=min(d, x);
    }

    printf("%lld\n",sum*2);

    return (0);
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        long N = long.Parse(input[0]);
        long K = long.Parse(input[1]);
        long[] H = new long[N];
        input = Console.ReadLine().Split();
        for (long i = 0; i < N; i++)
        {
            H[i] = long.Parse(input[i]);
        }
        Array.Sort(H);
        Array.Reverse(H);
        long ans = 0;
        for(long i = K; i < N; i++)
        {
            ans += H[i];
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 33408
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int n;

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	n=read();int ans=0,i;
	for (i=1;i<=n;i++)
	{
		int x=read();
		if (x%2) ans=1;
	}
	if (ans) cout << "first"; else cout << "second";
	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int dp[13];

signed main() {
  string s = readString();
  int lst = s.size() - 1;
  int multiple = 1;
  dp[0] = 1;
  for (int i = lst; i >= 0; i--) {
    int _dp[13] = {};
    if (s[i] == '?') {
      REP(num, 10) {
        int remain = (num * multiple) % 13;
        REP(j, 13) {
          _dp[(remain + j) % 13] = (_dp[(remain + j) % 13] + dp[j]) % mod;
        }
      }
    } else {
      int remain = (int)(s[i] - '0');
      remain = (remain * multiple) % 13;
      REP(j, 13) { _dp[(remain + j) % 13] = dp[j]; }
    }
    REP(j, 13) { dp[j] = _dp[j]; }
    multiple = (multiple * 10) % 13;
  }
  std::cout << dp[5] << std::endl;
}


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

int main() {
	int l,a,b,c,d;
	int m,j;
	cin>>l>>a>>b>>c>>d;
	if(a%c==0)j=a/c; else j=a/c+1;
	if(b%d==0)m=b/d; else m=b/d+1;
	if(m>j)l-=m; else l-=j;
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[1001];
while(1){
scanf("%s", a);
if( a[0] == '0' ) break;
int sum = 0;
for (int i = 0; i < strlen(a); i++ ){
sum += (a[i]-'0');
}
printf("%d\n", sum);
}
return 0;
}

Measured memory_bytes: 3228
N, M = map(int, input().split())
mod = 998244353

if N > M:
  N, M = M, N

fact = [0] * (M + 1)
powm = [0] * (M + 1)
pown = [0] * (M + 1)
fact[0] = 1
powm[0] = 1
pown[0] = 1
for i in range(1, M + 1):
  fact[i] = fact[i - 1] * i % mod
  powm[i] = powm[i - 1] * (M + 1) % mod
  pown[i] = pown[i - 1] * (N + 1) % mod

def pow(n, m):
  if m == 0:
    return 1
  elif m == 1:
    return n
  elif m % 2 == 0:
    return pow(n, m // 2)**2 % mod
  else:
    return pow(n, m // 2)**2 % mod * n % mod

inv_fact = [0] * (M + 1)
inv_fact[M] = pow(fact[M], mod-2)
for i in reversed(range(0, M)):
  inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod
    
def C(n, r):
  return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod
  
ans = 0
for i in range(N+1):
  ans += (-1)**i * C(N, i) * C(M, i) * fact[i] * powm[N - i] * pown[M - i]
  ans = ans % mod

print(ans)


Measured memory_bytes: 82164
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  string s;
  cin>>s;
  int n=s.size();
  int re=0;
  reps(c,'a','z'+1){
    string t=s;
    while(t.size()>1){
      if(t==string(t.size(),c)) break;
      string nxt;
      reps(i,1,t.size()) nxt.pb((t[i-1]==c)?t[i-1]:t[i]);
      t=nxt;
    }
    //out((char)c,t,1);
    if(t==string(t.size(),c)) MX<int>(re,t.size());
  }
  cout<<n-re<<endl;
  return 0;
}


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

int main() {
  int a, b, x;
  string str;
  long long max = 0;
  cin >> a;
  if (a % 2 == 0) {

    cout << a << endl;
  } else {
    cout << a * 2;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	}

}


Measured memory_bytes: 8788
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  
  REP(i,s.size()/2){
    if(s[i] != s[s.size()-i-1]){
      ans++;
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  ll k;cin>>k;
  vector<ll>p(n);
  rep(i,0,n)cin>>p[i];
  sort(ALL(p));
  rep(i,0,k)res+=p[i];
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	vector<int> d(n);
	int d_max = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {
			continue;
		}
		int d = a[i] - a[i - 1];
		if (i == 1) {
			d_max = d;
		}
		else {
			d_max = max(d_max, d);
		}
	}
	d_max = max(d_max, k - a[n - 1] + a[0]);
	cout << k - d_max << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   int n,w;cin>>n>>w;
   ll w1,v1;cin>>w1>>v1;
   vector<vector<ll>> a(4,vector<ll>());
   a[0].push_back(v1);
   rep(i,n-1){
       ll w,v;cin>>w>>v;
       a[w-w1].push_back(v);
   }
   rep(i,4){
       sort(all(a[i]),greater<ll>());
   }
   vector<vector<ll>> sum(4,vector<ll>());
   rep(i,4){
       sum[i].push_back(0);
       rep(j,a[i].size()){
           sum[i].push_back(sum[i].back()+a[i][j]);
       }
   }
   ll res = 0;
   rep(i,a[0].size()+1)rep(j,a[1].size()+1)rep(k,a[2].size()+1)rep(l,a[3].size()+1){
       ll tmpW = w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
       if(tmpW>w)continue;
       ll tmpV = sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l];
       res=max(res,tmpV);
   }
   cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  int n,a[120],m[120],l,j;
  cin >> n;
  j=0;
  rep(i,n) m[i]=0;
  rep(i,n) cin >> a[i];
  rep(i,n) if(a[i]==a[i+1])m[i]=1;
  rep(i,n) {if(m[i]==1)l++;
            else {j+=(l+1)/2;
                  l=0;
                 }
           }
  printf("%d",j);
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
a_lis = [int(_) for _ in input().split()]

count = 0

for key, value in Counter(a_lis).items():
    if int(value) - int(key) > 0:
        count += int(value) - int(key)
    elif int(value) - int(key) < 0:
        count += int(value)
    else:
        count += 0
print(count)

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

int main() {
  int n;
  std::cin >> n;
  std::vector<long long> a(n);
  std::vector<long long> h(n); // 踏み台の高さ
  for (int i = 0; i < n; ++i) std::cin >> a[i];

  long long sum = 0;
  for (int i = 1; i < n; ++i) {
    /* 前の人の方が高い */
    if (a[i-1] + h[i-1] > a[i]) {
      h[i] = a[i-1] + h[i-1] - a[i];
      sum += h[i];
    } 
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 6428
import collections
N = int(input())
a = list(map(int, input().split()))
a_count = collections.Counter(a)
# print(a_count)
ans = 0
for i, j in a_count.items():
    # print(i, j)
    if i <= j:
        ans += j - i
    else:
        ans += j

print(ans)

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

signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> cnt(M);
    for (int i = 0; i < N; i++) {
        int K, A;
        cin >> K;
        for (int j = 0; j < K; j++) {
            cin >> A;
            cnt[--A]++;
        }
    }

    int ans = 0;
    for (int x : cnt) {
        ans += (x == N);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
l=len(S)
S=list(S)
K=int(input())#Kと異なる文字

B=[]
for i in range(N):
    if S[K-1]!=S[i]:
        B.append("*")
    elif S[K-1]==S[i]:
        B.append(S[i])

c="".join(B)
print(c)



Measured memory_bytes: 38384
import Control.Applicative
import Text.Printf
import Debug.Trace

solve :: [Integer] -> Integer
solve [] = 0
solve [x] = x
solve (x:xs) = x*(2^((length xs) - 1)) + (solve xs) + (solve ((10*x+(xs!!0)):(tail xs)))

solve_sub :: Int->[Integer] -> Integer
solve_sub n [] = 0
solve_sub n [x] = x*2^n
solve_sub n (x:xs) = x*(2^n)*10^(length xs) + (1-5^(length xs))`div`(1-5)*x*2^(length xs - 1 + n) + (solve_sub (n+1) xs)
  
solve_ :: [Integer] -> Integer
solve_ l = solve_sub 0 l 

listize :: Integer->[Integer]
listize 0 = []
listize n = (listize $ n`div`10)++[(n`mod`10)]

main :: IO()
main = do
  n <- readLn
  -- O(2^N)
  printf "%d\n" $ solve $ listize n
  -- O(N)
  --printf "%d\n" $ solve $ listize n


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	int cnt=0;
	int i=1;
	while(i<n-1){
	if((a[i-1]<a[i] && a[i]<a[i+1]) || (a[i-1]>a[i] && a[i]>a[i+1])){
		cnt++;
	}
	i++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
N = int(input())
p = [int(input()) for _ in range(N)]
q = [0] * N
for i in range(N):
    q[p[i] - 1] = i
cnt = 0
ma = 0
for i in range(N - 1):
    if q[i] < q[i + 1]:
        cnt += 1
        ma = max(ma, cnt)
    else:
        cnt = 0
print(N - 1 - ma)

Measured memory_bytes: 18888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    if (s[0] == s[1]) {
        printf("%d %d\n", 1, 2);
        return 0;
    }
    
    rep(i, s.length() - 2) {
        if (s[i] == s[i + 1]) {
            printf("%d %d\n", i + 1, i + 2);
            return 0;
        }
        
        if (s[i] == s[i + 2]) {
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    }
    
    printf("%d %d\n", -1, -1);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int pow_mod(int a, int n, int m = MOD) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

int inv_mod(int a, int m = MOD) {
  int b = m, x = 1, y = 0;
  while (b) {
    int t = a/b;
    a -= t*b; swap(a,b);
    x -= t*y; swap(x,y);
  }
  x %= m;
  if (x < 0) x += m;
  return x;
}

int log_mod(int a, int b, int m = MOD) {
  a %= m; b %= m;
  int ok = m, ng = -1;
  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if (mid * mid >= m) ok = mid;
    else ng = mid;
  }
  unordered_map<int,int> baby;
  baby.reserve(ok);
  int factor = 1;
  for (int i = 0, e = b; i < ok; i++) {
    baby[e] = i;
    (factor *= a) %= m;
    (e *= a) %= m;
  }
  for (int i = 1, e = factor; i <= ok; i++) {
    auto it = baby.find(e);
    if (it != end(baby)) return i * ok - it->second;
    (e *= factor) %= m;
  }
  return -1;
}

map<int,int> prime_factor(int x) {
  map<int,int> res;
  for (int i = 2; i*i <= x; i++) {
    while (x % i == 0) {
      res[i]++;
      x /= i;
    }
  }
  if (x != 1) res[x]++;
  return res;
}

int gcd(int a, int b) {
  while (b) {
    int c = a % b;
    a = b; b = c;
  }
  return a;
}

int lcm(int a, int b) {
  return a / gcd(a,b) * b;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  auto pf = prime_factor(N);
  int LCM = 1;
  for (auto p : pf) {
    if (p.second != 1) {
      cout << -1 << endl;
      return 0;
    }
    LCM = lcm(LCM,p.first-1);
  }
  cout << (gcd(N,LCM) != 1 ? -1 : log_mod(N,1,LCM)) << endl;

  return 0;
}


Measured memory_bytes: 3744
package main

import (
	"fmt"
)

func main() {
	var h1, m1, h2, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)
	
	getup := (h2 - h1) * 60 + (m2 - m1)
	fmt.Println(getup - k)
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int m = 1000000, S;
  rep(i, s.size()-t.size()+1) {
    S = 0;
    rep(j, t.size()) {
      if(s[i+j] != t[j]) S++;
    }
    if(S < m) m = S;
  }
  cout << m << endl;
}

Measured memory_bytes: 3628
n, k = map(int, input().split())
L = [0]*(pow(10,5)+1)

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

s = 0
for i in range(pow(10,5)+1):
  s += L[i]
  if s >= k:
    print(i)
    break
    

Measured memory_bytes: 5836
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int k;
  cin>>k;
  int x,y;
  cin>>x>>y;
  if (((k%2) == 0) && (abs(x+y)%2) == 1) {
    cout << -1 << endl;
    return 0;
  }
  bool flipx = false, flipy = false, flipxy = false;
  if (x < 0) {
    x = -x;
    flipx = true;
  }
  if (y < 0) {
    y = -y;
    flipy = true;
  }
  if (x < y) {
    swap(x, y);
    flipxy = true;
  }
  vector<tuple<int, int>> moves;
  int nx = 0, ny = 0;
  while (true) {
    int d = abs(x-nx) + abs(y-ny);
    if (d <= 2*k) break;
    if (x-nx >= k) {
      nx += k;
    } else {
      ny += k;
    }
    moves.emplace_back(nx, ny);
  }
  int d = abs(x-nx) + abs(y-ny);
  if (d != k && (d%2) != 0) {
    if (d >= k) {
      int h = min(x-nx, k);
      nx += h;
      ny += k - h;
    } else {
      nx -= k;
    }
    moves.emplace_back(nx, ny);
  }
  d = abs(x-nx) + abs(y-ny);
  if (d != k) {
    int dx = x-nx;
    int dy = y-ny;
    int h = (dy-dx)/2;
    if (h >= 0) {
      ny += h;
      nx += k-h;
    } else {
      nx += -h;
      ny += k+h;
    }
    moves.emplace_back(nx, ny);
  }
  moves.emplace_back(x, y);
  cout << moves.size() << endl;
  for (auto&& t : moves) {
    int a, b;
    tie(a, b) = t;
    if (flipxy) swap(a, b);
    if (flipy) b = -b;
    if (flipx) a = -a;
    cout << a << ' ' << b << endl;
  }
  return 0;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,c=0;
  cin>>n;
  int x[n],y[n];
  for(int i=0;i<n;i++)
  {
    cin>>x[i]>>y[i];
  }
  for(int i=1;i<n-1;i++)
  {
    if(x[i-1]==y[i-1] && x[i]==y[i] && x[i+1]==y[i+1])
    {
      c=1;
      break;
    }
  }
  if(c==1)
    cout<<"Yes";
  else
    cout<<"No";



}  


Measured memory_bytes: 3632
n, m = gets.split.map(&:to_i)

i = 1
j = 2 + m + m % 2 - 1

m.downto(1) do |k|
    if k.odd?
        puts "#{i} #{i + k}"
        i += 1
    else
        puts "#{j} #{j + k}"
        j += 1
    end
end

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


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    rep(i, M){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
    }
    vector<vector<int>> v(N, vector<int>(N,INF)); // 隣接行列
    rep(i, N){
        v[i][i] = 0;
    }
    rep(i, M){
        v[a[i]][b[i]] = c[i];
        v[b[i]][a[i]] = c[i];
    }

    // ワーシャルフロイド
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
            }
        }
    }
    int res = 0;
    for(int i = 0; i < M; i++){
        if(c[i] > v[a[i]][b[i]]){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	cout<<min(A,B)<<" "<<max(0,(A+B-N));
}

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

int main(){
  int counts[2]={0,0};
  int A,B,C;
  cin>>A>>B>>C;
  int x[3]={A,B,C};
  for(int i=0;i<3;i++){
    if(x[i]==5) counts[0]++;
    if(x[i]==7) counts[1]++;
  }
  cout<<(counts[0]==2&&counts[1]==1?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
N = 5
ARR = [24, 11, 8, 3, 16]

N = int(input())
ARR = list(map(int,input().split()))

def calculate(n, arr):
    maxValue = max(arr) + 1
    maxValue = 1000006
    krr = [0 for i in range(maxValue)]

    for start in arr:
        if krr[start] > 0:
            krr[start] = 2
            continue

        for i in range(start, maxValue, start):
            krr[i] += 1

    result = 0
    for ar in arr:
        if krr[ar] == 1:
            result = result + 1

    print(result)


calculate(N, ARR)


Measured memory_bytes: 33220
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

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

  ll n;
  cin>>n;
  vector<ll> A(n);
  for(auto &I:A){cin>>I;}
  priority_queue<ll> S;
  ll ans=0;
  for(auto &I:A){
    while(!S.empty() && S.top()>I){S.pop();}
    if(S.empty() || I!=S.top()){ans++; S.push(I);}
  }
  cout<<ans<<endl;
  

  return 0;
}



Measured memory_bytes: 6444
#include <bits/stdc++.h>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define ev g[i].y
#define eps 1e-10
#define fr first
#define sd second
using namespace std;
typedef long long ll;
typedef double db;
const int N = 200005, mod = 1000000007;
int n, m, T, q = 1, ans, a[N], k;
set<int> s;
int main()
{
	scanf ("%d%d", &n, &m);
	Rep(i, 1, n) {
		scanf ("%d", &a[i]);
	}
	a[0] = -1;
	Rep(i, 1, m) {
		s.insert(a[i]);
		if (i > 1) k += (a[i] < a[i - 1]);
	}
	if (k) ans ++;
	else ans += q, q = 0;
	Rep(i, m + 1, n) {
		k += (a[i] < a[i - 1]) - (a[i - m + 1] < a[i - m]);
		// cout << ans<<" "<<*s.begin()<<" "<<*(-- s.end())<<" "<<k<< endl;
		if (*s.begin() != a[i - m] || *(-- s.end()) > a[i]) {
			if (k) ans ++;
			else ans += q, q = 0;
		}
		s.erase(a[i - m]);
		s.insert(a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  string a, b, c;
  
  cin >> a >> b >> c;
  
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
      cout << "YES";
      return 0;
  }
  
  cout << "NO";
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.ABC123.B
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var orders = Enumerable.Range(0, 5)
                .Select(_ => sc.Nextint())
                .OrderBy(val => (val % 10) == 0 ? 0 : 10 - (val % 10))
                .ToArray();
            var time = 0;
            foreach (var order in orders)
            {
                Console.Error.WriteLine($"{time} += {order}");
                while (time % 10 != 0)
                {
                    time++;
                }
                time += order;
            }
            Console.WriteLine(time);
        }
    }

    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13396
#define f(I,H)(p[I]+h[I]*(h[I]-2*H))
long C,h[2<<17],p[2<<17],X;
P[2<<17];
s,t=-1,i,a;
c(x,y,z){
	return (h[y]-h[x])*(f(y,0)-f(z,0))>=(h[z]-h[y])*(f(x,0)-f(y,0));
}
main(){
	for(scanf("%*d%ld",&C);~scanf("%d",&a);){
		for(;X=f(P[s],a),s<t&&X>=f(P[s+1],a);s++);
		h[i]=a;
		X=p[i]=i?1L*a*a+C+X:0;
		for(;s<t&&c(P[t-1],P[t],i);t--);
		P[++t]=i++;
	}
	printf("%ld",X);
}

Measured memory_bytes: 4608
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <queue>
using namespace std;

int main()
{
    // 整数の入力
    long long N,K,i,j,temp,total;
    total = 0;
    cin >> N;
    long long* data = new long long[N];
    for (i= 0; i< N;i++){
        cin >> temp;
        data[i] = temp;
    }


    bool allCrear =false;
    while(!allCrear){
        allCrear = true;
        for (i= 0; i< N;i++){
            if (data[i] >= 2 * N){
                allCrear = false;
                total += data[i]/N - 1;
                for (j= 0; j< N;j++){
                    if (i!=j){
                        data[j] += data[i]/N - 1;
                    }
                }
                data[i] = data[i] % N + N;
            }
        }
    }

    priority_queue <long long> q; // default 大きい順
    for (i= 0; i< N;i++){
        q.push(data[i]);
    }
    allCrear = false;
    int added = 0;
    while(!allCrear){
        allCrear = true;
        if (q.top() + added >= N){
            long long next = q.top() - N - 1;
            allCrear = false;
            added++;
            q.push(next);
            q.pop();
            total++;
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
import math
N=int(input())
data=[]
p=math.pi
e=10**(-9)
for i in range(N):
    x,y=map(int,input().split())
    data.append([math.atan2(y,x),x,y])
    data.append([math.atan2(y,x)+2*p,x,y])
data.sort()
ans=0
for left in range(N):
    x_sum=0
    y_sum=0
    right=left
    while data[right][0]-data[left][0]<=p-e:
        x_sum+=data[right][1]
        y_sum+=data[right][2]
        ans=max(ans,x_sum**2+y_sum**2)
        right+=1
print(ans**0.5)

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

using namespace std;

int main(){
  string S;
  cin >> S;
  int i = 0, ans = 0, l = 0;
  while (S[i] != '\0'){
    if (S[i] != 'A' && S[i] != 'C' && S[i] != 'G' && S[i] != 'T') l = 0;
    else {
      ++l;
      ans = max(l, ans);
    }
    ++i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline
from bisect import bisect_left

def dfs(i,before):
    global seq
    global ans
    added  = 0

    #現在地のAの値を、以前までのseqリストのどこに追加するか決める
    pos = bisect_left(seq,a[i-1])
    old = seq[pos]
    seq[pos]=a[i-1]
    ans[i-1]=bisect_left(seq,INF)

    #隣接する頂点に関して再帰
    for u in to[i]:
        if u==before:
            continue
        dfs(u,i)

    #seq配列をもとに戻す
    seq[pos]=old


N = I()
a = LI()
to = [[] for i in range(N+1)]
to[0] += [1]
for i in range(N-1):
    u,v = MI()
    to[u].append(v)
    to[v].append(u)
seq = [INF]*N
ans = [-1]*N

dfs(1,-1)
[print(i) for i in ans]


Measured memory_bytes: 351152
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



void solve(){
  string s;
  cin >> s;
  int k;cin >> k;
  set<string> d;
  int n=min(k,(int)s.size());
  for(int i=0;i<s.size();i++){
    for(int j=0;j<=n;j++){
      string t=s.substr(i,j);
      d.insert(t);
    }
  }
  auto itr=d.begin();
  for(int i=0;i<k;i++){
    itr++;
  }
  cout << *itr << endl;
}

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


Measured memory_bytes: 1664
import java.util.*;

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

        String s = sc.nextLine();
        String str = s+s;
        String p = sc.nextLine();
        int i;
        int j;
        int count=0;
        
        String[] strArray = str.split("");
        String[] pArray = p.split("");
//        String[] check = new check[p.length];
        String check ="";
 //     while(sc.hasNextLine()){      
        for(i = 0; i < s.length(); i++){
            if(pArray[0].equalsIgnoreCase(strArray[i])){   
                for(j=0; j < p.length(); j++){
                    check += strArray[i+j];
//                        System.out.println(check);
                    }if(p.equals(check)){
                        count++;
                    }
                    check = "";
            }
        }
        if(count==0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}
                        



Measured memory_bytes: 26736
N, M = map(int, input().split())

R = []
G = {k: [] for k in range(N)}  # 0-indexed
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    R.append((a-1, b-1))


def dfs(p, i, arrived):
    for n in G[p]:
        if arrived[n] is False and tuple(sorted((p, n))) != R[i]:
            arrived[n] = True
            dfs(n, i, arrived)


ans = 0
for i in range(M):
    arrived = [False]*N
    arrived[0] = True
    dfs(0, i, arrived)
    if not all(arrived):
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 100

typedef struct node{
  int u;
  int k;
  int v[MAX];

}Node;

Node node[MAX];

int main(){
  int n;
  int i,j,k;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&node[i].u);
    scanf("%d",&node[i].k);

    for(j=0;j<node[i].k;j++){
      scanf("%d",&node[i].v[j]);
    }
  }
  
  for(i=0;i<n;i++){
    k=0;
    for(j=0;j<n;j++){
      if(node[i].v[k]==j+1){
	printf("1");
	k++;
      }
      else {
	printf("0");
      }

      if(j==n-1)printf("\n");
      else printf(" ");

		      }
  }




  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,A,B,C;
    cin>>N>>A>>B>>C;
    string s[N];
    rep(i,N) {
        cin >> s[i];
    }
    string ans="Yes";
    char v[N]={};
    rep(i,N){
        if(s[i]=="AB"){
            if(A==1&&B==1){
                if(s[i+1]=="AC"){
                    v[i]='A';
                A++;
                B--;
                }else if(s[i+1]=="BC"){
                    v[i]='B';
                A--;
                B++;
                }else {
                    v[i]='A';
                    i++;
                    if(i==N) break;
                    v[i]='B';
                }
            }
            else if(A>=B) {
                v[i]='B';
                A--;
                B++;
            }else{
                v[i]='A';
                A++;
                B--;
            }
        }
        if(s[i]=="AC"){
            if(A==1&&C==1){
                if(s[i+1]=="AB"){
                    v[i]='A';
                A++;
                C--;
                }else if(s[i+1]=="BC"){
                    v[i]='C';
                A--;
                C++;
                }else {
                    v[i]='A';
                    i++;
                    if(i==N) break;
                    v[i]='C';
                }
            }
            else if(A>=C) {
                v[i]='C';
                A--;
                C++;
            }else{
                v[i]='A';
                A++;
                C--;
            }
        }
        if(s[i]=="BC"){
            if(C==1&&B==1){
                if(s[i+1]=="AC"){
                    v[i]='C';
                C++;
                B--;
                }else if(s[i+1]=="AB"){
                    v[i]='B';
                C--;
                B++;
                }else {
                    v[i]='B';
                    i++;
                    if(i==N) break;
                    v[i]='C';
                }
            }
            else if(B>=C) {
                v[i]='C';
                B--;
                C++;
            }else{
                v[i]='B';
                B++;
                C--;
            }
        }
            if(A<0||B<0||C<0) {
                ans="No";
                break;
            }
    }
    if(ans=="No") cout << ans << endl;
    else{
        cout << ans << endl;
        rep(i,N){
            cout << v[i] << endl;
        }
    }





}


Measured memory_bytes: 6872