akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int n, m;
	cin >> n;
	while( true ){
		char op;
		cin >> op;
		if( op == '=' ){
			cout << n << endl;
			return 0;
		}
		cin >> m;
		if( op == '+' ) n += m;
		if( op == '-' ) n -= m;
		if( op == '*' ) n *= m;
		if( op == '/' ) n /= m;
	}
}

Measured memory_bytes: 1160
const NUMS_753: [u64; 3] = [7, 5, 3];

fn count(s: &String, c: char) -> u64 {
    let chars_vec: Vec<char> = s.chars().collect();
    chars_vec.iter().filter(|cmp_c| **cmp_c == c).count() as u64
}

fn dfs(num: u64, limit: u64) -> u64 {
    if num > limit {
        0
    }
    else {
        let is_753 = NUMS_753.iter().all(|n| {
            let c = std::char::from_digit(*n as u32, (*n + 6) as u32).unwrap();
            count(&num.to_string(), c) > 0
        });
        let sum: u64 = NUMS_753.iter().map(|n| {
            dfs(num * 10 + n, limit)
        }).sum();
        sum + if is_753 { 1 } else { 0 }
    }
}

fn main() {
    let limit: u64 = read();
    println!("{}", dfs(0, limit));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
M=9999;main(n,i,j,k,a,b,c){
    double p=atan(1)*4,X[100],Y[100],x,y;
    for(;scanf("%d",&n),n;printf("%d\n",a)){
        for(i=0;i<n;i++)scanf("%lf,%lf",X+i,Y+i);
        for(a=i=0;i<n;i++){
            for(b=k=0;k<M;k++){
                x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
                for(c=0,j=i;j<n;j++){
                    if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-7)c++;
                }
                if(b<c)b=c;
            }
            if(a<b)a=b;
        }
    }
exit(0);}

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

int main(){

  long long x, y;

  cin>>x>>y;

  long long z=x;
  int ans=0;
  while(1){
    z*=2;
    if(z<=y) ans++;
    else break;
  }

  cout<<++ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int x,y;
    cin >> x>>y;
    int sum=0;
    if(x==1) sum+=300000;
    else if(x==2) sum+=200000;
    else if(x==3) sum+=100000;

    if(y==1) sum+=300000;
    else if(y==2) sum+=200000;
    else if(y==3) sum+=100000;

    if(x==1 && y==1) sum+=400000;

    cout << sum << endl;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

ll N;
map<char, ll> m;

signed main() {
    REP(i, 4) {
        char c;
        cin >> c;
        m[c]++;
    }
    ll cnt = 0;
    FOREACH(x, m) {
        if(x.second != 2 || ++cnt > 2) {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    eputs("Yes");
}


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

int n,m=4000000;
bool ns[300005]={0};
int est[300005]={0};

int main(){
  int i,j,co=0;
  int e=0,w=0;
  char c;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> c;
    if(i>0)est[i]=est[i-1];
    if(c=='.')est[i]++;
    //cout << est[i];
  }
  m = est[n-1]-est[0];
  for(i=1;i<n-1;i++){
    co = 0;
    co +=i-est[i-1];
    co+=est[n-1]-est[i];
    if(m>co)m=co;
    
  }
  if(m>n-1-est[n-2])m=n-1-est[n-2];
  

  cout <<m<< endl;

  return 0;
}


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

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

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

    int y[M];
    for(int i = 0; i < M; i++){
        cin >> y[i];
    }

    int frag = 0;
    int frag_j = 0;

    for(int i = X + 1; i <= Y; i++){
        frag = 0;
        for(int j = 0; j < N; j++){
            if(x[j] >= i){
                frag = 1;
                break;
            }
        }
        for(int j = 0; j < M; j++){
            if(frag == 1){
                break;
            }
            if(y[j] < i){
                frag = 1;
                break;
            }
        }

        if(frag == 0){
            frag_j = 1;
            break;
        }
    }

    if(frag_j == 1){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	ps := make([]int,n)
	for i:= 0; i < n; i++ {
		var p int
		fmt.Scan(&p)
		ps[i] = p
	}

	count := 0
	for i := 1; i < n - 1; i++ {
		tmp := make([]int,3)
		tmp[0] = ps[i - 1]
		tmp[1] = ps[i]
		tmp[2] = ps[i + 1]

		sort.IntSlice(tmp).Sort()
		if tmp[1] == ps[i] {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};

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

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;

#define EPSILON 1.0e-12

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
};
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
};
bool compare_by_b_higheer(tuple<string, int, int> a, tuple<string, int, int> b) {
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) <get<0>(b);
    }else{
        if(get<1>(a) != get<1>(b)){return get<1>(a) > get<1>(b);}
        else{return get<2>(a) > get<2>(b);}
    }
};


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

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        String[] in = input.split(" ");
        
        int M = Integer.parseInt(in[0]);
        int D = Integer.parseInt(in[1]);
        
        int count = 0;
        for (int i = 1; i <= M; i++ ) {
            for (int j = 10; j <= D; j++) {
                String a = String.valueOf(j).substring(0,1);
                String b = String.valueOf(j).substring(1);
                int A = Integer.parseInt(a);
                int B = Integer.parseInt(b);
                if (A < 2 || B < 2) {
                    continue;
                }
                if (A * B == i) {
                    count++;
                }
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,k;
	cin >> n >> k;
	vector<int> ar(n);
	for(int &it : ar){
		cin >> it;
	}
	int l = 1, r = 1e9;
	while(l < r){
		int m = (l+r)/2;
		int cnt = 0;
		for(int i=0;i<n;i++){
			cnt += (ar[i]+m-1)/m-1;
		}
		if(cnt > k){
			l = m+1;
		}else{
			r = m;
		}
	}
	cout << l << '\n';
}

Measured memory_bytes: 4040
s = input()
n = len(s)

ans = 0
for i in range(2**(n-1)) :
  bit = i
  v = 0
  vt = 0
  for j in range(n-1) :
    vt += int(s[j])
    c = bit%2
    bit = bit//2
    if c == 0 :
      vt *= 10
    else :
      v += vt
      vt = 0
  v += vt + int(s[n-1])
  ans += v

print(ans)

Measured memory_bytes: 3064
public class Main {


  private static void solve() {
    int n = ni();
    int k = ni();
    int mod = 1000000000 + 7;
    int[] a = na(n);

    long[][] dp = new long[n + 1][k + 1];
    dp[0][k] = 1;
    for (int i = 1; i <= n; i ++) {
      long now = 0;
      for (int s = 0; s <= Math.min(a[i - 1], k); s ++) {
        now += dp[i - 1][s];
        now %= mod;
      }
      for (int j = 0; j <= k; j ++) {
        dp[i][j] = now;
        
        now = (now + mod - dp[i - 1][j]) % mod;
        if (j + a[i - 1] + 1 <= k)
          now = (now + dp[i - 1][j + a[i - 1] + 1]) % mod;
      }
    }
    System.out.println(dp[n][0]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 122324
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

ans = 0
for i in range(N):
    l = len([a for a in A[0:i] if a < A[i]])
    r = len([a for a in A[i + 1:N] if a < A[i]])
    ans += (K - 1) * K * (l + r) // 2 + K * r
    ans %= MOD
print(ans)


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

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

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int K;
  cin >> K;
  int64 ret = 0;
  for(int i = 1; i <= K; i++) {
    for(int j = 1; j <= K; j++) {
      for(int k = 1; k <= K; k++) {
        ret += __gcd(__gcd(i, j), k);
      }
    }
  }
  cout << ret << endl;
}



Measured memory_bytes: 3648
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int l=sc.nextInt();
        sc.close();
        int n=0, m=0;
        while(l>=(1<<n++));n--;
        StringBuilder sb =new StringBuilder();
        int sum=0;
        for(int bit=0;bit<n-1;bit++){
            sb.append((bit+1)+" "+(bit+2)+" "+0+"\n");
            m++;
                sb.append((bit+1)+" "+(bit+2)+" "+(1<<bit)+"\n");
                m++;
                if((l&(1<<bit))!=0){
                    sb.append((bit+1)+" "+n+" "+(l-sum-(1<<bit))+"\n");
                    sum+=(1<<bit);
                    m++;
                }
        }
        System.out.println(n+" "+m);
        System.out.print(sb);
    }
}


Measured memory_bytes: 23764
#include <stdio.h>

int main()
{
        int n, i, start, end;
        int data[100];
        int search;
        int count;
        int center;
     while (scanf("%d", &n) && n != 0) {
                for (i = 0; i < n; i++) {
                        scanf("%d", &data[i]);
                }
                scanf("%d", &search);
                start = 0;
                end = n-1;
                count = 0;
                while (start <= end) {
                  center = (start+end)/2;
                  count++;
                  if (search > data[center]) {
                    start = center+1;
                  }  else if (search < data[center]){
                    end = center-1;
                  } else if (search == data[center])
                         break;
                }
                printf("%d\n", count);
        }
        return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 1.0e9
#define MOD 1.0e9+7
using namespace std;
typedef long long ll;

int H, W;
const int MAX_HW = 500;
int a[MAX_HW][MAX_HW];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i][j];
        }
    }
    int cnt = 0;
    vector<string> ans;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W-1; j++){
            if (a[i][j] % 2 == 1) {
                a[i][j+1] += 1;
                a[i][j] -= 1;
                cnt++;
                ans.push_back(to_string(i+1) + " " + to_string(j+1) + " " +
                    to_string(i+1) + " " + to_string(j+2));
            }
        }
    }
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H-1; i++){
            if (a[i][j] % 2 == 1) {
                a[i+1][j] += 1;
                a[i][j] -= 1;
                cnt++;
                ans.push_back(to_string(i+1) + " " + to_string(j+1) + " " +
                    to_string(i+2) + " " + to_string(j+1));
            }
        }
    }
    cout << cnt << endl;
    for (int i = 0; i < cnt; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 11892
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int pos[] = {0, 1, 4, 1, 4, 1, 2, 1, 2};
	vector<int> p(9), c(pos, pos + 9);

	while(1){
		for(int i = 1; i <= 8; ++i){
			if(scanf("%d", &p[i]) == EOF){ return 0; }
		}

		vector<int> ans(9, 1000000000);
		for(int i = 0; i < 8; ++i){
			c[0] = 0;
			for(int j = 1; j <= 8; ++j){
				c[0] += max(p[j] - c[j], 0);
			}
			ans = min(ans, c);
			rotate(c.begin() + 1, c.begin() + 2, c.end());
		}

		for(int i = 1; i <= 8; ++i){
			printf("%d%c", ans[i], i == 8 ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 1052
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  int maximum = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      ans++;
      maximum = max(ans, maximum);
    } else {
      ans = 0;
    }
  }
  cout << maximum << endl;
  return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 3005, P = 998244353;

int n, X, C[N][N], f[N][N << 1];

int main() {
	read(n), read(X);
	for (int i = 0; i <= n; ++i) {
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % P;
		}
	}
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= 2 * i && j < X; ++j) {
			f[i][j] = (f[i - 1][j - 1] + (j > 1 ? f[i - 1][j - 2] : 0)) % P;
		}
		for (int j = X + 1; j <= 2 * i; j += 2) {
			int c = (j - X + 1) / 2;
			if (i >= 2 * c && j >= 4 * c) {
				f[i][j] = f[i - 2 * c][j - 4 * c];
			} else if (2 * (i - 2 * c) == j - 4 * c) {
				f[i][j] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= 2 * i; ++j) {
			ans = (ans + 1ll * C[n][i] * f[i][j]) % P;
			// debug("%d ", f[i][j]);
		}
		// debug("\n");
	}
	print(ans);
}


Measured memory_bytes: 77280
H = int(input())
A = [0]
for i in input().split(): A.append(i)
for i in range(1,H+1):
    print("node {}: key = {}, ".format(i,A[i]),end = "")
    if i != 1: print("parent key = {}, ".format(A[i//2]),end = "")
    if 2*i <= H: print("left key = {}, ".format(A[2*i]),end = "")
    if 2*i+1 <= H: print("right key = {}, ".format(A[2*i+1]),end="")
    print("")


Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    for(int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)

int main()
{
  int n,m,ans=0;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  rep(i,n-2){
    for(int j=i+1; j<n-1; j++){
      if(l[i]==l[j]) continue;
      for(int k=j+1; k<n; k++){
        if(l[i]==l[k] || l[j]==l[k]) continue;
        if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#!python3

import numpy as np

LI = lambda: list(map(int, input().split()))

# input
N, K = LI()
A = np.array(LI())

MOD = 10 ** 9 + 7


def main():
    if np.count_nonzero(A == 0) > N - K:
        print(0)
        return
    m = A[A < 0] * -1
    p = A[A > 0]
    m = np.sort(m)[::-1]
    p = np.sort(p)[::-1]
    mn = len(m)
    pn = len(p)
    i, j = 0, 0
    for _ in range(K):
        if i >= mn:
            j += 1
            continue
        if j >= pn:
            i += 1
            continue
        if m[i] < p[j]:
            j += 1
        else:
            i += 1
    if i % 2 == 1:
        if i < mn and j > 0:
            if j < pn:
                x = m[i - 1] * m[i]
                y = p[j - 1] * p[j]
                if x < y:
                    i -= 1
                    j += 1
                else:
                    i += 1
                    j -= 1
            else:
                i += 1
                j -= 1
        elif j < pn - 1:
            i -= 1
            j += 1
    if i % 2 == 0:
        ans = 1
        for x in m[:i]:
            ans = ans * x % MOD
        for x in p[:j]:
            ans = ans * x % MOD
    else:
        if 0 in A:
            ans = 0
        else:
            ans = -1
            for x in m[mn - i:]:
                ans = ans * x % MOD
            for x in p[pn - j:]:
                ans = ans * x % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,l,r) for(int i=l;i<r;i++)
using ll = long long;
const int inf=2e9+10;
const ll MOD=1e9+7;
const ll INF=9e18+10;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

int main(){
	int n;cin>>n;
	ll ans=0;
	for(int i=1;i<n;i++){
		ans+=((n-1)/i);
	}
	cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int x1=0,x2=w,y1=0,y2=h;

  rep(i,n){
    int x,y,a; cin >> x >> y >> a;
    if(a==1){
      x1 = max(x1,x);
    }else if(a==2){
      x2 = min(x2,x);
    }else if(a==3){
      y1 = max(y1,y);
    }else if(a==4){
      y2 = min(y2,y);
    }
  }

  if(x1>x2 || y1>y2) puts("0");
  else cout << (x2-x1)*(y2-y1);

}


Measured memory_bytes: 3508
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    int n = S.length();
    
    long ans = 0L;
    for(int i = 0; i < Math.pow(2, n - 1); i++){
      StringBuffer sb = new StringBuffer(S);
      for(int j = n - 1; 0 <= j; j--){
        if((1&i>>j) == 1){
           sb.insert(j + 1,"+");
        }
      }
      //System.out.println(sb); 
      String[] array = sb.toString().split("\\+", 0);
      for(int l = 0; l < array.length; l++){
        ans += Long.parseLong(array[l]);
      } 
    } 
    System.out.println(ans);
  }
}

Measured memory_bytes: 23380
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//答えが見つかったか判定
	static bool found;
	//答え
	static int[] ans = new int[3];
	//合計枚数
	static int N;
	//合計額
	static int Y;

	//判定
	static bool check(int a, int b, int c)
	{
		//成り立つ場合
		if(10000*a + 5000*b + 1000*c == Y){
			found = true;
			ans[0] = a;
			ans[1] = b;
			ans[2] = c;

			found = true;
			return true;
		}
		else{
			return false;
		}
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		N = int.Parse(S[0]);
		Y = int.Parse(S[1]);

		//全探索
		for(int i=0; i<N+1; i++){
			for(int j=0; j<(N+1-i); j++){
				int k = N - (i + j);
				if(check(i,j,k)){
					break;
				}
			}
			if(found){
				break;
			}
		}

		//答えが見つからなかった場合
		if(!found){
			for(int i=0; i<3; i++){
				ans[i] = -1;
			}
		}

		Console.Write(ans[0] + " ");
		Console.Write(ans[1] + " ");
		Console.Write(ans[2]);

	}
}



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

int main(){
  while(true){
    string g;
    int y, m, d;
    cin>>g;

    if(g == "#") break;
    
    cin>>y>>m>>d;
    if(y<=30) cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    else if(y == 31)cout<<(m<=4?g:"?")<<" "<<(m<=4?y:y-30)<<" "<<m<<" "<<d<<endl;
    else  cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
  }
  return 0;
}



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

enum color {red, blue};

vector<vector<int>> to(200001);
queue<int> v_red;
queue<int> v_blue;

void dfs(int v, color c, int prev)
{
  if (c == red) {
    v_red.push(v);
  } else {
    v_blue.push(v);
  }
  for (int next : to.at(v)) {
    if (next == prev) continue;
    dfs(next, c == red ? blue : red, v);
  }
}

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

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }

  dfs(1, red, 0);

  queue<int> q;
  for (int i = 3; i >= 1; i--) {
    for (int j = i; j <= n; j += 3) {
      q.push(j);
    }
  }

  vector<vector<int>> v(3);
  for (int i = 1; i <= n; i++) {
    v[i % 3].push_back(i);
  }

  vector<int> ans(n + 1);

  if (v_red.size() <= v[0].size()) {
    while (!v_red.empty()) {
      ans[v_red.front()] = q.front();
      v_red.pop();
      q.pop();
    }
    while (!v_blue.empty()) {
      ans[v_blue.front()] = q.front();
      v_blue.pop();
      q.pop();
    }
  } else if (v_blue.size() <= v[0].size()) {
    while (!v_blue.empty()) {
      ans[v_blue.front()] = q.front();
      v_blue.pop();
      q.pop();
    }
    while (!v_red.empty()) {
      ans[v_red.front()] = q.front();
      v_red.pop();
      q.pop();
    }
  } else {
    for (int i = 0; i < int(v[1].size()); i++) {
      ans[v_red.front()] = v[1][i];
      v_red.pop();
    }
    for (int i = 0; i < int(v[2].size()); i++) {
      ans[v_blue.front()] = v[2][i];
      v_blue.pop();
    }
    for (int i = 0; i < int(v[0].size()); i++) {
      if (!v_red.empty()) {
        ans[v_red.front()] = v[0][i];
        v_red.pop();
      } else {
        ans[v_blue.front()] = v[0][i];
        v_blue.pop();
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << " " << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 22904
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main()
{
ll N; cin >> N;
ll mod = 1e9+7;

ll ans10 = 1;
ll ans9 = 1;
ll ans8 = 1;
for(int i = 0 ; i < N ; i++)
{
    ans10 = (ans10*10) % mod ;
    ans9 = (ans9*9) % mod ;
    ans8 = (ans8*8) % mod ;
}

cout << (ans10 - 2*ans9 + ans8 + 2*mod) % mod;
}

Measured memory_bytes: 3568
from copy import *
from sys import *
from math import *
import queue
from collections import defaultdict,Counter,deque

setrecursionlimit(1000000)

def main():
	n=int(input())
	l=[];t=0;flg=0
	for i in range(1,n+1,1):
		a,b=map(int,input().split())
		c=(b,a)
		l.append(c)
	l.sort()
	flag = True
	for x,y in l:
		t+=y
		if t>x:
			flag = False
	if flag:print("Yes")
	else:print("No")

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	#競プロ用のQueue
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)

class Stack():
	#怯プロ用のStack
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)

main()

Measured memory_bytes: 70100
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(ll i=(ll)(x);i<(ll)(y);i++)
#define RREP(i,x,y) for(ll i=(ll)(x);i>=(ll)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const ll MAX_N = 200000;
ll N;
ll A[MAX_N];
ll sums[MAX_N];
map<ll, ll> cmb;

ll solve() {
    ll answer = 0;

    ll sum = 0;
    sums[0] = 0;
    REP(i,0,N) {
        sum += A[i];
        sums[i] = sum;
    }

    cmb.clear();
    cmb[0] = 1;
    REP(i,0,N) {
        ll key = sums[i];
        if(cmb.count(key) == 0) cmb[key] = 0;
        cmb[key]++;
    }

    for (map<ll, ll>::iterator it = cmb.begin(); it != cmb.end(); ++it){
        ll key = it->first;
        ll cnt = it->second;

        eprintf("key: %d, cnt: %d\n", key, cnt);

        if (cnt <= 1) continue;

        answer += cnt * (cnt - 1) / 2;
    }

    return answer;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,0,N) cin >> A[i];
    cout << solve() << "\n";
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll dp[100010][2];
int gcd(int x, int y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
int main() {
	cin >> s;
	cin >> k;
	bool flg1 = true;
	for (int i = 0; i < k; i++) {
		if (s[i] != '1') {
			flg1 = false;
			cout << s[i] << endl;
			return 0;
		}
	}
	if (flg1) {
		cout << 1 << endl;
	}
}




Measured memory_bytes: 384
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{

        int cnt = 0;
        while (N)
        {
                cnt++;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N;
        ll s = 0;

        cin >> N;
        vector<int> A(N + 1);
        rep(i, N) cin >> A[i];
        rep(i, N) s += A[i];
        if (s % 2 == 0)
        {
                cout << "YES" << endl;
        }
        else
        {
                cout << "NO" << endl;
        }

        return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<pair<int,int> > ab(N);
  for (int i=0; i<N; i++) {
    cin>>ab[i].first>>ab[i].second;
  }
  vector<pair<int,int> > cd(N);
  for (int i=0; i<N; i++) {
    cin>>cd[i].first>>cd[i].second;
  }
  sort(cd.begin(),cd.end());
  bool used[N];
  memset(used,false,sizeof(used));
  int ans=0;
  for (int i=0; i<N; i++) {
    int maxy=-1,x=-1;
    for (int j=0; j<N; j++) {
      if (!used[j] && cd[i].first>ab[j].first && cd[i].second>ab[j].second && maxy<ab[j].second) {
        maxy=ab[j].second;
        x=j;
      }
    }
    if (x>-1) {
      used[x]=true;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
s = [[0 for j in range(10)] for i in range(n)]
for i in range(n):
    t = input()
    s[i] = "".join(sorted(t))
s.sort()
ans = 0

c = collections.Counter(s)
for i in set(s):
    n = c[i]
    ans += n * (n-1) // 2
print(ans)

Measured memory_bytes: 30580
using AtCoderBeginnerContest134.Questions;
using AtCoderBeginnerContest134.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest134.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nd = inputStream.ReadIntArray();
            var n = nd[0];
            var d = nd[1];

            var range = 2 * d + 1;
            yield return (int)Math.Ceiling((double)n / range);
        }
    }
}


namespace AtCoderBeginnerContest134
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest134.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest134.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
package main
import (
  . "fmt"
  . "os"
)
func main() {
  var n,m int
  var a,b []string
  Scan(&n,&m)
  a = make([]string,n)
  b = make([]string,m)
  for i:=0;i<n;i++ {
    Scan(&a[i])
  }
  for i:=0;i<m;i++ {
    Scan(&b[i])
  }
  for i:=0;i<n-m+1;i++ {
    LABEL:
    for j:=0;j<n-m+1;j++ {
      for k:=0;k<m;k++ {
        if a[i+k][j:j+m] != b[k] { continue LABEL }
      }
      Println("Yes")
      Exit(0)
    }
  }
  Println("No")
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define LL long long 
using namespace std;
const int MOD=1000000007;
const int N=100007;
string s1,s2;
int main(void)
{
	int n;
	scanf("%d",&n);
	cin>>s1;
	cin>>s2;
	LL res=1;
	int flag=0;
	rep(i,0,s1.length())
	{
		if(s1[i]==s2[i])
		{
			if(flag==0)res=(res*3ll)%MOD;
			else if(flag==1)res=(res*2ll)%MOD;
			//else if(flag==2)res=(res*1ll)%MOD;
			flag=1;
		}
		else 
		{
			if(flag==0)res=(res*6ll)%MOD;
			else if(flag==1)res=(res*2ll)%MOD;
			else if(flag==2)res=(res*3ll)%MOD;
			flag=2;
			i++;
		}
	}
	printf("%lld",res);
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        int i,j;
        while(n!=0||r!=0){
            int[] num = new int[n];
            for(i=0;i<n;i++) num[i] = n-i;
            for(i=0;i<r;i++){
                int p = sc.nextInt();
                int c = sc.nextInt();
                if(p-1>=c){
                    int[] tmp = new int[p-1];
                    for(j=0;j<p-1;j++) tmp[j] = num[j];
                    for(j=0;j<c;j++)   num[j] = num[p-1+j];
                    for(j=0;j<p-1;j++) num[c+j] = tmp[j];
                }else{
                    int[] tmp = new int[c];
                    for(j=0;j<c;j++)   tmp[j] = num[p-1+j];
                    for(j=0;j<p-1;j++) num[c+j] = num[j];
                    for(j=0;j<c;j++)   num[j] = tmp[j];
                }
            }
            System.out.println(num[0]);
            n = sc.nextInt();
            r = sc.nextInt();
        }
    }
}


Measured memory_bytes: 36900
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n>>k;
    vl v(n);
    fo(i,n)cin>>v[i];
    sort(all(v));h=inf;
    for(int i=0;i<n-k+1;i++)h=min(h,v[i+k-1]-v[i]);
    cout<<h;
    return 0;
}


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

using namespace std;

int main( int argc, char* argv[] ){
#ifdef DBG
	freopen( "in.in", "r", stdin );
	freopen( "out.out", "w", stdout );
#endif
	stack<int> stack;
	string str;

	while( cin >> str ){
		if( str[ 0 ] - '0' >= 0 && str[ 1 ] - '9' <= 0 ){
			int tmp = 0;

			for( unsigned int i = 0; i < str.length(); ++i ){
				tmp *= 10;
				tmp += str[ i ] - '0';
			}
			stack.push( tmp );
		}
		else{
			int b = stack.top(), a;

			stack.pop();
			a = stack.top();
			stack.pop();
			//cout << a << " " << b << endl;

			switch( str[ 0 ] ){
				case '+':
					stack.push( a + b );
					break;
				case '-':
					stack.push( a - b );
					break;
				case '*':
					stack.push( a * b );
					break;
			}
		}
	}
	cout << stack.top() << endl;

	return 0;
}


Measured memory_bytes: 3204
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main()
{
  int n;
  cin >> n;
  switch(n){
    case 1:
      cout << "Hello World" << endl;
      break;
    case 2:
      int a, b;
      cin >> a >> b;
      cout << a + b << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int F[50];
  F[0] = F[1] = 1;
  for (int i = 2; i <= n; i++) {
    F[i] = F[i - 1] + F[i - 2];
  }
  cout << F[n] << endl;
  return 0;
}

Measured memory_bytes: 3068
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
ab = [LIST() for _ in range(N-1)]
c = LIST()
c.sort(reverse=True)
tree = [[] for _ in range(N)]
for a, b in ab:
	tree[a-1].append(b-1)
	tree[b-1].append(a-1)

start=None
for i in range(N):
	if len(tree[i]) == 1:
		start = i
		break

ans = [0]*N
q = deque()
q.append(start)
ans[start] = c[0]
cnt = 1
while q:
	n = q.popleft()
	for node in tree[n]:
		if ans[node]:
			continue
		ans[node] = c[cnt]
		cnt += 1
		q.append(node)
print(sum(c)-max(c))
print(*ans)


Measured memory_bytes: 9820