akhauriyash/Code-Regression huggingface dataset:
A, B = gets.chomp.split(" ").map(&:to_i)

def f(x)
  if x.even?
    a = x / 2
    if a.even?
      ret = 0 ^ x
    else
      ret = 1 ^ x
    end
  else
    a = (x + 1) / 2
    if a.even?
      ret = 0
    else
      ret = 1
    end
  end
  ret
end

if A == B
  puts A
elsif A > 0
  puts f(A - 1) ^ f(B)
else
  puts f(B)
end


Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
using namespace std;
const int N=200010;
const int mod=2019;
char str[N];
int a[N];
int arr[N];
int cnt[3000];
int main()
{
    cnt[0]=1;
    int sum=0;
    cin>>str;
    int n=strlen(str);
    for(int i=0;i<n;i++){
        sum=(10*sum+str[i]-'0')%mod;
        arr[i]=sum;
    }
    int h=1;
    for(int i=n-1;i>=0;i--){
        arr[i]=(arr[i]*h)%mod;
        h=h*10%mod;
    }
    for(int i=0;i<n;i++){
        cnt[arr[i]]++;
    }
    long long ans=0;
    for(int i=0;i<2019;i++)ans+=1ll*cnt[i]*(cnt[i]-1)/2;
    cout<<ans<<endl;
}

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

const int maxl=1e5+10;

int n,ans;
int a[maxl],b[maxl],aa[maxl],bb[maxl],nxt[maxl];
map <int,int> mpa,mpb;
bool vis[maxl];

inline void prework()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),aa[i]=a[i];
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]),bb[i]=b[i];
}

inline void mainwork()
{
	ans=0;
	sort(aa+1,aa+1+n);
	sort(bb+1,bb+1+n);
	for(int i=1;i<=n;i++)
	if(aa[i]>bb[i])
		return;
	for(int i=2;i<=n;i++)
	if(aa[i]<=bb[i-1])
	{
		ans=1;
		return;
	}
	for(int i=1;i<=n;i++)
		mpa[aa[i]]=i,mpb[bb[i]]=i;
	for(int i=1;i<=n;i++)
		nxt[mpa[a[i]]]=mpb[b[i]];
	int cnt=0;
	for(int i=1;i<=n;i++)
	if(!vis[i])
	{
		int u=i;cnt++;
		while(!vis[u])
		{
			vis[u]=u;
			u=nxt[u];
		}
	}
	if(cnt>1)
		ans=1;
}

inline void print()
{
	if(ans)
		puts("Yes");
	else
		puts("No");
}

int main()
{
	prework();
	mainwork();
	print();
	return 0;
}

Measured memory_bytes: 11648
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
#define int long long
using namespace std;
signed main() {
    char C;
    cin >> C;
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < 26; i++) {
        if (C == alphabet.at(i)) {
            cout << alphabet.at(i + 1) << endl;
        }
    }
}


Measured memory_bytes: 3592
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int k, s; cin >> k >> s;
    // 0 <= x, y, z <= k
    // x + y + z = s を満たすのが何通りか

    set< pair<int, int> > st;
    FOR(x, 0, k) {
        FOR(y, 0, k) {
            if (x + y <= s && (s - x - y) <= k) {
                st.insert(make_pair(x, y));
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
const int maxi = 1e6+10;
int a[maxi], b[maxi];
string s;
int n;
vector<int> v[maxi];
set<pair<int,int>> st;

int levo(int x)
{
    if (x==1) return n; else
        return x-1;
}
int desno(int x)
{
    if (x==n) return 1; else
        return x+1;
}
int main(){

    cin>>n;

    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    for (int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        st.insert({b[i],i});
    }

    long long ans = 0;

    while(!st.empty())
    {
        pair<int, int> node = *st.rbegin();
        st.erase(node);
        if (a[node.second] == b[node.second]) continue;

        long long sum = b[levo(node.second)] + b[desno(node.second)];
        if (sum>b[node.second] - a[node.second]) return !printf("-1\n");
        long long val = (b[node.second] - a[node.second])/sum;
        b[node.second]-=val*sum;
        ans+=val;
        node.first = b[node.second];
        st.insert(node);
        //cout<<node.first<<" "<<node.second<<endl;
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 36224
#include<stdio.h>
#include<string.h>
int main(){
    char s[11],t[12];
    scanf("%s",s);
    scanf("%s",t);
    int k=strncmp(s,t,strlen(s));
    if(k==0 && strlen(s)+1==strlen(t)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int x; cin>>x;
    int ans = 0, acu = 0;
    for(int i=1; i<=x; i++){
        acu += i;
        ans = i;
        if(acu >= x)
            break;
    }
    OUT(ans);
}

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

using namespace std;

int main() {

    int n;
    cin >> n;
    vector<string> strs(n);
    vector<int> alphs(26, INT_MAX);

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 26; j++) {
            char srch_alph = (char)('a' + j);
            int cnt = 0;
            for (int k = 0; k < strs[i].size(); k++) {
                if (strs[i][k] == srch_alph) {
                    cnt++;
                }
            }
            alphs[j] = min(cnt, alphs[j]);
        }
    }

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < alphs[i]; j++) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
5 2
8 7 6
rsrpr

*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	string t;
	ll i,j;
	ll n,k,r,s,p;
	cin>>n>>k;
	cin>>r>>s>>p;
	cin>>t;
	ll ans=0;
	ll a[n];
	rep(i,0,k){
		if(t[i]=='r')
			ans+=p;
		if(t[i]=='s')
			ans+=r;
		if(t[i]=='p')
			ans+=s;
		a[i]=1;
	}
	rep(i,k,n){
		if(t[i-k]!=t[i]||!a[i-k]){
			if(t[i]=='r')
				ans+=p;
			if(t[i]=='s')
				ans+=r;
			if(t[i]=='p')
				ans+=s;
			a[i]=1;
		}else
			a[i]=0;
	}cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 1232
loop {
	n, m = gets.split.map &:to_i
	break if n == 0
	a = (1..n).map { gets.to_i }
	b = (1..m).map { gets.to_i }
	a_sum = a.inject(:+)
	b_sum = b.inject(:+)
	ok = false
	a.product(b).each{|x, y|
		if a_sum - x + y == b_sum - y + x
			puts "#{x} #{y}"
			ok = true
			break
		end
	}
	puts -1 unless ok
}

Measured memory_bytes: 6780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt();
			int b = in.nextInt();

			int ans = 0;
			for (int i = a; i <= b; i++) {
				String s = String.valueOf(i);
				StringBuffer sb = new StringBuffer();
				for (int j = s.length() - 1; j >= 0; j--) {
					sb.append(s.substring(j, j+1));
				}
				if (s.equals(sb.toString())) {
					ans++;
				}
			}
			out.println(ans);

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 43584
use std::io;

enum Direction {
    U,R,D,L
}

const U : Direction = Direction::U;
const R : Direction = Direction::R;
const D : Direction = Direction::D;
const L : Direction = Direction::L;

fn towards(d:Direction) {
    print!("{}",
           match d {
               Direction::U => "U",
               Direction::R => "R",
               Direction::D => "D",
               Direction::L => "L",
           }); }

fn main (){
    let input = get_line();
    let nums : Vec<i32>
        = input.split_whitespace().map(|st| {st.parse().unwrap()}).collect();
    let (dx,dy) = (nums[2]-nums[0],nums[3]-nums[1]); // ?
    report_path(dx,dy);
}

fn mks(dx:i32, dy:i32){
    for _ in 0..dy-1{
        towards(U);
    }
    for _ in 0..dx {
        towards(R);
    }
    for _ in 0..dy{
        towards(D);
    }
    for _ in 0..dx-1 {
        towards(L);
    }
}

fn report_path(dx:i32, dy:i32){
    // think of stdout as []
    towards(L);
    towards(U);
    mks(dx+1,dy+1);
    mks(dx+1,dy+1);
    towards(L);
    towards(U);
    println!("");
}

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define read ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl;
#define debug2(x, y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<endl;
#define forr(i, s, n) for(ll i=(s); i<(int)(n); ++i)
#define fori(i, n) forr(i, 0, n)
#define pb(n) push_back(n)
#define fst first
#define snd second
#define INF 2e9 + 5
#define LINF 1e18l + 5l
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<string> vs;

int main(){
    read;
    int n, w;
    cin>>n>>w;
    vi v(n + 1), we(n + 1);
    ll smv = 0;
    forr(i, 1, n + 1) {
        cin>>we[i]>>v[i];
        smv += v[i];
    }
    ll dp[n + 10][smv + 10];
    memset(dp, 0, sizeof dp);
    fori(i, smv + 1) {
        dp[0][i] = LINF;
    }
    dp[0][0] = 0;
    forr(i, 1, n + 1) {
        fori(k, smv + 1) {
            if(k - v[i] >= 0) {
                dp[i][k] = min(
                    dp[i - 1][k],
                    we[i] + dp[i - 1][k - v[i]]
                );
            } else dp[i][k] = dp[i - 1][k];
        }
    }
    /*fori(i, n + 1) {
        fori(k, smv + 1) {
            cout<<dp[i][k]<<" ";
        } cout<<endl;
    }*/
    int ans = 0;
    fori(i, smv + 1) {
        if(dp[n][i] <= w) {
            ans = i;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int a,b,c,d,f;
	double e;
	cin >> a >> b >> c >> d >> e >> f;
	e = e / (100+e) * 100;
	double maxConcentration = 0;
	int ans1=a*100, ans2=0;
	FOR(ai,0,(f/100+a)/a+1){
		FOR(bi,0,(f/100+b)/b+1){
			FOR(ci,0,f/c+1){
				FOR(di,0,f/d+1){
					//cout << ai << " " << bi << " " << ci << " " << di << " ";
					int sugar = c * ci + d * di;
					int solutionMass = 100 * a * ai + 100 * b * bi + sugar;
					if(solutionMass == 0)continue;
					double concentration = (double)sugar / solutionMass * 100;
					//cout << concentration << "\n";
					if(solutionMass <= f && concentration <= e + DBL_EPSILON && maxConcentration < concentration){
						maxConcentration = concentration;
						ans1 = solutionMass;
						ans2 = sugar;
					}
				}
			}
		}
	}
	cout << ans1 << " " << ans2 << "\n"; 
	return 0;
}


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

int main() {

  const int M = 448;

  vector <int> mod(M);
  for(int i=0; i<M; i++ ){
    if(i ==0){
      mod.at(i)=1;
    }
    else{
      mod.at(i)=10*mod.at(i-1)%2019;
    }
  }

  //sort(mod.begin(),mod.end());
  /*for(int i=0; i<224; i++){
    cout << "i" << i << ":" << mod.at(i) <<endl;
  }*/



  string S;
  cin >> S;

  long long int N = (long int)(S.length()); //Nketa
  //cout << len << endl;

  vector <long int> s(N);
  //cout << (s.size()) << endl;

  for(long long int i=0; i<N; i++){
    long int tmp = S.at(i)-'0';
    s.at(i) = tmp;
    //cout << s.at(i) ;
  }


  vector <int> t(N+1);
  for(long long int i=0; i<N+1; i++){
    if(i==0){
      t.at(i)=0;
    }
    else if(i==1){
      t.at(i)=s.at(N-i);
    }
    else{
      int tmp;
      tmp = (i-1)%M;
      t.at(i) = (t.at(i-1) + s.at(N-i)*mod.at(tmp)) % 2019;
    }
  }

  long long int count=0;
  long long int sum = 1;

  sort(t.begin(),t.end());
  for(long long int i=0; i<N; i++){
    if(t.at(i)==t.at(i+1)){
      sum++;
      if(i==N-1){
        count+=sum*(sum-1)/2;
      }
    }
    else{
      count+=sum*(sum-1)/2;
      sum = 1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 5908
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long


int main(){
  int n;
  cin >> n;
  cout << (n+1)/2-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	vector<int> geko;
	REP(i, n) {
		int a;
		cin >> a;
		geko.push_back(a);
	}
	int ans = 0;
	for (int i = 1; i < n - 1; ++i) {
		if (geko[i] >= geko[i - 1] && geko[i + 1] >= geko[i]) {
			ans++;
		}
		if (geko[i] <= geko[i - 1] && geko[i + 1] <= geko[i]) {
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
S = input()
T = input()
def f(x):
  d = {chr(97+i):[] for i in range(26)}
  for i in range(len(x)):
    d[x[i]].append(i)
  D = list(d.values())
  D.sort()
  return D
if f(S) == f(T):
  print("Yes")
else:
  print("No")

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

int main () {
	string s; cin >> s;
	int n = s.size();
	vector<int> a(n + 1);
	for (int i=0; i<n; i++) {
		if (s[i] == '<') a[i+1] = max(a[i+1], a[i]+1);
	}
	for (int i=n-1; i>=0; i--) {
		if (s[i] == '>') a[i] = max(a[i], a[i+1]+1);
	}
	long long res = accumulate(a.begin(), a.end(), 0LL);
	cout << res;
} 
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), set tle
	* do smth instead of nothing and stay organized
*/

Measured memory_bytes: 5852
package main

import (
	"fmt"
	"math"
)

type pair struct {
	x, y float64
}

func abs(a float64) float64 {
	if a >= 0 {
		return a
	}
	return -a
}

func max(a, b float64) float64 {
	if a > b {
		return a
	}
	return b
}
func main() {
	var n int
	fmt.Scan(&n)
	x := make([]float64, n)
	y := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&y[i])
	}
	var D1, D2, D3, D4 float64
	for i := 0; i < n; i++ {
		D1 += abs(x[i] - y[i])
	}
	for i := 0; i < n; i++ {
		D2 += (x[i] - y[i]) * (x[i] - y[i])
	}
	D2 = math.Sqrt(D2)
	for i := 0; i < n; i++ {
		D3 += abs(x[i]-y[i]) * abs(x[i]-y[i]) * abs(x[i]-y[i])
	}
	D3 = math.Cbrt(D3)
	D4 = 0.0
	for i := 0; i < n; i++ {
		D4 = max(D4, abs(x[i]-y[i]))
	}
	fmt.Println(D1)
	fmt.Println(D2)
	fmt.Println(D3)
	fmt.Println(D4)
}



Measured memory_bytes: 1176
/*
    if you can't see the repay
    Why not just work step by step
    rubbish is relaxed
    to ljq
*/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <algorithm>
using namespace std;

#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define lc (rt<<1)
#define rc (rt<<11)
#define mid ((l+r)>>1)

typedef pair<int,int> pll;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll _INF = 0xc0c0c0c0c0c0c0c0;
const ll mod =  (int)1e9+7;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}
void exgcd(ll a,ll b,ll &x,ll &y,ll &d){if(!b) {d = a;x = 1;y=0;}else{exgcd(b,a%b,y,x,d);y-=x*(a/b);}}//printf("%lld*a + %lld*b = %lld\n", x, y, d);
const int MAX_N = 100025;
ll dp[MAX_N],arr[MAX_N];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,k;scanf("%d%d",&n,&k);
    for(int i = 1;i<=n;++i) scanf("%lld",&arr[i]);
    for(int i = 2;i<=n;++i)
    {
        dp[i] = 0x3f3f3f3f;
        for(int j = 1;j<=k;++j)
        {
            if(i-j<1) break;
            dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    printf("%lld\n",dp[n]);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn 3005
using namespace std;
int dp[maxn][maxn];
short vis[maxn][maxn];
vector<char> v;
int main(){
	ios::sync_with_stdio ( false );
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	a = ' '+a; b = ' '+b;
	int asz = a.size(), bsz = b.size();
	for ( int i=1; i<asz; ++i )
		for ( int j=1; j<bsz; ++j ){
			if ( a[i] == b[j] )	{
				dp[i][j] = dp[i-1][j-1]+1;
				vis[i][j] = 1;
			}
			else if ( dp[i-1][j] > dp[i][j-1] ){
				dp[i][j] = dp[i-1][j];
				vis[i][j] = 2; 
			}
			else {
				dp[i][j] = dp[i][j-1];
				vis[i][j] = 3;
			}
		}
	int posi = asz-1, posj = bsz-1;
	while ( posi && posj ){
		if ( vis[posi][posj] == 1 ) {
			v.emplace_back(a[posi]);
			posi--; posj--;
		}
		else if ( vis[posi][posj] == 2 ) posi--;
		else posj--;
	}
	for ( int i=v.size()-1; i>=0; --i ) cout << v[i];
	cout << '\n';
	return 0;
}


Measured memory_bytes: 53120
#include<iostream>
using namespace std;
int main(){
int n,a,b,ans=0,k,s=0,n2;
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
n2=i;
for(int j=10000;j>=1;j/=10){
k=n2/j;
s+=k;
n2-=k*j;
}
if(a<=s&&s<=b)ans+=i;
s=0;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N,P = map(int, input().split())
    S = input().rstrip()
    D = list(map(int, S))
    
    ans = 0
    if P == 2:
        for i, d in enumerate(D):
            if d&1 == 0: ans += i + 1
        return ans

    if P == 5:
        for i, d in enumerate(D):
            if d == 0 or d == 5: ans += i + 1
        return ans

    A = [0] * P
    num = Mint(0, P)
    for i in range(N):
        num += Mint(D[-1-i], P) * pow(10, i, P)
        A[num.value] += 1
    for a in A:
        ans += a * (a-1) // 2
    ans += A[0]
    return ans

class Mint:
    def __init__(self, value=0, mod=10**9+7):
        self.value = ((value % mod) + mod) % mod
        self.mod = mod

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, self.mod
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        return (u + self.mod) % self.mod

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.value
    def __neg__(self): return Mint(-self.value, self.mod)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % self.mod
        return self
    def __add__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % self.mod
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other, self.mod)
        self *= other.inverse
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj //= self
        return new_obj

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 48204
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;

ll gcd(ll x, ll  y){
    if(x<y){
        ll z = x;
        x = y;
        y = z;
    }
    if(x % y == 0)return y;
    else return gcd( y, x % y);
}

int main()
{
    FASTIO
     /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        int n,l;
        cin >> n >> l;
        vector<int> v;
        int ans = 0;
        for(int i = 1; i <= n; i++){
            v.push_back(l+i-1);
            ans += l + i - 1;
       }

       int mn = 99999999;
       int res;
        for(int i = 0; i < (int)v.size(); i++){
            int sum = 0;
            for(int k = 0; k < (int)v.size(); k++){
                if(i == k) continue;
                sum += v[k];
            }
            cerr << sum << endl;
            int t = abs(ans - sum);
            if(mn > t){
                res = sum;
                mn = t;
            }
        }
        cout << res << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (long long int)(2019)
#define pb push_back
#define ll long long int 
using namespace std;
typedef pair<int,int> pii;
 
int main(){
  ll l,r;
 
  cin>>l>>r;
 
  if(r-l+1>=2019){
    cout<<0<<endl;
    return 0;
  }
  ll res=l*(l+1)%mod;
 
  for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
      //if(res==0) break;
      res=min(res,(i*j)%mod);
    }
  }
  
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
using namespace std;
typedef pair<int,int>pii;
main(){
	int n,x,i;
	for(;scanf("%d%d",&n,&x),n;printf("%d\n",x)){
		vector<pii>v;
		v.push_back(make_pair(x,1));
		for(i=1;i<n;i++){
			pii p=v.back();v.pop_back();
			scanf("%d",&x);
			if(i&1){
				if(x==p.first)
					v.push_back(make_pair(x,p.second+1));
				else{
					pii q=make_pair(0,0);
					if(v.size())q=v.back(),v.pop_back();
					v.push_back(make_pair(x,q.second+p.second+1));
				}
			}else{
				if(x==p.first)v.push_back(make_pair(x,p.second+1));
				else v.push_back(p),v.push_back(make_pair(x,1));
			}
		}
		for(x=i=0;i<v.size();i++){
			if(!v[i].first)x+=v[i].second;
		}
	}
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e9+5, mod = 1e9+7;

void solve() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);

    ll mn = x % d;

    if (x < d) {
        if (k & 1) {
            cout << abs(d - x) << endl;
        } else {
            cout << x << endl;
        }
        return;
    }

    ll c = x / d;
    if (k >= c) {
        k -= c;
        x = mn;
    }

    if (x > mn) {
        cout << x - (k * d) << endl;
    } else {
        if (k & 1) {
            cout << abs(d - x) << endl;
        } else {
            cout << x << endl;
        }
    }
    
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


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

int main()
{
	int N = 0, K = 0;
	cin >> N >> K;
	vector<int> D(K);
	for(int i = 0; i < K; i++){
		cin >> D[i];
	}
	int t = N;
	while(1){
		bool insufficient = false;
		int tmp = t;
		int digit = 1;
		while(1){
			if(t /= 10){
				digit++;
			}else
				break;
		}
		t = tmp;
		for(int j = 0; j < digit && (insufficient == false); j++){
			for(int i = 0; (i < K) && (insufficient == false); i++){
				if((tmp % 10) == D[i]){
					insufficient = true;
				}
			}
			tmp /= 10;
		}
		if(insufficient)
			t++;
		else
			break;
	}
	cout << t;
}


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

int main() {
	int n;
	cin >> n;
	int a[4][3][10];
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 10; k++)
				a[i][j][k] = 0;
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++)
				cout << ' ' << a[i][j][k];
			cout << endl;
		}
		if (i != 3)
			cout << "####################" << endl;
	}
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

int dig_sum(string x){
    int ans = 0;
    rep(i,x.size()){
        ans += x[i]-'0';
    }
    
    return ans;
}

int main(){
    while(true){
        string x; cin >> x;
        
        if(x == "0") break;
        
        cout << dig_sum(x) << endl;
        
    }
}






Measured memory_bytes: 3152
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;
const MOD: i32 = 1000000007;
// const MOD: i32 = 998244353;

fn main() {
    let n: usize = read!();
    let d: isize = read!();

    let d = d * d;

    let mut ans = 0;

    for _ in 0..n {
        let xi: isize = read!();
        let yi: isize = read!();

        if xi * xi + yi * yi <= d {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2192
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int main(){
	ios::sync_with_stdio(false);

	int n;
	int count=0;

	cin>>n;

	vi a(n+1);

	FOR(i,1, n+1){
		cin>>a[i];
	}

	FOR(i,1,n+1){
		if(a[a[i]]==i){
			count++;
		}

	}
	printf("%d\n", count/2);
}


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

int main(){
   string s;
   cin >> s;
   char a=s[0], b =s[1], c=s[2], d=s[3];
   if ((a==b&&b==c&&c!=d)||(a!=b&&b==c&&c==d)||
       (a==b&&b==c&&c==d)){
       cout << "Yes" << endl;
   }
   else {
       cout << "No" << endl;
   }
}


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

int main() {
  
  while (true) {
    
    int m, f, r; cin >> m >> f >> r;
    
    if (m == -1 && f == -1 && r == -1) return 0;
    
    if (m == -1 || f == -1) {
      cout << "F" << endl;
      continue;
    }
    
    if (80 <= m + f) cout << "A" << endl;
    else if (65 <= m + f) cout << "B" << endl;
    else if (50 <= m + f) cout << "C" << endl;
    else if (30 <= m + f) {
      if (50 <= r) cout << "C" << endl;
      else cout << "D" << endl;
    }
    else cout << "F" << endl;
    
  }
  
}


Measured memory_bytes: 3080
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main(){
	int n;
	while(cin>>n){
		n%=39;
		if(n==0)n=39;
		
		printf("3C%02d\n",n);
	}
}

Measured memory_bytes: 0
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	var N string = next()
	var sum int
	for i := 0; i < len(N); i++ {
		sum += int(N[i] - '0')
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2504
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            var read = Console.ReadLine();
            var temp_string = read.Split(' ');

            var X_vec = new int[int.Parse(temp_string[0]), int.Parse(temp_string[1])];
            var Y_vec = new int[int.Parse(temp_string[1])];


            int x = int.Parse(temp_string[0]), y = int.Parse(temp_string[1]),temp=0;

            for(int i=0;i<x;i++)
            {
                read = Console.ReadLine();
                temp_string = read.Split(' ');

                for(int j=0;j<y;j++)
                {
                    X_vec[i, j] = int.Parse(temp_string[j]);
                }

            }

            for(int i=0;i<y;i++)
            {
                read = Console.ReadLine();
                Y_vec[i] = int.Parse(read);
            }

            for (int i = 0; i < x; i++)
            {
                temp = 0;
                for(int j=0;j<y;j++)
                {
                    temp += X_vec[i, j]*Y_vec[j];
                }
                Console.WriteLine((temp));
            }
        }
    }
}

Measured memory_bytes: 9396
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = N % K;
	ll ans1 = min(ans, K - ans);

	cout << ans1 << endl;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		cin >> p.at(i);
	}
	sort(p.begin(),p.end());
	int ans=1000000;
	for(int i=p.at(0);i<=p.at(n-1);i++){
		int q=0;
		for(int j=0;j<n;j++){
			q=q+(i-p.at(j))*(i-p.at(j));
		}
		if(q<ans){
			ans=q;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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 main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin>>a>>b;
    if (a == 1)
        a += 13;
    if (b == 1)
        b += 13;
    if (a > b)
    {
        cout << "Alice"
             << "\n";
    }
    else if (a < b)
    {
        cout << "Bob"
             << "\n";
    }
    else
        cout << "Draw"
             << "\n";
}


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

int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;

    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int k=n-i*r-j*g;
            if(k>=0&&k%b==0) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
import java.util.*;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		Map<Integer,Integer> m=new TreeMap<Integer,Integer>();
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
			Integer aObj=Integer.valueOf(a);
			if(m.containsKey(aObj)) {
				m.put(aObj,m.get(aObj)+1);
			}
			else {
				m.put(aObj, 1);
			}
		}
		Collection<Integer> nums=m.values();
		List<Integer> l=new ArrayList<Integer>();
		l.addAll(nums);
		java.util.Collections.sort(l);
		int count=l.size();
		int ans=0;
		while(count>k) {
			ans+=l.get(l.size()-count);
			count--;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 100416
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long> A(n+1, 0);
	map<long long, long long> mp;
	mp[0]++;
	long long ans = 0, s = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		s += a;
		ans += mp[s];
		mp[s]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17164
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 100000000
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	return sc
}()

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

func main() {
	input := scanIntNum()
	bminf := root(float64(input), 5)
	bmin := -1 * int(math.Floor(bminf))
	var a float64

	for i := bmin; ; i++ {
		a5 := input + int(math.Pow(float64(i), 5))
		if a5 == 0 {
			a = 0
		} else {
			a = root(float64(a5), 5)
		}
		if a-math.Floor(a) == 0.0 {
			fmt.Println(int(math.Floor(a)), i)
			return
		}
	}
}

func root(a float64, n int) float64 {
	n1 := n - 1
	n1f, rn := float64(n1), 1/float64(n)
	x, x0 := 1., 0.
	for {
		potx, t2 := 1/x, a
		for b := n1; b > 0; b >>= 1 {
			if b&1 == 1 {
				t2 *= potx
			}
			potx *= potx
		}
		x0, x = x, rn*(n1f*x+t2)
		if math.Abs(x-x0)*1e15 < x {
			break
		}
	}
	return x
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define err(...) //fprintf(stderr, __VA_ARGS__), fflush(stderr)

typedef long long ll;

using namespace std;

const int dd = (int)2e5 + 7;

int n;
int len[dd];

bool check(int c) {
	vector<pair<int, int>> st;
	
	st.emplace_back(-1, 0);
	
	auto add = [&](int val, int cnt) {	
		err("add val = %d, cnt = %d\n", val, cnt);
		if (cnt <= 0) return;
		if (st.size() && st.back().first == val) st.back().second += cnt;
		else st.emplace_back(val, st.back().second + cnt);
	};
	
	for (int i = 0; i < n; i++) {
		err("st = "); for (auto c : st) err("(%d, %d), ", c.first, c.second); err("\n");
		if (len[i] > st.back().second) {
			add(0, len[i] - st.back().second);
		} else {
			int last = -1;
			while (st.back().second >= len[i]) {
				last = st.back().first;
				st.pop_back();
				err("remove1\n");
			}
			
			int was = 0;
			int clen = -1;
			
			while (st.size() && last == c - 1) {
				last = st.back().first;
				was = 1, clen = st.back().second;
				st.pop_back();
				err("remove2\n");
			}
				
			if (st.empty()) return false;
			
			err("was = %d, last = %d\n", was, last);
			
			if (was) {
				add(last, clen - st.back().second - 1);
				add(last + 1, 1);
				add(0, len[i] - st.back().second);
			} else {
				add(last, len[i] - st.back().second - 1);
				add(last + 1, 1);
			}
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) cin >> len[i];
	
	//check(2);
	//return 0;
	
	int l = 0, r = (int)1e9 + 7;
	while (r - l > 1) {
		int m = (l + r) / 2;
		
		if (check(m)) r = m;
		else l = m;
	}
	cout << r << "\n";
	return 0;
}


Measured memory_bytes: 1152
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int idx, a, b, pl;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.pl != t.pl)
		return s.pl > t.pl; // 降順
	return s.idx < t.idx;
}



int main() {

	int n, m;
	cin >> n >> m;
	int a[31] = {};

	int k;
	int A;
	REP(i, n) {
		cin >> k;
		REP(j, k) {
			cin >> A;
			a[A]++;
		}
	}
	int ans=0;
	FOR(i,1, m) {
		if (a[i] == n) {
			ans++;
		}
	}

	ANS(ans);



	return 0;
}


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

using namespace std ;

const int MAX = 2e5 + 10 ;

int arr[MAX] , pref[MAX] , pref2[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i] ;
	for(int i = 1 ; i <= n ; ++i)
	{
		pref[i] = pref[i-1] + arr[i] ;
		pref2[i] = pref2[i-1] ^ arr[i] ;
	}
	long long ans = 0ll ;
	for(int i = 1 ; i <= n ; ++i)
	{
		int l = i , r = n ;
		long long ans2 = i-1 ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			if((pref[mid] - pref[i-1]) == (pref2[mid] ^ pref2[i-1]))
				ans2 = mid , l = mid+1 ;
			else
				r = mid-1 ;
		}
		ans += (ans2*1ll-i*1ll+1ll) * 1ll ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 2688
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int ans = k;
  REP(i,n-1) ans *= (k-1);
  cout << ans << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
n = gets.to_i
m = gets.split.map(&:to_i).sort!.reverse!
alice = []
bob = []
for i in 0..(n - 1)
    if i.even?
        alice << m[i]
    elsif i.odd?
        bob << m[i]
    end
end
puts alice.inject(:+) - bob.inject(:+)


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k ;
	vector<int> vec(n);
	for(int i=0;i<n;i++) cin>> vec[i];
	
	sort(vec.begin(),vec.end());
	
	int x=0;
	
	for(int i=0;i<k;i++) x+=vec[i];
	
	cout << x <<endl;
	
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

long long N;

int main() {
    while (cin >> N) {
        long long res = 1;
        for (long long i = 1; i * i <= N; ++i) {
            res = i * i;
        }
        cout << res << endl;
    }
}







Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int x,y;
  int flag = 0;
  scanf("%d %d", &x, &y);
  for(int i=0;i<=x;i++){
    if(2*i+4*(x-i)==y){
      flag = 1;
    }
  }
  if(flag==1){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 1660