akhauriyash/Code-Regression huggingface dataset:
#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 n; cin >> n;
  int Max = 0;
  vector<int> num(1.0e+5,0);
  rep(i,n){
    int x; cin >> x;
    if(x!=0) num[x-1]++;
    num[x]++;
    if(x!=1.0e+5) num[x+1]++;
    Max=max(Max,x);
  }

  int ans=0;

  for(int i=0;i<=Max;i++){
    ans = max(ans,num[i]);
  }

  cout << ans <<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int i, j, k, a, b;
	map<int, int> ct;
	for (i = 0; i < 3; i++) {
		cin >> a >> b;
		ct[a]++;
		ct[b]++;
	}
	bool valid = true;
	for (auto p : ct) {
		if (p.second > 2) valid = false;
	}
	if (valid) cout << "YES";
	else cout << "NO";

	return 0;
}



Measured memory_bytes: 256
import math

N=int(input())
A=list(map(int, input().split()))
a=A[0]
if 0 in A:
  print(0)
  exit(0)  

for i in range(1,len(A)):
  a*=A[i]
  if pow(10,18)<a:
    print('-1')
    exit(0)
print(a)

Measured memory_bytes: 22320
import java.util.*;
import java.io.*;

public class Main {

  void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    int m = in.nextInt();
    int k = in.nextInt();

    UnionFind uf = new UnionFind(n);
    int[] deg = new int[n];
    for (int i = 0; i < m; ++i) {
      int u = in.nextInt() - 1;
      int v = in.nextInt() - 1;

      deg[u]++;
      deg[v]++;
      uf.union(u, v);
    }

    int[] ans = new int[n];
    for (int i = 0; i < n; ++i) {
      ans[i] = uf.sizeOfSet(i) - deg[i] - 1;
      //System.err.println(i + " " + uf.sizeOfSet(i) + " " + deg[i]);
    }

    for (int i = 0; i < k; ++i) {
      int u = in.nextInt() - 1;
      int v = in.nextInt() - 1;

      if (uf.isSameSet(u, v)) {
        ans[u]--;
        ans[v]--;
      }
    }

    for (int i = 0; i < n; ++i) {
      out.print(ans[i] + " ");
    }
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}

class UnionFind {
  int[] p, size;
  
  public UnionFind(int n) {
    p = new int[n];
    size = new int[n];
    for (int i = 0; i < n; ++i) {
      size[i] = 1;
      p[i] = i;
    }
  }

  public int find(int u) {
    if (p[u] == u) {
      return u;
    }

    return p[u] = find(p[u]);
  }

  public boolean isSameSet(int u, int v) {
    return find(u) == find(v);
  }

  public int sizeOfSet(int u) {
    return size[find(u)];
  }

  public void union(int u, int v) {
    int x = find(u);
    int y = find(v);

    if (x != y) {
      if (size[x] > size[y]) {
        size[x] += size[y];
        p[y] = x;
      } else {
        p[x] = y;
        size[y] += size[x];
      }
    }
  }
}


Measured memory_bytes: 45912
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 1000000007

using namespace std;

typedef long long int lli;
lli dp[100005][13];
string s;

lli solve(int i, int rem){
	lli &res = dp[i][rem];

	if(res > 0) return res;
	if(i == s.size()) return res = (rem == 5);
	

	if(s[i] == '?'){
		for(int digit=0; digit<10; digit++){
			int new_rem = (rem * 10 + digit) % 13;
			res += solve(i+1, new_rem);
			res %= MOD;
		}
	}else{
		int digit = s[i]-'0';
		int new_rem = (rem * 10 + digit) % 13;
		res += solve(i+1, new_rem);
		res %= MOD;
	}
	return res % MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin >> s;
	//memset(dp, -1, sizeof(dp));
	cout << solve(0, 0) % MOD;


	return 0;
}

Measured memory_bytes: 16848
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color, D; vll path;
//***********//
int main() {
	ll D;
	cin >> D;
	if (D == 25) cout << "Christmas";
	else if (D == 24) cout << "Christmas Eve";
	else if (D == 23) cout << "Christmas Eve Eve";
	else if (D == 22) cout << "Christmas Eve Eve Eve";
}

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

int main() {
  int map[3] = {};
  string s; cin >> s;
  
  for(int i=0; i<3; i++){
    if(s[i] == 'a') map[0]++;
    if(s[i] == 'b') map[1]++;
    if(s[i] == 'c') map[2]++;
  }
  
  bool flag = true;
  for(int i=0; i<3; i++) if(map[i]!=1) flag = false;
   
  cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
    int[] pena = new int[n];
    for(int i = 0; i < n; i++) pena[i] = 0;
    int acCount = 0;
    int waCount = 0;

    for(int i = 0; i < m; i++)
    {
		  string[] inputa = Console.ReadLine().Split(' ');
      int p = int.Parse(inputa[0])-1;

      if(inputa[1] == "AC" && pena[p] != -1)
      {
        acCount++;
        waCount += pena[p];
        pena[p] = -1;
      }else if(inputa[1] == "WA" && pena[p] != -1) pena[p]++;
    }

		Console.WriteLine(acCount+" "+waCount);
	}
}

Measured memory_bytes: 17224
#include <bits/stdc++.h>
using namespace std;
const int N = 55556;

int arr[N];
vector<int> prim;

void Erat(){
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 2; i < N; i++){
		if(arr[i]){
			//cout << i << endl;
            if(i % 5 == 1) prim.push_back(i);
		}
	}
}


int main(){
    int n;
    cin >> n;
    //素数を生成
    Erat();

    //for(int i = 0; i < (int)prim.size(); i++) cout << prim[i] << endl;


    //出力
    for(int i=0; i < n; i++){
        if(i == n-1) cout << prim[i] << endl;
        else cout << prim[i] << " ";
    }


    return 0;
}


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

const int INF = 1e9 + 5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    vector<int> wt(n), vl(n);
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> wt[i] >> vl[i];
        sum += vl[i];
    }
    vector<int> dp(sum + 1, INF);
    // dp[i] - lowest weight with value i
    dp[0] = 0;
    for(int item = 0; item < n; item++) {
        for(int value = sum - vl[item]; value >= 0; value--) {
            dp[value+vl[item]] = min(dp[value+vl[item]], dp[value] + wt[item]);
        }
    }

    int answer = 0;
    for(int i = 0; i <= sum; i++) {
        if (dp[i] <= w) {
            answer = i;
        }
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    int n; cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));
    double res=0;
    while(v.size()>1){
        double item=(v[0]+v[1])/2;
        v.erase(v.begin(),v.begin()+2);
        v.PB(item);
        sort(all(v));
    }
    cout<<v[0]<<endl;

}

Measured memory_bytes: 256
a, b, c, d = gets.chomp.chars.map(&:to_i)
pm = [:+, :-]
pm.product(pm, pm).each do |op1, op2, op3|
  if a.send(op1, b).send(op2, c).send(op3, d) == 7
    puts "#{a}#{op1}#{b}#{op2}#{c}#{op3}#{d}=7"
    exit 0
  end
end
exit 1


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

int main(){
	LL n, x;
	cin >> n >> x;
	LL a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	LL m[n][n];
	for(int i = 0; i < n; i++){
		for(int j = i; j < n; j++){
			m[i][j] = 1100000000;
			if(j > i) m[i][j] = m[i][j-1];
			m[i][j] = min(m[i][j], a[j]);
		}
	}
	LL d = 1e18;
	for(int c = 0; c <= n; c++){
		LL ans = c*x;
		for(int i = 0; i < n; i++){
			if(i+c < n){
				ans += m[i][i+c];
			} else {
				ans += min(m[i][n-1],m[0][(i+c)%n]);
			}
		}
		d = min(d,ans);
	}
	cout << d << endl;
}


Measured memory_bytes: 22912
p=0
ans=[]
while p==0:
    s=input()
    if s=="-":
        p=1
    else:
        m=int(input())
        l=len(s)
        for i in range(m):
            h=int(input())
            s=s[h:l]+s[0:h]
        ans.append(s)
for i in ans:
    print(i)


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    ll x;
    cin >> x;
    ll a = x / 500;
    a *= 1000ll;
    x %= 500;
    ll b = x / 5;
    b *= 5;
    cout << a + b << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main()
{
    int n, in;
    std::cin >> n;
    std::vector<int> v;
    for(int i = 0; i < n; i++){
        std::cin >> in;
        v.push_back(in);
    }
    sort(v.begin(), v.end());
    int answer = 1;
    for(int i = 0; i < n-1; i++){
        if(v[i] < v[i+1]){
            answer = answer + 1;
        }
    }
    std::cout << answer << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String s1[] = s.split("");
    Arrays.sort(s1);
    if (!(s1[0].equals(s1[3]))){
      if (s1[0].equals(s1[1]) && s1[2].equals(s1[3])){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35648
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;

ll n, k, l;
ll p, q;

ll rail[200005];
ll tree[200005];

map<ll, ll> mp[200005];

void init(ll n);
ll   root(ll x, ll tree[]);
void merge(ll a, ll b, ll tree[]);

int main()
{
    scanf("%lld %lld %lld", &n, &k, &l);

    init(n);

    for (int i = 0; i < k; i++) {
        scanf("%lld %lld", &p, &q);

        merge(p, q, rail);
    }

    for (int i = 0; i < l; i++) {
        scanf("%lld %lld", &p, &q);

        merge(p, q, tree);
    }

    for (int i = 1; i <= n; i++) {
        mp[root(i, rail)][root(i, tree)]++;
    }

    for (int i = 1; i <= n; i++) {

        if (i > 1) {
            printf(" %lld", mp[root(i, rail)][root(i, tree)]);
        }
        else {
            printf("%lld", mp[root(i, rail)][root(i, tree)]);
        }
    }
    putchar('\n');

    return 0;
}

void init(ll n)
{
    for (int i = 0; i <= n; i++) {
        tree[i] = -1;
        rail[i] = -1;
    }

    return;
}

ll root(ll x, ll tree[])
{
    if (tree[x] < 0) {
        return x;
    }
    
    tree[x] = root(tree[x], tree);

    return tree[x];
}

void merge(ll a, ll b, ll tree[])
{
    a = root(a, tree);
    b = root(b, tree);

    if (a != b) {
        tree[a] += tree[b];
        tree[b] = a;
    }

    return;
}


Measured memory_bytes: 24576
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	bb := make([]int, n+1)
	ww := make([]int, n+1)
	for i := 0; i < n; i++ {
		if s[i] == '#' {
			bb[i+1]++
		}
		bb[i+1] += bb[i]
	}
	for i := n - 1; i >= 0; i-- {
		if s[i] == '.' {
			ww[i]++
		}
		ww[i] += ww[i+1]
	}
	var ans int
	ans = n
	for i := 0; i < n+1; i++ {
		if ans > ww[i]+bb[i] {
			ans = ww[i] + bb[i]
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 5516
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

const ll mod = 1e9 + 7;

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

vector <vl> dp(2002, vl (2002, 0));

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll s;
	cin >> s;
	ll ans = 0;
	for (ll i = 3; i <= s; i++){
		dp[0][i] = 1;
		if(i==s)
			ans++;
	}
	for (ll i = 1; i < s; i++) {
		for (ll j = 1; j <= s; j++) {
			dp[i - 1][j] += dp[i - 1][j - 1];
			dp[i - 1][j] %= mod;
		}
		for (ll j = 3 * i + 3; j <= s; j++) {
			ll ma = j - 3;
			ll mi = 3 * (i);
			if (ma < mi)
				continue;
			dp[i][j] = (dp[i][j] + dp[i - 1][ma] - dp[i - 1][mi - 1] + mod) % mod;
			//cout << i << " " << j << " " << dp[i][j] << "\n";
		}
		ans = (ans + dp[i][s]) % mod;
	}
	ans = (ans) % mod;
	cout << ans << "\n";
}


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

int  main(){
int n;
cin >>n;
int c1=0,c2=0,c3=0,c4=0;
vector<string> ary;
for(int i=0; i<n; i++){
string s;
cin >>s;
ary.push_back(s);
}
for(int i=0; i<n; i++){
if(ary[i]=="AC") c1++;
else if(ary[i]=="WA") c2++;
else if (ary[i]=="TLE") c3++;
else if (ary[i]=="RE")c4++;
}
cout <<"AC" <<" " <<"x" <<" " <<c1 <<endl;
cout <<"WA" <<" " <<"x" <<" " <<c2 <<endl;
cout <<"TLE" <<" " <<"x" <<" " <<c3 <<endl;
cout <<"RE" <<" " <<"x" <<" " <<c4 <<endl;
return 0;
}

Measured memory_bytes: 7464
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> h(n); REP(i, n) cin >> h[i];
  int ans = 0, mx = 0;
  REP(i, n) {
    if (mx <= h[i]) {
      mx = h[i];
      ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    count = 0
    for x in range(m):
      for y in range(m):
        if b[x][y]!=a[i+x][j+y]:
          break
        else:
          count += 1
    if count == m**2:
      print('Yes')
      exit()
print('No')

Measured memory_bytes: 3064
/* AtCoder My Practice
 * author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>
#include <stdlib.h>

#define N_MAX (200001)

typedef struct _range {
    int upper, lower;
    struct _range *ubound, *lbound;
} Range;

Range *newRange(int lower, int upper) {
    Range *range = (Range*)malloc(sizeof(Range));
    range->lower = lower;
    range->upper = upper;
    return range;
}

int idx[N_MAX];
long long sum;
Range range;

void calc(int value, int index) {
    Range *tmp = &range;
    long long len1, len2, len3;
    for (;;) {
        if (tmp->lower <= index && index <= tmp->upper) {
            len1 = (long long)(tmp->upper - tmp->lower + 1);
            len2 = (long long)(tmp->upper - index);
            len3 = (long long)(index - tmp->lower);
            sum += ((len1 * (len1 + 1LL) - (len2 * (len2 + 1LL)) - (len3 * (len3 + 1))) >> 1) * (long long)value;
            if (tmp->lower == index) {
                tmp->lower++;
            } else if (tmp->upper == index) {
                tmp->upper--;
            } else {
                tmp->lbound = newRange(tmp->lower, index - 1);
                tmp->ubound = newRange(index + 1, tmp->upper);
                tmp->lower = tmp->upper = index;
            }
            break;
        } else if (index < tmp->lower) {
            tmp = tmp->lbound;
        } else {
            tmp = tmp->ubound;
        }
    }
}

char buf[N_MAX * 10];
char *p = buf;

int getInt(void) {
    int v = 0;
    while (*p < '0' || '9' < *p) p++;
    while ('0' <= *p && *p <= '9') {
        v = v * 10 + (int)(*p - '0');
        p++;
    }
    return v;
}

int main(void){
    int i, n;
    int a;
    
    a = fread(buf, sizeof(char), sizeof(buf), stdin);
    
    n = getInt();

    for (i = 0; i < n; i++) {
        a = getInt();
        idx[a] = i;
    }
    
    range.upper = n - 1;
    
    for (i = 1; i <= n; i++) {
        calc(i, idx[i]);
    }
    
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1e9 ;
const int MAXN = 10100 ;
vector<pair<int, int> > edge[MAXN];
int n;
int d[MAXN], vis[MAXN];
priority_queue<pair<int, int> > q;
void Dij()
{
	for (int i = 0; i < n; ++i) d[i] = INF;
	d[0] = 0;
	q.push(make_pair(0, 0)) ;
	vis[0] = 1;
	while (! q.empty())
	{
		pair<int, int> cur = q.top();
		int u = cur.second;
		q.pop();
		vis[u] = 2;
		if (d[u] < cur.first * (-1)) continue ;
		for (int i = 0; i < edge[u].size(); ++i)
		{
			int to = edge[u][i].first;
			if (vis[to] == 2) continue ;
			if (d[to] > d[u] + edge[u][i].second)
			{
				d[to] = d[u] + edge[u][i].second;
				q.push(make_pair(d[to] * (-1), to));
				vis[to] = 1;
			}
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 1; j <= k; ++j)
		{
			int v, c;
			cin >> v >> c;
			edge[u].push_back(make_pair(v, c));
		}
	}
	Dij();
	for (int i = 0; i < n; ++i)
		cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
	return 0;
}



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

int main()
{
  int N,t[50];
  char X[100],s[50][100];
  int i,j,len,x,ans = 0;

  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%s",s[i]);
    scanf("%d",&t[i]);
  }
  scanf("%s",X);

  len = strlen(X);

  for(i = 0;i < N;i++){
    if(X[0] == s[i][0]){
      j = 0;
      for(j = 0;j < len;j++){
	if(X[j] != s[i][j]){
	  break;
	}	  
      }
    }
    if(j == len){
      x = i;
    }
    j = 0;
  }

  for(i = x + 1;i < N;i++){
    ans += t[i];
  }

  printf("%d\n",ans);

return 0;
}
  


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void)
{
  long long int n;
  cin >> n;
  
  vector<long long int> a(n);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  
  for(int i = 0; i < n; i++)
  {
    if(a[i] == a[i+1])
    {
      cout << "NO";
      return 0;
    }
  }
  
  cout << "YES";
  return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


void main() {
    immutable int M = 31;
    auto N = readln.chomp.to!int;
    auto X = readln.split.map!(to!int).array;
    auto L = readln.chomp.to!int;
    auto Q = readln.chomp.to!int;
    auto AB = Q.iota.map!(_ => readln.split.map!(to!int).array).array;


    auto doubling = new int[][](M, N);
    int r = -1;
    foreach (i; 0..N) {
        while (r < N - 1 && X[r+1] - X[i] <= L) r++;
        doubling[0][i] = r;
    }

    foreach (i; 1..M) {
        foreach (j; 0..N) {
            doubling[i][j] = doubling[i-1][doubling[i-1][j]];
        }
    }

    foreach (ab; AB) {
        ab.sort();
        auto a = ab[0]-1;
        auto b = ab[1]-1;
        int ans = 0;
        while (true) {
            if (doubling[0][a] >= b) {
                ans += 1;
                break;
            }
            int i = -1;
            while (doubling[i+1][a] < b) i++;
            a = doubling[i][a];
            ans += (1 << i);
        }
        
        ans.writeln;
    }
}


Measured memory_bytes: 30052
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  rep(i, N) cin >> D[i];
  int M;
  cin >> M;
  vector<int> T(M);
  rep(i, M) cin >> T[i];
  map<int, int> mp;
  rep(i, M) mp[T[i]]++;
  rep(i, N) mp[D[i]]--;
  for (auto e : mp) {
    if (e.second > 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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


using namespace std;

int main() {
 int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  vector<int> dp(n, INT_MAX);
  
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= max(0, i - k); j--) {
     dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j])); 
    }
  }
  cout << dp[n - 1];
}

Measured memory_bytes: 1152
import math
n = int(input())

x = int(n / 1.08)

if math.floor(x*1.08) == n:
    print(x)
elif math.floor((x - 1) * 1.08) == n:
    print(x-1)
elif math.floor((x + 1) * 1.08) == n:
    print(x+1)
else:
    print(':(')



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,a0) memset(a,a0,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii;
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
#define int ll
int n,ans=0;
signed main(){
	cin>>n;
	int x=100;
	while(x<n){
		x+=floor(x*0.01);
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
    int N;
    cin >> N;
    int res;
    res = N* N;

    cout << res << endl;

    return 0;    
}



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

int main(){
	int a;
	int b = 0;
	string s;
	cin >> a >> s;
for(int i = 0; i< s.size(); i++){
   if(s[i] == 'R'){
		 b++;
	 }
}
if(b <= a / 2){
	cout << "No";
}
else{
	cout << "Yes";
}
	return 0;
}

Measured memory_bytes: 384
k, n = map(int, input().split())
a = [int(x) for x in input().split()]

dis = [0] * n

for i in range(n-1):
    dis[i] = abs(a[i+1] - a[i])

dis[n-1] = min(abs(a[n-1] - a[0]), abs((a[0]+k)-a[n-1]))

print(sum(dis)-max(dis))

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

const int N = 2e5 + 100;

int n, q;
char t[N], d[N];
string s;

int get(int dex) {
	for (int i = 0; i < q; i++)
		if(t[i] == s[dex]) {
			if(d[i] == 'L')
				dex--;
			else
				dex++;
			if(dex < 0)
				return -1;
			if(dex >= n)
				return 1;
		}
	return 0;
}

int get_l() {
	int l = -1, r = n;
	while(r - l > 1) {
		int c = (l + r) >> 1;
		if(get(c) == -1)
			l = c;
		else
			r = c;
	}
	return l;
}

int get_r() {
	int l = -1, r = n;
	while(r - l > 1) {
		int c = (l + r) >> 1;
		if(get(c) == 1)
			r = c;
		else
			l = c;
	}
	return r;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> q >> s;
	for (int i = 0; i < q; i++)
		cin >> t[i] >> d[i];
	cout << n - (get_l() + 1 + n - get_r());
	return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
const int MAX_V=100100;
vector<int> G[MAX_V];
int dis1[MAX_V];
int dis2[MAX_V];

void dfs1(int v){
	for(int i=0;i<G[v].size();i++){
		if(dis1[G[v][i]]==-1){
			dis1[G[v][i]]=dis1[v]+1;
			dfs1(G[v][i]);
		}
	}
}

void dfs2(int v){
	for(int i=0;i<G[v].size();i++){
		if(dis2[G[v][i]]==-1){
			dis2[G[v][i]]=dis2[v]+1;
			dfs2(G[v][i]);
		}
	}
}



int n;
int u,v;
int main(){
	cin>>n;
	cin>>u>>v;
	u--,v--;
	REP(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	REP(i,MAX_V){
		dis1[i]=-1;
		dis2[i]=-1;
	}
	dis1[u]=0;
	dis2[v]=0;
	dfs1(u);
	dfs2(v);
	int ans=0;
	for(int i=0;i<n;i++){
		if(dis2[i]>=dis1[i]){
			ans=max(ans,dis2[i]);
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d);
    return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
ab=[]
ans=0
for i in range(n):
  a,b=map(int,input().split())
  ab.append([a,b])
ab.sort()
for a,b in ab:
  t=min(b,m)
  ans+=t*a
  m-=t
print(ans)

Measured memory_bytes: 20064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i <(int)(n); i++)
 
int main(){
  int N;
  cin >> N;
  map < string,int> score;
  rep(i,N){
    string a;
    cin >> a;
    if (score.count(a)){
      score[a]++;
    }
    else{
      score[a]=1;
    }
  }
  int max = 0;
  vector < string > vec;
  for (auto i:score){
    if (max >i.second){
    }
    else if (max ==i.second){
      vec.push_back(i.first);
    }
    else if (max <i.second){
      vec.clear();
      string b = i.first;
      vec.push_back(b);
      max = i.second;
    }
  }
  rep (i,vec.size()){
    cout << vec[i] << endl;
  }
}
    
    
    
    

Measured memory_bytes: 26868
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int arr[int(1e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   string s;cin>>s;
   map<char,int> m;
   for(auto x:s)
    m[x]++;
  for(auto x:m)
    if(x.second%2!=0)
    {
      cout<<"No"<<endl;return 0;
    }
    cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

double n;

int main(){
	cin>>n;
	cout<<syosu(9)<<n*n*n/27<<endl;
}

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

using namespace std;

int main(){

    int X,Y;
    cin>>X;
    cin>>Y;
    bool flag=false;
    for(int a=0;a<=100;++a){
        for(int b=0;b<=100;++b){
            if((a+b==X)&&(2*a+4*b==Y)){
                flag=true;
                break;
            }
        }
    }

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

Measured memory_bytes: 3616
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);

  char S[N + 2];
  scanf("%s", S);

  int c[N][2];

  int i, w = 0, b = 0;

  for(i = 0; i < N; i++){
    if(S[i] == 35){
      b++;
    } else {
      w++;
    }
    c[i][0] = w;
    c[i][1] = b;
  }

 int min = w;
 if(b < min) min = b;
 
 for(i = 0; i < N; i++){
   if(min > w - c[i][0] + c[i][1]) min = w - c[i][0] + c[i][1];
 }

 printf("%d\n", min);

 return 0;
}


Measured memory_bytes: 1920
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define A(p) (b[p]-1<0?0:a[p][b[p]-1])
using namespace std;
int m;
int fn(int a[][15],int b[],int p){
  int i;
  for(i=0;i<m+1&&(b[1]||(b[0]&&b[2]));i++){
    if(0){
    }else if(p==0){
      if(b[2]==0||a[1][b[1]-1]>a[2][b[2]-1]){
	b[1]--;
	a[2][b[2]]=a[1][b[1]];
	b[2]++;
	p=3;
      }else{
	b[2]--;
	a[1][b[1]]=a[2][b[2]];
	b[1]++;
	p=1;
      }
    }else if(p==1){
      if(b[0]==0||a[1][b[1]-1]>a[0][b[0]-1]){
	b[1]--;
	a[0][b[0]]=a[1][b[1]];
	b[0]++;
	p=2;
      }else{
	b[0]--;
	a[1][b[1]]=a[0][b[0]];
	b[1]++;
	p=0;
      }
    }else if(p==2){
      if(b[1]==0||a[1][b[1]-1]<a[2][b[2]-1]){
	b[2]--;
	a[1][b[1]]=a[2][b[2]];
	b[1]++;
	p=1;
      }else{
	b[1]--;
	a[2][b[2]]=a[1][b[1]];
	b[2]++;	
	p=3;
      }
    }else if(p==3){
      if(b[1]==0||a[1][b[1]-1]<a[0][b[0]-1]){
	b[0]--;
	a[1][b[1]]=a[0][b[0]];
	b[1]++;
	p=0;
      }else{
	b[1]--;
	a[0][b[0]]=a[1][b[1]];
	b[0]++;	
	p=2;
      }
    }
  }
  return i;
}
int main(){
  int i,j;
  int a[3][15],b[3],c[3][15],d[3],n;
  int mn;
  while(cin>>n>>m&&n+m){
    memset(b,0,sizeof(b));
    for(i=0;i<3;i++){
      cin>>n;
      for(j=0;j<n;j++){
	int p;
	cin>>p;
	a[i][b[i]]=p;
	b[i]++;
      }
    }
    memcpy(c,a,sizeof(c));
    memcpy(d,b,sizeof(d));
    if(0){
    }else if(A(0)<A(1)&&A(1)>A(2)){
      mn=fn(c,d,2);
      memcpy(c,a,sizeof(c));
      memcpy(d,b,sizeof(d));
      mn=min(mn,fn(c,d,3));
    }else if(A(0)>A(1)&&A(1)<A(2)){
      mn=fn(c,d,0);
      memcpy(c,a,sizeof(c));
      memcpy(d,b,sizeof(d));
      mn=min(mn,fn(c,d,1));
    }else if(A(0)<A(1)&&A(1)<A(2)){
      mn=fn(c,d,1);
      memcpy(c,a,sizeof(c));
      memcpy(d,b,sizeof(d));
      mn=min(mn,fn(c,d,2));
    }else if(A(0)>A(1)&&A(1)>A(2)){
      mn=fn(c,d,0);
      memcpy(c,a,sizeof(c));
      memcpy(d,b,sizeof(d));
      mn=min(mn,fn(c,d,3));
    }
    if(mn==m+1)
      cout<<-1<<endl;
    else
      cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt().sortedDescending().toIntArray()
    val a = A[0]
    val h = a / 2
    var b1 = 0; var b2 = 0
    for (n in 1 until N) {
        if (h <= A[n]) {
            b1 = A[n]
            b2 = A[n+1]
        }
    }
    val ans = if (Math.abs(h - b1) <= Math.abs(h - b2)) b1 else b2
    println("${a} ${ans}")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { it.toInt() + d }



Measured memory_bytes: 56540
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	y := nextInt()

	var i, j, k int
	for i = 0; i <= n; i++ {
		for j = 0; j <= n-i; j++ {
			k = n - i - j
			if i*10000+j*5000+k*1000 == y {
				fmt.Printf("%d %d %d\n", i, j, k)
				return
			}
		}
	}

	fmt.Println("-1 -1 -1")
}

func nextInt() int {
	i, err := strconv.Atoi(nextWord())
	pnc(err)
	return i
}

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

func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


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

using namespace std;

#define li int64_t
#define mod (li)(1e9+7)
const int MX1=1e5+5;

int n,k;

void solve(){
	cin>>n>>k;
	int ans=1e8;
	for(int i=1;i<=n;i++){
		int j,cnt=1;
		for(j=1;cnt<=i;j*=2){
			cnt++;
		}
		int p=n-i;
		while(p--){
			j+=k;
		}
		ans=min(ans,j);
	}
	cout<<ans;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FILE
#define ll long long
#define cn continue
using namespace std;
const ll M = 1e3;
ll n  ,mx = -1e9 , m  , ans;
long long a , b , cnt;
string s , s1;
int main(){
    #ifdef FILEs
        freopen(".in" , "r" , stdin);
        freopen(".out" , "w" , stdout);
    #endif
    cin >> n;
    if( !(n % 2) or !(n % 5) )
        return cout << -1 , 0;
    cnt =7 % n;
    ans = 1;
    while( cnt != 0 ){
        cnt = cnt * 10 + 7;
        cnt%=n;
        ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

ll K,a[52],N;

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

    N=50;
    int i;
    for (i=1; i<=N; i++)
        a[i]=N-1;

    ll val=K/N,r=K%N;
    for (i=1; i<=N; i++)
        a[i]+=val-r;

    for (i=1; i<=r; i++)
        a[i]+=N+1;

    cout << N << "\n";
    for (i=1; i<=N; i++)
        cout << a[i] << " ";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}


int main()
{
  
  vector<int> sosuu;
  int N;
  cin >> N;
  FOR(i,2,55556){
    if(IsPrime(i)&&i%5==1){
      sosuu.push_back(i);
    }
  }

  REP(i,N){
    cout << sosuu.at(i);
    if(i!=N-1){
      cout << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 3632
import sys
def input():
	return sys.stdin.readline()[:-1]
n, p = map(int, input().split())
snacks = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0])
dp = [0 for _ in range(p)]
ans = snacks[0][1]

for i in range(1, n):
	x, y = snacks[i-1]
	z = snacks[i][1]
	for j in range(p-1, 0, -1):
		if j >= x:
			dp[j] = max(dp[j], dp[j-x]+y)
		ans = max(ans, dp[j]+z)

print(ans)

Measured memory_bytes: 44780
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MOD = 1e9+7;
const int MAX = 2e5+5;

int expo(int b, int e = MOD-2) {
    int ans = 1;
    while(e) {
        if(e&1) ans = (1LL*ans*b)%MOD;
        b = (1LL*b*b)%MOD; e >>= 1;
    }
    return ans;
}

int main(int argc, char ** argv) {
	int N, M, a, b, ans = 0;
	scanf("%d%d", &N, &M);
	scanf("%d%d", &a, &b); a = N-a+1;
	vector<int> fact(MAX+1, 1);
	REP(i, 1, MAX) fact[i] = (1LL*fact[i-1]*i)%MOD;
	function<int(int,int)> calc = [&](int p, int n) {
	    return (1LL*fact[n]*expo((1LL*fact[n-p]*fact[p])%MOD))%MOD;
	};
	function<int(int,int)> comb = [&](int n, int m) {
	    return calc(n-1, n+m-2);
	};
	REP(i, b+1, M) {
	    int a1 = comb(a-1, i);
	    int a2 = comb(N-a+1, M-i+1);
	    ans = (ans+(1LL*a1*a2)%MOD)%MOD;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pair <int,int>> >
#define vvb vector <vector <bool> >
#define fr(i,n) for (int i = 0; i < (n); i++)
#define frbig(i,n) for (lli i = 0; i < (n); i++)
#define fra(i,a,n) for (lli i = a; i < (n); i++)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
const lli MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    readll(x);
    lli now=100,steps=0;
    while(now/100<x/100){
        lli k=now/100,ss=(k+1)*100-now;
        steps+=ss/k+(ss%k>0);
        now+=(ss/k+(ss%k>0))*k;
    }
    if(now>=x) cout << steps;
    else{
        while(now<x){
            now+=now/100;
            steps++;
        }
        cout << steps;
    }
    return 0;
}

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

using namespace std;



int main(){
    int n, m;
    cin >> n >> m;
    string s[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i][j] == "snuke"){
                char a = 65+j;
                cout << a << i + 1;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import Foundation

func originSqrt(_ n: Int) -> Int {
    return Int(sqrt(Double(max(0,n))))
}

let N = Int(readLine()!)!

for n in 1...N {
    var cnt = 0
    for x in 1...originSqrt(n)+1 {
        let xx = x * x
        for y in 1...originSqrt(n-xx)+1 {
            let yy = y * y
            let xy = x * y
            for z in 1...originSqrt(n-xx-yy)+1 {
                let zz = z * z
                let yz = y * z
                let zx = z * x
                let f_n = xx + yy + zz + xy + yz + zx
                if n == f_n {
                    cnt += 1
                }
            }
        }
    }
    print(cnt)
}

Measured memory_bytes: 12948