akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

void Calc() {
  int n = in;
  ll a, b;
  in, a, b;
  auto t = in.Array(n);

  int ans = 0;
  for (auto& i : t) {
    if (a <= i && i < b) {
      continue;
    }
    ans++;
  }

  cout << (ans) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main(void){
int a,b;
cin >> a >> b;
if (a*2<=b&&a*4>=b){
 if (b%2 ==0 && b%6 ==0){
  cout << "Yes" << endl;
 }
 else if(b%6 == 0||b%2 == 0){
 cout << "Yes" << endl;
 }
 else{
 cout << "No" <<endl;
 }
}
else{cout << "No"<<endl;}
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

string s;
int n,ans=0,nums[8];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	nums[1] = 9; nums[3] = 909; nums[5] = 90909; nums[7] = 90910;
	cin>>s;
	n = stoi(s);
	int l = s.size();
	if(l % 2 == 0){
		l--;
		ans = nums[l];
	}
	else{
		if(s.size() > 1){
			char c = s[0];
			s.erase(s.begin());
			int t = stoi(s);
			int hd = c - '0';
			hd--;
			hd *= pow(10, s.size());
			hd += t + 1;
			ans = hd;
			ans += nums[s.size() - 1];
		}
		else
			ans = n;
	}
	cout<<ans;
	return 0;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,a,b;
  cin >> n >> a >> b;
  if(n*a<b){
    cout << n*a << endl;
  }else{
    cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int k;
    cin>>k;
    queue<ll> que;
    for(ll i=1; i<10; i++) que.push(i);
    int cnt=0;
    while(!que.empty()){
        ll i = que.front();
        if((i%10)-1>=0) que.push((i*10LL)+((i%10)-1));
        que.push((i*10LL)+(i%10));
        if((i%10)+1<10) que.push((i*10LL)+((i%10)+1));
        que.pop();
        cnt++;
        if(cnt==k){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
def shortest_path(s,n,w,es):
#s→iの最短距離
# s:始点, n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
    d = [float('inf')] * n
    #d[i] : s→iの最短距離
    d[s] = 0
    while True:
        for p,q,r in es:
        # e: 辺iについて [from,to,cost]
            #print(d,p,q,r)
            if d[p] != float('inf') and d[q] > d[p] + r:
                d[q] = d[p] + r
                update = True
            ans1=d[-1]
        update = False
        for p,q,r in es:
        # e: 辺iについて [from,to,cost]
            #print(d,p,q,r)
            if d[p] != float('inf') and d[q] > d[p] + r:
                d[q] = d[p] + r
            ans2=d[-1]
        return -ans1 if ans1==ans2 else 'inf' 
################
n,w = map(int,input().split()) #n:頂点数　w:辺の数
es = [] #es[i]: [辺の始点,辺の終点,辺のコスト]
for _ in range(w):
 x,y,z = map(int,input().split())
 es.append([x-1,y-1,-z])
print(shortest_path(0,n,w,es))

Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  
  rep(i,(n-3)/2) {
    if(s[i]!=s[(n-3)/2-i] || s[n-1-i]!=s[n-1-((n-3)/2-i)]
      ||s[i]!=s[i+(n+1)/2]) {
    cout << "No" << endl;
    return 0;
    }
  }
  
  puts("Yes");
  
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        long x = input.nextLong();
        System.out.println(x * x * x);
    }         
}

Measured memory_bytes: 17164
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    int A,B,C;
    cin >> A >> B >> C;

    cout << YorN(A<=C&&C<=B) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    int V[H][W];
    rep(i,0,H)rep(j,0,W)cin >> V[i][j];
    vector< P > a,b; 
    rep(i,0,H){
        rep(j,0,W-1){
            if(V[i][j] % 2){
                V[i][j+1]++;
                a.push_back(P(i+1,j+1));
                b.push_back(P(i+1,j+2));
            }
        }
        if(i != H-1 && V[i][W-1] % 2){
            V[i+1][W-1]++;
            a.push_back(P(i+1,W));
            b.push_back(P(i+2,W));
        }
    }
    cout << a.size() << endl;
    rep(i,0,a.size()){
        cout << a[i].first << " " << a[i].second << " " << b[i].first << " " << b[i].second << endl;
    }
}

Measured memory_bytes: 5228
//
//  main.c
//  ITP1_6_A
//
//  Created by ??±??°?????? on 2015/10/11.
//  Copyright ?? 2015??´ HamadaShogo. All rights reserved.
//

#include <stdio.h>

void reverseNum(int *num, int size);

int main(int argc, const char * argv[]) {
    int size;
    int num[100];
    int i;
    
    scanf("%d", &size);
    for (i=0; i<size; i++) {
        scanf("%d", &num[i]);
    }
    reverseNum(num, size);
    
    return 0;
}

void reverseNum(int *num, int size){
    int i;
    
    for (i=0; i<size; i++) {
        printf("%d", num[size-i-1]);
        if (!(i == size-1)) {
            printf(" ");
        }
    }
    puts("");
}

Measured memory_bytes: 1040
n = int(input())
A = []
for i in range(n):
  A.append(list(input().split()))
x = input()
b = 0
for i in range(n):
  if A[i][0] == x:
    b = i+1
ans = 0
for j in range(b, n):
  ans += int(A[j][1])
print(ans)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int K,X;
  cin >> K >> X;
  int sum=500*K;
  if(sum>=X){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int, input().split()))

import heapq

heapq.heapify(d)

for i in range(n//2-1):
	heapq.heappop(d)
	
a=heapq.heappop(d)
b=heapq.heappop(d)

print(b-a)

Measured memory_bytes: 14396
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    long long N, K, Q, A_i;
    std::cin >> N >> K >> Q;
    std::vector<long long> vec(N);
    long long sub = 0;
    for (int i = 0; i < N; i++) { vec[i] = K; }
    for (int i = 0; i < Q; i++)
    {
        std::cin >> A_i;
        vec[A_i - 1] = vec[A_i - 1] + 1;
        sub++;
    }
    for (long long l : vec)
    {
        if (l - sub > 0) { std::cout << "Yes" << std::endl; }
        else
        {
            std::cout << "No" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
N = int(input())
S = list(input())
lis = [ str(i) for i in range(1000)]
ans = 0
for l in lis:
    if int(l) == 0:
        l0,l1,l2 = 0,0,0
    if int(l) < 10:
        l0 = 0
        l1 = 0
        l2 = l[0]
    elif int(l) < 100:
        l0 = 0
        l1 = l[0]
        l2 = l[1]
    else:
        l0 = l[0]
        l1 = l[1]
        l2 = l[2]
    try:
        id0 = S.index(str(l0))
        id1 = S[id0+1:].index(str(l1))
        id2 = S[id0+id1+2:].index(str(l2))
    except:
        continue
    ans += 1
print(ans)

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x,y;
    cin >> x >> y;
    while ( y > 0 ) {
        int t = y;
        y = x % y;
        x = t;
    }
    int ans = x;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3088
def isok(arg):
    count = arg
    for i in range(n):
        if -(-(h[i]-b*arg)//(a-b)) >= 0:
            count -= -(-(h[i]-b*arg)//(a-b))
    if count >= 0:
        return True
    else:
        return False

def bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if isok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n,a,b = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
print(bisect(0,10**9))


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

int main() {
  int a;
  std::vector<int> vec;
  for(int i=0; i<3; i++){ std::cin >> a; vec.push_back(a); }
  std::sort(vec.begin(), vec.end());
  std::cout << vec[0] << " " << vec[1] << " " << vec[2] << std::endl;
}


Measured memory_bytes: 3148
//by xxj
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
const int mod=1000003;
const int maxn=1000002;
int jc[1000007],njc[1000007],ny[1000007];
int qsm(int a,int c){
	int re=1;
	while (c!=0){
		if (c%2==1){
			re=1ll*re*a%mod;
		}
		a=1ll*a*a%mod;
		c/=2;
	}
	return re;
}
void init(){
	jc[0]=1;
	for (int i=1;i<=maxn;i++){
		jc[i]=1ll*jc[i-1]*i%mod;
//		cout<<i<<' '<<jc[i]<<endl;
	}
	njc[maxn]=qsm(jc[maxn],mod-2);
//	cout<<jc[maxn-1]<<endl;
	for (int i=maxn-1;i>=0;i--){
		ny[i+1]=1ll*njc[i+1]*jc[i]%mod;
		njc[i]=1ll*njc[i+1]*(i+1)%mod;
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	init();
	int q;
	scanf("%d",&q);
	int x,d,n;
	while (q--){
		scanf("%d%d%d",&x,&d,&n);
		int k=1ll*x*ny[d]%mod;
		if (d==0){
			printf("%d\n",qsm(x,n));
			continue;
		}
		if (k==0 || k+n-1>=mod){
			puts("0");
			continue;
		}
		if (k==1){
			printf("%d\n",1ll*jc[k+n-1]*qsm(d,n)%mod);
			continue;
		}
		printf("%d\n",1ll*jc[k+n-1]*njc[k-1]%mod*qsm(d,n)%mod);
	}
	return 0;
}
/*
input:
*/


Measured memory_bytes: 12544
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (h, w) = get!(u64, u64);

    if h % 3 == 0 || w % 3 == 0 {
        println!("0");
        return;
    }

    let mut ans = min(h, w);

    for &(h, w) in [(h, w), (w, h)].into_iter() {
        for x in 1..w  {
            let a = h * x;

            let b = h / 2 * (w - x);
            let c = (h - h / 2) * (w - x);
            ans = min(
                ans,
                [a, b, c].into_iter().max().unwrap() - [a, b, c].into_iter().min().unwrap(),
            );
            for y in a / (w - x)..min(h, a / (w - x) + 2) {
                let b = y * (w - x);
                let c = (h - y) * (w - x);
                ans = min(
                    ans,
                    [a, b, c].into_iter().max().unwrap() - [a, b, c].into_iter().min().unwrap(),
                );
            }
        }
    }

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


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

class line
{
public:
    long long a;
    long long b;

    line()
    {
        ;
    }

    line(long long A, long long B)
    {
        a = A;
        b = B;
    }

    long long eval(long long x)
    {
        return a*x + b;
    }
};

vector<line> S;

bool good(long long a, long long b)
{
    if(S.size() <= 1) return 1;

    line l1 = S[S.size()-2], l2 = S[S.size()-1];

    return (l2.b - l1.b)*(a - l2.a) > (l2.b - b)*(l1.a - l2.a);
}

void addLine(long long a, long long b)
{
    while(!good(a, b)) S.pop_back();
    S.push_back(line(a, b));
}

// S[m].a*x + S[m].b = S[m+1].a*x + S[m+1].b
//x = (S[m+1].b - S[m].b)/(S[m].a - S[m+1].b)
//X <= x =>

long long b_search(long long a, long long b, long long X)
{
    if(a == b) return a;
    long long m = (a+b)/2;
    //X <= intersect(m, m+1)
    //X <= x, a[m]*x + b[m] <= a[m+1]*x + b[m+1]
    //X <= x, x = (b[m+1]-b[m])/(a[m]-a[m+1])
    //X <= (S[m+1].b - S[m].b) / (S[m].a - S[m+1].a)
    if(X * (S[m].a - S[m+1].a) <= (S[m+1].b - S[m].b)) return b_search(a, m, X);
    else return b_search(m+1, b, X);
}

int main()
{
    long long N, C;
    cin >> N >> C;

    long long h[N+1];
    for(long long i = 1; i <= N; i++) cin >> h[i];

    long long DP[N+1];
    DP[1] = 0;

    //DP[i] = h[i]*h[i] + C + min(1 <= j < i, (-2*h[j])*h[i] + (h[j]*h[j] + DP[j]))

    addLine(-2*h[1], h[1]*h[1]);
    //cout << "0\n";
    for(long long i = 2; i <= N; i++)
    {
        DP[i] = h[i]*h[i] + C + S[b_search(0, S.size()-1, h[i])].eval(h[i]);
        //DP[i] = 4000000000000000000;
        //for(line y:S) DP[i] = min(DP[i], h[i]*h[i] + C + y.a*h[i] + y.b);
        //for(line y:S) cout << "(" << y.a << ", " << y.b << ") ";
        //cout << "-> ";
        //cout << DP[i] - h[i]*h[i] - C << ' ' << DP[i] << '\n';

        addLine(-2*h[i], h[i]*h[i] + DP[i]);
    }
    cout << DP[N] << '\n';
    return 0;
}


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mn=1e5+7;
vector< vector<ll> >ab(mn);
bool bl[mn];
vector<ll> temp;
vector<ll> ret;

void dfs(ll a){
	bl[a]=true;
	for(ll b:ab[a])if(!bl[b]){
		temp.push_back(b);
		dfs(b);
		break;
	}
}

int main(){
	ll N,M;cin>>N>>M;
	for(ll a=0;a<M;++a){
		ll p;cin>>p;--p;
		ll q;cin>>q;--q;
		ab[p].push_back(q);
		ab[q].push_back(p);
	}
	for(ll a=0;a<mn;++a)bl[a]=false;
	dfs(0);
	reverse(temp.begin(),temp.end());
	ret=temp;
	temp.clear();
	dfs(0);
	ret.push_back(0);
	for(ll a:temp)ret.push_back(a);
	cout<<ret.size()<<endl;
	for(ll a:ret)cout<<a+1<<endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll K;  cin >> K;
    if( K <= 49){
      //exception when N == 1
      if( K == 0){ cout << 4 << endl;  for(int i = 0; i < 4; i++){ cout << 3 << " ";}
                  cout << endl; return 0;}
      
      ll N = K + 1;
      cout << N << endl;
      for(ll i = 0; i < N; i++){
        if( i == 0){ cout<< K*N + N - 1<<" ";}
        else{
          cout << 0 <<" ";} }
      
      cout <<endl; return 0;}
  else{
    // in the case of K is large enough
    
       ll N = 50;
    
       vector<ll> A(50,0);
      ll a = K / N; ll b = K % N;
      
      for(int i = 0; i < N; i++){ A[i] = a + (ll)i;}
    
    for(int i = 0; i < N; i++){
      if( b ==0 ){ break;}
      if( i <= b - 1){ A[i] += N - b + 1;}
      else{ A[i] -= b;}}
    
         cout << N << endl;
         for(int i = 0; i < N; i++){ cout << A[i] <<" ";}
                                cout << endl; return 0;
    
    
    
    
       }
  
  return 0;}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define float long double
using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N;

vector<vector<float>> graph;

float dijkstra(int p1, int p2) {
	vector<float> distance (N+2, INFINITY);
	vector<bool> visited (N+2);

	distance[p1] = 0;

	while (true) {
		int cur = -1;
		float dist = INFINITY;

		F0R(i, N+2) {
			if (visited[i]) continue;
			if (distance[i] < dist) {
				dist = distance[i]; cur = i;
			}
		}

		if (cur == -1) break;

		visited[cur] = true;

		F0R(i, N+2) {
			if (graph[cur][i] >= 0) {
				distance[i] = min(distance[i], graph[cur][i] + distance[cur]);
			}
		}		
	}

	return distance[p2];
}

float dist(pair<pair<int, int>, float> c1, pair<pair<int, int>, float> c2) {
	int x1 = c1.first.first;
	int y1 = c1.first.second;
	int r1 = c1.second;

	int x2 = c2.first.first;
	int y2 = c2.first.second;
	int r2 = c2.second;

	return max(0.0, sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) - r1 - r2);
}

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

	int XS, YS, XE, YE; cin >> XS >> YS >> XE >> YE;

	cin >> N;
	
	graph = vector<vector<float>> (N+2, vector<float> (N+2, -1.0));

	vector<pair<pair<int, int>, float>> circles;

	circles.push_back({{XS, YS}, 0});

	F0R(i, N) {
		int x, y, r; cin >> x >> y >> r;
		circles.push_back({{x, y}, r});
	}

	circles.push_back({{XE, YE}, 0});

	F0R(i, N + 2) {
		F0R(j, N + 2) {
			graph[i][j] = dist(circles[i], circles[j]);
		}
	}

	cout << setprecision(10) << dijkstra(0, N+1) << endl;
}

Measured memory_bytes: 16128
s = input()

class RL():
  def __init__(self, ind, r, l):
    self.ind = ind
    self.r = r
    self.l = l
  
  def calc(self):
      return [1 + self.r // 2 + (self.l // 2 + 1 if self.l % 2 == 1 else self.l // 2), 1 + self.l // 2 + (self.r // 2 + 1 if self.r % 2 == 1 else self.r // 2)]



r = 0
l = 0
ind = 0
rl = False

rls = {}

for i, c in enumerate(s):
  if c == 'R' and not rl:
    r += 1
    continue
  if c == 'R' and rl:
    rls[ind - 1] = RL(ind - 1, r - 1, l)
    r = 1
    l = 0
    rl = False
    continue
  if c == 'L' and not rl:
    ind = i
    rl = True
    continue
  if c == 'L' and rl:
    l += 1
    continue

rls[ind - 1] = (RL(ind - 1, r - 1, l))

ans = []

skip = False

for i in range(len(s)):
  if skip:
    skip = False
    continue
  if i in rls:
    skip = True
    ans += rls[i].calc()
  else:
    ans.append(0)

print(' '.join(map(str, ans)))



Measured memory_bytes: 59372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    int ans = a+b;
    if (ans >= 10) {
        cout << "error\n";
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//bool solve(string s, int k){
//    rep(i,sz(s)-k,k-2)
//        if(s[i] != s[i+1])
//            return false;
//    return true;
//}
//int _(){
//    string s;
//    cin >> s;
//    int lo = 1, hi = sz(s), mid;
//    while(lo < hi){
//        mid = (lo+hi+1)/2;
//        if(solve(s,mid))
//            lo = mid;
//        else
//            hi = mid-1;
//    }
//    return lo;
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
bool solve(string s, int k){
    rep(i,sz(s)-k,k-2)
        if(s[i] != s[i+1])
            return false;
    return true;
}
int _(){
    string s;
    cin >> s;
    int lo = 1, hi = sz(s), mid;
    while(lo < hi){
        mid = (lo+hi+1)/2;
        if(solve(s,mid))
            lo = mid;
        else
            hi = mid-1;
    }
    return lo;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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 (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    // sort(all(l));
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]){
                    if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split() ))
from collections import Counter
d=dict(Counter(A))
#print(d)
cnt=0
for item in d:
    cnt += (d[item])*(d[item]-1)//2

#print("cnt",cnt)
   
for num in A:
    new = max(0, (d[num]-1)*(d[num]-2)//2)
    print(cnt- d[num]*(d[num]-1)//2 + new)

Measured memory_bytes: 27732
#include <bits/stdc++.h>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000000000 //5･10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define cend cout<<endl;
using namespace std;
int n, cnt=0;
int a[114514], b[114514], c[114514];
signed main() {
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a, a + n);
  sort(b, b + n);
  sort(c, c + n);
  rep(i, n) {
    cnt += (low(a, a + n, b[i]) - a) * (n - (upp(c, c + n, b[i]) - c));
  }
  cout << cnt << endl;
}


Measured memory_bytes: 2688
#include <iostream>
using namespace std;
 
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  int d[n];
  for(int i = 0; i < n; i++) cin>>d[i];
  
  int wrong = 0;
  for(int i = 0; i < n; i++) {
    if(d[i] != i+1) wrong++;
  }
  
  if(wrong>2) cout<<"NO"<<"\n";
  else cout<<"YES"<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll sa = b-a;
    if(sa%2LL==0) cout<<sa/2LL<<endl;
    else cout<<min(n-a-(b-a-1)/2,b-1LL-(b-a)/2)<<endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

#[proconio::fastout]
fn main() {
	input! {
		cs: Chars,
	}

	// 頭から順に、XXとXYXをチェック
	if cs[0] == cs[1] {
		println!("1 2");
		return;
	}
	if cs.len() == 2 {
		println!("-1 -1");
		return;
	}
	for i in 2..cs.len() {
		if cs[i-1] == cs[i] {
			println!("{} {}", i-1+1, i+1);
			return;
		}
		if cs[i-2] == cs[i] {
			println!("{} {}", i-2+1, i+1);
			return;
		}
	}

	println!("-1 -1");

	// let mut v = vec![[0usize; 26]; cs.len()];

	// v[0][(cs[0] as u8 - 'a' as u8) as usize] = 1;
	// for i in 1..cs.len() {
	// 	v[i] = v[i-1];
	// 	v[i][(cs[i] as u8 - 'a' as u8) as usize] += 1;
	// }

	// for end in 1..cs.len() {
	// 	let mut nmax = 0;
	// 	for i in 0..26 {
	// 		nmax = max(nmax, v[end][i]);
	// 	}
	// 	if nmax > (end+1) / 2 {
	// 		println!("{} {}", 0+1, end+1);
	// 		return;
	// 	}
	// }
	// for start in 1..cs.len()-2 {
	// 	for end in start+1..cs.len() {
	// 		let mut nmax = 0;
	// 		for i in 0..26 {
	// 			nmax = max(nmax, v[end][i]- v[start-1][i]);
	// 		}
	// 		if nmax > (end-start+1) / 2 {
	// 			println!("{} {}", start+1, end+1);
	// 			return;
	// 		}
	// 	}
	// }
	// println!("-1 -1");
}


Measured memory_bytes: 2588
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll tate, yoko;
    bool flag1 = false, flag2 = false;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    for (int i = 1; i < n; i++)
    {
        if (flag1 == false && a[i] == a[i - 1])
        {
            tate = a[i];
            i += 2;
            flag1 = true;
            if (i >= n)
            {
                break;
            }
        }
        if (a[i] == a[i - 1])
        {
            yoko = a[i];
            flag2 = true;
            break;
        }
    }
    if (flag2)
    {
        cout << tate * yoko << endl;
    }
    else
    {
        cout << "0" << endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
using vd = vector<double>;

double d(double x1, double y1, double x2, double y2) {
  return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main() {
  int n;
  cin >> n;
  vd x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  double ep = 1e-9;
  double ans = 1e18;
  rep(i, n - 1) rep2(j, i + 1, n) {
    double ox = (x[i] + x[j]) / 2;
    double oy = (y[i] + y[j]) / 2;
    double r = 0;
    rep(l, n) r = max(r, d(ox, oy, x[l], y[l]));
    ans = min(ans, r);
  }
  rep(i, n - 2) rep2(j, i + 1, n - 1) rep2(k, j + 1, n) {
    double a = d(x[j], y[j], x[k], y[k]);
    double b = d(x[k], y[k], x[i], y[i]);
    double c = d(x[i], y[i], x[j], y[j]);
    if(a + b - c < ep || b + c - a < ep || c + a - b < ep) continue;
    double aa = a * a * (b * b + c * c - a * a);
    double bb = b * b * (c * c + a * a - b * b);
    double cc = c * c * (a * a + b * b - c * c);
    double ox = (aa * x[i] + bb * x[j] + cc * x[k]) / (aa + bb + cc);
    double oy = (aa * y[i] + bb * y[j] + cc * y[k]) / (aa + bb + cc);
    double r = 0;
    rep(l, n) r = max(r, d(ox, oy, x[l], y[l]));
    ans = min(ans, r);
  }
  printf("%.18f\n", ans);
}

Measured memory_bytes: 3868
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, k = map(int, input().split()) # 入力が複数
tree = []
for _ in range(n):
    h = int(input())
    tree.append(h)
tree.sort()

diff = float('inf')
s = 0
e = k - 1
while e < n:
    d = tree[e] - tree[s]
    diff = min(diff, d)
    s += 1
    e += 1
print(diff)

Measured memory_bytes: 44796
R,G,B,N = map(int,input().split())

ct = 0

for r in range(int(N/R)+1):
  N_ = N - R*r
  if N_==0:
    ct+=1
    continue
  for g in range(int(N_/G)+1):
    N__ = N_ - G*g
   	
    if N__%B == 0:
      ct+=1
      
print("{0}".format(ct))
  

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

int main() {
	
	int h,n,s=0;
	
	cin>>h>>n;
	
	int a[n];
	
	int i;
	
	for(i=0;i<n;i++)
	{
	  cin>>a[i];  
	  s=s+a[i];  
	}
	
	if(s>=h)
	    cout<<"Yes";
	else
	    cout<<"No";
	   
	
	return 0;
}


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

int main(){
    int n, a, b, s; scanf("%d%d%d%d", &n, &a, &b, &s);
    for(int x; --n; ){
        scanf("%d", &x);
        ans += min(1LL * b, 1LL * a * (x - s));
        s = x;
    }
    printf("%lld\n", ans);
}

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

using namespace std;

int main()
{
    int N;cin >> N;
    vector<long long>v;

    for(int i=0;i<N;++i)
    {
        long long t;
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(),v.end());
    for(int j=0;j<N;++j)
    {
        if(v[j]==v[j+1])
        {
            cout << "NO" <<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,sum=0;
  cin >> N;
  vector<int> L(N);
    for(int n=0;n<N;n++){
      cin >> L.at(n);
    }
  
  sort(L.begin() , L.end());
  
  for(int x=0;x<N;x++){
    for(int y=x+1;y<N;y++){
        for(int z=y+1;z<N;z++){
          if( L.at(z) <L.at(x)+L.at(y) )sum++;
          else break;
        }
    }
  }
  
 cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
	char a, b;
	scanf("%c %c", &a, &b);

	if (a == 'H')
	{
		if (b == 'H')
		{
			printf("H\n");
		}
		else
		{
			printf("D\n");
		}
	}
	else
	{
		if (b == 'H')
		{
			printf("D\n");
		}
		else
		{
			printf("H\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15

struct lex_compare {
    bool operator() (pp(ll) p1,pp(ll) p2){
        ll x1 = (p1.ff*(p1.ss-p1.ss/2));
        ll x2 = (p2.ff*(p2.ss-p2.ss/2));
        return x1 > x2;
    }
};

int main(){
    FIO;
    ll n; cin >> n;
    ll arr[n]; forn(i,0,n) cin >> arr[i];
    ll sum = 0;
    ll ans = 0;
    for(ll i = 0;i<n;i++){
        ll temp = ((arr[i]%mod)*sum)%mod;
        ans += (temp);
        sum += arr[i];
        sum %= mod;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long cnt = 0;
    for (int a = 0; a <= N; a++)
    {
        for (int b = 0; b <= N; b++)
        {
            int c = N - R * a - b * G;
            if (c >= 0 && c % B == 0)
                cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    ll N;
    cin >> N;
    ll a[N];
    for (ll i = 0; i < N; ++i) {
        cin >> a[i];
    }
    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        ans += a[i] - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input()) 
    S, T = input().split()

    for s,t in zip(S, T):
        print(s + t, end="")


main()


Measured memory_bytes: 4980
import java.util.*;
public class Main {
	final int MAX = 151200;
	final int N = 100;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		int [] a = new int[N + 1];
		int [] b = new int[N + 1];
		for(int i = 1; i <= N; i++){
			a[i] = i * i * i;
		}
		for(int i = 1; i <= N; i++){
			b[i] = i * (i+1) * (i+2) / 6;
		}
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int ans = n;
			for(int i = 1; i <= N; i++){
				int result = a[i];
				if(n < result) break;
				ans = Math.min(ans, n - result);
			}
			for(int i = 1; i <= N; i++){
				int result = b[i];
				if(n < result) break;
				ans = Math.min(ans, n - result);
			}
			for(int i = 1; i <= N; i++){
				for(int j = 0; j <= N; j++){
					int result = a[i] + b[j];
					if(n < result) break;
					ans = Math.min(ans, n - result);
				}
			}
			System.out.println(n - ans);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n,x,y;
//vector<int> dist(n,INF);
vector<int> ans(2010,0);
queue<int> q;
int dist[2010][2010];
void bfs(int v,int now){
    queue<pair<int,int>> qi;
    qi.push({v,now});
    while(qi.size()){
        int a = qi.front().first;
        int b = qi.front().second;
        qi.pop();
        //cout<<a<<" "<<b<<endl;
        if(dist[v][a]==inf){
            dist[v][a]=b;
            //cout<<"dist"<<v<<a<<"="<<b<<endl;
            if(a==x) qi.push({y,b+1});//,cout<<"a"<<" "<<y<<" "<<b+1<<endl;
            if(a==y) qi.push({x,b+1});//,cout<<"b"<<" "<<x<<" "<<b+1<<endl;
            if(a+1<=n) qi.push({a+1,b+1});//,cout<<"c"<<" "<<a+1<<" "<<b+1<<endl;
            if(a-1>=0) qi.push({a-1,b+1});//,cout<<"d"<<" "<<a-1<<" "<<b+1<<endl;
        }
    }
}
int main(){
    cin>>n>>x>>y;
    --x,--y,--n;
    for(int i=0;i<2010;i++){
        for(int j=0;j<2010;j++){
            dist[i][j]=inf;
        }
    }
    for(int i=0;i<=n;i++){
        //cout<<"bfsstart"<<" "<<i<<endl;
        bfs(i,0);
        //cout<<"bfsstart"<<" "<<i<<endl;
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            //cout<<dist[i][j]<<" ";
            ans[dist[i][j]]++;
        }
        //cout<<endl;
    }
    //return 0;
    int start=1;
    //cout<<endl;
    //cout<<"koko"<<endl;
    //for(int i=0;i<10;i++) cout<<ans[i]<<" ";
    //cout<<endl;
    //return 0;
    while(start<n+1){
        cout<<ans[start]/2<<endl;
        start++;
    }
    return 0;
}

Measured memory_bytes: 16000
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  int ans=0;
  if(s[0]=='2') ans++;
  if(s[1]=='2') ans++;
  if(s[2]=='2') ans++;
  if(s[3]=='2') ans++;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define forit(it, st) for(auto it : st)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void solve(){
	vector<string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string s;
	cin >> s;
	rep(i, sz(v)){
		if(v[i] == s){
			cout << 7 - i;
			return;
		}
	}
}	

 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s;
int m;
signed main(){
  while(cin >> s && s!="-"){
    cin >> m;
    for(int i=0;i<m;i++){
      int a;
      cin >> a;
      string shuffle = s;
      shuffle.resize(a);
      //cout << shuffle << "1" << endl;
      string rest = s.substr(a);
      s=rest+shuffle;
      //cout << s << endl;
    }
    cout << s << endl;
  }
  return 0;
}



Measured memory_bytes: 3156
N = int(input())
from collections import deque
e = []
for i in range(N-1):
    a,b = map(int,input().split())
    e.append((min(a,b)-1,max(a,b)-1))
e.sort()
e = deque(e)
c = list(map(int,input().split()))
c.sort()
print(sum(c)-c[-1])

d = [0]*N
d[0] = str(c.pop())
while e:
    a,b = e.popleft()
    if d[a] != 0 and d[b] == 0:
        d[b] = str(c.pop())
    elif d[a] == 0 and d[b] != 0:
        d[a] = str(c.pop())
    else:
        e.append((a,b))

print(' '.join(d))

Measured memory_bytes: 143236
class List
  class Cell
    attr_accessor :val, :prev, :next
    def initialize(v,p=nil,n=nil)
      @val = v
      @prev = p
      @next = n
    end
  end

  def insert(x)
    o = Cell.new(x)
    @top.prev = o unless @top == nil
    o.next = @top
    @top = o
    @bottom = o if @bottom == nil
  end

  def delete(x)
    p = @top
    until p == nil || p.val == x
      p = p.next
    end
    unless p == nil
      if p == @top
        @top = p.next
      else
        p.prev.next = p.next
      end
      if p == @bottom
        @bottom = p.prev
      else
        p.next.prev = p.prev
      end
    end
  end

  def deleteFirst
    @bottom = nil if @bottom == @top
    @top = @top.next unless @top == nil
    @top.prev = nil unless @top == nil
  end

  def deleteLast
    @top = nil if @top == @bottom
    @bottom = @bottom.prev unless @bottom == nil
    @bottom.next = nil unless @bottom == nil
  end

  def show
    p = @top
    until p == nil
      print " " unless p == @top
      print p.val
      p = p.next
    end
    print "\n"
  end
end

n = gets.to_i
list = List.new
for i in 1..n
  com,v = gets.split
  case com
  when "insert"
    list.insert(v.to_i)
  when "delete"
    list.delete(v.to_i)
  when "deleteFirst"
    list.deleteFirst
  when "deleteLast"
    list.deleteLast
  end
end
list.show

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


int main() {

  int N;
  cin >> N;

  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  // x、y は 0 から 100 まで
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {

      // あるべき高さ
      // -2:調査中止 -1:継続して調査する 0以上:高さ確定
      int height = -1;

      for (int k = 0; k < N; k++) {
        if (0 < h[k]) {
          // 頂点（j,i）の高さがいくつであるべきかを計算する。
          int tmp = h[k] + abs(i - x[k]) + abs(j - y[k]);
          if (height == -1) {
            height = tmp;
          } else {
            // height が -1 以外のときは高さが計算されている。
            // あるべき高さが同じじゃないと矛盾している。
            if (height != tmp) {
              height = -2;
              break;
            }
          }
        }
      }
      
      // 矛盾している場合は次の点に移動する
      if (height == -2) {
        continue;
      }

      // 高さ 0 の場合矛盾していないかを確認する
      for (int k = 0; k < N; k++) {
        if (h[k] == 0) {
          // 距離を計算する
          int tmp = abs(i - x[k]) + abs(j - y[k]);
          // 高さが距離より小さい場合は矛盾している
          if (height > tmp) {
            height = -2;
            break;
          }
        }
      }

      // 矛盾している場合は次の点に移動する
      if (height == -2) {
        continue;
      }

      cout << i << " " << j << " " << height << endl;

    }
  }

  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define LONG 6378.1
#define PI 3.1415926535897932384626433832795

double xa,ya,xb,yb,l1,l2;

int main(){
	while(scanf("%lf %lf %lf %lf",&xa,&ya,&xb,&yb)){
		if(ya<0)break;

		xa=xa*PI/180;
		ya=ya*PI/180;
		xb=xb*PI/180;
		yb=yb*PI/180;

		printf("%.0lf\n",floor(LONG*acos(sin(xa)*sin(xb)+cos(xa)*cos(xb)*cos(ya-yb))+0.5));

	}
	return 0;
}

Measured memory_bytes: 716
import sys
L=list()
N=int(input())
for i in range(N):
  a=int(input())
  L.append(a)
L=sorted(L)
c=sum(L)
if c%10!=0:
  print(c)
  sys.exit()
for i in range(N):
  if L[i]%10!=0:
    print(c-L[i])
    sys.exit()
print(0)

Measured memory_bytes: 9080