akhauriyash/Code-Regression huggingface dataset:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,a,b,c,d = iim()
s = input()
st = s[b-2:min(c,d)+1]
s = s[a-1:max(c,d)]

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
else:
    print('Yes' if '...' in st else ' No')

Measured memory_bytes: 3572
N,K=map(int,input().split())
p=list(map(int,input().split()))

m=0

for i in range(0,K):
    m=m+p[i]+1

A=[]
A.append(m)

if N==K:
    print(A[0]/2)
else:
    for i in range(1,N-K+1):
        s=A[i-1]-p[i-1]+p[i+K-1]
        A.append(s)
    print(max(A)/2)


Measured memory_bytes: 24804
package main

import "fmt"

func reverseCopy(r, s []byte) {
	n := len(s)
	for i := 0; i < n; i++ {
		r[i] = s[n-i-1]
	}
}

func main() {
	var s string
	var q int
	fmt.Scan(&s, &q)

	rev := false
	head := []byte{}
	tail := []byte{}
	body := []byte(s)

	for ; q > 0; q-- {
		var t int
		fmt.Scan(&t)
		if t == 1 {
			head, tail = tail, head
			rev = !rev
		} else {
			var f int
			fmt.Scan(&f, &s)

			if f == 1 {
				head = append(head, s[0])
			} else {
				tail = append(tail, s[0])
			}
		}
	}

	// fmt.Println(string(head), string(body), string(tail))
	res := make([]byte, len(head))
	reverseCopy(res, head)
	if rev {
		tmp := make([]byte, len(body))
		reverseCopy(tmp, body)
		res = append(res, tmp...)
	} else {
		res = append(res, body...)
	}
	res = append(res, tail...)
	fmt.Println(string(res))
}


Measured memory_bytes: 5888
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;

	string str;
	vector<LL> hist(26,0);
	for(int i=0;i<N;++i){
		cin >> str;
		hist[ str[0]-'A' ]++;
	}
	vector<LL> V(5,0);
	V[0] = hist['M'-'A'];
	V[1] = hist['A'-'A'];
	V[2] = hist['R'-'A'];
	V[3] = hist['C'-'A'];
	V[4] = hist['H'-'A'];
	vector<bool> S(5,false);
	S[0] = true;
	S[1] = true;
	S[2] = true;
	sort(S.begin(),S.end());
	LL ans = 0;
	do{
		LL res = 1;
		for(int i=0;i<5;++i){
			if( S[i] ){
				res *= V[i];
			}
		}
		ans += res;
	}while(next_permutation(S.begin(),S.end()));
	cout << ans << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int[] c = new int [N];
		int[] t = new int[N];
		int p = 1100;
		for (int i = 0; i < N ; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if (t [i] <= T) {
				if (c[i] < p) {
					p = c[i];
				}
			}
		}
		if (p == 1100) {
			System.out.println ("TLE");
		} else {
			System.out.println(p);
		}
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
999999999
)");
#define cin input
#endif

int main()
{
	int n;
	cin >> n;
	int na;
	na = n;
	int s = 0;

	while (n!=0)
	{
		s += n%10;
		n = n/10;
	}
	
	if (na%s==0)
		cout << "Yes" << endl;
	else
	{
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {

    int i, j, n, q, c, left, right, mid;
    int a[100000], b[50000];

    c = 0;

    scanf("%d", &n);

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

    scanf("%d", &q);

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

    for (i = 0; i < q; i++) {
        left = 0; right = n;
        for (; left < right; ) {
            mid = (left + right) / 2;
            if (b[i] == a[mid]) {
                c += 1;
                break;
            } else if (b[i] < a[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
    }

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

    return 0;

}



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

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;
    static final long INF = (long) 4E18;

    public static void main(String[] args) {
        int N = nint();
        int K = nint();
        
        long[] h = nlongs(N, 1, 0);
        long[] cost = new long[N+1];
        Arrays.fill(cost, INF);
        cost[1] = 0;
        
        for (int i = 1; i < N; i++) {
            for (int k = 1; k <= K; k++) {
                int next = i + k;
                if (N < next) continue;
                cost[next] = min(cost[next], cost[i] + cost(h, next, i));
            }
        }
        
        System.out.println(cost[N]);
    }
    
    static long cost(long[] h, int from, int to) {
        return abs(h[to] - h[from]);
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static long abs(long a) {
        return Math.abs(a);
    }
}


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

int main() {
    int a, b, c;
	cin >> a >> b >> c;
    // a  =  b  =  c
    // a  =  b !=  c
    // a !=  b  =  c
    // a  =  c !=  b 
    // a !=  b !=  c
    int count = 0;
    if (a == b && b == c) {
        count = 1;
    } else if (a == b && b != c) {
        count = 2;
    } else if (a != b && b == c) {
        count = 2;
    } else if (a == c && c != b) {
        count = 2;
    } else {
        count = 3;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int h[maxn],go[maxn*2],dis[maxn*2],nxt[maxn*2],fa[maxn],co[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,tot,top,cnt,zero,one,two,mx;
bool czy;
ll ans;
void add(int x,int y,int z){
    go[++tot]=y;
    dis[tot]=z;
    nxt[tot]=h[x];
    h[x]=tot;
}
void dfs(int x){
    bz[x]=1;
    top++;
    if (!co[x]) zero++;
    else if (co[x]==1) one++;
    else two++;
    mx=max(mx,co[x]);
    int t=h[x];
    while (t){
        if (!pd[(t+1)/2]){
            pd[(t+1)/2]=1;
            cnt++;
            if (!bz[go[t]]){
                co[go[t]]=(co[x]+dis[t]+3)%3;
                dfs(go[t]);
            }
            else{
                if (co[go[t]]!=(co[x]+dis[t]+3)%3) czy=1;
            }
        }
        t=nxt[t];
    }
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        add(j,k,1);add(k,j,-1);
    }
    fo(i,1,n)
        if (!bz[i]){
            czy=top=zero=one=two=cnt=mx=0;
            dfs(i);
            if (czy){
                ans+=(ll)top*top;
                continue;
            }
            if (!zero||!one||!two){
                ans+=(ll)cnt;
                continue;
            }
            ans+=(ll)zero*one;
            ans+=(ll)one*two;
            ans+=(ll)two*zero;
        }
    printf("%lld\n",ans);
}

Measured memory_bytes: 6656
#include <iostream>
#include<iomanip>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
using namespace std;

const int NN=1e5+10;
const int mod=1e9+7;

int n,m;
int a[60],b[60];
int c[60],d[60];

int leng(int aa,int bb,int cc,int dd)
{
    return abs(cc-aa)+abs(dd-bb);
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(int j=0;j<m;j++){
        scanf("%d%d",&c[j],&d[j]);
    }
    for(int i=0;i<n;i++){
        int Min=leng(a[i],b[i],c[0],d[0]);
        int numb=0;
        for(int j=1;j<m;j++){
            int len=leng(a[i],b[i],c[j],d[j]);
            if(len<Min){
                Min=len;
                numb=j;
            }
        }
        printf("%d\n",numb+1);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int d, n;
    cin >> d >> n;
    if(n == 100)
        n++;
    cout << n * int(pow(100, d)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<con>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a==0&&b==0)
        cout<<0<<endl;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
      
        if ((x-a)>b||x<a){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const int MAX_N = (int)2e5 + 5;
pii A[MAX_N];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i].second>>A[i].first;
    sort(A, A+N);
    int cur = 0;
    for(int i=0;i<N;i++){
        if(cur+A[i].second>A[i].first){
            cout<<"No"<<endl;
            return 0;
        }
        cur += A[i].second;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int a[10];
  int n[10],k[10];
  for(int i=0;i<7;i++){
    cin>>n[i]>>k[i];
  }
  for(int i=0;i<7;i++){
    a[i]=n[i]-k[i];
  }
  for(int i=0;i<7;i++){
    cout<<a[i]<<endl;
  }
  return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    fastio();
    int a;
    cin >> a;
    cout << a + a*a + a*a*a;
    return 0;
}


Measured memory_bytes: 3636
A, B, C, D = map(int, list(input()))

op1 = '-'
op2 = '-'
op3 = '-'
if A + B + C + D == 7:
  op1 = '+'
  op2 = '+'
  op3 = '+'
elif A + B + C - D == 7:
  op1 = '+'
  op2 = '+'
elif A + B - C + D == 7:
  op1 = '+'
  op3 = '+'
elif A + B - C - D == 7:
  op1 = '+'
elif A - B + C + D == 7:
  op2 = '+'
  op3 = '+'
elif A - B + C - D == 7:
  op2 = '+'
elif A - B - C + D == 7:
  op3 = '+'

print('{}{}{}{}{}{}{}=7'.format(A, op1, B, op2, C, op3, D))

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
a, b, x = map(int, input().split())
if a**2*b == x:
  print(0)
  exit()
import math
if 2*x <= a**2*b:
  t1 = a*b**2
  t2 = 2*x
  ans = math.degrees(math.atan(t1/t2))
else:
  t1 = a**3
  t2 = 2*a**2*b - 2*x
  ans = 90 - math.degrees(math.atan(t1/t2))
print(ans)
if em: sys.stdin = open('/dev/tty')


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

int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, k;
	cin >> n >> k;
	int cnt=  0;
	while(n) {
		n /= k;
		cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int abs(int x)
{
	if (x < 0)return -x;
	else return x;
}
int huiwen(char a[], int n)
{
	char b[100005] = { 0 };
	int i, j,f=0;
	for (i = 0; i < n; i++)
		b[i] = a[n - i - 1];
	for (i = 0; i < n; i++)
	{
		if (a[i] != b[i])f++;
	}
	if (f)return 0;
	else return 1;
}
int main()
{
	int na,nb, i,j, num=0,I,J;
	char a[100005] = { 0 }, b[100005] = {0};
	int c[50005] = { 0 }, d[50005] = { 0 };
	cin >> a;
	//去掉字符串中所有x
	i = 0;
	while (a[i])i++;
	na = i; i = 0; j = 0;
	while (i < na) {
		if (a[i] != 'x') { b[j] = a[i]; j++; }
		i++;
	}i = 0;
	while (b[i])i++;
	nb = i;
	//如剩下的字符串是回文则可以，继续
	if (huiwen(b,nb) == 0)
	{
		cout << -1 << endl;
		return 0;
	}
	//找到对称点
	I = 0; i = 0;
	while (I < (nb / 2)+1)
	{
		if (a[i] != 'x')I++;
		i++;
	}
	//从对称点一侧开始检索
	j = 0; i--; I = i;
		while (a[i])
		{
			while (a[i] == 'x')
			{
				i++;
				c[j]++;
			}
			i++; j++;
		}
		j = 0;
		if (nb % 2 == 0)
		{
			i = I - 1;
			while (a[i] == 'x')i--;
		}
		else i = I;
		while (i >= 0)
		{
			while (a[i] == 'x')
			{
				i--;
				d[j]++;
			}
			i--; j++;
		}
	//在原回文数组中找出各个子母间x的数值，两边都算
	for (i = 0; i <= (nb+1)/2; i++)
		num += abs(c[i] - d[i]);
	//两边每个区间的x值之差求和
	cout << num << endl;
	return 0;
}
//测试数据：abcdxxxdxxcbxaxx 答案：5

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

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    int x = 0;
    int maximum = 0;
    for (int i = 0; i < N; i++){
        if (s.at(i) == 'I'){
            x++;
            maximum = max(maximum, x);
        }
        else x--;
    }
    cout << maximum << endl;
    return 0; 
}




Measured memory_bytes: 256
#include <iostream>
#include <climits>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;
int main() {
    int K, N, A[2 * 100000 + 1];
    cin >> K >> N;
    rep(i, N) {
        cin >> A[i];
    }
    int maxB = 0;
    rep(i, N - 1) {
        int b = A[i + 1] - A[i];
        if (maxB < b) {
            maxB = b;
        }
    }
    int bEnd = A[0] + (K - A[N - 1]);
    if (maxB < bEnd) {
        maxB = bEnd;
    }
    cout << (K - maxB) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=2000005,INF=1<<30;

vector<int> prime;//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(MAX-2);
    
    ll N;cin>>N;
    int ans=0;
    
    for(int p:prime){
        for(int j=1;;j++){
            ll x=1;
            for(int k=1;k<=j;k++){
                x*=p;
            }
            if(N%x==0){
                ans++;
                N/=x;
            }else break;
        }
    }
    
    for(int p:prime){
        while(N%p==0) N/=p;
    }
    
    if(N!=1) ans++;
    
    cout<<ans<<endl;
}




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

#define REP(i,n) for(int (i)=0; i<(int)(n); i++)

bool used[100005];
vector < pair<long long,long long> > g[100005];
long long dist[100005];

void dfs(int pos,long long depth)
{
	if(dist[pos] != -1)
		return;
	dist[pos] = depth;
	for(int i = 0;i < g[pos].size();i++)
		dfs(g[pos][i].first,depth + g[pos][i].second);
}

int main(void)
{
	long long N;
	cin >> N;
	memset(dist,-1,sizeof(dist));
	REP(i,N-1)
	{
		long long x,y,z; 
		cin >> x >> y >> z;
		x--; y--;
		g[x].push_back({y,z});
		g[y].push_back({x,z});
	}
	int T,K;
	cin >> T >> K;
	dfs(K-1,0);
    while(T--){
    	long long x,y;
    	cin >> x >> y;
    	x--; y--;
    	cout << dist[x]+dist[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 12800
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()

    println(hitachi2020a(s))
}

private fun hitachi2020a(s: String): String {
    var check = ""
    for (i in 1..5) {
      check += "hi"
      if (s.equals(check)) return "Yes"
    }

    return "No"
}

Measured memory_bytes: 29600
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n / 2 - 1 << endl;
    } else {
        cout << n / 2 << endl;
    }
}

Measured memory_bytes: 892
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let ans1 = 0;
   let ans2 = 0; 
  
   for(let i=0; i<xs.length; i++){
     if(xs[i]==5){
       ans1++
     }else if(xs[i]==7){
       ans2++
     }
   }
   if(ans1==2&&ans2==1){
     console.log('YES');
   }else{
     console.log('NO');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main() {
  int n, l, i;
  cin >> n >> l;

  vector<string> v(n);
  for (i=0; i<n; i++) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());

  for (i=0; i<n; i++) {
    cout << v[i];
  }
  cout << endl;
}

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

long long a,b;

long long f(long long n,long long x){
		if(n%x==0)return (n<<1)-x;
		return 2*(n/x)*x+f(x,n%x);
	
}

int main(){
	cin>>a>>b;
	cout<<f(b,a-b)+a<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  vector<ll> S(N+1,0);
  for(int i=0; i<N; i++){
    S[i+1] = S[i] + A[i];
  }
  ll ans = INF;
  // [0,l),[l,i),[i,r),[r,N)
  int l=1,r=3;
  for(int i=2; i<=N-2; i++){
    while(l+1<i){
      if(abs(S[l]-(S[i]-S[l])) < abs(S[l+1]-(S[i]-S[l+1]))) break;
      l++;
    }
    chmax(r,i+1);
    while(r+1<N){
      if(abs((S[r]-S[i])-(S[N]-S[r])) < abs((S[N]-S[r+1])-(S[r+1]-S[i]))) break;
      r++;
    }
    ll mn = INF,mx = 0;
    chmax(mx,S[l]);
    chmax(mx,S[i]-S[l]);
    chmax(mx,S[r]-S[i]);
    chmax(mx,S[N]-S[r]);
    chmin(mn,S[l]);
    chmin(mn,S[i]-S[l]);
    chmin(mn,S[r]-S[i]);
    chmin(mn,S[N]-S[r]);
    chmin(ans,mx-mn);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5572
#include <cstdio>
#include <cstdlib>
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node {int key;Node *right,*left,*parent;};
Node *root,*NIL;
void insert(int k){
  Node *y=NIL,*x=root,*z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else {
    if(z->key < y->key) y->left=z;
    else y->right=z;
  }
}
void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n,x;
  char com[6];
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 26560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define all(c) (c).begin(),(c).end()

using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Real norm(){return sqr(x*x+y*y);}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}

  Line tangent(Real theta){
    Point a(r*cos(theta),r*sin(theta));
    Point b(a.y,-a.x);
    return Line(p+a,p+a+b);
  }
  
  vector<Line> commonTangent(Circle x){
    vector<Line>res;
    x.p=x.p-p;
    Real a=x.p.arg();
    Real b[2]={(r-x.r),(r+x.r)};
    for(int i=0;i<2;i++){
      b[i]/=x.p.norm();
      if(sgn(b[i],-1.0)<0 || sgn(b[i],1.0)>0)return res;
      Real c=asin(b[i])-asin(1.0);
      res.push_back(tangent(a-c));
      res.push_back(tangent(a+c));
    }
    return res;
  }
  
};

int n;
vector<Circle>c;
vector<Real>m;

vector<Line> enumerate(){
  vector<Line>res;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      vector<Line>tmp=c[i].commonTangent(c[j]);
      for(int k=0;k<tmp.size();k++){
	res.push_back(tmp[k]);
      }
      c[i].r+=m[i];
      tmp=c[i].commonTangent(c[j]);
      for(int k=0;k<tmp.size();k++){
	res.push_back(tmp[k]);
      }
      c[i].r-=m[i];
    }
  }
  return res;
}

int count(Line l){
  int cnt=0;
  for(int i=0;i<n;i++){
    Real d=l.dist(c[i].p)-c[i].r;
    cnt+=(sgn(d)>=0 && sgn(d,m[i])<=0);
  }
  return cnt;
}

int main(void){

  while(cin >> n,n){
    c.resize(n);
    m.resize(n);

    for(int i=0;i<n;i++)
      cin >> c[i].p.x >> c[i].p.y >> c[i].r >> m[i];
    
    vector<Line>res=enumerate();
    
    int cnt=0;
    for(int i=0;i<res.size();i++){
      cnt=max(cnt,count(res[i]));
    }
    cout << max(1,cnt) << endl;
  }
  return 0;
}

Measured memory_bytes: 2828
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

inline void YESNO(bool ans){cout<<(ans?"YES":"NO")<<endl;}
inline void YesNo(bool ans){cout<<(ans?"Yes":"No")<<endl;}
inline void yesno(bool ans){cout<<(ans?"yes":"no")<<endl;}

int main(){
	int a[3];
	int k;
	REP(i,3) cin>>a[i];
	cin>>k;
	
	int cnt=0;
	for(int i=1;i<3;++i){
		for(;a[i]<=a[i-1];a[i]*=2) cnt++;
	}
	
	bool ans=(cnt<=k);
	
	YesNo(ans);
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int X = getint(), Y = getint(), A = getint(), B = getint(), C = getint();

	int abc[400000];
	auto a = abc;
	auto b = abc + A;
	auto c = abc + A + B;

	rep(i, A + B + C) a[i] = getint();

	nth_element(a, b - X, b);
	nth_element(b, c - Y, c);
	ll kotae = 0;
	if (B - Y) {
		memcpy(c + C, b - X, X * sizeof(int));
		nth_element(c - Y, c + C - Y, c + C + X);
		for (auto kari = c + C - Y; kari < c + C + X; kari++) kotae += *kari;
	}
	else {
		nth_element(c - X - Y, c + C - X - Y, c + C);
		for (auto kari = c + C - X - Y; kari < c + C; kari++) kotae += *kari;
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
module ABC138

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_C
  private :: sort_heap

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer      :: num_ingredient
    real(REAL64) :: value_maximum

    ! support variables for this <subroutine>
    integer :: itr

    ! arrays for this <subroutine>
    real(REAL64), dimension(:), allocatable :: value_ingredient

    ! STEP.01
    ! read out the number of given ingredient
    read(unit=INPUT_UNIT, fmt=*) num_ingredient

    ! STEP.02
    ! allocate the array to store value of ingredients
    allocate( value_ingredient(1:num_ingredient) )

    ! STEP.03
    ! read out given value of ingredients
    read(unit=INPUT_UNIT, fmt=*) value_ingredient(:)

    ! STEP.04
    ! sort the array storing the value of ingredients
    call sort_heap ( value_ingredient(:), num_ingredient )

    ! STEP.05
    ! calculate the answer of this task
    value_maximum = value_ingredient(1)

    do itr = 2, num_ingredient, 1
      value_maximum = 0.5_REAL64 * (value_maximum + value_ingredient(itr))
    end do

    ! STEP.06
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(ES23.15e3)', advance='yes') value_maximum

    ! STEP.05
    ! deallocate the array to store the given data
    deallocate( value_ingredient )

    ! STEP.END
    return

  end subroutine task_C

  subroutine sort_heap (array, size)

    ! arguments for this <subroutine>
    real(REAL64), intent(inout) :: array(:)
    integer,      intent(in)    :: size

    ! variables for this <subroutine>
    integer      :: idx_p
    integer      :: idx_c
    integer      :: size_heap
    real(REAL64) :: buffer_val

    ! support variables for this <subroutine>
    integer :: itr

    size_heap = size     + 1
    itr       = size / 2 + 1
    
    do while (.true.)

      if (itr .gt. 1) then

        itr        = itr - 1
        buffer_val = array(itr)

      else

        size_heap = size_heap - 1
        if (size_heap .eq. 1) return
        buffer_val       = array(size_heap)
        array(size_heap) = array(1)

      end if
    
      idx_p = itr
      idx_c = itr * 2

      do while ( idx_c .lt. size_heap )

        if ( idx_c + 1 .lt. size_heap ) then
          if ( array(idx_c + 1) .gt. array(idx_c) ) idx_c = idx_c + 1
        end if

        if ( array(idx_c) .gt. buffer_val ) then
          array(idx_p) = array(idx_c)  
          idx_p        = idx_c         
          idx_c        = idx_p * 2     
        else
          exit 
        end if

      end do

      array(idx_p) = buffer_val

    end do

  end subroutine sort_heap

end module ABC138


program main

  ! <module>s to import
  use, non_intrinsic :: ABC138

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a, b, c, used[100];

int main() {
	cin >> a >> b >> c;
	int sum = a;
	while (true) {
		if (sum%b == c) {
			cout << "YES" << endl;
			break;
		}
		else if (used[sum%b] == 1) {
			cout << "NO" << endl;
			break;
		}
		else {
			used[sum%b] = 1;
			sum += a;
		}
	}
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    pair<double, string> p[10];

    for(int i = 0; i < n; i++) {
        double t;
        string u;
        cin >> t >> u;

        p[i] = make_pair(t, u);
    }

    double sum;
    sum = 0;
    for(int i = 0; i < n; i++) {
        if(p[i].second == "BTC"){
            sum = sum + p[i].first * 380000.0;
        }
        else(p[i].second == "JPY");{
            sum = sum + p[i].first;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>

using namespace std;
typedef long long ll;

const int mod = 1e9+7; 

int main(){
	ios::sync_with_stdio(false);
	int n, k, ans= 0, happy = 0;
	string que;
	cin >> n;
	cin >> k;
	cin >> que;
	for(int i = 1; i < n; ++i){
		if(que[i] == 'L' && que[i-1] == 'L')
			++happy;
	}	
	for(int i = 0; i < n-1; ++i){
		if(que[i] == 'R' && que[i+1] == 'R')
			++happy;
	}
	ans = happy + k * 2;
	cout << (ans > n-1 ? n-1 : ans);
	return 0;
} 

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        switch ((a[i] == b[i]) + (b[i] == c[i]) + (c[i] == a[i])) {
        case 0:
            ans += 2;
            break;
        case 1:
            ans += 1;
            break;
        }
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
import sys


def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = float('inf')
    for i in range(N - M + 1):
        cnt = 0
        for j in range(M):
            if T[j] != S[i:(i + M)][j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)


if __name__ == '__main__':
    main()


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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int n,k;
int a[105];
int dp[100005][2];

int f(int cur,bool t)
{
    int &ret=dp[cur][t];
    if(ret!=-1)
        return ret;
    if(t)
    {
        ret=0;
        for(int i=0; i<n; i++)
        {
            if(cur-a[i]>=0)
                ret=max(ret,f(cur-a[i],0));
            else
                break;
        }
    }
    else
    {
        ret=1;
        for(int i=0; i<n; i++){
            if(cur-a[i]>=0)
                ret=min(ret,f(cur-a[i],1));
            else
                break;
        }
    }
    return ret;
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n>>k;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        memset(dp,-1,sizeof dp);
        int ans=f(k,0);
        cout<<(ans==0?"First":"Second")<<endl;
    }
    return 0;
}


Measured memory_bytes: 11432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;
ll t=1;

void solve()
{
    cin>>n;
    if(n>=400 and n<=599)cout<<8;
    else if(n>=600 and n<=799)cout<<7;
    else if(n>=800 and n<=999)cout<<6;
    else if(n>=1000 and n<=1199)cout<<5;
    else if(n>=1200 and n<=1399)cout<<4;
    else if(n>=1400 and n<=1599)cout<<3;
    else if(n>=1600 and n<=1799)cout<<2;
    else if(n>=1800 and n<=1999)cout<<1;
   
 if(t>0)cout<<"\n";
   
}



int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

ll n, k;
ll a[100002], b[100002];
ll msk[32];
ll answer = 0;

int main()
{



	cin >> n >> k;

	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	
	for (int i = 0; i < n; i++) {
		if ((a[i] | k) <= k) {
			answer += b[i];
		}
	}


	for (int keta = 0; keta < 32; keta++) {
		ll temp = k >> keta;
		if (temp & 1 == 1) {
			if ((temp & 1) == 1 && keta>0) {
				temp = temp - 1;
			}
			for (int i = 0; i < keta; i++) {
				temp = (temp << 1)+1 ;
			}
			ll res = 0;
			for (ll i = 0; i < n; i++) {
				if ((temp | a[i]) == temp) {
					res += b[i];
				}
			}
			answer = max(answer, res);
		}
	}

	cout << answer;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    int n; cin>>n;
    vector<int> a(n),b(n),c(n-1);
    
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin>>b[i];
    }
    for (int i = 0; i < n-1; i++)
    {
        cin>>c[i];
    }
    
    int sumb=0;

    for (int i = 0; i < n; i++)
    {
        sumb=sumb+b[i];
    }

   for (int i = 0; i < n-1; i++)
   {
      if (a[i]+1==a[i+1])
      {
          sumb+=c[a[i]-1];
      }
      
   }
   cout<<sumb<<endl;
    
    

    return 0;
}

Measured memory_bytes: 256
//nani?
//omo ta tori da
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
using namespace __gnu_pbds;
//const ll inf=1e10;
const ll MOD=1e9+7;
const ll mod=998244353;
const ll N = 1e7 + 5;
// ac cmtr;
const int MAX_N = 2e5+5;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll dp[2005][2005];
ll cnt[MAX_N];
ll n;
vector <pair <ll,ll > > adj[MAX_N];

void dij(ll a){

    set <pair <ll,ll> > s;
    f(i,0,n+1) {dp[i][a]=inf;}
    s.insert(mp(0,a));
    dp[a][a] = 0;
    //ans[a] = 1;
    while(!s.empty()){
        ll ini  = s.begin()->sc;s.erase(s.begin());
        for(auto xd : adj[ini]){
            if(dp[xd.fs][a] > dp[ini][a] + xd.sc){
                s.erase(mp(dp[xd.fs][a],xd.fs)); 
                //ans[xd.fs] = ans[ini];
                dp[xd.fs][a] = dp[ini][a] + xd.sc;
                s.insert(mp(dp[xd.fs][a],xd.fs));
            }
        }
        
    }
  return;
}

int main(){
    fastio;
    ll x,y;
    cin>>n>>x>>y;
    f(i,1,n){
        adj[i].pb({i+1,1});
        adj[i+1].pb({i,1});
    }
    adj[x].pb({y,1});
    adj[y].pb({x,1});
    f(i,1,n+1){
        dij(i);
    }
    f(i,1,n+1){
        for(int j=1;j<=n;j++){
            cnt[dp[i][j]]++;
        }
    }
    f(i,1,n){
        cout<<cnt[i]/2<<" "<<endl;
    }
//ga

   
}

Measured memory_bytes: 38016
import static java.lang.System.*;

import java.util.Scanner;

class Main {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        	int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1) {
            	break;
            }else if(m == -1 || f == -1) {
            	out.println("F");
            }else if(m + f >= 80) {
            	out.println("A");

            }else if(m + f >= 65) {
            	out.println("B");

            }else if(m + f >= 50) {
            	out.println("C");

            }else if(m + f >= 30) {
            	if(r >= 50) {
            		out.println("C");
            		continue;
            	}
            	out.println("D");

            }else {
            	out.println("F");
            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

template<int N>
struct Sieve {
  int F[N + 1];
  deque<int> P;
  Sieve(){}
  void build(){
    iota(begin(F), end(F), 0);
    for (int i = 2; i <= N; ++i){
      const int Fi = F[i];
      if (Fi == i) P.emplace_back(i);
      for (const auto& Pi : P){
        int tmp = Pi * i;
        if (Pi > Fi || tmp > N) break;
        F[tmp] = Pi;
      }
    }
  }
  bool is_prime(int x){
    return F[x] == x;
  }
  int count(int l, int r){
    if (l) return count(0, r) - count(0, l);
    return lbnd(P, r);
  }
};
Sieve<9999> sieve;
int dp[15][9999];

int main()
{
  sieve.build();
  dp[0][0] = 1;
  for (int p : sieve.P){
    if (p > 1120) break;
    for (int k = 13; k >= 0; k--){
      for (int i = 0; i <= 1120; i++){
        if (!dp[k][i]) continue;
        dp[k + 1][i + p] += dp[k][i];
      }
    }
  }
  int n, k;
  while (n = in(), k = in(), n || k) printf("%d\n", dp[k][n]);

  return 0;
}

Measured memory_bytes: 1412
#最大公約数
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
#最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)
  
A,B,C,D = map(int,input().split())

#ans = 全体 - (cで割れる+Dで割れる-(CかつDで割れる))
#Cで割れる
#(ex)C=3
#1~A : Cで割れる A//3個
#1~B : Cで割れる B//3個
#A~B : Cで割れる (Aが3の倍数なら) B//3 - A//3 + 1個 (Aが3の倍数でないなら) B//3 - A//3個

#全体
all = B-A+1
#Cで割れる
if(A%C == 0): c_count = B//C-A//C+1
else: c_count = B//C-A//C
#Dで割れる
if(A%D == 0): d_count = B//D-A//D+1
else: d_count = B//D-A//D
#CかつDで割れる
C_D = lcm(C,D)
if(A%C_D == 0): c_d_count = B//C_D-A//C_D+1
else: c_d_count = B//C_D-A//C_D

ans = all - (c_count+d_count-c_d_count)
print(ans)

Measured memory_bytes: 3064
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
for i in range(k+1):
  for j in range(n):
    if i-a[j]>=0:
      if dp[i-a[j]]==0:
        dp[i]=1
        break
if dp[k]:print('First')
else:print('Second')

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

typedef long long ll;

ll a[12345];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (ll i = 1; i <= 100; ++i) {
		for (ll j = i; j <= 100; ++j) {
			for (ll k = j; k <= 100; ++k) {
				ll cur = i*i+j*j+k*k+i*j+k*j+k*i;
				if (cur > n) break;
				else {
					if (i == j & j == k) ++a[cur];
					else if (j == k || i == j) a[cur] += 3;
					else a[cur] += 6;
				}
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		cout << a[i] << "\n";
	}
	return 0;
}

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

int main(){
    int n; ll k; 
    cin >> n >> k;
    int a[n]; 
    rep(i,n) cin >> a[i];

    vector<int> s;
    vector<int> ord(n+1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while(ord[v] == -1){
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l) cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5884
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	string h;
	cin >> h;
	if(h=="hi")
	{
		cout << "Yes" << endl;
	}else if(h=="hihi")
	{
		cout << "Yes" << endl;
	}else if(h=="hihihi")
	{
		cout << "Yes" << endl;
	}else if(h=="hihihihi")
	{
		cout << "Yes" << endl;
	}else if(h=="hihihihihi")
	{
		cout << "Yes" << endl;
	}else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
	int N;
	cin >> N;
	int minText;
	char s[N];
	char t[N];

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

	for(int j=0; j<N; j++){
		cin >> t[j];
	}
	minText = N;
	for(int i=0; i<N; i++){
		bool err = false;
		for(int j=0; j<N-i;j++){
			if(t[j] != s[i+j]){
				err = true;
				break;
			}
		}
		if(err){
			minText++;
			continue;
		} else {
			break;
		}
	}

	if(minText<N){
		minText = N;
	}
	cout << minText << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>


using namespace std;

double a, b, x;

int main()
{

	cin >> a;
	cin >> b;
	cin >> x;

	double ans = 0.0;
	if (a*a*b / 2 >= x) {
		double y = 2.0 * x / b / a;
		ans = atan2(b, y);
	}
	else {
		double y = 2.0 * b - 2.0 * x / a / a;
		ans = atan2(y, a);
	}

	ans = 180.0 * ans /  M_PI;
	cout << fixed << setprecision(10) << ans << endl;


	return 0;


}

Measured memory_bytes: 256