akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, W;
  cin >> N >> W;

  vector<int> w(N), v(N);
  REP(i, N) cin >> w[i] >> v[i];

  // dp[i]: 価値がiの時の重さ
  vector<int> dp(100010, INF);
  dp[0] = 0;
  REP(i, N){
    RREP(j, 100010){
      if(dp[j] != INF) chmin(dp[j+v[i]], dp[j]+w[i]);
    }
  }

  RREP(i, 100010){
    if(dp[i] <= W){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, M := sc.nextInt(), sc.nextInt()
	m := sc.nextIntSlice(M)
	m = append(m, N)
	Q := sc.nextInt()
	l := sc.nextIntSlice(Q)
	base := m[0] - 1
	sums := make([]int, N+1)
	for i := 1; i <= M; i++ {
		var diff int
		if i != M {
			diff = m[i] - m[i-1] - 1
		} else {
			diff = m[i] - m[i-1]
		}
		for j := 0; j < diff; j++ {
			sums[j+1] += diff - j
		}
	}
	for _, allow := range l {
		ok := N + 1
		ng := 0
		for abs(ok-ng) > 1 {
			mid := (ok + ng) / 2
			if base+sums[mid] <= allow {
				ok = mid
			} else {
				ng = mid
			}
		}
		if ok == N+1 {
			fmt.Fprintln(wtr, -1)
		} else {
			fmt.Fprintln(wtr, ok)
		}
	}

	wtr.Flush()
}



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

int main(void) {
	char cnt[24];
	int limit,num,time1,time2,i,j,diff;
	while(1){
		scanf("%d",&limit);
		if (limit == 0){
			break;
		}
		diff = 0;
		for(i = 0;i <= 24;i++){
			cnt[i] = 0;
		}
		scanf("%d",&num);
		for (i = 1;i <= num;i++){
			scanf("%d %d",&time1,&time2);
			for (j = (time1 + 1);j <= time2;j++){
				cnt[j] = 1;
			}
		}
		for (i = 0;i <= 24;i++){
			if (cnt[i] == 1){
				diff = diff + 1;
			}
		}
		if(limit <= diff){
			printf("OK\n");
		}
		else {
			printf("%d\n",limit - diff);
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <cstdio>
#ifdef _MSC_VER
#define GC getchar
#else
#define GC getchar_unlocked
#endif
int input()
{
	int x=0;
	char c;
	bool minus=false;
	for(;;)
	{
		c=GC();
		if (c=='-')
		{
			minus=true;
			continue;
		}
		if (c==' '||c=='\n')
			if (minus)
				return -x;
			else
				return x;
		x=10*x+c-'0';
	}
}
void fix()
{
	char c;
	for(;;)
	{
		c=GC();
		if (c==-1||c!=' '&&c!='\n')
			break;
	}
	if (c!=-1)
		ungetc(c,stdin);
}
int main()
{
	int N,i,j,k,d;
	int a[6];
	int m[32];
	int M[32];
	for (i=0; i<32; i++)
	{
		m[i]=1000000000;
		M[i]=-1000000000;
	}
	scanf("%d",&N);
  	d=2;
	fix();
	for (i=0; i<N; i++)
	{
		for (j=0; j<d; j++)
			a[j]=input();//,fix();
		for (j=0; j<1<<(d-1); j++)
		{
			int x=a[0];
			for (k=0; k<d-1; k++)
				if (j&(1<<k))
					x+=a[k+1];
				else
					x-=a[k+1];
			if (m[j]>x)
				m[j]=x;
			if (M[j]<x)
				M[j]=x;
		}
	}
	int ans=0;
	for (i=0; i<1<<(d-1); i++)
		if (ans<M[i]-m[i])
			ans=M[i]-m[i];
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;

    int h[n];
    bool judge[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
        judge[i] = true;
    }

    int a[m], b[m];
    
    for(int j = 0; j < m; j++){
        cin >> a[j] >> b[j];

        if(h[ a[j]-1 ] > h[ b[j]-1 ]){
            judge[ b[j]-1 ] = false;
        }else if(h[ b[j]-1 ] > h[ a[j]-1 ]){
            judge[ a[j]-1 ] = false;
        }else{
            judge[ a[j]-1 ] = false;
            judge[ b[j]-1 ] = false;
        }
    }

    int sum = 0;
    for(int i = 0; i < n; i++){
        if(judge[i] == true) sum++;
    }

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

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int a, b; cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int n;
  cin>>n;

int ans=0;
  rep(i,n){
    int a;
    cin>>a;
    if(i%2==0&&a%2==1) ans++;
  }
  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
a = [[min(i,int(j)-1)+max(i,int(j)-1)*(max(i,int(j)-1)-1)//2 for j in readline().split()] for i in range(n)]

N =n*(n-1)//2

g = [[] for i in range(N)]
p = [[] for i in range(N)]

for i in range(n):
    for j in range(n-2):
        g[a[i][j]].append(a[i][j+1])
        p[a[i][j+1]].append(a[i][j])
        
#print(g)
#print(p)

ans = [0]*(N)

indegree = [len(v) for v in p] # 流入辺の数を数えた配列
Source = [i for i, c in enumerate(indegree) if c == 0] #流入辺0の点の集合
#L = [] #ソート結果をためておく配列
num = 0
while Source:
    node = Source.pop()
    #L.append(node)
    num += 1
    for child in g[node]:
        indegree[child] -= 1 #辺 node -> child を削除する
        if ans[child] < ans[node]+1: ans[child] = ans[node]+1     
        if indegree[child] == 0:
            Source.append(child)

#print(num)
if num != N:
    print(-1)
else:
    print(max(ans)+1)

#print(ans)
    


Measured memory_bytes: 183384
N, K = gets.chomp.split.map(&:to_i)
H = gets.chomp.split.map(&:to_i)

if N <= K
  print (H[0] - H[-1]).abs
  exit
end

cost = []

K.times do |i|
  cost << (H[0] - H[i]).abs
end

K.upto(N - 1) do |i|
  cost << Float::INFINITY

  (1..K).each do |j|
    c = cost[i - j] + (H[i - j] - H[i]).abs

    if c < cost[-1]
      cost[-1] = c
    end
  end
end

print cost[-1]


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

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

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    string n;
    cin >> n;
    ll sum=0;
    REP(i,n.size()){
        char x = n[i];
      	int a = x-'0';
        sum+= a;
    }
    if(sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int64_t MOD=1e9+7;

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

  int64_t ans=0;
  for(int i=K;i<=N+1;++i){
    ans += (N+1-i)*i;
    ans += 1;
    ans %= MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

const int MAX = 1e5 + 10;
int N;
LL A[MAX];
LL B[MAX];

int main(void) {
    cin >> N;
    REP(i, N + 1) {
        cin >> A[i];
    }
    REP(i, N) {
        cin >> B[i];
    }

    LL ans = 0;
    REP(i, N) {
        REP(j, 2) {
            if (A[i + j] <= B[i]) {
                ans += A[i + j];
                B[i] -= A[i + j];
                A[i + j] = 0;
            } else {
                ans += B[i];
                A[i + j] -= B[i];
                B[i] = 0;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,c=0;cin>>n;
    pair<string,int>a[n];
    for(auto &x:a) cin>>x.first>>x.second;
    string s;cin>>s;
    int ans=0;
    for(auto x:a)
    {
    	if(x.first==s) c=1;
    	if(x.first!=s and c==1) ans+=x.second;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int counter(int x){
    if(x==0)return 0;
    return counter(x >> 1) + (x & 1);
}

int main(){
    
    int n;
    cin >> n;
    int a[16];
    int x[16][16];
    int y[16][16];
    for(int i=1; i<=n ; i++){
        cin >> a[i];
        for(int j=1; j<= a[i]; j++){
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    
    for(int div=1; div<1<<n ; div++){
        bool ok = true;
        for(int i = 1; i<=n ;i++){
            if(!(div & (1<<(i-1)))) continue; //なんじゃこりゃ
            for(int j = 1; j <= a[i] ; j++){ //iさんのしている証言をチェック
                if(((div>>(x[i][j]-1)) & 1) ^ y[i][j]) ok = false; // ^ はEOR,証言と事実が違う場合 falseを返す
            }
        }
        if(ok) ans = max(ans, counter(div));
    }
    cout << ans << endl;
	return 0;
}



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

int main() {
    string n; cin >> n;
    for(int i = 0; i < n.size(); i++){
        if(n[i] == '1') n[i] = '9';
        else if (n[i] == '9') n[i] = '1';
    }
    cout << n;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long INF=1e18,N=100002;
long A,B,Q,s[N],t[N],x,c,d,ans;
int main(void){
  cin>>A>>B>>Q;
  for(int i=1;i<=A;i++)cin>>s[i];
  s[0]=-INF;
  s[A+1]=INF;
  for(int i=1;i<=B;i++)cin>>t[i];
  t[0]=-INF;
  t[B+1]=INF;
  for(int i=0;i<Q;i++){
    cin>>x;
    c=lower_bound(s,s+A+2,x)-s;
    d=lower_bound(t,t+B+2,x)-t;
    ans=INF;
    for(int j=c-1;j<c+1;j++){
      for(int k=d-1;k<d+1;k++){
        ans=min(ans,abs(x-s[j])+abs(s[j]-t[k]));
        ans=min(ans,abs(x-t[k])+abs(t[k]-s[j]));
      }
    }
    cout<<ans<<endl;
  }
  return EXIT_SUCCESS;
}


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

#define INF 1000000000
typedef long long ll;

ll minCost(ll n, ll *arr, ll *dp, ll k)
{
    if(n < 1)
        return INF;
    if(n == 1)
        return 0;
    if(dp[n] != -1)
        return dp[n];
    ll ans = INF;
    for(ll i=1; i<=k; i++)
    {
        if(i < n)
            ans = min(ans, abs(arr[n]-arr[n-i]) + minCost(n-i, arr, dp, k));
    }
    dp[n] = ans;
    return ans;
}

int main()
{
    ll n, k;
    cin>>n>>k;
    ll arr[n+1];
    for(ll i=1; i<=n; i++)
        cin>>arr[i];
    ll *dp = new ll[n+1];
    for(ll i=0; i<=n; i++)
        dp[i]=-1;
    cout<<minCost(n, arr, dp,k);
}

Measured memory_bytes: 11136
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;
typedef long long ll;
//find_by_order, order_of_key
#define forn(i, n) for (ll i=0;i<ll(n);++i)

void solve()
{
    int n; scanf("%d", &n);
    string s; cin>>s;
    forn(i, min(n, (int)s.size()) ) printf("%c", s[i]);
    if (s.size() > n) printf("...");
    puts("");
}
int main()
{
    ll T=1;
    while(T--) solve();
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    string ans;
    if(s.at(s.size() - 1) == 's'){
        ans = s + "es";
    }
    else{
        ans = s + "s";
    }
    
    cout << ans << endl;
    
    return 0;
}
 
 //vector<int> a(3);
 //a.at(0);
 //a.size();
 //vector<vector<int>> a(3, vector<int>(3));
 //uint64_t sum = 0;
 //max(a, b);
 //min(a, b);
 //swap(a, b);
 //sort(vec.begin(), vec.end());  昇順
 //reverse(vec.begin(), vec.end());  降順


Measured memory_bytes: 3604
use std::io::stdin;

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().parse().unwrap();

    let mut ps = String::new();
    stdin().read_line(&mut ps).unwrap();
    let ps: Vec<usize> = ps.trim().split_whitespace().flat_map(str::parse).collect();

    let mut res = 0;
    for i in 1..n-1 {
        let mut a: Vec<_> = ps.clone().into_iter().skip(i-1).take(3).collect();
        a.sort();
        if a[1] == ps[i] {
            res += 1;
        }
    }
    println!("{}", res);
}


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

long long a, b, k;
bool ch = 0;

int main() {
  cin >> k >> a >> b;
  long long now = 0;
  while (now <= b) {
    now += k;
    if (a <= now && now <= b) ch = 1;
  }
  if (ch)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,h,m;cin>>a>>b>>h>>m;
    double hh = h+m*1.0/60; //時針は分針の影響をうける
    double ax = a*cos(hh*1.0/12*2*PI);
    double ay = a*sin(hh*1.0/12*2*PI);
    double bx = b*cos(m*1.0/60*2*PI);
    double by = b*sin(m*1.0/60*2*PI);
    cout << fixed << setprecision(10);
    out(hypot(abs(ax-bx),abs(ay-by)));
}


Measured memory_bytes: 4080
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#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 trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
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); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pctll(ll x) { return __builtin_popcountll(x); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int n;
	cin >> n;
	ll ans = 0LL;
	for (ll i = 1; i <= n; ++i) {
		if (i * i < n) {
			++ans;
		}
		for (ll j = i + 1; i * j < n; ++j) {
			ans += 2;
		}
	}
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3628
import math
n = int(input())
a = list(map(int, input().split()))
v = 0
for x in a:
    v = math.gcd(x, v)
if v > 1:
    print("not coprime")
else:
    #co or set
    primes = []
    primer = [True for i in range(10**6+1)]
    for p in range(2, 10**6+1):
        if primer[p] == True:
            primes.append(p)
            for i in range(2, 10**6+1):
                if p*i > 10**6:
                    break
                else:
                    primer[p*i] = False
    counter = [0 for i in range(10**6+1)]
    for num in a:
        counter[num] += 1
    pair = True
    for p in primes:
        res = 0
        for j in range(1, 10**6+1):
            if p*j > 10**6:
                break
            else:
                res += counter[p*j]
        if res > 1:
            pair = False
            break
    if pair:
        print("pairwise coprime")
    else:
        print("setwise coprime")

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   ll n; cin >> n;
   string s; cin >> s;
   ll temp = 0;
   REP(i, n){
      (s[i] == 'R') ? temp++ : temp--;
   }
   cout << ((temp > 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            int[][] hr1 = new int[n][2];
            for(int i=0; i<n; i++){
                hr1[i][0] = sc.nextInt();
                hr1[i][1] = sc.nextInt();
            }
            int m = sc.nextInt();
            int[][] mato = new int[n+m][2];
            for(int i=0; i<n; i++){
                mato[i][0] = hr1[i][0];
                mato[i][1] = hr1[i][1];
            }
            for(int i=0; i<m; i++){
                mato[i+n][0] = sc.nextInt();
                mato[i+n][1] = sc.nextInt();
            }
            
            Arrays.sort(mato, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b){
                        if(a[0]<b[0]) return -1;
                        if(a[0]>b[0]) return 1;
                        if(a[1]<b[1]) return -1;
                        if(a[1]>b[1]) return 1;
                        return 0;
                    }
                });

            int[][] dp = new int[1000][1000];
            for(int i=0; i<mato.length; i++){
                int idx1 = mato[i][0], idx2 = mato[i][1];
                dp[idx1][idx2] = 1;
                for(int j=0; j<i; j++){
                    int idx3 = mato[j][0], idx4 = mato[j][1];
                    if(idx1>idx3 && idx2>idx4)
                        dp[idx1][idx2] = Math.max(dp[idx1][idx2], dp[idx3][idx4]+1);
                }
            }

            int max = 0;
            for(int i=0; i<1000; i++){
                for(int j=0; j<1000; j++){
                    max = Math.max(max, dp[i][j]);
                }
            }
            System.out.println(max);
        }
   }

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

Measured memory_bytes: 59524
import java.util.Scanner;
public class Main
{
	static int n,s,ans;
	public static void main(String[] args) 
	{
		Scanner in =new Scanner(System.in);
		for(;;)
		{
			n=in.nextInt();
			s=in.nextInt();
			if((n|s)==0)
				return;
			ans=0;
			solve(0,0,0);
			System.out.println(ans);
		}
	}
	public static void solve(int i,int sum,int N)
	{
		if(sum==s&&N==n)
		{
			ans++;
			return;
		}
		if(i>=10||sum>s)
			return;
		solve(i+1,sum,N);
		solve(i+1,sum+i,N+1);
		return;
	}
}

Measured memory_bytes: 11000
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000000;
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

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

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

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


int main(){

    int n,m;
    cin>>n>>m;

    vector<int> a(m);
    struct s{int a,b,c;};
    vector
 side(m);
    REP(i,m)cin>>side[i].a>>side[i].b>>side[i].c;
    vector<ll> graph(n+1);
    for(auto&g:graph)g=(-INF);
    graph[1]=0;

    bool infflag=false;
    int count=0;
    while(1){
        bool flagflag=false;
        bool flag=false;
        for(auto&s:side){
            if(graph[s.a]!=(-INF)){
                int end_=graph.back();
                if(graph[s.b]<graph[s.a]+s.c)flag=true;
                graph[s.b]=max(graph[s.b],graph[s.a]+s.c);
                if(end_!=graph.back())flagflag=true;
            }
        }

        if(count>n+2000||!flag)break; // kousin end or kankeinai loop
        if(count>n && flagflag){infflag=true;break;} // junkan loop
        ++count;
    }
    if(infflag)cout<<"inf"<<endl;
    else cout<<graph.back()<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
#include<stdlib.h>
 
 
#include<string.h>
 
 
int main(void){
 
 
 
 
 
char num_str[1002];
 
 
int num;
 
 
long sum = 0;
 
 
int i;
 
 
char tmp;
 
 
while (1){
 
 
fgets(num_str,sizeof(num_str),stdin);
 
 
if(num_str[0] == '0') break;
 
 
for(i=0;i<strlen(num_str)-1;i++){
 
 
tmp = num_str[i];
 
 
num=atoi(&tmp);
 
 
sum=sum+num;
 
 
}
 
 
printf("%ld\n",sum);
 
 
sum=0;
 
 
memset(num_str,1002,0);
 
 
}
 
 
return 0;
 
 
}

Measured memory_bytes: 532
import math

def process(number_list):
    left, point = number_list[0], number_list[-2]
    if left == 1:
        print(1)
        return 0
    right = number_list[-1] % left
    number_list.pop(-1)
    if right == 0:
        if len(number_list) == 1:
            print(number_list[0])
            return 0
    else:
        number_list.insert(0, right)
    return number_list

def main():
    num = int(input())
    number_list = list(map(int, input().split()))
    number_list.sort()
    while 1:
        number_list = process(number_list)
        if number_list == 0:
            break


if __name__ == '__main__':
    main()

Measured memory_bytes: 15020
from itertools import accumulate

def main():
    n, k = map(int, input().split())
    a = [0] + list(accumulate(map(int, input().split())))

    btfl = []
    for i in range(0, n):
        for j in range(i + 1, n + 1):
            btfl.append(a[j] - a[i])

    # 解説AC
    ans = 0
    for i in range(50)[::-1]:
        num, cnt = ans + pow(2, i), 0
        for b in btfl:
            if num == num & b:
                cnt += 1
        if cnt >= k:
            ans = num
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28824
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

    sort(a.begin(),a.end());
    int num = 0;

    int i = 0;
    for (i;i < N;i++) {
        int it = a[i];
        if(x - it < 0){
            break;
        }else {
            x -= it;
            num++;
        }
    }

    if(i == N && x > 0) num--;


    cout << num;


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	map<int,int>m;
	int n,k,x=0,cnt=0;
	cin>>n>>k;
	pair<int,int>p[n+3];
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		m[x]++;
	}
	for(auto &g:m)
	p[x++]={g.second,g.first};
	sort(p,p+x);
	int i=0;
	while(x>k)
	{
		cnt+=p[i].first;
		x--;
		i++;
	}
	cout<<cnt;
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<pair<long long, long long>> prime_factorize(long long N)
{
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    ll N,P;
    string S;
    cin >> N>>P;

    const auto &res = prime_factorize(P);

    ll ans = 1;

    /*REP(i, res.size())
    {
        cout << "{" << res.at(i).first << "^" << res.at(i).second << "}" << endl;
    }*/

    REP(i, res.size())
    {
        ll tmp1 = res.at(i).first;
        ll tmp2 = res.at(i).second;
        while(tmp2 >= N)
        {
            ans *= tmp1;
            tmp2 -= N;
        }
    }
    cout << ans << endl;
}


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

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

using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> C[i];
    rep(i, N) P[i]--;

    ll ans = -1e18;

    rep(si, N) {
        int x = si;
        vector<int> s;
        ll tot = 0;
        while (true) {
            x = P[x];
            s.push_back(C[x]);
            tot += C[x];
            if (x == si) break;
        }

        int l = s.size();
        ll t = 0;
        rep(i, l) {
            t += s[i];
            if (i + 1 > K) break;
            ll now = t;
            if (tot > 0) {
                ll e = (K - (i + 1)) / l;
                now += tot * e;
            }
            ans = max(ans, now);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll m,n;
    cin >> n >> m;
    vector<PL> ab;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        ab.push_back(PL(a,b));
    }
    sort(ab.begin(),ab.end());
    ll cnt=0,ans=0;
    rep(i,n){
        cnt += ab[i].second;
        if(cnt<=m) ans += ab[i].first*ab[i].second;
        else ans += ab[i].first*(ab[i].second-(cnt-m));
        if(cnt>=m) break;
    }

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

Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static int[] dp;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var N = input[0];
        var M = input[1];

        solver(N,M, Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
    }

    public static void solver(int N, int K, int[] plans){

        /*
            dp[K] 石K個でスタートした場合の勝ち負け

            2 3 での2~10

            F,F,F,S,S,

            例えば7のとき、2を選んだ場合は5を後手が先手始点で見た結果になる。
            5では後手が勝つ、つまり相手視点での敵、自分が勝てる。
            3を選ぶと4が残り、相手視点で自身が勝ち、つまり自分が負ける。
            

        
         */

        dp = new int[100010];

/*
        for(int i = 0; i <= K; i++){
            dp[i] = SECOND_WIN;
        }*/
        /*
        for(int i = min; i <= judgePoint + min; i++){
            dp[i] = FIRST_WIN;
        }
        */

        for(int i = 0; i <= K; i++){
            foreach(var tgt in plans){
                if(tgt > i) break;
                if(dp[i - tgt] == SECOND_WIN){
                    dp[i] = FIRST_WIN;
                    break;
                }
            }
        }

        Console.WriteLine(dp[K] == 1 ? "First" : "Second");
        


    }

}

Measured memory_bytes: 13524
/*
    Don't practice until you get it right. Practice until you can't get it wrong.
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const int INF=0x3f3f3f3f;
 
ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}
 
ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}
 
vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}
 
ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;
 
int main()
{
	vivek_ghosh;
 
	cin>>n;
	vector<pair<string,ll> > vec(n);
	map<string,ll> hash;
	for(i=0;i<n;i++)
	{
		cin>>vec[i].ff>>vec[i].ss;
		hash[vec[i].ff] =i;
	}
	string X;
	cin>>X;
	
	m = hash[X]+1;
	ans = 0;
	for(i=m;i<n;i++)
	{
		ans+=vec[i].ss;
	}
	cout<<ans<<endl;
	
		
		
		
		
 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void a_restricted(void) {
	int a, b;
	cin >> a >> b;
	int sum = a + b;

	if (sum >= 10) cout << "error" << endl;
	else           cout << sum << endl;
}

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

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

#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector <T> a = vector<T>(n + oneIndexed);

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

    return move(a);
}

template<typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}

void solve() {
    ll n, x, y;
    cin >> n >> x >> y;

    v dist(1e6, 0);
    for (ll start = 1; start <= n; start++) {
        for (ll end = start + 1; end <= n; end++) {
            ll d = end - start;

            if (end >= y && start <= x) {
                d -= y - x;
                d++;
            } else if (start <= x && end <= y && end >= x) {
                ll d1 = x - start;
                ll d2 = min(y - end + 1, end - x);
                amin(d, d1 + d2);
            } else if (start >= x && start <= y && end >= y) {
                ll d1 = min(start - x + 1, y - start);
                ll d2 = -y + end;
                amin(d, d1 + d2);
            } else if (start >= x && start <= y && end >= x && end <= y) {
                amin(d, start - x + 1 + y - end);
            }

            dist[d]++;
        }
    }
    for (ll k = 1; k <= n - 1; k++) cout << dist[k] << endl;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

typedef pair<int, int> ii;

string S;
int N;
int sum[100005];

ii solve(char x) {
	int ch = 0;
	for (int i = 1; i <= N; ++i) {
		if (i - 2 >= 0 && sum[i - 2] < sum[ch]) ch = i - 2;
		sum[i] = sum[i - 1] + (S[i] == x ? 1 : -1);
		if (i >= 2 && sum[i] - sum[ch] > 0) return ii(ch + 1, i);
	}
	return ii(-1, -1);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> S; N = (int)S.length(); S = '~' + S;
	ii ans(-1, -1);
	for (char i = 'a'; i <= 'z'; ++i) ans = max(ans, solve(i));
	cout << ans.first << ' ' << ans.second << endl;
}

Measured memory_bytes: 748
import java.util.Scanner;

public class Main {

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

    // 目的地までの距離
    int d = sc.nextInt();

    // 待ち合わせ時間
    int t = sc.nextInt();

    // 分速
    int s = sc.nextInt();

    if ((double)d / s <= t) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35640
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
string s;
llint dp[3005][3005];
llint sum[3005];

int main(void)
{
	cin >> n;
	cin >> s;
	s = "#" + s;
	
	dp[1][1] = 1;
	for(int i = 2; i <= n; i++){
		for(int j = 1; j <= i; j++) sum[j] = sum[j-1] + dp[i-1][j], sum[j] %= mod;
		if(s[i-1] == '<'){
			for(int j = 1; j <= i; j++) dp[i][j] = sum[j-1];
		}else{
			for(int j = 1; j <= i; j++){
				dp[i][j] = sum[i-1] +mod - sum[j-1];
				dp[i][j] %= mod;
			}
		}
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++) ans += dp[n][i], ans %= mod;
	cout << ans << endl;
	
	return 0;
}

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

#define ll long long

using namespace std;


int main()
{
    string S, T;

    cin >> S >> T;

    int m = S.length(), n = T.length();

    int min = n;

    for(int i = 0; i <= (m-n); i++) {
        int change = 0;
        for(int j = i, x = 0; j < i + n; j++, x++) {
            if(S[j] != T[x]) change++;
        }
        if(change < min) min = change;
    }

    cout << min;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    string s;
    ll ans=0;
    cin >>n>>s;
    vector<int> rs(n+2,0),gs(n+2,0),bs(n+2,0);
    rep(i,n){
        switch(s[i]){
        case 'R':
        rs[i+1]++;
        break;
        case 'G':
        gs[i+1]++;
        break;
        case 'B':
            bs[i + 1]++;
            break;
        }
        rs[i+1]+=rs[i];
        gs[i + 1] += gs[i];
        bs[i + 1] += bs[i];
    }
int id=7;
int iid;
    for(int i=0;i<n-2;i++){
        iid=7;
        if(s[i]=='R'){
            iid-=1;
        }else if(s[i]=='G'){
            iid-=2;
        }else{
            iid-=4;
        }
        
        for(int j=i+1;j<n-1;j++){
            id = iid;
           // clog << i << " " << j;
            
            if(s[i]==s[j]){
              //  clog<<" pass "<<endl;
                continue;
            }
           
            if (s[j] == 'R')
            {
                id -= 1;
            }
            else if (s[j] == 'G')
            {
                id -= 2;
            }
            else
            {
                id -= 4;
            }
            switch(id){
                case 1://r
                ans+=rs[n]-rs[j];
                if(j+j-i<n &&s[j+j-i]=='R'){
                    ans--;
                }
                break;
                case 2://g
                    ans += gs[n] - gs[j];
                    if (j + j - i < n && s[j + j - i] == 'G')
                    {
                        ans--;
                    }
                    break;
                case 4://b
                    ans += bs[n] - bs[j];
                    if (j + j - i < n && s[j + j - i] == 'B')
                    {
                        ans--;
                    }
                    break;
            }
          //  clog<<" --> "<<ans<<endl;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    string s;
    cin >> s;
    if(s.size()==2){
        cout << s << endl;
    }else{
        reverse(s.begin(), s.end());
        cout << s<< endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int n,a[maxn];
ll sum[maxn];
int l1,l2;
//[1,l1][l1+1,i][i+1,l2][l2+1,r]
//枚举中间分界点i 把区间划成左右两半
ll mx,mn;
ll ans;
ll getsum(int l,int r)
{
	return sum[r]-sum[l-1];
}
ll update(int l,int r)
{
	mx=max(mx,getsum(l,r));
	mn=min(mn,getsum(l,r));
}
int main()
{ 
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
	{
	 scanf("%d",&a[i]);
     sum[i]=sum[i-1]+a[i];
    }
    ans=1e18,l1=1,l2=3;//考虑n==4的情况下是这些值
	//l1和l2最靠左是这些值，以后是单增的 
	for(int i=2;i<=n-2;++i)
	{
		mx=-1e18,mn=1e18;
		while(l1+2<=i&&abs(getsum(1,l1)-getsum(l1+1,i))>abs(getsum(1,l1+1)-getsum(l1+2,i)))l1++;
		while(l2+2<=n&&abs(getsum(i+1,l2)-getsum(l2+1,n))>abs(getsum(i+1,l2+1)-getsum(l2+2,n)))l2++;
		update(1,l1),update(l1+1,i);
		update(i+1,l2),update(l2+1,n);
		ans=min(ans,mx-mn);
	} 
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
using ll = long long;

int main() {
  ll n; cin >> n;
  int ok = 1;
  int tmp;
  int sum = 0;
  rep(i, n) {
    cin >> tmp;
    if (tmp == ok) {
      sum++;
      ok++;
    }
  }
  if (sum == 0) {
    cout << -1 << endl;
  } else {
    cout << n-sum << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double h,w,x,y;
  cin >> w >> h >> x >> y;
  int ans = 0;
  if(w / 2 == x && h / 2 == y)ans = 1;
  printf("%.10f %d\n",(h*w)/2,ans);
}

Measured memory_bytes: 256