akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	n, k := oneInt(), oneInt()

	sss := oneStr()

	ans := calc(sss, n, k)
	fmt.Println(ans)

}

type runLength struct {
	cnt int
	s   string
}

func calc(sss string, n, k int) int {
	nums := []runLength{}

	tmp := ""
	for _, s := range sss {
		if tmp == "" {
			tmp = string(s)
			nums = append(nums, runLength{1, tmp})
		} else {
			if tmp == string(s) {
				nums[len(nums)-1].cnt++
			} else {
				tmp = string(s)
				nums = append(nums, runLength{1, tmp})
			}
		}
	}

	nums = append(nums, runLength{0, "1"})

	sums := []int{0}

	for i, n := range nums {
		sums = append(sums, sums[i]+n.cnt)
	}

	ans := -1
	right := 0

	for left := 0; left < len(sums)-1-right; left++ {
		right = min(len(sums)-1, 2*k+1)
		if nums[left].s == "0" {
			right = min(len(sums)-1, 2*k)
		}

		ans = max(ans, sums[right+left]-sums[left])
	}

	//fmt.Println(nums)
	//fmt.Println(sums)

	return ans
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n;
	cin >> n;
	int a[n], b[n];
	REP(i, n) cin >> a[i];
	REP(i, n) cin >> b[i];
	int ans = 0;
	REP(i, 30){
		int am[n], bm[n], bit = 0;
		REP(j, n){
			am[j] = a[j] % (1<<(i+1));
			bm[j] = b[j] % (1<<(i+1));
		}
		sort(bm, bm+n);
		REP(j, n){
			if(am[j] < (1<<i)){
				int x = upper_bound(bm, bm+n, (1<<(i+1))-1-am[j]) - lower_bound(bm, bm+n, (1<<i)-am[j]);
				bit = (x+bit)%2;
			}
			else{
				int x = n - (upper_bound(bm, bm+n, (1<<(i+1))+(1<<i)-1-am[j]) - lower_bound(bm, bm+n, (1<<(i+1))-am[j]));
				bit = (x+bit)%2;
			}
		}
		ans += bit<<i;
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << "\n"; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


template<typename T>
struct edge {
  int v; T w;
  edge(int v, T w=1) : v(v), w(w) {}
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using Graph = vector<Edges<T>>;


template<typename T>
vector<T> dijkstra(Graph<T> &G, int s) {
  const auto INF = numeric_limits<T>::max();
  vector<T> dist(G.size(), INF);

  using PTi = pair<T, int>;
  priority_queue<PTi, vector<PTi>, greater<PTi>> pq;
  dist[s] = 0;
  pq.emplace(dist[s], s);

  while (!pq.empty()) {
    T cost; int u;
    tie(cost, u) = pq.top(); pq.pop();
    if (dist[u] < cost) continue;
    for (auto &e : G[u]) {
      auto n_cost = cost + e.w;
      if (dist[e.v] <= n_cost) continue;
      dist[e.v] = n_cost;
      pq.emplace(dist[e.v], e.v);
    }
  }
  return dist;
}


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

  Graph<int> G(n);
  rep(_, m) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  auto dst = dijkstra(G, 0);

  V ans(n-1);
  rep2(i, 1, n) {
    for (auto &e: G[i]) if (dst[i] == dst[e.v]+1) ans[i-1] = e.v+1;
  }

  cout << "Yes\n";
  cout << ans;
  return 0;
}


Measured memory_bytes: 13164
//PointCard
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int N, M, a, b;
    priority_queue<int> PQ;
    cin >> N >> M;

    int cnt = 0, cost = 0;
    for(int i = 0; i < M; i++) {
        cin >> a >> b;
        if(a >= N) cnt++;
        else PQ.push(a);
    }

    while(cnt < M - 1) {
        cost += N - PQ.top();
        PQ.pop();
        cnt++;
    }

    cout << cost << endl;
}


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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> stat;
  stat.push_back(0);
  char c;
  char prev;
  cin >> prev;
  int count = 1;
  for(int i = 1; i < n - 1; i++){
    cin >> c;
    if(c == prev){
      count++;
    }else{
      if(prev == '0'){
        stat.push_back(-count);
      }else{
        stat.push_back(count);
      }
      count = 1;
    }
    prev = c;
  }
  if(n > 1){
    cin >> c;
    if(c == prev){
      count++;
      if(prev == '0'){
        stat.push_back(-count);
      }else{
        stat.push_back(count);
      }
    }else{
      if(prev == '0'){
        stat.push_back(-count);
        stat.push_back(1);
      }else{
        stat.push_back(count);
        stat.push_back(-1);
      }
    }
  }else{
    if(c = '1'){
      stat.push_back(1);
    }else{
      stat.push_back(-1);
    }
  }
  stat.push_back(0);
  int stat_size = stat.size();
  
  long long max_rev = 0;
  long long prev_rev = 0;
  int left, right;
  if(stat[1] < 0){
    left = 0;
    right = min(2 * k + 1, stat_size);
  }else{
    left = 1;
    right = min(2 * k + 2, stat_size);
  }
  
  for(int j = left; j < right; j++){
    prev_rev += (long long)abs(stat[j]);
  }
  max_rev = prev_rev;
  left += 2;
  right += 2;
  while(right <= stat_size){
    prev_rev = prev_rev + (long long)(-stat[left - 2] + stat[left - 1] + stat[right - 1] - stat[right - 2]);
    max_rev = (long long)max(max_rev, prev_rev);
    left += 2;
    right += 2;
  }
  
  cout << max_rev << endl;
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[200005],t[200005];
ll dp[1005][1005];
bool flag,dame;
int main(){
	cin >> n >> k;
	p(n - k + 1);

	
	return 0;
}

Measured memory_bytes: 25216
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	private static double day;
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		String S = sc.next();
		double K = sc.nextDouble();
		day = Math.pow(10, 15) * 5;
		int res = 0;
		int count = 0;
		while(S.length()>0){
			double top = Double.parseDouble(S.substring(count, count+1));
			double after = Math.pow(top, day);
			if(after>=K){
				res = (int)top;
				break;
			}else {
				K -= after;
				count++;
			}
		}
		out.println(res);
		out.flush();

	}
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::set<int> s;
    for (int i = 0; i < n; i++) {
        int in;
        std::cin >> in;
        s.insert(in);
    }

    std::cout << (s.size() == n ? "YES" : "NO") << std::endl;

    return 0;
}


Measured memory_bytes: 9600
n,k = gets.chomp.split(" ").map(&:to_i)

# 合同式の変形を行うと a ≡ b ≡ c (mod k) ということに注目

# key: kで割ったあまり, value: 個数
hash = {}
(1..n).each do |i|
  r = i % k
  # 2倍してkの倍数にならないものは除外
  next if (r * 2) % k != 0
  hash[r] ||= 0
  hash[r] += 1
end

result = 0
hash.each do |k, v|
  # a, b, cが取りうる組み合わせ
  result += v ** 3
end

puts result


Measured memory_bytes: 14416
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;


long long gcd(long long a,long long b){
  if(a<b){
    swap(a, b);
  }
  if(a%b==0)
    return b;
  return gcd(a % b, b);
}

int main()
{
  int N, M;
  cin >> N >> M;
  char A[N][N];
  char B[M][M];
  for (int i = 0; i < N;i++){
    for (int j = 0; j < N;j++)
      cin >> A[i][j];
  }
  for (int i = 0; i < M; i++)
  {
    for (int j = 0; j < M; j++)
      cin >> B[i][j];
  }
  bool ans = false;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N;j++){
      if (j + M - 1 >= N or i + M - 1 >= N)
        continue;

      //一致しているか
      bool an = true;
      for (int a = 0; a < M;a++){
        for (int b = 0; b < M;b++){
          if (i + a < N && j + b < N){
            if (A[i + a][j + b] != B[a][b])
              an = false;
          }

        }
      }
      if(an)
        ans = true;
    }
  }

  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

const int maxn = 600, maxm = maxn * maxn;
int n, tot, id[maxn + 3][maxn + 3], row[maxm + 3], col[maxm + 3];
int x, y, num[maxm + 3], res[maxm + 3], cnt[5];
bool vis[maxm + 3];
vector<int> G[maxm + 3];

void add(int u, int v) {
	G[u].push_back(v);
}

void dfs(int u) {
	vis[u] = true;
	for (int i = 0, v; i < G[u].size(); i++) {
		v = G[u][i];
		if (vis[v]) continue;
		num[v] = num[u] ^ 1;
		dfs(v);
	}
}

void solve(int x, int y) {
	for (int i = 1; i <= tot; i++) {
		vis[i] = false;
		vector<int>().swap(G[i]);
	}
	for (int a = 0; a < n * 2; a++) {
		for (int b = 0; b < n * 2; b++) {
			if (a * a + b * b == x) {
				for (int i = 0; i < n * 2 - a; i++) {
					for (int j = 0; j < n * 2 - b; j++) {
						add(id[i][j], id[i + a][j + b]);
						add(id[i + a][j + b], id[i][j]);
						add(id[i][j + b], id[i + a][j]);
						add(id[i + a][j], id[i][j + b]);
					}
				}
			}
		}
	}
	num[1] = 0;
	for (int i = 1; i <= tot; i++) {
		if (!vis[i]) dfs(i);
	}
	for (int i = 1; i <= tot; i++) {
		res[i] |= num[i] << y;
	}
}

int dist(int a, int b, int x, int y) {
	return (x - a) * (x - a) + (y - b) * (y - b);
}

int dist(int i, int j) {
	return dist(row[i], col[i], row[j], col[j]);
}

int main() {
	scanf("%d %d %d", &n, &x, &y);
	for (int i = 0; i < n * 2; i++) {
		for (int j = 0; j < n * 2; j++) {
			id[i][j] = ++tot;
			row[tot] = i, col[tot] = j;
		}
	}
	solve(x, 0), solve(y, 1);
	for (int i = 1; i <= tot; i++) {
		cnt[res[i]]++;
	}
	int pnt = 0;
	for (int i = 0; i < 4; i++) {
		if (cnt[i] >= n * n) {
			pnt = i;
			break;
		}
	}
	int all = 0;
	for (int i = 1; i <= tot; i++) {
		if (res[i] == pnt) {
			printf("%d %d\n", row[i], col[i]);
			if (++all == n * n) break;
		}
	}
	/*
	for (int i = 1; i <= tot; i++) {
		for (int j = i + 1; j <= tot; j++) {
			if (res[i] == pnt && res[j] == pnt) {
				if (dist(i, j) == x || dist(i, j) == y) {
					puts("Fuck");
					printf("(%d, %d), (%d, %d)\n", row[i], col[i], row[j], col[j]);
					return 0;
				}
			}
		}
	}
	*/
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> S(m, vector<bool>(n, false));
  rep(i, m) {
    int k, s;
    cin >> k;
    rep(j, k) {
      cin >> s;
      s--;
      S[i][s] = true;
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(i, 1 << n) {
    bool all_on = true;
    rep(j, m) {
      int num_on = 0;
      rep(k, n) if ((i >> k & 1) && S[j][k]) num_on++;
      if (num_on % 2 != p[j]) all_on = false;
    }
    if (all_on) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}
///////////////////////////

ll beki(ll n) {
	if (n == 0) { return 1;}
	return 10 * beki(n - 1);
}



int main() {

	
	ll c[MAX] = {};

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

	vector<pair<ll, ll>> city[MAX];

	repn(i, M) {
		ll p, y;
		cin >> p >> y;
		city[p].push_back({ y, i });
	}

	repn(p, N) {
		sort(city[p].begin(), city[p].end());
	}
	
	pair<ll, ll> ans[MAX];

	repn(p, N) {
		rep(i, city[p].size()) {
			ans[city[p][i].second] = { p,i + 1 };
		}
	}

	repn(i, M) {
		repn(k, 6) {
			cout << ans[i].first / beki(6 - k) % 10;
		}
		repn(k, 6) {
			cout << ans[i].second / beki(6 - k) % 10;
		}
		cout << endl;
	}


	system("PAUSE");
}

Measured memory_bytes: 43896
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define lbd(a, x) lower_bound(all(a), x)
const int mod = 1e9 + 7;
const int M = 10010;
template<typename T>
vector<int> z_function(const T&s, int n) {
	vector<int> z(n + 1);
	for(int i = 1, x = 0, y = 0; i < n; i++) {
		if(i <= y) z[i] = min(y - i, z[i - x]);
		while(i + z[i] < n && s[i + z[i]] == s[z[i]]) ++z[i];
		if(y <= i + z[i]) x = i, y = i + z[i];
	}
	z[0] = n;
	return z;
}
vector<int> z_function(const string &s) {
	return z_function(s, s.size());
}

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#define M 40
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, k; cin >> n >> k;
	vector<string> vs(n);
	for(auto &s : vs) cin >> s;
	vector<bitset<M> > ok(n + 1);
	ok[n][k] = 1;
	for(int i = n - 1; i >= 0; i--) {
		ok[i] = ok[i + 1] | (ok[i + 1] >> vs[i].size());
	}
	string ans;
	bitset<M> dp;
	dp[0] = 1;
	for(int i = 0; i < n; i++) {
		auto z = z_function(vs[i] + ans);
		int l = vs[i].size();
		for(int j = 0; j <= ans.size() && j + l <= k; j++) {
			if(!dp[j] || !ok[i + 1][j + l]) continue;
			int d = z[j + l];
			if(d >= l) {
				dp[j + l] = 1;
				continue;
			}
			if(j == ans.size() || vs[i][d] < ans[j + d]) {
				ans = ans.substr(0, j) + vs[i];
				for(int o = j + d + 1; o <= k; o++) dp[o] = 0;
				dp[ans.size()] = 1;
				break;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3968
INF = 10 ** 12

N = int(input())
X = [0] * N
Y = [0] * N
P = [0] * N
for i in range(N):
    X[i], Y[i], P[i] = map(int,input().split())

score_X = []

for i in range(2 ** N):
    x = []
    I = i
    for j in range(N):
        i = I
        score = abs(X[j]) * P[j]
        for k in range(N):
            if i & 1:
                score = min(score, abs(X[j] - X[k]) * P[j])
            i >>= 1
        x.append(score)
    score_X.append(x)

score_Y = []

for i in range(2 ** N):
    y = []
    I = i
    for j in range(N):
        i = I
        score = abs(Y[j]) * P[j]
        for k in range(N):
            if i & 1:
                score = min(score, abs(Y[j] - Y[k]) * P[j])
            i >>= 1
        y.append(score)
    score_Y.append(y)

ans = [INF] * (N + 1)

for i in range(2 ** N):
    cnt = 0
    for j in range(N):
        if (i >> j) & 1:
            cnt += 1
    
    j = i
    
    while True:
        score = 0
        for k in range(N):
            if not (i >> k) & 1:
                score += min(score_X[j][k], score_Y[i - j][k])
        ans[cnt] = min(ans[cnt], score)
        if j == 0:
            break
        j = (j - 1) & i

for i in range(N + 1):
    print(ans[i])

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

void solve(int n) 
{
    int seq[n];
    for (int i = 0; i < n; i++) {
        cin >> seq[i];
    }

    bool all_minus = true;
    for (int i = 0; i < n; i++) {
        if (seq[i] >= 0) {
            all_minus = false;
        }
    }
    if (all_minus) {
        int min = seq[0];
        for (int i = 1; i < n; i++) {
            min = seq[i] > min ? seq[i] : min;
        }
        cout << min << endl;
        return;
    }

    int cur_sum = seq[0];
    int cur_max = seq[0];

    for (int i = 1; i < n; i++) {
        cur_sum += seq[i];
        if (cur_sum < 0) {
            cur_sum = 0;
        } else {
            cur_max = cur_sum > cur_max ? cur_sum : cur_max;
        }
    }
    cur_max = (cur_max > cur_sum ? cur_max : cur_sum);
    cout << cur_max << endl;
}

int main(void)
{
    int n;
    while (cin >> n) {
        if (n == 0) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int A,B,C;
    cin >> A >> B >> C;

    cout << ((A + B >= C) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n, x, y;
int sum[N];
int main()
{
	cin >> n >> x >> y;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			if (i <= x)
			{
				if (j <= x) sum[j - i]++;
				else if (j > y) sum[j - i - (y - x - 1)]++;
				else sum[x - i + min(j - x, 1 + y - j)]++;
			}
			else if (i > x && i < y)
			{
				if (j > y)sum[j - y + min(i - x + 1, y - i)]++;
				else sum[min(j - i, i - x + y - j + 1)]++;
			}
			else
			sum[j - i]++;
		}
	}
	for (int i = 1; i < n; i++) cout << sum[i] << endl;
}

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

typedef vector<double> V;
typedef vector<V>   VV;
typedef vector<VV>  VVV;
typedef pair<int,int> P;
typedef pair<double,P> PP;

const int INF = 1 << 28;
const double dINF = 1e15;

int main ()
{
    int n, m, p, a, b;
    while (cin >> n >> m >> p >> a >> b, a + b + m + n + p) {
        VV v(m + 1, V(m + 1, INF));
        V t(n);
        vector<vector<pair<int,double> > > e(m + 1);
        for (int i = 0; i < n; i++) cin >> t[i];
        for (int i = 0; i <= m; i++) v[i][i] = 0;

        for (int i = 0; i < p; i++) {
            int x, y;
            double z;
            cin >> x >> y >> z;
            e[x].push_back(P(y, z));
            e[y].push_back(P(x, z));
            v[x][y] = v[y][x] = z;
        }


        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= m; j++) {
                for (int k = 1; k <= m; k++) {
                    v[j][k] = min(v[j][k], v[j][i] + v[i][k]);
                }
            }
        }

        // cout << "DBG > succes" << endl;

        if (v[a][b] == INF) {
            cout << "Impossible" << endl;
        } else {
            priority_queue<PP, vector<PP>, greater<PP> > pq;
            vector<vector<double> > dp((1 << n), V(m + 1, INF));
            dp[0][a] = 0.;
            pq.push(PP(0, P(0, a)));
            double res = dINF;

            while (pq.size()) {
                PP pp = pq.top(); pq.pop();
                double cost = pp.first;
                int used = pp.second.first;
                int now = pp.second.second;

                if (dp[used][now] < cost) continue;

                for (int i = 0; i < e[now].size(); i++) {
                    int next = e[now][i].first;
                    double dis = e[now][i].second;
                    for (int j = 0; j < n; j++) {
                        double cost_ = dis / t[j] + cost;
                        if (~used & (1 << j) && dp[used | (1 << j)][next] > cost_) {
                            dp[used | (1 << j)][next] = cost_;
                            pq.push(PP(cost_, P(used | (1 << j), next)));
                            if (next == b) res = min(res, cost_);
                        }
                    }
                }
            }
            if (res == dINF) cout << "Impossible" << endl;
            else printf("%.3f\n", res);
        }

    }

    return 0;
}

Measured memory_bytes: 2832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"

int main(){
    int n,m,x,temp,ans1 = 0,ans2 = 0;
    int cost[101] = {0};
    cin >> n >> m >> x;
    REP(i,m) {
        cin >> temp;
        cost[temp] = 1;
    }
    REP(i,x) ans1 += cost[i];
    FOR(i,x,n+1) ans2 += cost[i];
    cout << min(ans1,ans2) << "\n";
    
    return 0;
}

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

using namespace std;

#define ll long long

void solve() {
	string a, b;
	cin >> a >> b;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	int mx = max(a.length(), b.length());
	for (int i = 0; i < mx; i++) {
		if (b[i] > a[i]) {
			cout << "Yes\n";
			return;
		} else if (a[i] > b[i]) {
			cout << "No\n";
			return;
		}
	}
	cout << "No\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



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

int main(){
  string s;cin>>s;
  int n=s.size(),f=0;
  sort(s.begin(),s.end());
  REP(i,n-1) if(s.at(i)==s.at(i+1)) f=1;
  cout<<(f?"no":"yes");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();

        long[] la = new long[121];
        for (int i = 0; i <= 120; i++) {
            la[i] = (long) i * i * i * i * i;
        }
        out:
        for (int i = 0; i < la.length; i++) {
            for (int j = 0; j < la.length; j++) {
                if (la[i] - la[j] == X) {
                    System.out.println(i + " " + j);
                    break out;
                } else if (la[i] + la[j] == X) {
                    System.out.println(i + " -" + j);
                    break out;
                }
            }
        }
    }
}

Measured memory_bytes: 38676
/*
[abc127] D - Integer Cards
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;
const int MAX_M = 1e5;

int N, M;
ll A[MAX_N];
int B[MAX_M];
ll C[MAX_M];
map<ll, int> m;

ll solve() {
    vector<pli> cb;
    for (int i = 0; i < M; i++) {
        cb.emplace_back(C[i], B[i]);
    }
    for (int i = 0; i < N; i++) {
        cb.emplace_back(A[i], 1);
    }
    sort(cb.begin(), cb.end());

    int rem = N;
    ll ans = 0;
    for (int i = cb.size() - 1; i >= 0; i--) {
        if (rem <= 0) {
            break;
        }
        int d = min(rem, cb[i].second);
        ans += cb[i].first * d;
        rem -= d;
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


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

vector<int> v(105);
int main(void)
{
  int a, b, c;
  cin >> a >> b >> c;
  v[a] = 1;
  v[b] = 1;
  v[c] = 1;

  cout << accumulate(v.begin(), v.end(), 0) << endl;
}

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

int main(){
    string S,S1,S2;
    cin >> S;
    int n;
    n = S.size();
    S1 = S.substr(0,(n-1)/2);
    S2 = S.substr((n+3)/2 - 1);

    bool ans = true;
    string S_ = S;
    reverse(S.begin(), S.end());
    if(S_ != S){
        ans = false;
    }
    string S1_ = S1;
    reverse(S1.begin(), S1.end());
    if(S1_ != S1){
        ans = false;
    }
    string S2_ = S2;
    reverse(S2.begin(), S2.end());
    if(S2_ != S2){
        ans = false;
    }

    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Out(S) cout << S << endl
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B,C,D=0;
  cin >> B >> A;
  Vecpr P(B);
  rep(i,B)cin >> P[i].first >> P[i].second;
  Sort(P);
  rep(i,B){
    if(A>=P[i].second){
      D+=P[i].first*P[i].second;
      A-=P[i].second;
    }else{
      D+=P[i].first*A;
      break;
    }
  }
  Out(D);
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
signed main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a!=c)
    cout<<1<<endl;
  else
    cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n,k;
  cin>>n>>k;
  int sum=1;
  rep(i,n){
    if(sum*2<sum+k)sum*=2;
    else sum+=k;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
def butterfly(arr, MOD):
    n = len(arr)
    h = (n - 1).bit_length()
    sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601,
                842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 0, 0, 0, 0, 0, 0, 0, 0, 0)
    for ph in range(1, h + 1):
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        now = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p] * now
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (l - r) % MOD
            now *= sum_e[(~s & -~s).bit_length() - 1]
            now %= MOD

def butterfly_inv(arr, MOD):
    n = len(arr)
    h = (n - 1).bit_length()
    sum_ie = (86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543,
                109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 0, 0, 0, 0, 0, 0, 0, 0, 0)
    for ph in range(1, h + 1)[::-1]:
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        inow = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p]
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (MOD + l - r) * inow % MOD
            inow *= sum_ie[(~s & -~s).bit_length() - 1]
            inow %= MOD



def convolution(a, b, MOD=10**9+7):
    n = len(a)
    m = len(b)
    if not n or not m: return []
    if min(n, m) <= 50:
        if n < m:
            n, m = m, n
            a, b = b, a
        res = [0] * (n + m - 1)
        for i in range(n):
            for j in range(m):
                res[i + j] += a[i] * b[j]
                res[i + j] %= MOD
        return res
    z = 1 << (n + m - 2).bit_length()
    a += [0] * (z - n)
    b += [0] * (z - m)
    butterfly(a, MOD)
    butterfly(b, MOD)
    for i in range(z):
        a[i] *= b[i]
        a[i] %= MOD
    butterfly_inv(a, MOD)
    a = a[:n + m - 1]
    iz = pow(z, MOD - 2, MOD)
    for i in range(n + m - 1):
        a[i] *= iz
        a[i] %= MOD
    return a

import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

print(*convolution(A, B, 998244353))


# def atcoder_practice2_f():
#     import sys
#     input = sys.stdin.buffer.readline

#     N, M = map(int, input().split())
#     A = [int(x) for x in input().split()]
#     B = [int(x) for x in input().split()]

#     print(*convolution(A, B, 998244353))


# if __name__ == "__main__":
#     atcoder_practice2_f()


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

int n = 10;
int S[10];
int idx = 0;
int bit_array[1024][10];

int F[100][10];
int P[100][11];

void rec(int i) {
    if (i == n) {
        for (int j = 0; j < n; j++) bit_array[idx][j] = S[j];
        idx++;
        return;
    }

    rec(i + 1);
    S[i] = 1;
    rec(i + 1);
    S[i] = 0;

    return;
}

void makeCombination() {
    for (int i = 0; i < n; i++) {
        S[i] = 0;
    }
    rec(0);
    return;
}

int main() {
    makeCombination();

    int N, profit, open_num, max_prof = -1000000000;
    cin >> N;

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

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

    for (int i = 1; i < 1024; i++) {
        profit = 0;
        for (int j = 0; j < N; j++) {
            open_num = 0;
            for (int k = 0; k < n; k++) {
                if (bit_array[i][k] == 1 && F[j][k] == 1) open_num++;
            }
            profit += P[j][open_num];
        }
        max_prof = max(max_prof, profit);
    }

    cout << max_prof << endl;

    return 0;
}

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

ll arr[MAXN];
ll book[MAXN];
ll dp[MAXN];
int main(){
    memset(dp,0,sizeof(dp));
    memset(book,0,sizeof(book));
    ll n;
    char x;
    ll y;
    cin >> n;
    for(ll i=1;i<=n;i++){
        cin >> x;
        y=x-'a'+1;
        arr[i]=y;
    }

    sort(arr+1,arr+n+1);
    for(ll i=1;i<=n;i++){
        if(!book[arr[i]])
            dp[i]=(2*dp[i-1]+1)%mod;
        else{
            int t=book[arr[i]];
            dp[i]=(dp[i-1]*2%mod+mod-dp[t-1]%mod)%mod;
        }
        book[arr[i]]=i;
    }
    printf("%lld\n",dp[n]%mod);
return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct pol{
	int X;int Y;int Z;
  bool operator<(const pol&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
char P[1000][1000];
int main(){
	int C,N;
	cin>>C>>N;
	FOR(i,0,N){
		FOR(j,0,N){
			cin>>P[i][j];
		}
	}
	int ans=0;
	set<int> S;
	FOR(i,0,C){
		if(i==0){
			FOR(j,0,N/2){
				FOR(k,0,N/2){
					if(P[j][k]==P[j][N-k-1]&&P[j][k]==P[N-j-1][k]&&P[j][k]==P[N-j-1][N-k-1]){
						continue;
					}else{
						S.insert(j*N+k);
					}
				}
			}
		}else{
			int D;
			cin>>D;
			FOR(j,0,D){
				int r,c;
				cin>>r>>c;
				r--;c--;
				P[r][c]=(P[r][c]=='0'?'1':'0');
				if(r>=N/2){
					r=N/2-r%(N/2)-1;
				}
				if(c>=N/2){
					c=N/2-c%(N/2)-1;
				}
				if(S.find(r*N+c)==S.end()){
					S.insert(r*N+c);
				}else{
					if(P[r][c]==P[r][N-c-1]&&P[r][c]==P[N-r-1][c]&&P[r][c]==P[N-r-1][N-c-1]){
						set<int>::iterator it=S.find(r*N+c);
						S.erase(it);
					}
				}
			}
		}
		if((int)S.size()==0){
			ans++;
		}
  }
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 13080
#include "bits/stdc++.h"
// #define rep(i, n) for(int i = 0; i < (int)(n); i++)
// #define all(a) (a).begin(),(a).end()
// #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
// int gcd(int a, int b){return b ? gcd(b, a%b) : a;}

#define int long long
#define SIZE 100000

using namespace std;

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

  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // int n; cin >> n;

  int a; cin >> a;
  int b; cin >> b;

  if (b % a == 0) cout << a + b << endl;
  else cout << b - a << endl;
  
  // array<int, SIZE> a;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) cin >> *it;
  // for (auto it = a.begin(); it < a.begin() + n; ++it) num += *it;

  // cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
ll r[N], f[N]; 

int main(){
    ll n, k; 
    string s; 
    cin >> n >> k >> s;
    if(k == 2 || k == 5){
        ll an = 0;
        for(int i = 0; i<n; ++i){
            if((s[i]-'0') % k == 0){
                an = (ll)(an + (i+1));
            }
        }
        return printf("%lld\n", an),0;
    }
    reverse(all(s));
    ll cur = 0, t = 1; 
    for(int i = 0; i<n; ++i){
        r[i] = (1ll * t * (s[i]-'0'))%k;
        t = (1ll * t * 10)%k;
    }
    ll an = 0;
    t = 0;
    for(int i = 0; i<n; ++i){
        t = (t%k + r[i]%k) % k;
        ++f[t];
    }
    for(int i = 0; i<k; ++i){
        an = (ll) (an + (1ll * f[i] * (f[i]-1))/2ll);
    }
    an = (ll) (an + f[0]);
    printf("%lld\n", an);
}

Measured memory_bytes: 2180
n = gets.chomp

a = ""
b = ""

n_s = n.split("")
first = n_s[0]
first_up = first == '9' ? '1' : (first.to_i + 1).to_s

n_s.each{
	a += first
	b += first_up
}

if n <= a then
	puts a
else
	puts b
end


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> qa(Q), qb(Q), qc(Q), qd(Q);
  for (int i = 0; i < Q; i++){
    cin >> qa[i] >> qb[i] >> qc[i] >> qd[i];
  }
  long long s_max = 0;
  for (int a = 1; a <= M; a++){
  for (int b = a; b <= M; b++){
  for (int c = b; c <= (N >= 3 ? M : b); c++){
  for (int d = c; d <= (N >= 4 ? M : c); d++){
  for (int e = d; e <= (N >= 5 ? M : d); e++){
  for (int f = e; f <= (N >= 6 ? M : e); f++){
  for (int g = f; g <= (N >= 7 ? M : f); g++){
  for (int h = g; h <= (N >= 8 ? M : g); h++){
  for (int i = h; i <= (N >= 9 ? M : h); i++){
  for (int j = i; j <= (N >= 10 ? M : i); j++){
    vector<int> A;
    A.push_back(a);
    if (N >= 2) A.push_back(b);
    if (N >= 3) A.push_back(c);
    if (N >= 4) A.push_back(d);
    if (N >= 5) A.push_back(e);
    if (N >= 6) A.push_back(f);
    if (N >= 7) A.push_back(g);
    if (N >= 8) A.push_back(h);
    if (N >= 9) A.push_back(i);
    if (N >= 10) A.push_back(j);
    long long score = 0;
    for (int q = 0; q < Q; q++){
      if (A[qb[q] - 1] - A[qa[q] - 1] == qc[q]){
        score += qd[q];
      }
    }
    /*
    cout << A[0] << ' ' << A[1] << ' ' << A[2] << endl;
    cout << "score = " << score << endl;
    */
    s_max = max(s_max, score);
  }
  }
  }
  }
  }
  }
  }
  }
  }
  }
  cout << s_max << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    Map<Integer, Integer> map = new HashMap<Integer, Integer>();

    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      int v = 1;
      if (map.containsKey(a)) {
        v = map.get(a);
        v++;
      }
      map.put(a,v);
    }

    sc.close();

    // 降順に並び替え
    List<Map.Entry<Integer, Integer>> list_entries = new ArrayList<Map.Entry<Integer, Integer>>(map.entrySet());
        
    Collections.sort(list_entries, new Comparator<Map.Entry<Integer, Integer>>() {
      public int compare(Map.Entry<Integer, Integer> obj1, Map.Entry<Integer, Integer> obj2) {
        return obj2.getValue().compareTo(obj1.getValue());
      }
    });

    int count = 0;
    int result = 0;

    for (Map.Entry<Integer, Integer> map_ : list_entries) {
      if (count == K){
        result += map_.getValue();
      } else {
        count++;
      }
    }

    System.out.println(result);

  }

}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	ll K;
	cin >> K;
	if (K == 0) {
		cout << 2 << "\n" << 1 << " " << 1 << "\n";
	}
	else if (K == 1) {
		cout << 2 << "\n" << 0 << " " << 2 << "\n";
	}
	else if (K <= 50) {
		cout << K << "\n";
		rep(i, K)cout << i + 1 << " ";
		cout << "\n";
	}
	else {
		cout << 50 << "\n";
		vector<ll>c(50);
		K -= 50;
		rep(i, 50)c[i] += i + 1 + K / 50;
		K %= 50;
		rep(i, K)c[49 - i]++;
		rep(i, 50)cout << c[i] << " ";
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 100000000 
#define N 100
 
int n;
int size[N];
int to[N][N];
int cost[N][N];
int dist[N];
  
void DFS(int,int);
  
main(int argc,char *argv[]){
  int i, j;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    int u;
    scanf("%d", &u);
    scanf("%d", &size[u]);
    for(j=0;j<size[u];j++){
      scanf("%d", &to[u][j]);
      scanf("%d", &cost[u][j]);
    }
  }
  for(i=0;i<n;i++) dist[i] = INF;
  DFS(0, 0);
  for(i=0;i<n;i++){
    printf("%d %d\n", i, dist[i]);
  }
  return 0;
}
void DFS(int p, int c){
  int i;
  dist[p] = c;
  for(i=0;i<size[p];i++){
    if(dist[to[p][i]] > c + cost[p][i])
      DFS(to[p][i], c + cost[p][i]);
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200)cout<<s;
    else cout<<"red";
}

Measured memory_bytes: 256
require 'tsort'

n = gets.to_i
m = gets.to_i

g = {}
(1..n).each{|i| g[i] = []}

m.times do
	i, j = gets.split.map &:to_i	
	g[j] << i
end

class << g
	include TSort
	alias :tsort_each_node :each_key
	def tsort_each_child(i, &block)
		self[i].each(&block)
	end
end

puts g.tsort * ' '

Measured memory_bytes: 8764
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
    int n, u, v, m;
    cin >> n >> u >> v >> m;
    vector<P> usa(1000010, P(-1, -1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int a;
            cin >> a;
            usa[a] = P(i, j);
        }
    }
    vector<P> nek(1000010, P(-1, -1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int a;
            cin >> a;
            nek[a] = P(i, j);
        }
    }
    vector<int> cui(n, 0);
    vector<int> cuj(n, 0);
    vector<int> cni(n, 0);
    vector<int> cnj(n, 0);
    int cuc1 = 0, cuc2 = 0, cnc1 = 0, cnc2 = 0;
    int cu = 0, cn = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        cin >> p;
        int wu = 0, wn = 0;
        if (usa[p].first != -1) {
            if (++cui[usa[p].first] == n)
                ++cu;
            if (++cuj[usa[p].second] == n)
                ++cu;
            if (usa[p].first == usa[p].second && ++cuc1 == n)
                ++cu;
            if (usa[p].first + usa[p].second == n - 1 && ++cuc2 == n)
                ++cu;

            if (n == 1)
                cu = min(cu, 1);

            wu = cu >= u;
        }
        if (nek[p].first != -1) {
            if (++cni[nek[p].first] == n)
                ++cn;
            if (++cnj[nek[p].second] == n)
                ++cn;
            if (nek[p].first == nek[p].second && ++cnc1 == n)
                ++cn;
            if (nek[p].first + nek[p].second == n - 1 && ++cnc2 == n)
                ++cn;

            if (n == 1)
                cn = min(cn, 1);

            wn = cn >= v;
        }
        if (wu && wn) {
            puts("DRAW");
            return 0;
        }
        if (wu) {
            puts("USAGI");
            return 0;
        }
        if (wn) {
            puts("NEKO");
            return 0;
        }
    }
    puts("DRAW");
    return 0;
}

Measured memory_bytes: 18412
def f(k):
    n = 50
    a = [k//n + n-1] * n
    for i in range(k%n):
        for j in range(n):
            if i == j:
                a[j] += n
            else:
                a[j] -= 1
    return a

def solve(k):
    a = f(k)
    print(len(a))
    print(" ".join(map(str, a)))

solve(k=int(input()))

Measured memory_bytes: 3060