akhauriyash/Code-Regression huggingface dataset:
s=input()
n=len(s)
alp=[[] for _ in range(26)]

for i in range(n):
    alp[ord(s[i])-97].append(i)
#print(alp)
flag=0
ans=[]
for i in range(26):
    for j in range(1,len(alp[i])):
        if (alp[i][j]-alp[i][j-1])<=2:
            flag=1
            ans=[alp[i][j-1],alp[i][j]]
            break
    if flag==1:
        break
if flag==0:
    print("-1 -1")
else:
    print(ans[0]+1,ans[1]+1)


Measured memory_bytes: 43376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int ans=0;
    string s;
    cin >> s;
    rep(i,s.length()){
        if((s[i]-'0')==(i%2))ans++;
    }
  	ans=min(ans,int(s.length()-ans));
	cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] x = new int [m];
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                x[sc.nextInt()-1] += 1;
            }
        }
        int ans = 0;
        for (int i = 0; i < m; i++)
            if (x[i] == n)
                ans += 1;

        System.out.println(ans);
    }
}

Measured memory_bytes: 23340
#include <iostream>
#include <vector>
#include <algorithm>
#include <string> 

using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
    string s;cin>>s;
    if(((s[0]==s[1]) && (s[2]==s[3]) && (s[0]!=s[2]))
    || ((s[0]==s[2]) && (s[1]==s[3]) && (s[0]!=s[1]))
    || ((s[0]==s[3]) && (s[1]==s[2]) && (s[0]!=s[1]))){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void B();

int main()
{
	B();
	fflush(stdout);
	return 0;
}

static void B()
{
	int N;
	get(N);

	std::vector<int> d1(N), d2(N);
	for (int i = 0; i < N; i++) {
		get(d1[i], d2[i]);
	}

	const char* ans = "No\n";
	for (int i = 2; i < N; i++) {
		if (d1[i] == d2[i] && d1[i - 1] == d2[i - 1] && d1[i - 2] == d2[i - 2]) {
			ans = "Yes\n";
			break;
		}
	}
	printf(ans);
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

string replace(string trans,int a,int b,string re){
	rep(i,a,b+1){
		trans[i]=re[i-a];
	}
	return trans;
}

string print(string trans,int a,int b){
	string transs = trans; 
	trans = trans.substr(a,b-a+1);
	cout << trans << endl;
	return transs;
}

string reverse(string trans,int a,int b){
		int i=a;
		int j=b;
		while(i<j){
			swap(trans[i],trans[j]);
			i++;
			j--;
		}
	return trans;
}

int main(){
	int q,a,b;
	string str,trans;
	cin>>trans;
	cin>>q;
	rep(i,0,q){
		cin >> str >> a >> b;
		if(str=="print") print(trans,a,b);
		else if(str=="replace"){
			string re;
			cin >> re;
			trans=replace(trans,a,b,re);
		}
		else if(str=="reverse") trans=reverse(trans,a,b);
	}
	return 0;
}


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

int main() {

    int N;
    cin >> N;
    int f = 0;
    int a = N;
    while (a > 0) {
        f += a%10;
        a /= 10;
    }

    if (N%f == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3604
using System;
using System.IO;

namespace Atcoder {
    class abc043b {
        public static void Main(){
            string s = Console.ReadLine();

            string ans = "";
            for(int i = 0; i < s.Length; i++){
                if(s[i] == 'B'){
                    if(ans != ""){
                        ans = ans.Substring(0, ans.Length-1);
                    }
                }
                else{
                    ans += s[i];
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 2648
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int b=400;
		int c=0;
		int j=0;
		for(int i=1;i<=8;i++) {
			while(j<N) {
				if(a[j]<i*b&&a[j]>=(i-1)*b) {
					c++;
					break;
				}
				else if(a[j]>=i*b) {
					break;
				}
				j++;
			}
		}
		int d=0;
		j=N-1;
		while(j>=0&&a[j]>=3200) {
			d++;
			j--;
		}
		System.out.println(Math.max(c, 1)+" "+(c+d));
		
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
int N,M;
int s[11][11];
int k[11],p[11];
int ans=0;
int main(){
	cin >> N >> M;
	for(int i=1;i<=M;i++){
	
		cin >> k[i];
		for(int j=1;j<=k[i];j++){
			cin >> s[i][j];
		}
	}
	for(int i=1;i<=M;i++)cin >> p[i];

	for(int a=0;a<=(1 << N)-1;a++){
		
		bool f = true;
		for(int b=1;b<=M;b++){
			int cnt = 0;
			for(int c=1;c<=k[b];c++){

				int x=a;
				if( (x >> (s[b][c]-1) &1) ==1 ) cnt++;
				//printf("%d %d %d %d\n",a,b,c,cnt);
			}
			if(cnt % 2 != p[b]){f = false;}
		}
		if(f)ans++;
	}
	cout << ans << endl;
		return 0;
}

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

void merge(int arr[], int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m; 
  
    int L[n1], R[n2]; 
  
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
  
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
  
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 
  
void mergeSort(int arr[], int l, int r) 
{ 
    if (l < r) 
    { 
        int m = l+(r-l)/2; 
  
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
} 

int A[100001];

int main() {
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>A[i];

	}
	mergeSort(A,1,n);

	int l,r;
	l=1;
	r=k;
	int ans=1000000001;
	while(r<=n){
		ans=min(ans, A[r]-A[l]);
		l++;
		r++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
from sys import stdin
from math import factorial
n = int(stdin.readline().rstrip())
b = list(map(int,stdin.readline().rstrip().split()))
point = 0
point += b[0]
for i in range(n-2):
    point += min(b[i],b[i+1])
point += b[n-2]
print(point)

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

#define var auto
#define long long long
#define APPLY(a, f, ...) f(a.begin(), a.end(), __VA_ARGS__)
#define FUN(x, f) [](auto x){return f;}

using namespace std;

int main() {
    while(true){
        int n;
        cin >> n;
        if (n == 0) break;
        vector<vector<bool>> exists(21, vector<bool>(21, false));
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            exists[x][y] = true;
        }
        int m;
        cin >> m;
        int curX = 10, curY = 10;
        exists[curX][curY] = false;
        for (int i = 0; i < m; ++i) {
            char dir; int dist;
            cin >> dir >> dist;
            int* axis = dir == 'E' || dir == 'W' ? &curX : &curY;
            int moveDir = dir == 'N' || dir == 'E' ? 1 : -1;
            for (int j = 0; j < dist; ++j) {
                *axis += moveDir;
                exists[curX][curY] = false;
            }
        }
        auto verdict = APPLY(exists, all_of, FUN(x, APPLY(x, all_of, FUN(y, !y))));
        cout << (verdict ? "Yes" : "No") << endl;
    }
}



Measured memory_bytes: 2996
n=int(input())
A=list(map(int,input().split()))
B=[[A[i],i+1] for i in range(n)]
B.sort()
A=[j for i,j in B]

bit=[0]*(n+1)
def add(a,w):
    x=a
    while(x<=n):
        bit[x]+=w
        x+= x&(-x)
def sum(a):
    ret=0
    x=a
    while(x>0):
        ret+=bit[x]
        x-=x&(-x)
    return ret
ans=0
for i in range(n):
    ans+=i-sum(A[i])
    add(A[i],1)
print(ans)



Measured memory_bytes: 40112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if(a+b > x and a <= x) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static int N,K;
    private static int[][] cum;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        cum = new int[2*K+1][2*K+1];
        for (int i = 0; i < N; i++) {
            int x = sc.nextInt()%(2*K);
            int y = sc.nextInt()%(2*K);
            String c = sc.next();
            if(c.equals("B")) {
                x = (x+K)%(2*K);
            }
            cum[y+1][x+1]++;
        }

        for(int y = 0; y < 2*K; y++) {
            for(int x = 0; x < 2*K; x++) {
                cum[y+1][x+1] += cum[y][x+1] + cum[y+1][x] - cum[y][x];
            }
        }

        int ans = 0;
        for(int y = 0; y <= K; y++) {
            for(int x = 0; x <= K; x++) {
                int tmp = count(0,0,x,y) + count(x+K,0,2*K,y) + count(x,y,x+K,y+K) + count(0,y+K,x,2*K) + count(x+K,y+K,2*K,2*K);
                ans = Math.max(ans, Math.max(tmp, N-tmp));
            }
        }
        System.out.println(ans);
    }

    private static int count(int x1, int y1, int x2, int y2) {
        return cum[y2][x2] - cum[y1][x2] - cum[y2][x1] + cum[y1][x1];
    }
}


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

#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()
const double pi = 3.141592653589793;

inline void Main() {
  // code
  double a, b; int h, m, time;
  double hdeg, mdeg, rad, result;
  cin >> a >> b >> h >> m;
  time = 60 * h + m;
  hdeg = time * 0.5;
  mdeg = m * 6;
  rad = abs(hdeg - mdeg);
  rad = (rad>180?360-rad:rad)*pi/180.0;
  result = a*a + b*b - 2*a*b*cos(rad);
  cout << sqrt(result) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	   c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,a[MAXN * 2],v[MAXN * 2];
bool check(int x) {
    for(int i = 1 ; i <= 2 * N - 1 ; ++i) {
        v[i] = (a[i] > x);
    }
    for(int i = 1 ; i < N ; ++i) {
        if(v[N - i] == v[N - i + 1]) {
            return v[N - i] != 1;
        }
        if(v[N + i] == v[N + i - 1]) {
            return v[N + i] != 1;
        }
    }
    v[N] ^= ((N - 1) & 1);
    return v[N] != 1;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= 2 * N - 1 ; ++i) read(a[i]);
    int L = 2,R = 2 * N - 2;
    while(L < R) {
        int mid = (L + R) >> 1;
        if(check(mid)) R = mid;
        else L = mid + 1;
    }
    out(L);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	ll m = 1;
	in(ll, X);
	for (ll i = 2; i*i <= X; ++i)
		for (ll p = 2; pow(i, p) <= X; ++p)
			m = max<ll>(m, pow(i, p));
	out(m);
}

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

int main(){
string S;
cin >> S;
bool a=true;
for(int i=0;i<2;i++){
if(S[i] != S[i+1]){a=false;}
}

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

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
        String s = sc.next();
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='?') out.print("D");
            else out.print(s.charAt(i));
        }
    }
    private static long gcd(long a, long b){
        if(b==0) return a;
        return  gcd(b, a%b);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair implements Comparable<Pair>{
   long x,y;
   Pair(long x, long y){
       this.x = x;
       this.y = y;
   }
   public int compareTo(Pair p){
       return (int)(this.x - p.x);
   }

}

Measured memory_bytes: 36468
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
 
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long
 
int main() {
	string N;
	cin >> N;
	
 
	if (N[0] == '9' || N[1] == '9') {
		cout << "Yes" << endl;
		return 0;
	} 
 
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
 
class MainClass {
    static void Main() {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
 
      int N = int.Parse(Console.ReadLine());
      int A = int.Parse(Console.ReadLine());
      int remain = N % 500;
      if(remain <= A){
      Console.WriteLine("Yes");
      }else{
         Console.WriteLine("No");
      }
 
        Console.Out.Flush();
    }
}

Measured memory_bytes: 11092
n =int(input())
s = list(str(input()))
l = []

for i in range(len(s)):
  t = ord(s[i])
  a = t+n
  if a >= 91:
    a = a-26
  l.append(a)
m =[]
for j in range(len(l)):
  b = chr(l[j])
  m.append(b)
print(''.join(m))

Measured memory_bytes: 3316
N,K = map(int,input().split())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    tmp = [float("inf")]
    for j in range(1,K+1):
        if i - j>=0:
            tmp.append(dp[i-j] + abs(A[i] - A[i-j]))
    dp[i] = min(tmp)

print(dp[len(A)-1])
    


Measured memory_bytes: 56032
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	bool ans = false;
	if (a == x)ans = true;
	else if(a <= x){
		if (a + b >= x)ans = true;
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



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

const int N = 100005, M = 100005;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

struct edge {
	int to, nxt;
} graph[M << 1];
int n, m, head[N], deg[N], cnt = 0;
void addedge (int u, int v) {
	edge e = {v, head[u]};
	graph[head[u] = cnt++] = e;
}

bool check (int s, int u, int t) {
	int prv = s;
	while (u != s && u != t) {
		int v;
		for (int i = head[u]; ~i; i = graph[i].nxt) {
			if (graph[i].to != prv) v = graph[i].to;
		}
		prv = u, u = v;
	}
	return u == t;
}
int main () {
	read(n), read(m);
	for (int i = 1; i <= n; i++) head[i] = -1, deg[i] = 0;
	for (int i = 1; i <= m; i++) {
		int u, v;
		read(u), read(v);
		addedge(u, v), addedge(v, u);
		deg[u]++, deg[v]++;
	}

	int deg4 = 0, bigdeg = 0;
	bool flag = true;
	for (int i = 1; i <= n; i++) {
		if (deg[i] & 1) flag = false;
		if (deg[i] == 4) deg4++;
		else if (deg[i] > 4) bigdeg++;
	}

	if (!flag) printf("No\n");
	else {
		if (bigdeg) printf("Yes\n");
		else if (deg4 > 2) printf("Yes\n");
		else if (deg4 <= 1) printf("No\n");
		else {
			vector<int> vec;
			for (int i = 1; i <= n; i++) {
				if (deg[i] == 4) vec.push_back(i);
			}

			int tot = 0;
			for (int i = head[vec[0]]; ~i; i = graph[i].nxt) {
				int to = graph[i].to;
				if (check(vec[0], to, vec[1])) tot++;
			}

			if (tot == 2) printf("Yes\n");
			else printf("No\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
using namespace std;
const int N=1e2+10;
int main(){
    string s;
    int dp[N][2],now,t,last;
    bool f=true;
    for(int i=0;i<N;i++)dp[i][0]=0;
    last=0;
    while(getline(cin,s)){
        if(s=="END")break;
        for(int i=0;i<N;i++)dp[i][f]=0;
        now=t=0;
        for(int i=0;i<s.size();i++){
            if(s[i]==','){
                dp[t++][f]=now;
                now=0;
            }
            else {
                now*=10;
                now+=s[i]-'0';
            }
        }
        dp[t][f]=now;
        if(last<t){
            dp[0][f]+=dp[0][!f];
            for(int i=1;i<=t;i++)dp[i][f]+=max(dp[i][!f],dp[i-1][!f]);
        }
        else for(int i=0;i<=t;i++)dp[i][f]+=max(dp[i][!f],dp[i+1][!f]);
        f=!f;
        last=t;
    }
    printf("%d\n",dp[0][!f]);
}


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

using namespace std;

int main()
{
	string a, b, c;
	char A, B, C;

	cin >> a >> b >> c;

	if ((char)a[a.length() - 1] != (char)b[0]) {
		cout << "NO" << endl;
	}
	else if ((char)b[b.length() - 1] != (char)c[0]) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

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

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

  int cnt = 0;
  for (int i=2; i<n; i++) {
    int a[3];
    a[0] = p[i-2];
    a[1] = p[i-1];
    a[2] = p[i];
    sort(a, a + 3);
    if (a[1] == p[i-1]) {
      ++cnt;
    }
  }
  cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

void merge_sort(int array[],int left,int right){
  int i,j,k,mid;
  int work[200000];
  
  if(left < right){
    mid = (left + right)/2;
    merge_sort(array,left,mid);
    merge_sort(array,mid+1,right);
    for(i=mid; i>= left;i--){work[i] = array[i];}
    for(j=mid+1; j<=right; j++){
      work[right-(j-(mid+1))] = array[j];
    }
    i = left;
    j = right;
    for(k=left; k<=right; k++){
      if(work[i] < work[j]){array[k] = work[i++];}
      else{array[k] = work[j--];}
    }
  }
}

int main(void){
  int array[200000];
  int a,n,i;
  a = 0;
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d",&array[i]);
  }
  
  merge_sort(array,0,n-1);
  
  for(i=0;i<n-1;i++){
    if(array[i] == array[i+1]){
      printf("NO");
      a = 1;
      break;
    }
  }
  
  if(a == 0)
  	printf("YES");
  return 0;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  int c[n],a[12][12]={};
  for(int i=0;i<n;i++){
     cin>>c[i];
    for(int j=0;j<m;j++){
     cin>>a[i][j];
    }
  }
  int ans=1001001001;
  for(int bit=0;bit<(1<<n);bit++){
      int cost=0;
      vector<int> d(m);
    for(int i=0;i<n;i++){
      if(bit>>i&1){
        cost+=c[i];
        for(int j=0;j<m;j++) d[j]+=a[i][j];
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++) if(d[j]<x) ok=false;
    if(ok) ans=min(ans,cost);
  }
  if(ans==1001001001) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

int main(){
    ll n; cin>>n;
    int ans;
    for(ll i = 1; i*i <= n; i++){
        if(n%i==0) ans = i;
    }
    cout<<ans + n/ans -2;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=3100;
const int inf=0x3f3f3f3f;

int f[Maxn][Maxn],pre[Maxn][Maxn],top;
char a[Maxn],s[Maxn],st[Maxn];

signed main() {
//	freopen("test.in","r",stdin);
	scanf("%s%s",a,s);
	int n=strlen(a),m=strlen(s);
	for(int i=0;i<m;i++) if(a[0]==s[i]) f[0][i]=1;
	for(int i=0;i<m;i++) pre[0][i]=-1;
	for(int i=1;i<n;i++) {
		int now=0,las=-1;
		for(int j=0;j<m;j++) {
			if(a[i]==s[j]) {
				if(f[i-1][j]>now+1) {
					now=f[i-1][j],las=(a[i-1]==s[j]?i-1:pre[i-1][j]);
					pre[i][j]=las;
					f[i][j]=now;
				}
				else {
					pre[i][j]=las;
					f[i][j]=now+1;
					if(f[i-1][j]>now)
						now=f[i-1][j],las=(a[i-1]==s[j]?i-1:pre[i-1][j]);
				}
			}
			else {
				if(f[i-1][j]>now)
					now=f[i-1][j],las=(a[i-1]==s[j]?i-1:pre[i-1][j]);
				pre[i][j]=las;
				f[i][j]=now;
			}
		}
	}
	int ans=0,temp;
	for(int i=0;i<m;i++) if(f[n-1][i]>ans) {
		ans=f[n-1][i];
		temp=i;
	}
	if(ans==0) return 0;
	int nx,ny=temp;
	if(a[n-1]==s[temp]) nx=n-1;
	else nx=pre[n-1][temp];
	while(nx!=-1) {
		st[++top]=a[nx];
		nx=pre[nx][ny];
		int ans=0,temp;
		for(int i=0;i<ny;i++)
			if(f[nx][i]>ans) ans=f[nx][i],temp=i;
		ny=temp;
	}
	while(top) putchar(st[top--]);
	return 0;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  
  int sum=0;
  for(int i=A; i<=B; i++){
    int a1=i/10000;
    int a2=i/1000%10;
    int a4=i/10%10;
    int a5=i%10;
    
    if(a1==a5&&a2==a4){
      sum++;
    }
  }
  
  cout << sum << endl;
  
}

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

int main()
{
	ll A,B;
    cin >> A;
	cin >> B;
	if(B%A == 0){
		cout << (A+B) << endl;
	}else{
		cout << (B-A) << endl;
	}

	return 0;
}

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

using int_ = int;
#define int int_least64_t

int_ main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n; cin >> n;
  cout << accumulate(istream_iterator<int>(cin), {}, -n) << '\n';
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 c.cc -o c && for f in *.in; do echo \"--- $f -------------\"; ./c <$f; done"
 * end:
 */


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    int N, L, S, i;
    scanf("%d %d", &N, &L);
    S=N*(2*L+N-1)/2;
    if (L>=1) S-=L;
    else if (L+N-1<0) S-=L+N-1;
    printf("%d", S);
    return 0;
}


Measured memory_bytes: 128
K, N = map(int, input().split())
A = list(map(int, input().split()))

B = []
for i in range(len(A)):
  B.append( (K -A[i] + A[0]) if i == (len(A)-1) else (A[i+1] - A[i]) )

print(sum(sorted(B)[:-1]))

Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
int F(int a,int b){
	return (max(a,b)+min(a,b))/(min(a,b)+1);
}
int main(){
	int T;cin>>T;
	while(T--){
		int a,b,st,ed;cin>>a>>b>>st>>ed;
		int c=F(a,b),l=1,r=a+b;
		while(l<=r){
			int mid=(l+r)/2,cnta=mid-mid/(c+1),cntb=mid/(c+1);
			if(cnta>a||cntb>b||F(a-cnta,b-cntb)>c||(mid%(c+1)==0&&F(a-cnta,b-cntb+1)>c))r=mid-1;
			else l=mid+1;
		}
		for(int i=st;i<=ed;i++)
			if(i<=r)cout<<"AB"[i%(c+1)==0];
			else cout<<"BA"[(a+b-i)%(c+1)==c];
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define EPS (1e-7)
#define INF (1e9)
#define MODI (1000000007)

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// dp[i][j][k] := 寿司が残り1個の皿がi枚、2個の皿がj枚、
// 3個の皿がk枚の状態から、寿司をすべてなくすのに必要な操作回数の期待値
#define NUM 301
double dp[NUM][NUM][NUM];
int N;

double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0)
        return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0)
        return 0.0;

    double res = 0.0;
    if (i > 0)
        res += rec(i - 1, j, k) * i;
    if (j > 0)
        res += rec(i + 1, j - 1, k) * j;
    if (k > 0)
        res += rec(i, j + 1, k - 1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t, c1 = 0, c2 = 0, c3 = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> t;
        if (t == 1)
            c1++;
        else if (t == 2)
            c2++;
        else if (t == 3)
            c3++;
    }
    // すべての要素を -1 で初期化
    fill((double *)dp, (double *)(dp + lengthof(dp)), -1);
    printf("%.10f\n", rec(c1, c2, c3));

    return 0;
}

Measured memory_bytes: 213376
from functools import reduce


def solve(N):
    if N <= 1:
        return 0
    primes = [
        2, 3, 5, 7, 11,
        13, 17, 19, 23, 29,
        31, 37, 41, 43, 47,
        53, 59, 61, 67, 71,
        73, 79, 83, 89, 97,
    ]
    primes = [p for p in primes if p <= N]
    exps = [0] * len(primes)
    for i in range(len(primes)):
        p = primes[i]
        pi = p
        while pi <= N:
            exps[i] += N // pi
            pi *= p

    ans = 0
    for i in range(len(exps)):
        a = exps[i]

        if 74 <= a:  # 75
            ans += 1

        for j in range(i + 1, len(exps)):
            b = exps[j]

            if 24 <= a and 2 <= b:  # 25*3
                ans += 1
            if 24 <= b:  # 3*25
                ans += 1

            if 14 <= a and 4 <= b:  # 15*5
                ans += 1
            if 14 <= b:  # 5*15
                ans += 1

            for k in range(j + 1, len(exps)):
                c = exps[k]

                if 4 <= c:  # 3*5*5 or 5*3*3
                    ans += 2
                if 4 <= b and 2 <= c:  # 5*5*3
                    ans += 1

    return ans


N = int(input())
print(solve(N))

Measured memory_bytes: 3572
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

int H, W;
vector<vector<char>> A;

int di[4] = { 1, 0, -1, 0 };
int dj[4] = { 0, 1, 0, -1 };

bool is_filled(vector<vector<char>> v) {
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (v[i][j] == '.')
				return false;
		}
	}
	return true;
}

int main() {
	cin >> H >> W;
	A.assign(H, vector<char>(W));
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			cin >> A[i][j];

	int ans = 0;
	queue<pii> cand;
	int nb;
	{
		nb = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (A[i][j] == '#') {
					nb++;
					for (int k = 0; k < 4; k++)
					{
						int ii = i + di[k], jj = j + dj[k];
						if (0 <= ii and ii < H and 0 <= jj and jj < W)
							if (A[ii][jj] == '.')
							{
								A[ii][jj] = ',';
								cand.push(pii(ii, jj));
							}
					}
				}
			}
		}
	}

	while (true) {
		if (nb == H * W)
			break;

		queue<pii> ncand;

		while (!cand.empty()) {
			int i = cand.front().first;
			int j = cand.front().second;
			cand.pop();
			nb++;
			for (int k = 0; k < 4; k++)
			{
				int ii = i + di[k], jj = j + dj[k];
				if (0 <= ii and ii < H and 0 <= jj and jj < W)
					if (A[ii][jj] == '.')
					{
						A[ii][jj] = ',';
						ncand.push(pii(ii, jj));
					}
			}
		}

		cand = ncand;
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6400
import math
a,b,h,m=map(int,input().split())
ang=min(abs(m*6-(h*30+m*0.5)),360-abs(m*6-(h*30+m*0.5)))
print((a**2+b**2-2*a*b*math.cos(math.radians(ang)))**0.5)

Measured memory_bytes: 9456
import java.util.*;
import java.math.*;
import java.text.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int[][] door = new int[59][30];
		int[][] room = new int[30][30];
		while(true){
			int x = in.nextInt();
			int y = in.nextInt();
			if(x==0 && y==0) break;
			for(int n=0; n<y*2-1; n++){
				if(n%2==1){
					for(int m=0; m<x; m++){
						door[n][m] = in.nextInt();
					}
				}else{
					for(int m=0; m<x-1; m++){
						door[n][m] = in.nextInt();
					}
				}
			}
			for(int m=0; m<y; m++){
				for(int n=0; n<x; n++){
					room[m][n]=9999;
				}
			}
			room[0][0]=1;
			while(true){
				boolean rev = true;
				for(int m=0; m<y; m++){
					for(int n=0; n<x; n++){
						//if (2,3) pull (4,2) from (2,2)
						//if (3,4) pull (6,3) from (3,3)
						if(n>0 && door[m*2][n-1]==0 && room[m][n]>room[m][n-1]+1){
							room[m][n]=room[m][n-1]+1;
							rev = false;
						}
						//if (2,3) pull (4,3) from (2,4)
						//if (3,4) pull (6,4) from (3,5)
						if(n<x-1 && door[m*2][n]==0 && room[m][n]>room[m][n+1]+1){
							room[m][n]=room[m][n+1]+1;
							rev = false;
						}
						//if (2,3) pull (3,3) from (1,3)
						//if (3,4) pull (5,5) from (2,4)
						if(m>0 && door[m*2-1][n]==0 && room[m][n]>room[m-1][n]+1){
							room[m][n]=room[m-1][n]+1;
							rev = false;
						}
						//if (2,3) pull (5,3)
						//if (3,4) pull (7,5)
						if(m<y-1 && door[m*2+1][n]==0 && room[m][n]>room[m+1][n]+1){
							room[m][n]=room[m+1][n]+1;
							rev = false;
						}
					}
				}
				if(rev) break;
			}
			if(room[y-1][x-1]==9999) System.out.println("0");
			else System.out.println(room[y-1][x-1]);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
ll n, k, a[100005] = {}, r, e[6], b[100005]= {}, i, j, g = 1000000007, m = -5, c, d,z=0;
string s;


int main() {
	
	cin >> n;
	rep(i, n + 1)cin >> a[i];
	rep(i, n)cin >> b[i];
	b[n] = 0;
	c = 0; d = 0;
	rep(i, n+1) {
		if (c >= a[i]) {
			z += a[i]; c = b[i]; continue;
		}
		a[i] -= c;
		z += c;
		if (a[i] > b[i]) {
			c = 0; z += b[i];
		}
		else {
			z += a[i]; c =b[i]-a[i];
		}
	}
	cout <<z;
	return 0;
}




Measured memory_bytes: 1792
#define P(x) cout << #x" = " << x << endl
#define PP(x, y) cout << "("#x", "#y") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "("#x", "#y", "#z") = (" << x << ", " << y << ", " << z << ")" << endl

#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int k;
int cost[100000];

deque<int> deq;

int main(){
    cin >> k;
    fill(cost, cost + k, k * 10);
    deq.push_back(1);
    cost[1] = 0;
    while(!deq.empty()){
        int x = deq.front();
        // cout << x << endl;
        deq.pop_front();
        int cur = cost[x];
        int next0 = (x * 10) % k;
        int next1 = (x + 1) % k;
        if (cost[next0] > cur) {
            cost[next0] = cur;
            deq.push_front(next0);
        }
        if (cost[next1] > cur + 1) {
            cost[next1] = cur + 1;
            deq.push_back(next1);
        }
    }
    cout << cost[0] + 1<< endl;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>

#define N 101

int selectionSort(int *, int);

int main() {
  int i, n, c;
  int A[N];
  
  scanf("%d", &n);
  if(n<0 || n>100) exit(1);

  for(i=0;i<n;i++) scanf("%d", &A[i]);

  c = selectionSort(A, n);

  for(i=0;i<n-1;i++) printf("%d ", A[i]);
  printf("%d\n%d\n", A[i], c);

  return 0;
}

int selectionSort(int *A, int n){
  int i, j, m, temp;
  int c=0;

  for(i=0;i<n;i++){
    m=i;
    for(j=i+1;j<n;j++){
      if(A[j]<A[m]) m=j;
    }

    if(i!=m){
      temp=A[i];
      A[i]=A[m];
      A[m]=temp;
      c++;
    }
  }
  return c;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int currentCount = 0;
        int lastColor = -1;
        int p = 0;
        int res = 0;
        for (int i = 0; i < a.Length; i++)
        {
            if (lastColor != a[i])
            {
                res += currentCount / 2;
                currentCount = 0;
            }
            currentCount++;
            lastColor = a[i];
        }
        res += currentCount / 2;
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13268
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    # index begins with 1
    A = [int(x)-1 for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]

    ans = B[A[0]]
    for i in range(1,N):
        ans += B[A[i]]
        if A[i]==A[i-1]+1:
            ans += C[A[i-1]]
    print(ans)

# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc140","b",main)

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

#define MaxN 300005
#define INF 2140000000

using namespace std;

int N,Min=INF,wb,eb,e,w;
string s;

int main()
{
    cin>>N>>s;
    for(int i=0;i<N;i++)
    {
        if(s[i]=='W')
            w++;
        else e++;
    }
    for(int i=0;i<N;i++)
    {
        if(s[i]=='W')
        {
            Min=min(Min,wb+e-eb);
            wb++;
        }
        else
        {
            Min=min(Min,wb+e-eb-1);
            eb++;
        }
    }
    cout<<Min;
    return 0;
}


Measured memory_bytes: 900
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] array1 = new int[m];
    int[] array2 = new int[m-1];
    int sum =0;

    for(int i=0;i<m;i++){
      array1[i] = sc.nextInt();
    }
    if(n>=m){
      System.out.println("0");
      System.exit(0);
    }


    Arrays.sort(array1);
    //for(int num : array1){
      //System.out.println(num);
    //}
    for(int i=1;i<m;i++){
      array2[i-1] = array1[i]-array1[i-1];
    }
    Arrays.sort(array2);
    //for(int num : array2){
      //System.out.println(num);
    //}

    int dis = array1[m-1] - array1[0];

    for(int i=0; i<n-1;i++){
      sum += array2[m-2-i];
    }
    int result = dis -sum;
    System.out.println(result);
  }

}

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

int c()
{
    int a, b, h, m;
    std::cin >> a >> b >> h >> m;
    
    
    int time = 60 * h + m;
    long double degA = 0.5 * time;
    long double degB = 6 * m;
    long double tempDeg = std::abs(degA - degB);
    const double PI = 3.14159265358979323846;
    if(180 < tempDeg)
    {
        tempDeg = 360 - tempDeg;
    }
    long double rad = (long double)tempDeg * PI / 180;
    
    long double temp = 2 * a * b * std::cos(rad);
    long double ans = ((long double)a * (long double)a) + ((long double)b * (long double)b) - temp;
    long double test = (long double)std::sqrt(ans);
    
    std::cout.precision(20);
    std::cout << test << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    c();
    return 0;
}

Measured memory_bytes: 4152
using System;

namespace A {
    class Program {
        static void Main(string[] args) {
            var l = Console.ReadLine().Split(' ');
            int a = int.Parse(l[0]);
            int b = int.Parse(l[01]);

            if(a + b == 15) {
                Console.WriteLine('+');
            }
            else if(a*b == 15) {
                Console.WriteLine('*');
            }
            else {
                Console.WriteLine('x');
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){long long int n,x,y,i,j,k;
cin>>n>>x>>y;
long long int ans[n+1]={0};
for(i=1;i<n;i++){
    for(j=i+1;j<=n;j++){
        if(j<=x||i>=y){k=j-i;}
        else{
            k=min(j-i,abs(x-i)+abs(y-j)+1);
        }
        ans[k]++;
    }
}
for(i=1;i<n;i++){cout<<ans[i]<<endl;}
    return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
const int INF = 1e9;

template <typename T>
class SegTree{
  using F = function<T(T,T)>;
  int n; F f; T uni;
  vector<T> dat;
  
  T _query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return uni;
    if(a <= l && r <= b) return dat[k];
    T vl = _query(a, b, k*2+1, l, (l+r)/2);
    T vr = _query(a, b, k*2+2, (l+r)/2, r);
    return f(vl,vr);
  }

public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n-1,uni);
  }

  void update(int k, T a) {
    k += n-1;
    dat[k] = a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = f(dat[2*k+1], dat[2*k+2]);
    }
  }

  T query(int a, int b){ 
    return _query(a, b, 0, 0, n);
  } 

  T operator[](int i) {
    return dat[i+n-1];
  }
};

int l(int a, int b) {return min(a,b);}
int r(int a, int b) {return max(a,b);}

int main(){
  int n, k;
  cin >> n >> k;
  int p[n];
  SegTree<int> stl(n,l,INF);
  SegTree<int> stu(n,r,-1);  
  rep(i,n) {
    cin >> p[i];
    stl.update(i,p[i]);
    stu.update(i,p[i]);
  }
  int c = 1, num = 0;
  for(int i = 1; i < n; i++) {
    if(p[i] > p[i-1]) c++;
    else {
      if(c >= k) num++;
      c = 1;
    } 
  }
  if(c >= k) num++;
  int ans = 1;
  for(int i = 1; i <= n-k; i++){
    if(p[i-1] != stl.query(i-1,i+k) || p[i+k-1] != stu.query(i-1,i+k)) ans++;
  }
  if(num >= 2) ans -= num-1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6656
N = int(input())
li = list(map(int,input().split()))
li.sort()
k = 0
while len(li) >1:
    k = (li[0] + li[1]) / 2
    del li[1]
    del li[0]
    li.insert(0,k)
print('{:.10g}'.format(li[0]))


Measured memory_bytes: 38256
#include <stdio.h>

int main() {
  int r, c, a[101][101] = {0};

  scanf("%d %d", &r, &c);
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      a[i][c] = a[i][c] + a[i][j];
      a[r][j] = a[r][j] + a[i][j];
    }
  }
  
  for (int i = 0; i < r; i++) {
    a[r][c] = a[r][c] + a[i][c];
  }

  for (int i = 0; i < r+1; i++) {
    for (int j = 0; j < c+1; j++) {
      if (j == 0)
        printf("%d", a[i][j]);
      else
        printf(" %d", a[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll n, k;
	cin>>n>>k;
	ll ans = 0;
	for(ll i = k; i <= n + 1; i++){
		ans += i*n - i*(i - 1) + 1;
	}
	ans %= 1000000007;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    long long l = 4 * a * b;
    long long r = (c - a - b);
    if (l < r * r and r >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b && b<c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<b && b>c){
		printf("%d %d %d\n",a,c,b);
	}
	else if(a>b && b>c){
		printf("%d %d %d\n",c,b,a);
	}
	else if(b<c && a>c){
		printf("%d %d %d\n",b,c,a);
	}
	else if(a>b && a<c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(a>c && a<b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(a==b && b>c){
		printf("%d %d %d\n",c,a,b);
	}
	else if(a==b && b<c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(a>b && a==c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(a<b && a==c){
		printf("%d %d %d\n",c,a,b);
	}
	else if(a>c && b==c){
		printf("%d %d %d\n",b,c,a);
	}else{
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}

Measured memory_bytes: 2684
X = int(input())

def dfs(a, b):
    if (a**5 - b**5) == X:
        print(a, b)
        exit()
    if(a**5 - b**5) > X:
        dfs(a-1, b)
        dfs(a, b-1)
    else:
        dfs(a+1, b)
        dfs(a, b+1)
   
def solve():
    for a in range(-120, 120):
        for b in range(-120, 120):
            if a**5 - b**5 == X:
                print(a, b)
                exit()

#dfs(1, 1)
solve()


Measured memory_bytes: 9096
S = input()
T = input()
N = len(S)
n = len(T)
ans = 0

x = 0
y = 0
s = ''
for i in range(N - n + 1):
    s = S[i:i + n]
    for j in range(n):
        if s[j] == T[j]:
            x += 1
    ans = max(ans, x)
    x = 0
ans = n - ans
print(ans)


            
    

    

Measured memory_bytes: 9012
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(i64);
    let a_lst = input!(i64; n);

    let mut index: i64 = n - 1;
    let mut step = -2;

    while index < n {
        print!("{} ", a_lst[index as usize]);
        index += step;
        if index < 0 {
            step = 2;
            index = if n % 2 == 0 { 0 } else { 1 };
        }
    }
    println!("");
}


Measured memory_bytes: 10492
// After contest. Reverse the process.
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;

	cin >> n;

	vector<int> b(n);

	for (int i = 0; i < n; ++i)
		cin >> b[i];

	bool ok = true;
	vector<int> a(n);

	for (int i = 0; i < n; ++i) {
		int j = b.size()-1;
		for ( ; j >= 0; --j)
			if (b[j] == j+1)
				break;

		if (j < 0) {
			ok = false;
			break;
		}

		a[n-1-i] = j+1;
		b.erase(b.begin() + j);
	}

	if (ok)
		for (int i = 0; i < n; ++i)
			cout << a[i] << endl;
	else
		cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256