akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a;
  cin>>a;
  V<int> b(a);
  fo(i,a)
  cin>>b[i];
  int c=0,d=b[0];
  fo(i,a){
    if(b[i]>=d){
      c++;
      d=b[i];
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<long long> a(N, 0);

	long long left_sum = 0;
	long long right_sum = 0;

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

	left_sum += a[0];
	right_sum -= a[0];

	long long min_diff = abs(left_sum - right_sum);

	for (int i = 1; i < N - 1; i++)
	{
		left_sum += a[i];
		right_sum -= a[i];

		min_diff = min(min_diff, abs(left_sum - right_sum));
	}

	cout << min_diff;

	return 0;
}


Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	x, a, b := nextInt(), nextInt(), nextInt()
	fmt.Println((x - a) % b)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#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;

int N;
//色ごとに人数をカウント
int c[9];

int main() {
	cin >> N;
	rep(i, 9) c[i] = 0;
	rep(i, N) {
		int rate;
		cin >> rate;
		if (rate >= 3200) c[8]++;
		else {
			int cl = rate / 400;
			c[cl]++;
		}
	}
	//虹以外で存在する色の数を出す
	int COL = 0;
		rep(i, 8)if (c[i]>0) COL++;
	int MIN = 0, MAX = 0;

	//まずMINについて
	//COL>1なら今ある色の数
	//COL=0なら1
	MIN = max(COL, 1);

		//MAXについて
		//これはCOL+c[8]でok
	MAX = COL + c[8];

	cout << MIN << " " << MAX;
}

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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll a, b;
  cin >> a >> b;
  cout << max({a+b, a-b, a*b}) ;
  return 0;
} //good night.

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <regex>

int main() {
  std::string str;
  std::cin >> str;
  std::regex erase("erase");
  auto const& erased = std::regex_replace(str, erase, "E");
  std::regex dream("dream");
  auto const& dreamed = std::regex_replace(erased, dream, "D");
  std::regex daydream(R"(((E(r)?)|(D(er)?))*)");
  std::cout << (std::regex_match(dreamed, daydream) ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
int main(){
    int n;
    sc1(n);
    vector<vector<int>> d(n,vector<int>(6));
    rep(i,n) rep(j,6) sc1(d[i][j]);
    char s[8]={'N','W','E','E','E','N','N','N'};
    rep(a,n) rep(b,a) rep(i,8) {
        int tmp,tmp2;
        if (s[i]=='N') {
            tmp=d[b][0];
            d[b][0]=d[b][1];
            d[b][1]=d[b][5];
            d[b][5]=d[b][4];
            d[b][4]=tmp;
        } else if (s[i]=='W') {
            tmp=d[b][0];
            d[b][0]=d[b][2];
            d[b][2]=d[b][5];
            d[b][5]=d[b][3];
            d[b][3]=tmp;
        } else if (s[i]=='E') {
            tmp=d[b][0];
            d[b][0]=d[b][3];
            d[b][3]=d[b][5];
            d[b][5]=d[b][2];
            d[b][2]=tmp;
        } else {
            tmp=d[b][0];
            d[b][0]=d[b][4];
            d[b][4]=d[b][5];
            d[b][5]=d[b][1];
            d[b][1]=tmp;
        }
        rep(j,4) {
            tmp2=d[b][1];
            d[b][1]=d[b][2];
            d[b][2]=d[b][4];
            d[b][4]=d[b][3];
            d[b][3]=tmp2;
            int f=1;
            rep(k,6) if (d[a][k]!=d[b][k]) f=0;
            if (f) {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    string S;
    cin >> S;
    ll K;
    cin >> K;
    
    char a = S[0];
    vector<ll> b;
    b.push_back(1);
    for (int i = 1; i < int(S.length()); i++) {
        if(a==S[i]) b.back()++;
        else a = S[i],b.push_back(1);
    }
    ll dd = 0;
    for (int i = 0; i < int(b.size()); i++) {
        if(b[i] == 1) continue;
        dd += (b[i]/2);
    }
    ll d1 = b[0],d2 = b.back();
    if(b.size() == 1){
        cout << b[0]*K/2 << endl;
    }else if(S[0] == S[int(S.length())-1]){
        ll l = b[0] + b.back();
        l /= 2;
        cout << (dd-d1/2-d2/2)*K + l*(K-1)+d1/2+d2/2 << endl;
    }else{
        cout << dd*K << endl;
    }
    
    
    return 0;
}



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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(true) {
    c -= b;
    if(c <= 0) {
      cout << "Yes"
           << "\n";
      return 0;
    }
    a -= d;
    if(a <= 0) {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  return 0;
}


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

int main()
{
  vector<int>a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a[k-1]<<endl;
}


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

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int count = 0;
	for (int r = 0; r < N / R + 1; r++) {
		for (int g = 0; g < (N - r * R) / G + 1; g++) {
			int ord = N - r * R - g * G;
			if(ord % B == 0) {
					count++;
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

ll cal_gcd(ll m, ll n) {
	while (m%n != 0) {
		ll c = m % n;
		m = n;
		n = c;
	}
	return n;
}



int main() {
	string s;
	cin >> s;
	int n = s.size() - 1;
	ll ans = 0;
	for (ll i = 0; i < (1 << n); i++) {
		ll bit = i;
		vector<int>section;
		section.push_back(0);
		for (int j = 0; j < n; j++) {
			if ((bit >> j) & 1) {
				section.push_back(j + 1);
			}
		}
		section.push_back(n + 1);
		for (int j = 0; j < section.size() - 1; j++) {
			string tmp = s.substr(section[j], section[j + 1] - section[j]);
			ll ten = 1;			
			reverse(tmp.begin(), tmp.end());
			for (int k = 0; k < tmp.size(); k++) {
				ans += (tmp[k] - '0')*ten;
				ten *= 10;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INF (INT32_MAX)
#define MOD (1000000000+7)
#define MAX 50

int N, A;
int x[MAX];

int y[MAX];
long long dp[MAX + 1][MAX*MAX*2 + 1];

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

	sort( x, x + N );
	int X = max( x[N - 1], A );
	for( int i = 0; i < N; i++ ) {
		y[i] = x[i] - A;
	}
	dp[0][N*X] = 1;
	for( int j = 1; j <= N; j++ ) {
		for( int t = 0; t <= N*X*2; t++ ) {
			int tt = t - y[j - 1];
			if( tt < 0 || N*X*2 < tt ) {
				dp[j][t] = dp[j - 1][t];
			}
			else {
				dp[j][t] = dp[j - 1][t] + dp[j - 1][tt];
			}
		}
	}

	long long ans = dp[N][N*X] - 1;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define MAX_C 1111111
long long mod_c[MAX_C + 1], mod_r[MAX_C + 1], mod_d;

long long mod_pow(long long x, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
void comb()
{
    if (mod_d == 0)
    {
        long long i;
        mod_c[0] = 1;
        mod_r[0] = 1;
        for (i = 1; i <= MAX_C; i++)
        {
            mod_c[i] = mod_c[i - 1] * i % 1000000007;
        }
        for (i = 1; i <= MAX_C; i++)
        {
            mod_r[i] = mod_pow(mod_c[i], 1000000005, 1000000007);
        }
        mod_d = 1;
    }
}
long long nck(long long n, long long k)
{
    comb();
    long long res = 1;
    res = res * mod_c[n] % 1000000007;
    res = res * mod_r[n - k] % 1000000007;
    res = res * mod_r[k] % 1000000007;
    res %= 1000000007;
    return res;
}
int main()
{
    ll n;
    cin >> n;
    string a;
    ll aa[n];
    rp(i, 0, n) cin >> a;
    rp(i, 0, n) aa[i] = a[i] - '0';
    ll ans = 0;
    ll ko[3], l, r;
    za(3, ko);
    l = llabs(aa[1] - aa[0]);
    r = llabs(aa[n - 1] - aa[n - 2]);
    rp(i, 0, n - 1)
    {
        ko[llabs(aa[i] - aa[i + 1])]++;
    }

    if (ko[1] != 0)
    {
        rp(i, 0, n)
        {
            ans += ((aa[i]) * (((n - 1) & i) == i)) % 2;
            ans %= 2;
            //  cout << ans << endl;
        }
        cout << ans % 2 << endl;
    }
    else
    {
        ll hu = 1;
        rp(i, 0, n - 1)
        {
            ans += hu * (llabs((aa[i] - aa[i + 1]) * (((n - 2) & i) == i))) % 4;
            hu *= -1;
            ans += 4;
            ans %= 4;
        }
        if (llabs(ans / 2) % 2 == 1)
        {
            cout << 2 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i]; 
    }
    vector<int> ans(n);
    rep(i,n-1){
        int now = 0;
        for(int j=i;j<n-1;j++){
            if(now<=s[j]){
                now = s[j]+c[j];
            }
            else{
                now+=((f[j]-(now-s[j])%f[j])%f[j]);
                now+=c[j];
            }
        }
        ans[i] = now;
    }
    for(auto i:ans){
        cout << i << endl;
    }
    return 0;
}

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

void solve(long long N)
{
    cout << ceil((double)N / 2) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

 using namespace std;

 int main() {
   int N, i;
   long long ans;
   cin >> N;

   ans = 1;
   for (i = 1; i <= N; i++) {
     ans = ans * i % 1000000007;
   }

   cout << ans << endl;
 }


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

//#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

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

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

#define pb push_back
#define inf 0x3f3f3f3f
#define all(v) (v).begin() , (v).end()
#define ones(n) __builtin_popcount(n)
#define watch(x) cout << (#x) << " is " << (x) << endl

int di[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[] = {1, -1, 0, 0, -1, 1, 1, -1};


int main() {
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//#endif
    int n;
    cin >> n;
    map<string , int> mp;
    string a[n];
    for(int i = 0 ; i < n ; ++i)cin >> a[i] , mp[a[i]]++;

    for(int i = 0 ; i < n ; ++i){
        if(mp[a[i]] > 1){
            cout << "No" << '\n';
            return 0;
        }
    }

    for(int i = 1 ; i < n ; ++i){
        if(a[i][0] != a[i - 1][(int)a[i - 1].size() - 1]){
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N, M;
	cin >> N >> M;

	vll P(M);
	vstring S(M);
	for (int i = 0; i < M; i++) {
		cin >> P[i] >> S[i];
	}

	ll n_ac = 0;
	ll n_wa = 0;

	vbool is_ac(N + 1);
	for (int i = 0; i <= N; i++) {
		is_ac[i] = false;
	}


	vll submit(N + 1);
	for (int i = 0; i < M; i++) {
		
		if (is_ac[P[i]] == false) {
			submit[P[i]]++;
			if (S[i] == "AC") {
				is_ac[P[i]] = true;
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		if (is_ac[i] == true) {
			n_ac++;
			n_wa += submit[i]-1;
		}
	}

	cout << n_ac << " " << n_wa;

}




Measured memory_bytes: 7296
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______ 
 * |\  \|\  \  |\  ___ \  |\  ___ \
 * \ \  \/  /|_\ \   __/| \ \   __/|
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 2010;
int BIT[mxN];
void upd(int ind,int val) {
	while(ind < mxN) {
		BIT[ind] += val;
		ind |= ind + 1;
	}
}
int get(int ind) {
	int res = 0;
	while(ind >= 0) {
		res += BIT[ind];
		ind = (ind & (ind+1)) -1;
	}
	return res;
}
int get(int a,int b) {
	if(a > b) swap(a,b);
	return get(b) - get(a-1);
}


int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, K, Q;
	cin >> N >> K >> Q;
	vector<pair<int, int> > a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i].first, a[i].second = i;
	sort(a.begin(), a.end());
	int res = INT_MAX;
	for (int st = 0; st < N; st++) {
		set<int> p;
		for (int k = 0; k < st; k++)
			p.insert(a[k].second);
		p.insert(N);
		p.insert(-1);
		int cnt = 0;
		memset(BIT,0,sizeof BIT);
		for (int to = st; to < N; to++) {
			auto it = p.upper_bound(a[to].second);
			int f = *prev(it);
			int s = *it;
			int can = s - f - 1;
			can -= get(s,f);
			if (can >= K)
				cnt++, upd(a[to].second,1);
			else
				p.insert(a[to].second);
			if(cnt >= Q) {
				res = min(res, a[to].first - a[st].first);
				break;
			}
		}
	}
	cout<<res<<'\n';
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	REP (i, n)
	{
		ll a, b;
		cin >> a >> b;
		ll r = sqrt(static_cast<long double>(a * b - 1));
		int m = 0;
		r *= 2;
        if (r / 2 * (r / 2 + 1) >= a * b)
			--r;
		if (r >= a)
			if (a < b || (a + 1) * (r - a + 1) >= a * b)
				--m;
		if (r >= b)
			if (b < a || (b + 1) * (r - b + 1) >= a * b)
				--m;
		cout << (r + m) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
X = input()
ans = []
for x in X:
    if x == 'S':
        ans.append(x)
    else:
        if len(ans) != 0:
            if ans[-1] == 'S':
                ans.pop()
            else:
                ans.append(x)
        else:
            ans.append(x)
print(len(ans))


Measured memory_bytes: 5096
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        long x=sc.nextLong(),y=sc.nextLong();
        if(x%y==0){
            out.println(-1);
        }else {
            out.println(x);
        }
    }
}

Measured memory_bytes: 22996
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
q = 0
for i in range(k):
  q += p[i]
r = q
for i in range(n - k):
  r -= p[i]
  r += p[i + k]
  if r > q:
    q = r
print((q + k) / 2)

Measured memory_bytes: 31976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int ans=0,max=0;
		for(int i=0;i<N; i++) {
			int p = sc.nextInt();
			ans+=p;
			if(max < p) max= p;
		}
		System.out.println(ans-max/2);
	}
}


Measured memory_bytes: 21972
N,M = map(int, input().split())
from collections import defaultdict
SC = defaultdict(set)
for _ in range(M):
    s,c = map(int, input().split())
    SC[s].add(c)

if N == 1:
    if len(SC[1]) > 1:
        ans = -1
    elif len(SC[1]) == 1:
        ans = SC[1].pop()
    else:
        ans = 0
    print(ans)
    exit()

ans = ""
for i in range(1, N + 1):
    if len(SC[i]) > 1:
        ans = -1
        break

    if i == 1:
        if len(SC[i]) == 1:
            tmp = SC[i].pop()
            if tmp == 0:
                ans = -1
                break
            else:
                ans += str(tmp)
        else:
            ans += "1"
    else:
        if len(SC[i]) == 1:
            ans += str(SC[i].pop())
        else:
            ans += "0"

print(ans)

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok=true;
  if(s[5]=='1')ok=false;
  else if(s[6]>='5')ok=false;
  if(ok) cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
  return 0;
}

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

int main() {
    string w;
    cin >> w;
    map<char, int> charmap;
    for (int i = 0; i < w.size(); i++) {
        charmap[w[i]]++;
    }
    for (auto i = charmap.begin(); i != charmap.end(); i++) {
        if ((*i).second % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
//1803115
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int i,x,n,*arr;
    long double ttl,ttl_sq,avg,y;
    while(1)
    {
        scanf("%d",&n);
        if(n==0) break;
        ttl=0.0;
        arr=(int *)malloc(n*sizeof(int));
        for(i=0;i<n;i++)
        {
            scanf("%d",&x);
            *(arr+i)=x;
            ttl+=x;
        }
        avg=ttl/n;
        ttl=0.0;
        for(i=0;i<n;i++)
        {
            y=*(arr+i)-avg;
            ttl+=y*y;
        }
        ttl=ttl/n;
        printf("%.10Lf\n",sqrtl(ttl));
        free(arr);
    }
    return 0;
}


Measured memory_bytes: 2032
def c_be_together(N, A):
    a_sum = sum(A)
    option = (a_sum // N, (a_sum + N - 1) // N)
    ans = float('inf')
    for opt in option:
        ans = min(ans, sum([(a - opt)**2 for a in A]))
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(c_be_together(N, A))

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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

#define mp make_pair
#define pb push_back
#define fir first
#define sec second

#define fo0(i,a,b) for(int i=(a);i<(b);i++)
#define fo1(i,a,b) for(int i=(a);i<=(b);i++)
#define fd0(i,a,b) for(int i=(a);i>(b);i--)
#define fd1(i,a,b) for(int i=(a);i>=(b);i--)
#define mset(a,b) memset(a,(b),sizeof(a))

#define max(a,b) (a > b ? a : b)
#define min(a,b) (a < b ? a : b)
#define abs(a) (a < 0 ? -a : a)
#define fabs(a) (a < 0 ? -a : 0)

template<typename T> inline void in(T &x){
	x = 0; int fl = 1; char ch = getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')fl=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=fl;
}
template<typename T> void out(T x){if(x<0){putchar('-');x=-x;}if(x/10)out(x/10);putchar(x%10+'0');}
template<typename T> inline void outln(T x){out(x);putchar(10);}
template<typename T> inline void outsp(T x){out(x);putchar(' ');}
template<typename T> inline T gcd(T a, T b){T t;if(a>b){while(b){t=b;b=a%b;a=t;}return a;}else{while(a){t=a;a=b%a;b=t;}return b;}}
template<typename T> inline T lcm(T a, T b){return a/gcd(a,b)*b;}

const int N = 100005;

int n, k, xx, x[N], pos;
int nn = 0;
LL ans = 1e17;

int main(){
	in(nn); in(k);
	bool b = false;
	fo1(i, 1, nn){
		in(xx);
		if(xx != 0)	x[++n] = xx;
		else	b = true;
	}
	if(nn == 1)	return outln(abs(x[1])), 0;
	if(b)	k--;
	pos = lower_bound(x+1, x+n+1, 0) - x;
	pos--;
	fo1(i, 1, k){
		if(i > pos || i < pos + k - n)	continue;
		LL t = -x[pos-i+1];
		if(i < k)	t += 1ll * x[pos+k-i] - x[pos-i+1];
		ans = min(ans, t);
	}
	pos++;
	fo1(i, 1, k){
		if(i > n - pos + 1 || i < k + 1 - pos)	continue;
		LL t = x[pos+i-1];
		if(i < k)	t += 1ll * x[pos+i-1] - x[pos-(k-i)];
		ans = min(ans, t);
	}
	outln(ans);
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

int main()
{


    lint s;
    cin >> s;

    lint a, b, c, d;

    lint ans, tmp=0;
    lint x = pow(10, 9);

    a = ceil(sqrt(s));
    b = a;

    while (a * b - s > x)
    {
        if(a < x){
        a++;
        b--;
        }
        else
        {
            b++;
        }
        if(b>x){
            b = x-1;
            tmp = 1;
            break;
        }
    }

    if(tmp==1){
        c = 0;
    }
    c = 1;
    d = a * b - s;

    cout << "0 0 " << a << " " << c << " " << d << " " << b;

    return 0;

}

Measured memory_bytes: 256
/*
 * Created by Dipta Das on 27-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;
const int SIZE = 3003 + 100;
int dp[SIZE][SIZE];

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

    string s1, s2;
    cin >> s1 >> s2;
    int n = (int) s1.length();
    int m = (int) s2.length();

    s1 = '#' + s1;
    s2 = '#' + s2;


    for (int i = 0; i <= n; ++i) dp[i][0] = 0;
    for (int i = 0; i <= m; ++i) dp[0][i] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (s1[i] == s2[j]) {
                dp[i][j] = 1 + dp[i-1][j-1];
            } else {
                dp[i][j] = max (dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int len = dp[n][m];
    whatis(len);
    int i = n, j = m;
    string ans = "";
    while (len > 0) {
        if (s1[i] == s2[j]) {
            ans += s1[i];
            --i; --j; --len;
        } else {
            if (dp[i-1][j] > dp[i][j-1]) {
                --i;
            } else {
                --j;
            }
        }
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;


    // for (int i = 0; i <= n; ++i) for (int j = 0; j <= m; ++j) dp[i][j] = 99;
    /* for (int i = 0; i <= n; ++i) { */
    /*     for (int j = 0; j <= m; ++j) { */
    /*         cout << dp[i][j] << "\t"; */
    /*     } */
    /*     cout << endl; */
    /* } */
    /* cout << endl; */
    


    return 0;
}



Measured memory_bytes: 37120
#include <bits/stdc++.h>
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 ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

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;
}

int read(){
	int i;
	#ifdef int
	scanf("%" SCNd64,&i);
	#else
	scanf("%d",&i);
	#endif
	return i;
}

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

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

void print(int x,int suc=1){
	#ifdef int
	printf("%" PRId64,x);
	#else
	printf("%d",x);
	#endif
	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;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

#ifdef int
const int inf=LLONG_MAX/3;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	string s=readString();
	vi cur(2,0),nx(2,0);
	int n=s.size();
	for(int i=n-1;i>=0;i--){
		nx[0]=s[i]-'0'+cur[0];
		if(s[i]>'0')chmax(nx[0],cur[1]+s[i]-'1');
		nx[1]=9+max(cur[0],cur[1]);
		swap(cur,nx);
	}
	cout<<cur[0]<<endl;
}


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

ll dp[301][301];
void solve() {
	int n, k; cin >> n >> k;
	vector<int> h(n + 1);
	h[0] = 0;
	rep1(i, n)cin >> h[i];
	rep(i, 301) {
		rep(j, 301) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (dp[i][j] == INF)continue;
			for (int k = i + 1; k <= n; k++) {
				ll nd = dp[i][j];
				if (h[i] > h[k])nd += h[i] - h[k];
				dp[k][k - i - 1 + j] = min(dp[k][k - i - 1 + j], nd);
			}
		}
	}
	ll ans = INF;
	rep(i, n + 1) {
		rep(j, i + 1) {
			int dif = n - i;
			if (j + dif <= k) {
				ans = min(ans, dp[i][j] + h[i]);
			}
		}
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	stop
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static double x1, x2, x3, x4, y1, y2, y3, y4;
	public static void main(String[] args) {
		while(read()){
			
		}
	}
	static boolean read(){
		if(!sc.hasNext())
			return false;
		int n;
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			x1 = sc.nextDouble();
			y1 = sc.nextDouble();			
			x2 = sc.nextDouble();
			y2 = sc.nextDouble();
			x3 = sc.nextDouble();
			y3 = sc.nextDouble();
			x4 = sc.nextDouble();
			y4 = sc.nextDouble();
			/*System.out.println(x1+" "+ y1+" "+ x2+" "+ y2+" "+
							x3+" "+y3+" "+ x4+" "+ y4);*/
			slove();
		}
		return true;
	}
	static void slove(){
		double a1, a2;
		if(x2-x1 == 0 && x4-x3 == 0){
			if(y2-y1 == 0 || y4-y3 == 0){
				System.out.println("NO");
			}else{
				System.out.println("YES");
			}
		}else if(x2-x1 == 0 || x4-x3 == 0){
			System.out.println("NO");
		}else if(x2-x1 != 0 && x4-x3 != 0){
			a1 = (y2-y1)/(x2-x1);
			a2 = (y4-y3)/(x4-x3);
			if(a1 == a2){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 12000
n = int(input())
ans_list = []
for i in range(n):
    if i % 2 == 1:
        ans_list.append((i,0))
    if i % 6 == 1:
        for j in range(2,n,2):
            ans_list.append((i,j))
    elif i % 6 == 4:
        for j in range(1,n,2):
            ans_list.append((i,j))

if n % 3 != 2:
    for i in range(1,n):
        if (n - 1 + i) % 2 == 1:
            ans_list.append((n-1,i))

print(len(ans_list))
for i in ans_list:
    print(*i)

Measured memory_bytes: 55544
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	string S;
	cin >> S;
	map<char, int>m;
	for (auto i : S) {
		if (m[i] == 1) {
			cout << "no";
			return 0;
		}
		m[i]++;
	}
	cout << "yes";
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> data(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data.at(i).at(j);
    }
  }
  double ans=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int x=pow(data[i][0]-data[j][0],2);
      int y=pow(data[i][1]-data[j][1],2);
      ans+=pow(x+y,0.5);
    }
  }
  ans=ans*2;
  ans=ans/n;
  cout << fixed << setprecision(7) << ans << endl;
}



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

H, W = [int(x) for x in input().split()]
a = []
for _ in range(H):
    a.append([int(x) for x in input().split()])

place = [0, 0]
ans = []
flag = 1

for i in range(H * W - 1):
    x, y = place
    if flag:
        new_x, new_y = x, y + 1
        if new_y >= W:
            new_x, new_y = x + 1, y
            flag = 0
    else:
        new_x, new_y = x, y - 1
        if new_y < 0:
            new_x, new_y = x + 1, y
            flag = 1
    if a[x][y] % 2 == 1:
        ans.append([x + 1, y + 1, new_x + 1, new_y + 1])
        a[new_x][new_y] += 1
    place = [new_x, new_y]

print(len(ans))
for j in ans:
    print(*j)

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

int main(){

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if((a-d<=c&&c<=a+d)||((a-d<=b&&b<=a+d)&&(b-d<=c&&c<=b+d))) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

const int INF = 100000;
int main()
{
    string s,t;
    cin >> s >> t;
    int ans=0;
    for (int i = 0; i < size(s); i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int k;
    cin>>k;
    queue<ll> q;
	//q.push(v);
    int cnt=9;
    for(int i=1;i<=9;i++){
        q.push(i);
    }
    ll ans=0;
    if(k>=10){
        while(SZ(q)&&cnt<k){
        ll a=q.front();
        q.pop();
        
            for(int i=-1;i<=1;i++){
                if(i+a%10<0||i+a%10>9)continue;
                ll t=10*a+i+a%10;
                if(cnt+1==k){
                    ans=t;
                    cnt++;
                    break;
                }else{
                    q.push(t);
                    cnt++;
                }
            }
        
        }
    OUT(ans);
    }else OUT(k);
    return 0;
}

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  for(int i=A; i<A+K; i++){
    if(i<=B){
      cout << i << endl;
    }
  }
  for(int i=B-K+1; i<=B; i++){
    if(A+K<=i){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define N 200005
using namespace std;

int n, m, bu[N], s[N];
vector<int> a[N];
void f(int p,int q) {
	int i, t;
	bu[p] = q;
	s[p] += s[q];
	for (i = 0; i < a[p].size(); i++) {
		t = a[p][i];
		if (q == t) continue;
		f(t, p);
	}
}
int main()
{
	int i, j, t1, t2;
	cin >> n >> m;
	for (i = 0; i < n - 1; i++) {
		scanf ("%d %d", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	f(1, 0);
	while (m--) {
		scanf ("%d %d", &t1, &t2);
		s[t1] += t2;
	}
	f(1, 0);
	for (i = 1; i <= n; i++) printf("%d ", s[i]);
    return 0;
}


Measured memory_bytes: 24320
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int w = stdIn.nextInt();
			if(w == -1) {
				break;
			}
			int sum = 0;
				sum = 1150;
			w-=10;
			for(int i = 0; i < 10; i++) {
				if(w <= 0) {
					break;
				}
				w--;
				sum += 125;
			}
			for(int i = 0; i < 10; i++) {
				if(w <= 0) {
					break;
				}
				w--;
				sum += 140;
			}
			while(true) {
				if(w <= 0) {
					break;
				}
				w--;
				sum += 160;
			}
			System.out.println((sum - 4280) * -1);
		
		}
			
	}
}

Measured memory_bytes: 18608
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main() {
	vector<int> array = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k; cin >> k;
	cout << array[--k] << endl;
	return 0;
}

Measured memory_bytes: 256
// ABC109_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N;
    cin >> N;
    vector<string> vec(N);
    set<string> set_s;
    REP(i, N) cin >> vec[i];
    REP(i, N) set_s.insert(vec[i]);
    
    // calculation
    if (set_s.size() != N) {
        cout << "No" << "\n";
    } else {
        string start = vec[0], now;
        bool flag = true;
        
        for (ll i = 1; i < N; ++i) {
            now = vec[i];
            if (start.back() == now.front()) {
                start = now;
            } else {
                flag = false;
                break;
            }
        }
        
        if (flag) {
            cout << "Yes" << "\n";
        } else {
            cout << "No" << "\n";
        }
    }
    
    return 0;
}


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


void solve(){
    string s;
    cin>>s;
    int n=s.size()-1;
    if(s[n]=='s'){
        s+="es";
    }else{
        s+="s";
    }
    cout<<s<<endl;
}

int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 3628
N, M = map(int, input().split())
ans = 0

if M <= 1:
    ans = 0

elif N >= M:
    ans = M//2

elif N < M:
    if N*2 >= M:
        ans = M//2
    else:
        ans += N
        ans += (M-N*2)//4
print(ans)

Measured memory_bytes: 3064
import java.util.*;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		
		int mrxA[][] = new int[n][m];
		int mrxB[][] = new int[m][l];
		long mrxC[][] = new long[n][l];
		
		//??????A??????????????\???
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				mrxA[i][j] = sc.nextInt();
			}
		}
		
		//??????B??????????????\???
		for(int i = 0; i < m; i++) {
			for(int j = 0; j < l; j++) {
				mrxB[i][j] = sc.nextInt();
			}
		}
		
		//??????C????????????????´?
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < l; j++) {
				for(int k = 0; k < m; k++) {
					mrxC[i][j] += (mrxA[i][k] * mrxB[k][j]);
				}
				System.out.print(mrxC[i][j]);
				if(j != l -1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 54612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 5e5 + 10;
int nums[MAXN], tree[MAXN], a[MAXN], b[MAXN], idx[MAXN], pre[MAXN], ret[MAXN];
int n;

int lowbit(int i) {
  return i&(-i);
}
void update(int i, int val) {
  while (i <= n) {
    tree[i] += val;
    i += lowbit(i);
  }
}

int query(int i) {
  int tot = 0;
  while (i > 0) {
    tot += tree[i];
    i -= lowbit(i);
  }
  return tot;
}




int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int q; cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> nums[i];
  }
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    idx[i] = i;
  }
  sort(idx, idx+q, [](int i, int j){return make_pair(b[i], a[i]) < make_pair(b[j], a[j]);});
  int cur = 1;
  for (int j = 0; j < q; j++) {
    int i = idx[j];
    while (cur <= b[i]) {
      if (pre[nums[cur]] != 0) update(pre[nums[cur]], -1);
      pre[nums[cur]] = cur;
      update(pre[nums[cur]], 1);
      cur++;
    }
    ret[i] = query(b[i]) - query(a[i]-1);
  }
  for (int i = 0; i < q; i++) {
    cout << ret[i] << '\n';
  }







/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


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

int main()
{
    string n;
    cin >> n;
    for (int i = 0; i < n.length(); i++)
    {
        if (n.at(i) == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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


int main(){
    string S;
    cin >> S;
    int front = (S.at(0)-'0')*10 + S.at(1)-'0';
    int back = (S.at(2)-'0')*10 + S.at(3)-'0';
    
    if((front >= 13 or front == 0) and (1 <= back and back <= 12)){
        cout << "YYMM";
    }else if((1 <= front and front <= 12) and (back >= 13 or back == 0)){
        cout << "MMYY";
    }else if((front >= 13 and back >= 13) or (front==0 and 13 <= back) or (back==0 and 13 <= front) or (back==0 and front == 0)){
        cout << "NA";
    }else{
        cout << "AMBIGUOUS";
    }
}

//いこーるはみぎ

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 2010

using namespace std;

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

int n, x, y, cnt[Maxn];

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

int main() {
    n = read(); x = read(); y = read();
    for(int i = 1; i <= n; ++i) {
        for(int j = i + 1; j <= n; ++j) {
            int dis1 = j - i;
            int dis2 = abs(i - x) + abs(j - y) + 1;
            ++cnt[min(dis1, dis2)];
        }
    }
    for(int i = 1; i < n; ++i) printf("%d\n", cnt[i]);
    return 0;
}

Measured memory_bytes: 256