akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int N = 3e5+10;

using namespace std;

main()
{
    fast;
    ll n,i;
    cin>>n;
    ll a[N];
    for (i=0;i<3*n;i++)
        cin>>a[i];
    priority_queue<int,vector<int>,greater<int>> left_part;
    priority_queue<int> right_part;
    ll left[N],right[N];
    ll cur_sum=0;
    for (i=0;i<3*n;i++)
    {
        left_part.push(a[i]);
        cur_sum+=a[i];
        while (left_part.size()>n)
        {
            cur_sum-=left_part.top();
            left_part.pop();
        }
        left[i]=cur_sum;
    }
    cur_sum=0;
    for (i=3*n-1;i>=0;i--)
    {
        right_part.push(a[i]);
        cur_sum+=a[i];
        while (right_part.size()>n)
        {
            cur_sum-=right_part.top();
            right_part.pop();
        }
        right[i]=cur_sum;
    }
    ll ans=-1e18;
    for (i=n-1;i<2*n;i++)
        ans=max(ans,left[i]-right[i+1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 8440
/*
 * ID: 0259
 * Problem: All numbers go to 6174
 */

#include <stdio.h>

int main(void)
{
    int i, number;

    while (1) {
        scanf("%d", &number);
        if (number == 0)
            return 0;

        if (number % 1111 == 0) {
            printf("NA\n");
            continue;
        }

        int try = 0;

        while (number != 6174) {
            int count[10] = {0};
            try++;
            for (i = 0; i < 4; i++) {
                count[number % 10]++;
                number /= 10;
            }

            int large = 0;
            for (i = 9; i >= 0; i--) {
                int k = 0;
                while (count[i] > k) {
                    large *= 10;
                    large += i;
                    k++;
                }
            }

            int small = 0;
            for (i = 0; i <= 9; i++) {
                int k = 0;
                while (count[i] > k) {
                    small *= 10;
                    small += i;
                    k++;
                }
            }

            number = large - small;
            //printf("%d %d -> %d\n", large, small, number);
        }
        printf("%d\n", try);
    }

    return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>

#define INF 10000000

int graph[100][100], n, d[100], c[100];

void init() {
    int i;
    for (i = 0; i < n; i++) {
        d[i] = INF;
        c[i] = 1;
    }
    d[0] = 0;
    c[0] = 0;
}

void sssp() {
    int min, i, k;
    
    init();
    while (1) {
        min = INF;
        k = -1;
        for (i = 0; i < n; i++) {
            if (min > d[i] && c[i] != -1) {
                k = i;
                min = d[i];
            }
        }
        if (k == -1) break;
        c[k] = -1;
        for (i = 0; i < n; i++) {
            if (c[i] != -1 && graph[k][i] != INF) {
                if (d[i] > d[k] + graph[k][i]) {
                    d[i] = d[k] + graph[k][i];
                    c[i] = 0;
                }
            }
        }
    }
}

int main(void){
    int i, j, a, b, c, e;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            graph[i][j] = INF;
        }
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d %d", &a, &b);
        for (j = 0; j < b; j++) {
            scanf("%d %d", &c, &e);
            graph[a][c] = e;
        }
    }
    
    sssp();
    
    for (i = 0; i < n; i++) {
        printf("%d %d\n", i, d[i]);
    }
    
    return 0;
}




Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
typedef pair<int,int> P;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
	int n,m;
	cin>>n>>m;
	vector<int> h(n);
	rep(i,n)cin>>h[i];
	vector<vector<int>> vec(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	int ans=0;
	rep(i,n){
		rep(j,vec[i].size()){
			if(h[i]<=h[vec[i][j]])goto joi;
		}
		ans++;
		joi:;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9764
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main() {
  int n;
  cin>>n;
  int A[n];
  for (int i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  int cnt=0;
  vector<int> G;
  for (int h=1; ; ) {
    if (h>n) {
      break;
    }
    G.push_back(h);
    h=3*h+1;
  }
  for (int i=G.size()-1; i>=0; i--) {
    for (int j=G[i]; j<n; j++) {
      int v=A[j];
      int k=j-G[i];
      while (k>=0 && A[k]>v) {
        A[k+G[i]]=A[k];
        k-=G[i];
        cnt++;
      }
      A[k+G[i]]=v;
    }
  }
  cout<<G.size()<<endl;
  for (int i=G.size()-1; i>=0; i--) {
    cout<<G[i]<<(i==0?"":" ")<<flush;
  }
  cout<<endl;
  cout<<cnt<<endl;
  for (int i=0; i<n; i++) {
    cout<<A[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7096
#約数の総数
def make_divisors(n):
	#divisors = []
	cnt=0
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			cnt+=1
			#divisors.append(i)
			if i != n // i:
				cnt+=1
				#divisors.append(n//i)
	#return divisors
	return cnt

cnt=0
i=1
n=int(input())
while i<=n:
	if make_divisors(i)==8:
		cnt+=1
	i+=2
print(cnt)

Measured memory_bytes: 3060
import math
N, D = map(int,input().split())
X = [0] * N
for i in range(N):
    X[i] = list(map(int,input().split()))
count = 0
def func(A,B):
    a = 0
    for k in range(D):
        a += (A[k] - B[k])**2
    a = math.sqrt(a)
    return a
for i in range(N):
    for j in range(i,N):
        sum_x = 0
        int_x = 0
        if i == j:
            continue
        sum_x = func(X[i],X[j])
        int_x = int(sum_x)
        if sum_x == int_x:
            count += 1
print(count)

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

bool b[10001];

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

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

    b[0] = 1;
    times(N, i) {
        int S; scanf("%d",&S);
        downto(10000, S, j) b[j] = b[j] || b[j-S];
    }

    downto(10000, 0, j) {
        if(b[j] && j % 10) {
            cout << j ln;
            return 0;
        }
    }

    cout << 0 ln;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int V = int.Parse(str[0]);
        int E = int.Parse(str[1]);
        bool[] odd = new bool[V];
        long[,] cost = new long[V,V];
        for(int i=0;i<V;i++){
            for(int j=0;j<V;j++){
                cost[i,j] = 1000000;
            }
        }
        long count = 0;
        for(int i=0;i<E;i++){
            str = Console.ReadLine().Split(' ');
            int s = int.Parse(str[0]);
            int t = int.Parse(str[1]);
            long d = int.Parse(str[2]);
            count += d;
            odd[s] = !odd[s];
            odd[t] = !odd[t];
            cost[s,t] = Math.Min(cost[s,t],d);
            cost[t,s] = cost[s,t];
        }
        for(int i=0;i<V;i++){
            Dijkstra D = new Dijkstra(cost,i,V);
            for(int j=0;j<V;j++){
                cost[i,j] = D.GetCost(j);
            }
        }
        long[] DP = new long[1 << V];
        for(int i=1;i<1 << V;i++){
            long min = 1000000;
            for(int j=0;j<V;j++){
                for(int k=j+1;k<V;k++){
                    if((i & (1 << j)) != 0 && (i & (1 << k)) != 0){
                        min = Math.Min(min,DP[i-(1 << j)-(1 << k)]+cost[j,k]);
                    }
                }
            }
            DP[i] = min;
        }
        int start = 0;
        for(int i=0;i<V;i++){
            if(odd[i]){
                start += 1 << i;
            }
        }
        count += DP[start];
        sb.Append(count+"\n");
    }
}
class Dijkstra{
	int N;
	int start;
	long[,] distance;
	long[] cost;
	public Dijkstra(bool[,] b,long[,] d,int s,int n){
		N = n;
		distance = new long[N,N];
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				distance[i,j] = b[i,j] ? d[i,j] : -1; 
			}
		}
		start = s;
		Calc();
	}
	public Dijkstra(long[,] d,int s,int n){
		N = n;
		distance = d;
		start = s;
		Calc();
	}
	void Calc(){
		bool[] finished = new bool[N];
		cost = new long[N];
		for(int i=0;i<N;i++){
			finished[i] = false;
			cost[i] = i == start ? 0 : -1;
		}
		while(true){
			int min = -1;
			for(int i=0;i<N;i++){
				if(!finished[i] && cost[i] != -1 && (min == -1 || cost[min] > cost[i])){
					min = i;
				}
			}
			if(min == -1){
				break;
			}
			finished[min] = true;
			for(int i=0;i<N;i++){
				if(!finished[i] && distance[min,i] != -1 && (cost[i] == -1 || cost[i] > cost[min] + distance[min,i])){
					cost[i] = cost[min] + distance[min,i];
				}
			}
		}
	}
	public long GetCost(int p){
		return cost[p];
	}
}

Measured memory_bytes: 9540
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define ok puts("OK");
#define int long long

using namespace std;

const int N = 305, inf = 1e18;

int n, ar[N][N], d[N][N], ans;

vector <pair <int, pair <int, int> > > vec;
main ()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            scanf("%lld", &ar[i][j]);

            if (i < j)
                vec.pb( mk( ar[i][j], mk(i, j) ) );

            if (i != j) d[i][j] = inf;
        }
    }
    sort( all(vec) );

    for (int i = 0; i < vec.size(); i++)
    {
        int len = vec[i].fr, x = vec[i].sc.fr, y = vec[i].sc.sc;
        if ( d[x][y] == inf || d[x][y] > ar[x][y] )
        {
            ans += len;

            d[x][y] = d[y][x] = len;

            for (int k = 1; k <= n; k++)
                for (int j = 1; j <= n; j++)
                {
                    d[k][j] = min (d[k][j], d[k][x] + d[x][j]);
                }

            for (int k = 1; k <= n; k++)
                for (int j = 1; j <= n; j++)
                {
                    d[k][j] = min (d[k][j], d[k][y] + d[y][j]);
                }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (ar[i][j] != d[i][j])
            {
                puts("-1");
                return 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2804
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>

#define REP(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

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

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

    vector <pair<int, pair<int, int>>> input(n);
    REP(i, 0, n) {
        scanf("%d %d %d", &input[i].S.F, &input[i].S.S, &input[i].F);
    }

    int ind = 0;
    sort(input.begin(), input.end());

    while(ind < n) {
        if (input[ind].F == input[ind+1].F && input[ind].S.S == input[ind+1].S.F) {
            input[ind+1].S.F = input[ind].S.F;
            input[ind].F = -1;
            input[ind].S.F = -1;
            input[ind].S.S = -1;
        }
        ind++;
    }

    //REP(i, 0, input.size()) {
    //    printf("channel: %d, start: %d, end: %d\n", input[i].F, input[i].S.F, input[i].S.S);
    //}
    vector <pair< int, int> > c(n);
    vector <pair<int, int>> end(n);

    REP(i, 0, n) {
            c[i].F = input[i].S.F;
            c[i].S = input[i].F;
            end[i].F = input[i].S.S;
            end[i].S = input[i].F;
    }

    sort(c.begin(), c.end());
    sort(end.begin(), end.end());
    //printf("contents of c[i]\n");
    //REP(i, 0, c.size()) {
    //    printf("channel: %d, start: %d, end: %d\n", c[i].S, c[i].F.F, c[i].F.S);
    //}

    set< int > st;
    int max = 0;
    int i_start = 0, i_end = 0;

    while(c[i_start].F <= 0) {
        i_start++;
    }

    while(end[i_end].F <= 0) {
        i_end++;
    }

    REP(i, 0, 100010*2) {
        if (i %2 == 1) {
            while((i_start < n) && (c[i_start].F == (i/2+1))) {
              st.insert(c[i_start].S);
                i_start++;
            //    printf("*******insert happen********\n");
            }
        }
        
        if (i%2 == 0) {
            while((i_end < n) && (end[i_end].F == (i/2))) {
                st.erase(end[i_end].S);
                i_end++;
            }
        }
        if(st.size() > max) {
            max = st.size();
        }
        //printf("%d loop: st.size() is %d\n", i, st.size());
    }

    printf("%d\n", max);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	ll n;
	cin>>n;

	int a[1000*1000+1]={};

	ll i=2;
	ll nroot=(int)sqrt(n);
	while(true){
		if(i>nroot)break;
		if(n%i==0){
			a[i]++;
			n/=i;
		}
		else i++;
	}
	ll q = n;

	ll ans=0;
	int k=1;
	i=2;
	while(true){
		if(i>nroot)break;
		if(a[i]>=k){
			a[i]-=k;
			ans++;
			k++;
		}
		else {
			i++;
			k=1;
		}
	}
	if(q!=1)ans+=1;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 7584
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
const int maxn=5000+10;
string a[maxn*10];
char s[maxn];
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
int main(){
	scanf("%s",s+1);
	int k=read();
	int n=strlen(s+1);
	int tmp=0;
	REP(i,1,n){
		string str="";
		REP(j,0,min(k-1,n-i)){
			str+=s[i+j];
			a[++tmp]=str;
		}
	}
	sort(a+1,a+tmp+1);
	tmp=unique(a+1,a+tmp+1)-a-1;
	cout<<a[k]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
    int s;
    cin >> s;
    int cnt = 0;
    while (s > 0) {
        int t = s % 10;
        if (t == 1) ++cnt;
        s /= 10;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char c;
    scanf("%c", &c);
    if (c == 'A') printf("T"); 
    if (c == 'T') printf("A"); 
    if (c == 'C') printf("G");
    if (c == 'G') printf("C");
    return 0;
}

Measured memory_bytes: 128
program a_sequence_of_permutations
  implicit none
  integer :: n, k, m, i
  integer, allocatable, dimension(:) :: p, q, a, b, c, d
  read(*,*) n, k
  allocate(p(n),q(n),a(n),b(n),c(n),d(n))
  read(*,*) p(1:n)
  read(*,*) q(1:n)
  select case (mod(k-1,6)+1)
  case (1)
    a = identity(n)
    b = p
  case (2)
    a = identity(n)
    b = q
  case (3)
    a = identity(n)
    b = composite(q,inverse(p))
  case (4)
    a = q
    b = inverse(p)
  case (5)
    a = composite(q,inverse(p))
    b = inverse(q)
  case (6)
    a = composite(q,inverse(p))
    b = composite(inverse(q),p)
  end select
  m = (k-1)/6
  c = composite(composite(q,inverse(p)),composite(inverse(q),p))
  d = identity(n)
  do while (m > 0)
    if (btest(m,0)) d = composite(c,d)
    c = composite(c,c)
    m = rshift(m,1)
  end do
  a = composite(d,a)
  call output(composite(a,composite(b,inverse(a))))
contains
  subroutine output(a)
    integer, intent(in) :: a(:)
    integer :: n, i
    n = size(a)
    write(*,'(i0)',advance='no') a(1)
    do i = 2, n
      write(*,'(x,i0)',advance='no') a(i)
    end do
    write(*,*)
  end
  function identity(n) result(ret)
    integer, intent(in) :: n
    integer :: ret(n), i
    do i = 1, n
      ret(i) = i
    end do
  end
  function composite(a,b) result(ret)
    integer, intent(in) :: a(:), b(:)
    integer :: n, ret(size(a)), i
    n = size(a)
    do i = 1, n
      ret(i) = a(b(i))
    end do
  end
  function inverse(a) result(ret)
    integer, intent(in) :: a(:)
    integer :: n, ret(size(a)), i
    n = size(a)
    do i = 1, n
      ret(a(i)) = i
    end do
  end
end program a_sequence_of_permutations

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

public class Main {
    static ArrayList<HashSet<Integer>> graph;
    static HashSet<Integer>components;
    static int cnt;
    static boolean[]visited;
    public static void dfs(int vertex){
        if (visited[vertex])return;
        components.add(vertex);
        visited[vertex] = true;
        for (int nbr:graph.get(vertex))
            dfs(nbr);
    }
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String [] inp = buffer.readLine().split(" ");
        int n = Integer.parseInt(inp[0]), m = Integer.parseInt(inp[1]);
        if (m==0)
            System.out.println(1);
        else
        {
            graph = new ArrayList<>();
            for (int pos = 0; pos < n; pos++) {
                graph.add(new HashSet<>());
            }
            visited = new boolean[n];
            for (int pos = 0; pos < m; pos++) {
                inp = buffer.readLine().split(" ");
                int a = Integer.parseInt(inp[0]), b = Integer.parseInt(inp[1]);
                a--;
                b--;
                graph.get(a).add(b);
                graph.get(b).add(a);
            }
            components = new HashSet<>();
            int ans = Integer.MIN_VALUE;
            for (int pos = 0; pos < n; pos++) {
                if (graph.get(pos).size() == 0) continue;
                if (!visited[pos]) {
                    components.clear();
                    dfs(pos);
                    ans = Math.max(ans, components.size());
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 173900
#include<iostream>

using namespace std;

int main() {
	
	int n;
	cin >> n;
	n %= 10;
	if(n == 2 || n == 5 || n == 4|| n == 7 || n == 9)
		cout << "hon";
	else if(n == 0 || n == 1 || n == 6 || n == 8)
		cout << "pon";
	else
		cout << "bon";
	return 0;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};
ll int n,m;
vector<ll> r,g,b;
string s;
int main()
{
    ll i,j,k,c,z,x;
    sfl(n);
    cin>>s;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R')r.pb(i);
        if(s[i]=='G')g.pb(i);
        if(s[i]=='B')b.pb(i);
    }
    z=0;
    for(i=0;i<r.size();i++)
    {
        for(j=0;j<g.size();j++)
        {
            c=b.size();
            if(r[i]<g[j])
            {
                x=2*g[j]-r[i];
                if(x>g[j] && x<n && s[x]=='B')c--;
            }
            if(r[i]>g[j])
            {
                x=2*r[i]-g[j];
                if(x>r[i] && x<n && s[x]=='B')c--;
            }
            int l=r[i]; int r=g[j];
            if(l>r)swap(l,r);

            x= 2*l - r;
            if(x<l && x>=0 && s[x]=='B')c--;
            x = (l+r);
            if(x%2==0)
            {
                x/=2;
                if(x>l && x<r && s[x]=='B')c--;
            }
            z+=c;
        }
    }
    cout<<z<<endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int K;
    cin >> K;
    int N = 50;

    vi ans(N);
    REP(i, N) ans[i] = i;
    
    int d = K / N;
    int m = K % N;
    
    REP(i, N) ans[i] += d;

    REP(i, N) {
        if (i < m) {
            ans[i] += N - (m - 1);
        } else {
            ans[i] += -m;
        }
    }

    cout << N << endl;
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

int n,m;
int A[100100][3];

int main() {
	cin >> n >> m;
	int little = min(n, m);
	int big = max(n, m);
	int ans = 0;
	int keta = 1;
	for (int i = 1;i <= big;++i) {
		ans += little * keta;
		keta *= 10;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

int n,ans,t[55];
string s[55],x;
 
int main()
{
	n=read();
	for(int i=n;i>=1;--i)
		cin>>s[i]>>t[i];
	cin>>x;
	for(int i=1;i<=n;++i)
	{
		if(x==s[i])
			break;
		ans+=t[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;






int main() {
    int a, b, k;
    cin >> a >> b >> k;
    if (k % 2 == 1) {
        for (int i = 0; i < (k-1)/2; i++) {
            int x = a;
            int y = b;
            if (x % 2 == 1)x--;

            y += x / 2;
            x /= 2;
            if (y % 2 == 1)y--;

            x += y / 2;
            y /= 2;
            a = x;
            b = y;
        }
        
        if (a % 2 == 1)a--;

        b += a / 2;
        a /= 2;

    }
    else {
        for (int i = 0; i < k/2; i++) {
            int x = a;
            int y = b;
            if (x % 2 == 1)x--;

            y += x / 2;
            x /= 2;
            if (y % 2 == 1)y--;

            x += y / 2;
            y /= 2;
            a = x;
            b = y;
        }
    }
    cout << a << " " << b << endl;
    




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;


// 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 pow(ll a, ll b) { ll ans = 1; while (b > 0) { if (b % 2 == 1) { ans *= a; ans %= MOD; }b /= 2; a *= a; a %= MOD; }return ans; }
// ll comb(ll n, ll r) { if (n - r < r) { return comb(n, n - r); }static VVL memo = {{1}}; if (memo.size() < n + 1) { memo.reserve(n + 1); FOR(i, memo.size(), n + 1) { memo.emplace_back(i + 1, 0); REP(j, i + 1) { memo[i][j] = 0;	if (j < i) { memo[i][j] += memo[i - 1][j]; }if (j > 0) { memo[i][j] += memo[i - 1][j - 1]; }memo[i][j] %= MOD; } } }return memo[n][r]; }
// ll comb_L(ll a, ll b) { if (a - b < b) { return comb(a, a - b); }static unordered_map<ll, ll> memo; ll c = 1; FOR(i, a - b + 1, a + 1) { c *= i; c %= MOD; }if (memo.find(b) == memo.end()) { ll k = 1; FOR(i, 2, b + 1) { k *= i;	k %= MOD; }memo[b] = pow(k, MOD - 2); }	c *= memo[b]; return c % MOD; }
multiset<ll> prime_decomposition(ll n) { ll i = 2; multiset<ll> table{}; while (i * i <= n) { while (n % i == 0) { n /= i;	table.emplace(i); }++i; }if (n > 1) { table.emplace(n); return table; }return table; }
//-- bit -- REP(i, (1 << n)) {REP(j, n) {cout << (1 & (i >> j));}cout << endl;}

//==============================================================================================

int main() {
	ll n;
	cin >> n;
	VL v(n);
	REP(i, n) { cin >> v[i]; }

	REPC(x, v) {
		if (x % 2) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();

        boolean result = true;

        if (n % 2 == 1) {
            result = false;
        } else {
            String left = s.substring(0, n / 2);
            String right = s.substring(n / 2, n);
            if (!left.equals(right)) {
                result = false;
            }
        }

        System.out.println(result ? "Yes" : "No");
    }
}

Measured memory_bytes: 23380
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.nextLine();
            int K = Integer.parseInt(in.nextLine());
            // StringBuilder sb = new StringBuilder();
            // for (int i = 0; i < 5000; i++) {
            // sb.append((char) ('a' + ((int) (26 * Math.random()))));
            // }
            // String s = sb.toString();
            // int K = 5;

            // char min = (char) 1e9;
            // ArrayList<Integer> indexes = new ArrayList<>();
            // for (int i = 0; i < s.length(); i++) {
            // char c = s.charAt(i);
            // if (c < min) {
            // min = c;
            // indexes.clear();
            // indexes.add(i);
            // } else if (c == min) {
            // indexes.add(i);
            // }
            // }
            //
            // if (K == 1) {
            // System.out.println(min);
            // return;
            // }

            HashSet<String> subs = new HashSet<>();
            // for (int i = 0; i < indexes.size(); i++) {
            for (int i = 0; i < s.length(); i++) {
                // int index = indexes.get(i).intValue();
                int index = i;
                for (int j = 0; j < K; j++) {
                    if (index + 1 + j <= s.length()) {
                        subs.add(s.substring(index, index + 1 + j));
                    }
                }
            }
            ArrayList<String> subs2 = new ArrayList<>();
            subs2.addAll(subs);
            Collections.sort(subs2);

            // Utils.debug(subs2);

            System.out.println(subs2.get(K - 1));

        }
    }
}


Measured memory_bytes: 25172
# ｎとｍの取得
data = input().split()
n = int(data[0]) #n == 人数
m = int(data[1]) #m == 数字の種類
ans = 0
#ｎ回データを取得してカウント

j = 1 #j == 好きな数字
i = 1 #i == 行数カウンタ
c = [0] * (m + 1)#c == ある数が含まれているかのカウンタ　0で初期化
    #データの取得

while i <= n:
    tmp = [int(s) for s in input().split()]
    td = tmp[1:] #td == 好きな番号
    tn = tmp[0]  #tn == 好きな番号の数
    
    # 数字が含まれているかの比較
    while j <= m: # jがすべての数字について実行
        
        if j in td: # jがｔｄに含まれるかの分岐
            j = int(j) #　ｊを数値に戻す
            
            c[j] += 1 # ｃのｊ番目の要素にカウント
        j = int(j) #if ではじかれたとき用にｊを数値に戻す
        j += 1# ｊをカウント
    j = 1    
    i += 1 # iをカウント

# 全てに含まれている数字の集計

for x in c:
    if x == n:
        ans += 1



print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

// int gcd(int a, int b){
//   if (a%b==0){
//     return(b);
//   }
//   else{
//     return(gcd(b,a%b));
//   }
// }

ll x[1010];
ll y[1010];
ll z[1010];
vector<ll> vec;


int main(){
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  rep(i,X) cin >> x[i]; sort(x,x+X,greater<ll>());
  rep(i,X) cin >> y[i]; sort(y,y+Y,greater<ll>());
  rep(i,X) cin >> z[i]; sort(z,z+Z,greater<ll>());

  rep(i,X){
    rep(j,Y){
      rep(k,Z){
	if((i+1)*(j+1)*(k+1) <= K) vec.push_back(x[i]+y[j]+z[k]);
	else break;
      }
    }
  }
  sort(vec.begin(),vec.end(),greater<ll>());
  rep(i,K) cout << vec[i] << endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

int digit_num(ll N){
  int ret=0;
  while(N>0){
    ++ret;
    N/=10;
  }
  return ret;
}
ll digit_2(ll N){
  if(digit_num(N)==1){
    return 0;
  }
  ll x=1;
  while(digit_num(x)<digit_num(N))x*=10;
  --x;
  dump(N);
  dump(x);
  return x;
}
void solve(long long N){
  ll ans=0;
  if(digit_num(N)%2==1){
    ans+=N-digit_2(N);
  }
  ll x=9;
  while(digit_num(x)<digit_num(N)){
    ans+=x;
    x*=100;
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    string s, t;
    cin >> s >> t;
    int nt = t.length();
    int ns = s.length();
    for(int i = ns-nt; i >= 0; i--){
        string subS = s.substr(i, nt);
        bool isSub = true;
        for(int j = 0; j < nt; j++){
            if(subS[j] != '?' && subS[j] != t[j]) {
                isSub = false;
                break;
            }
        }
        if(isSub) {
            for(int j = 0; j < nt; j++){
                s[i+j] = t[j];
            }
            for(int j = 0; j < ns; j++){
                if(s[j] == '?') s[j] = 'a';
            }
            cout << s << endl;
            return;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

int main()
{
    solve();
    return 0;
}

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

using namespace std;
const int maxn = 100+5;
int n,m;
int mp[maxn][maxn];
int mp_l[maxn],mp_r[maxn];
int vis[maxn];
void dfs(int j){
    for(int i=1;i<=n;i++){
        if(!vis[i] && mp[j][i]==1){
            vis[i] = 1;
            dfs(i);
        }
    }
    return;
}
bool is(int j){
    memset(vis,0,sizeof vis);
    mp[mp_l[j]][mp_r[j]] = 0;
    mp[mp_r[j]][mp_l[j]] = 0;
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i);
            cnt++;
        }
    }
    mp[mp_l[j]][mp_r[j]] = 1;
    mp[mp_r[j]][mp_l[j]] = 1;
    if(cnt==1)
        return false;
    else
        return true;
}
int main()
{
    cin >> n >> m;
    int a,b;
    for(int i=0;i<m;i++){
        cin >> a >> b;
        mp[a][b] = 1;
        mp[b][a] = 1;
        mp_l[i] = a;
        mp_r[i] = b;
    }
    int ans = 0;
    for(int i=0;i<m;i++){
        if(is(i))
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int n;cin>>n;
	if(n==3||n==5||n==7)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


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

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

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

int main(void) {
  int n, k;
  cin >> n >> k;
  arrll(h,n);

  vecll dp(n);

  dp[0]=0;
  REP(i,1,n){
    ll tmp=1e10;
    REP(j,1,k+1){
      if(i-j<0){continue;}
      tmp=min(tmp,dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=tmp;
  }

  prt(dp[n-1]);



}


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

typedef pair<int,int> ii;

const int N = 100009;

int n, m;
ii a[N] = {};

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a[i].first, &a[i].second);
    }

    sort(a, a + m);

    int ans = 0, r = 1e9;
    for (int i = 0; i < m; i++) {
        if (a[i].first >= r) {
            ans++;
            r = 1e9;
        }
        r = min(r, a[i].second);
    }

    printf("%d\n", ans + 1);
    return 0;
}


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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int n, m;
Int dp[1<<12];

int main() {
    cin >> n >> m;
    vector<Int> a(m), b(m);
    vector<vector<Int>> c(m);
    for (Int i = 0; i < (Int)m; i++) {
        cin >> a[i] >> b[i];
        c[i].resize(b[i]);
        for (Int j = 0; j < (Int)b[i]; j++) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    vector<Int> d(m);
    for (Int i = 0; i < (Int)m; i++) {
        Int bit = 0;
        for (Int j = 0; j < (Int)b[i]; j++) {
            bit = bit | (1<<c[i][j]);
        }
        d[i] = bit;
    }
    for (Int i = 0; i < (Int)(1<<n); i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    queue<Int> q;
    q.push(0);
    while (not q.empty()) {
        Int state = q.front();
        q.pop();
        for (Int i = 0; i < (Int)m; i++) {
            Int next = state | d[i];
            if (dp[next] > dp[state] + a[i]) {
                dp[next] = dp[state] + a[i];
                q.push(next);
            }
        }
    }
    print(dp[(1<<n) - 1] == INF ? -1 : dp[(1<<n) - 1]);
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner
import scala.annotation.tailrec

object Main{
  def main(args: Array[String]){
    val in = new Scanner(System.in)
    val a = in.nextInt
    val line = Array.fill(a)(in.nextInt).toList

    val res = sSort(List(), line, 0)
    println(res._1.mkString(" ") + "\n" + res._2)
  }

  @tailrec
  def sSort(sorted: List[Int], unsorted: List[Int], n: Int):(List[Int], Int)={
    if(unsorted.sorted == unsorted) ((sorted ::: unsorted), n)
    else if(unsorted.indexWhere(_ == unsorted.min) == 0) sSort(sorted :+ unsorted.head, unsorted.tail, n)
    else {
      val pos = unsorted.indexWhere(_ == unsorted.min)
      val swapped = unsorted.updated(0, unsorted(pos)).updated(pos, unsorted.head)

      sSort(sorted :+ unsorted.min, swapped.tail, n+1)
    }
  }
}

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

int main() {
    int n,d,ans = 0;
    cin >> n >> d;
    int x,y;
    
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if(sqrt(pow(x, 2) + pow(y, 2)) <= d) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int N=510;
const int p=998244353;
#define ll long long
ll i,j,k,n,m,x,y,t,a[N][N];
ll w[N][N],r[N][N],f[N][N];
ll val(ll a,ll b,ll c){return w[b][c]-w[a-1][c];}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++)for(j=1;j<=n;j++)if(i!=j)scanf("%d",&a[i][j]);
	for (i=1;i<=n;i++)for(j=n;j>=i+1;j--){w[i][j]=w[i][j+1];for (k=1;k<=i;k++)w[i][j]+=a[j][k];}
	for (i=1;i<=n;i++)for(j=i+1;j<=n+1;j++){r[i][j]=r[i][j-1];for (k=i;k<=j-1;k++)r[i][j]+=a[k][j];}
    memset(f,0x3f,sizeof(f));
	f[0][0]=0;for(i=0;i<=n;i++)for(j=i;j<=n;j++)if(f[i][j]<1e18){for(k=j+1;k<=n+1;k++)f[j][k]=min(f[j][k],f[i][j]+r[j+1][k]+val(i+1,j,k+1));}
    ll ans=1e18;for(i=0;i<=n;i++)ans=min(ans,f[i][n+1]);
	return printf("%lld\n",ans),0;
} 

Measured memory_bytes: 8320
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class CTaxIncrease {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int A, B;
    cin >> A >> B;
    rep(i, 1000000) {
      if (floor((i + 1) * 0.08) == A and floor((i + 1) * 0.1) == B) {
        cout << i + 1 << endl;
        return;
      } else if (i+1 == 1000000) {
        cout << -1 << endl;
      }
    }
  }
};


signed main() {
  CTaxIncrease solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		while (true) {
			int t = sc.nextInt();
			int p = sc.nextInt();
			int r = sc.nextInt();

			if(t==0&&p==0&&r==0)break;
			
			Team[] team = new Team[t];
			for (int i = 0; i < t; i++)
				team[i] = new Team(i, p);

			for (int i = 0; i < r; i++) {
				int tid = sc.nextInt() - 1;
				int pid = sc.nextInt() - 1;
				int time = sc.nextInt();
				String message = sc.next();

				if (message.equals("CORRECT")) {
					team[tid].correct++;
					int tasu=team[tid].problem[pid] * 1200 + time;
					team[tid].point +=tasu; 
				} else
					team[tid].problem[pid]++;

			}
			
			Arrays.sort(team,new Com());
			
			for(int i=team.length-1;i>=0;i--){
				int reteam=team[i].tid+1;
			//	for(int j=0;j<p;j++)System.out.println(team[i].problem[j]);
				System.out.println(reteam+" "+team[i].correct+" "+team[i].point);
			}
			
			
		}

	}

}

class Team {
	int tid;
	int point;
	int correct;
	int[] problem;

	public Team(int num, int array) {
		tid = num;
		point = 0;
		correct = 0;
		problem = new int[array];
	}
}

class Com implements Comparator<Team> {
	public int compare(Team t1, Team t2) {
		if (t1.correct != t2.correct)
			return t1.correct - t2.correct;
		else if (t2.point != t1.point)
			return t2.point - t1.point;
		else
			return t2.tid - t1.tid;
	}
}

Measured memory_bytes: 69012
using System;

class Code_01
{
    
    public static void Main()
    {
        string line = Console.ReadLine();

        int Len = line.Length;
        string ANSWER = "";
        for(int i = 0; i < Len; i++)
        {
            ANSWER += "x";
        }
        Console.WriteLine(ANSWER);


    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>

typedef std::pair<int,int> pii;

int n,k,q;

int a[2005];
bool rem[2005];

pii bottoms[2005];

std::vector<int> choices;
std::vector<int> subseq;
int lo;

int ans=0x3f3f3f3f;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d%d",&n,&k,&q);
    for (int i=0; i<n; i++) {
        scanf("%d",a+i);
        bottoms[i]={a[i],i};
    }
    std::sort(bottoms,bottoms+n);
    rem[n]=1;
    for (int i=0; i<n; i++) {
        // do current position
        choices.clear();
        lo=0;
        for (int j=0; j<=n; j++) {
            if (rem[j]) {
                if (j-lo>=k) {
                    subseq.clear();
                    for (int kk=lo; kk<j; kk++) {
                        subseq.push_back(a[kk]);
                    }
                    std::sort(subseq.begin(),subseq.end());
                    for (int kk=0; kk<=(j-lo)-k; kk++) choices.push_back(subseq[kk]);
                }
                lo=j+1;
            }
        }
        if (choices.size()<q) break;
        std::sort(choices.begin(),choices.end());
        if (ans>choices[q-1]-choices[0]) {
            ans=choices[q-1]-choices[0];
        }
        // remove next bottom element
        rem[bottoms[i].second]=1;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) (x&-x)
#define FalunDafaIsGood puts("No"),exit(0)
using namespace std;

const int S=1<<20;
char buf[S],*H,*T;
inline char Get()
{
	if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
	if(H==T) return -1;return *H++;
}
inline int read()
{
	int x=0;char c=Get();
	while(!isdigit(c)) c=Get();
	while(isdigit(c)) x=x*10+c-'0',c=Get();
	return x;
}

const int N=100010;
int bit[N],n;
int a[4][N],num[N];
int inv[2],flip[2],w[N];

void Add(int p,int x){for(;p;p-=lowbit(p)) bit[p]+=x;}
int Sum(int p){int res=0;for(;p<=n;p+=lowbit(p)) res+=bit[p];return res;}

int main()
{
	n=read();
	for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
			a[i][j]=read();
	static int c[4];
	for(int i=1;i<=n;i++)
	{
		c[1]=a[1][i];c[2]=a[2][i];c[3]=a[3][i];
		sort(c+1,c+4);
		if(c[2]!=c[1]+1||c[3]!=c[2]+1||c[2]!=a[2][i]||c[3]%3) FalunDafaIsGood;
		int x=c[3]/3;
		if((i-x)&1) FalunDafaIsGood;
		inv[i&1]=(inv[i&1]+(a[1][i]>a[3][i]))&1;
		num[i]=x;
	}
	for(int i=1;i<=n;i++) w[num[i]]=i;
	for(int i=1;i<=n;i+=2)
	{
		int now=w[i]+2*Sum(w[i]);
		flip[1]=(flip[1]+abs(i-now)/2)&1;
		Add(w[i],1);
	}
	memset(bit,0,sizeof(bit));
	for(int i=2;i<=n;i+=2)
	{
		int now=w[i]+2*Sum(w[i]);
		flip[0]=(flip[0]+abs(i-now)/2)&1;
		Add(w[i],1);
	}
	puts((flip[0]!=inv[1]||flip[1]!=inv[0])?"No":"Yes");
	return 0;
}

Measured memory_bytes: 3584