akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    ll *a = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    ll ans = 0;

    for (int i = 1; i < n; i++) {
        if (a[i] < a[i-1]) {
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }

    cout << ans << endl;

    return 0;
}

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

main(){
  ll i,n;
  cin >> n;
  ll h[n];
  for(i=0;i<n;i++) cin >> h[i];

  for(i=1;i<n;i++){
    if(h[i]>h[i-1]) h[i]--;
    if(h[i]<h[i-1]){
      puts("No");
      exit(0);
    }
  }
  
  puts("Yes");
}
    
  
  

Measured memory_bytes: 1024
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    [n] :: [Int] <- map read . words <$> getLine
    aue :: [Int] <- map read. words <$> getLine
    ashita :: [Int] <- map read . words <$> getLine
    print $ maximum [ sum (take k aue) + sum (drop (pred k) ashita) | k <- [1..n]] 

Measured memory_bytes: 1020
N,K = [int(x) for x in  input().split()]
S = list(input())
ans = [0]
a = []
for i in range(N-1):
  if S[i]!=S[i+1]:
  	ans.append(i)
ans.append(N-1)
#print(ans)
a = []
for i in range(1,len(ans)):
  a.append(ans[i]-ans[i-1])
a[0] +=1
ans2 = sum(a)-len(a)
#print(a)
#print(ans2)
#print(len(a)//2*2-1)
if len(a)!=1:
  ans2 = ans2 +(2*K)
print(min(ans2,len(S)-1))


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=1,s=7;cin>>N;
  if(N%2==0||N%5==0)ans=-1;
  else{
    while(s%N!=0){
      s*=10;s+=7;s%=N;ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){

int n,i;
double sum1=0,sum2=0,sum3,max=0,ans[4];

scanf("%d",&n);
double x[n],y[n];
for(i=0;i<n;i++)
     scanf("%lf",&x[i]);
for(i=0;i<n;i++)
 scanf("%lf",&y[i]);
for(i=0;i<n;i++){

    sum1+=abs(x[i]-y[i]);
    if(abs(x[i]-y[i])>max)
        max=abs(x[i]-y[i]);

    sum2+=pow(abs(x[i]-y[i]),2);
    sum3+=pow(abs(x[i]-y[i]),3);

}


printf("%lf\n",sum1);
printf("%lf\n",sqrt(sum2));
printf("%lf\n",cbrt(sum3));
printf("%lf\n",max);

}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define abs abs_

using namespace std;
typedef long long ll;

const int N=200005;
const ll inf=1e14;

ll mv1[N<<2],mv2[N<<2],sum;
int n,Q,x,y,A,B;

int abs(int x){return x<0?-x:x;}
void build(int x,int l,int r){
	mv1[x]=mv2[x]=inf;
	if(l==r)return;
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	build(ls,l,mid),build(rs,mid+1,r);
}
void update(int x,int l,int r,int p,ll u){
	if(l==r){
		mv1[x]=min(u-l,mv1[x]);mv2[x]=min(u+l,mv2[x]);
		return;
	}
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	if(p<=mid)update(ls,l,mid,p,u);
	else update(rs,mid+1,r,p,u);
	mv1[x]=min(mv1[ls],mv1[rs]);mv2[x]=min(mv2[ls],mv2[rs]);
}
ll ask1(int x,int l,int r,int s,int t){
	if(l==s&&r==t)return mv1[x];
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	if(t<=mid)return ask1(ls,l,mid,s,t);
	if(s>mid)return ask1(rs,mid+1,r,s,t);
	return min(ask1(ls,l,mid,s,mid),ask1(rs,mid+1,r,mid+1,t));
}
ll ask2(int x,int l,int r,int s,int t){
	if(l==s&&r==t)return mv2[x];
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	if(t<=mid)return ask2(ls,l,mid,s,t);
	if(s>mid)return ask2(rs,mid+1,r,s,t);
	return min(ask2(ls,l,mid,s,mid),ask2(rs,mid+1,r,mid+1,t));
}
ll ask(int x,int l,int r){
	if(l==r)return mv1[x]+l;
	int ls=x<<1,rs=ls|1,mid=(l+r)>>1;
	return min(ask(ls,l,mid),ask(rs,mid+1,r));
}

int main(){
	scanf("%d%d%d%d",&n,&Q,&A,&B);
	build(1,1,n);y=B;update(1,1,n,A,0);
	for(int i=1;i<=Q;i++){
		scanf("%d",&x);
		ll cur=min(ask1(1,1,n,1,x)+x,ask2(1,1,n,x,n)-x);
		sum+=abs(x-y);cur-=abs(x-y);
		update(1,1,n,y,cur);y=x;
	}
	printf("%lld\n",sum+ask(1,1,n));
	return 0;
}

Measured memory_bytes: 12544
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	A, B, C := readInt(), readInt(), readInt()
	if A <= C && C <= B {
		println("Yes")
	} else {
		println("No")
	}
}


Measured memory_bytes: 640
// LQDNT_TTMinh
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define req(i,a,b) for(ll i=(a);i>=(b);--i)
#define name ""
#define pb push_back
#define sz size()
#define ff first
#define ss second
typedef pair < ll , ll > ii;
const ll maxn=1e6+7,oo=1e18,base=311,mod=1e9+7;
ll n,x;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

vector<vector<int> > edges;
vector<vector<long long> > memo;

long long solve(int curr, int prev, bool isBlack)
{
    if(memo[isBlack][curr] != -1)
        return memo[isBlack][curr];

    long long ans = 1;
    for(int next : edges[curr]){
        if(next == prev)
            continue;

        long long tmp = solve(next, curr, false);
        if(!isBlack){
            tmp += solve(next, curr, true);
            tmp %= MOD;
        }
        ans *= tmp;
        ans %= MOD;
    }

    return memo[isBlack][curr] = ans;
}

int main()
{
    int n;
    cin >> n;
    edges.assign(n, vector<int>());
    for(int i=0; i<n-1; ++i){
        int x, y;
        cin >> x >> y;
        -- x;
        -- y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    memo.assign(2, vector<long long>(n, -1));
    long long ans = solve(0, -1, true) + solve(0, -1, false);
    ans %= MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15600
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	int a, v;
	int ai, vi;
	int n;

	a = 1, v = 0;
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d %d", &ai, &vi);
		if (vi > v || (vi == v && ai < a))
		{
			a = ai;
			v = vi;
		}
	}

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

Measured memory_bytes: 600
#include<iostream>
#include<string>
int main()
{
	for (std::string str; std::cin >> str;)
	{
		auto check = [&str](char c)
		{
			return
				str[0] == c && str[1] == c && str[2] == c ||
				str[3] == c && str[4] == c && str[5] == c ||
				str[6] == c && str[7] == c && str[8] == c ||
				str[0] == c && str[3] == c && str[6] == c ||
				str[1] == c && str[4] == c && str[7] == c ||
				str[2] == c && str[5] == c && str[8] == c ||
				str[0] == c && str[4] == c && str[8] == c ||
				str[2] == c && str[4] == c && str[6] == c;
		};
		std::cout << (check('o') ? 'o' : check('x') ? 'x' : 'd') << std::endl;
	}
}


Measured memory_bytes: 3160
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())
s = input().rstrip()

cnt = Counter(s)
R = cnt['R']
G = cnt['G']
B = cnt['B']

cnt = 0
for i in range(n):
    for j in range(1, n):
        if n <= i + j * 2:
            break
        if s[i] != s[i + j] and s[i + j] != s[i + 2 * j] and s[i] != s[i + 2 * j]:
            cnt += 1

print(R*G*B-cnt)


Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MA 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e


const int MAX = 1000004;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
cout << fixed << setprecision(16);
  ll x,y;
   COMinit();

  cin>>x>>y;
  if(x>2*y||y>2*x){
    putout(0);
  }
  else{
    if((x+y)%3!=0){
      putout(0);
    }
    else{
      ll n=(x+y)/3;
      ll t=x-n;
      putout(COM(n,t));
    }
  }
  

}

Measured memory_bytes: 23680
using System;

namespace abc149_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ABK = Console.ReadLine().Split(" ");
            long A = long.Parse(ABK[0]);
            long B = long.Parse(ABK[1]);
            long K = long.Parse(ABK[2]);

            if(K > A)
            {
                K -= A;
                A = 0;
            }
            else
            {
                A -= K;
                K = 0;
            }

            if (K != 0)
            { 
                if (K > B)
                {
                    K -= B;
                    B = 0;
                }
                else
                {
                    B -= K;
                    K = 0;
                }
            }
            Console.WriteLine(A + " " + B);
        }
    }
}


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

int main(void) {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    if ((int)(i * 1.08) == N) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

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

int main(){
	float v;
	while(cin >> v){
		float t = v / 9.8;
		float y = 4.9 * t * t;
		int i = 1;
		while(1){
			if(y <= 5*i-5) break;
			i++;
		}
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	if(A>=B*2) {
		System.out.println(A-B*2);
	}
	else {
	System.out.println(0);
}
}
}

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

int main() {
  int N;
  int K;
  int s = 1;
  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
    if(2 * s <=  s + K){
      s *= 2;
    }
    else{
      s += K;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>

using namespace std;

int main()
{
	int k,n,r;
	cin >> n >> r;
	if(n >= 10){
		cout << r << endl;
	}
	else{
		int num;
		num = 100 * (10 - n);
		cout << num + r << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define MAX_N 100

int main()
{
  int n, x, tmp;
  int minm = INT_MAX;
  int cnt = 0;

  scanf("%d %d", &n, &x);
  for(int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    x -= tmp;
    cnt++;
    minm = min(minm, tmp);
  }

  cnt += x / minm;
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P =pair<int,int>;
int main(){
	int N;
	cin>>N;
	vector<int>A(N);
	vector<int>B(N);
	rep(i,N){
		cin>>A.at(i);
	}
	rep(i,N){
		B.at(A.at(i)-1)=i+1;
		//cout<<B.at(i)<<" ";
	}

	rep(i,N){
		//B.at(A.at(i)-1)=i+1;
		cout<<B.at(i)<<" ";
	}
	
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 string s;
  cin>>s;
  int ans=inf;
  int n=s.size();
  rep(i,0,n-2){
   
     int g=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
     // cout<<g<<endl;
      ans=min(ans,abs(753-g)); 
   
  }
  cout<<ans<<endl;
}










Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

//  　 　 　 　／ 　 　 　 　 　 　 ｀　､ 　 　 　 感謝するぜ　　お前と出会えた
// 　　　 　 　/　 　　　　　　　　ノﾉ　　ヽ
// 　　　　　 ,　　　　　ニニ彡'⌒　　　 /｀ヽ　　　　　　　 これまでの　　全てに
// 　　 　　　' 　 ニミ　ニニ彡　 　 　 〈ｒう├－-ミ
// 　　 　 　 { {　ニミ　} j ｊ ｊﾉｘ'ィイく　　}し｛＼　　 ｀丶、＿＿_／ニニニ
// 　　　　 　ｊ_ニニミV ﾊﾚﾉ ｘ＜⌒ヽ　 V ﾍ 　＼　　　 ＼ニニニニニニニ
// 　　　　　 {xミミｰ'ヾ(､ﾙ( 厶ｔｧァく⌒ヾ}　　）ﾊ::::::.　　　　＼ニニニニニニ
// 　　　　　彡ｨ'"＞tｧ}　＼(｀ニ彡 ノ` /ト=く 　 ::::::i　　　　　＼ニニニニニニ
// 　　 　　( 　 V＾`こ7　 _, ＼｀`ヾヽ｀　ﾉ|｀ヽ ヽ ｌ:::::|　　　　　　 ＼ニニニニニ
// 　　 　 　 　 ∧　　{ '　　｀ ﾉ＾ヽ 　 　{ ﾉ　　 　 !:::::|　　　＿__ノ^ヽニニニニニニ
// 　　　　　 ／.::::＼ゝヽ. _ノヽ｀｀ヽ, -――- 、 /:::::/　／ 　 　　￣｀ヽニニニニニ
// 　　 　 ／.::::::::::::::::>'"ﾉﾙﾊヽ`／ -―- ､⌒Ｖ::::::/.／／ ｊ＿__ノ、　　ヽニニニニニ
// 　　／ニニ、｀ヽ｀ヾﾍ{ {､ﾑイ　､＿（　　 >　 ＼／ （__ ノニニニ　　 　 ＼ニニニニ
// 　,仁ニニニ＼ヽヽヽ ∨　　　/ニﾆ＞彡＞--'）__ ノ　　 　｀ヽニ　　　　　＼ニニニ二
// 　ニニニニニﾆヽ 　 /　　 　 {ニニ＞ ´　｀¨¨´　　　　　　　　 ﾆ}　　　　　　＼＞''"´
// 　ニニニニニニﾆﾆ/　　　　 ∨　/　　　　　　　　　　　　　　　}八
// 　ニニニニニニﾆ./　 　 　 　 }ニ{　　　　　　　　　　　　　 　 ﾉニヽ　　　　 ﾉ
// 　ニニニニニﾆﾆ/　　　　　　 }ニﾊ　　　　　　　　 　 　 　 ／⌒ヽヽヽ ___彡
// 　ニニニニニﾆﾆ!　　　 　 　 ﾉニニヽ、　 　 　 　 　 　 ／　　　　　｀ ー=彡'ニニニニニ
// 　ニニニニニﾆﾆ}　　　　　　　　　　⌒`丶、　　　　 ／⌒ヽ　 ﾉ　　　　　ノ＿＿＿＿＿
// 　 ／￣￣￣｀ヽ/ヽ、　＿彡ﾍ{ ｛　　　 　 　 ＞ ､　/　　 　 ／ ￣￣￣
// 　　 　 ) ､　 　 /　　 ヾ､　　　 ヽ ヽ　 　 　 （ 　 　`{　　　 /
// 　//　⌒ヽ　 /　　　　〃 トミ　　＿__　＞--‐=､ 　 ヽ ＿ﾉ
// 　 { 　 　 　 /　　　　//　　　　 /　　　　　　　　 ＼__ﾉ

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

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

let main() =
    let n = read int
    let bs = Array.zeroCreate n
    for i in 0 .. n - 1 do
        let a = read int64
        bs.[i] <- a

    let ok = bs |> Array.forall (fun x -> x % 2L = 0L)
    if ok then "second" else "first"
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 17464
n,k,q = map(int,input().split())

a = [0]*n

for i in range(q):
    s = int(input())
    a[s-1] += 1
    
m = max(q-k+1,0)
    
for i in a:
    if i>=m:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(int argc, char** argv) 
{
	char a[]={"A"},b[]={"T"},c[]={"C"},d[]={"G"},p[5];
	cin >> p;
	if(strcmp(p,a)==0)
	cout << b << endl;
	else if( strcmp (p,b)==0)
	cout << a << endl;
	else if( strcmp(p,c)==0)
	cout << d << endl;
	else
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	string s;
	cin >> s;
	if(s[0]=='7' or s[1]=='7' or s[2]=='7')
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;




}


Measured memory_bytes: 3132
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,res=1;
  cin >> N;
  while(1){
    if(res*2 > N)
      break;
    res *= 2;
  }
  cout << res << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

long long n_idx(long long , long long);

//xはyで何回割れるか計算
long long n_idx(long long x, long long y){
    long long n = 0;
    while(x % y == 0){
        x = x / y;
        n++;
    }
    return n;
}

int main(){
    int N;
    int cnt0 = 0, cnt1 = 0, cnt2 = 0;
    cin >> N;
    long long a;
    for(int i=0; i<N; i++){
        cin >> a;
        int n = n_idx(a, 2);
        if(n == 0){
            cnt0++;
        }else if(n == 1){
            cnt1++;
        }else{
            cnt2++;
        }
    }
    if(cnt1 >= 1){
        if(cnt2 >= cnt0){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else if(N%2 == 0){
        if(cnt2 >= cnt0){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
        if(cnt2+1 >= cnt0){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	int fu1 = (N + 1) % 2, fu2 = (N - 1) / 2, pu1, pu2;
	if (N < 4) {
		pu2 = 0;
	}
	else {
		pu2 = N / 2 - 1;
	}
	if (N < 3) {
		pu1 = 1;
	}
	else {
		if (N % 2 == 1)
			pu1 = 2;
		else
			pu1 = 1;
	}
	rSORT(A);
	int ans = 0;
	int i = 0;
	while (pu2 > 0) {
		ans += A[i] * 2;
		pu2--;
		i++;
	}
	while (pu1 > 0) {
		ans += A[i];
		pu1--;
		i++;
	}
	while (fu1 > 0) {
		ans -= A[i];
		fu1--;
		i++;
	}
	while (fu2 > 0) {
		ans -= A[i] * 2;
		fu2--;
		i++;
	}
	int anss = 0;

	pu1 = (N + 1) % 2;
	pu2 = (N + 1) / 2 - 1;
	fu1 = N % 2 + 1;
	if (N == 1)fu1 = 1;

	if (N < 4) {
		fu2 = 0;
	}
	else {
		fu2 = (N - 2) / 2;
	}
	i = 0;
	while (pu2 > 0)
	{
		anss += A[i] * 2;
		pu2--;
		i++;
	}
	while (pu1 > 0){
		anss += A[i];
		i++;
		pu1--;
	}
	while (fu1 > 0) {
		anss -= A[i];
		i++;
		fu1--;
	}
	while (fu2 > 0) {
		anss -= A[i] * 2;
		i++; 
		fu2--;
	}
	//cout << pu1 << " " << pu2 << " " << fu1 << " " << fu2 << endl;

	cout << max(ans, anss) << endl;
	return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] ruisekiWA = new long[n];
		ruisekiWA[0] = sc.nextLong();
		for(int i = 1; i < n; i++) {
			ruisekiWA[i] = sc.nextLong()+ruisekiWA[i-1];
		}
		long ans = Long.MAX_VALUE;
		for(int i = 0; i < n-1; i++) {
			long x = ruisekiWA[i];
			long y = ruisekiWA[n-1] - x;
			//System.out.println("一人目："+ruisekiWA[i]);
			//System.out.println("二人目："+ruisekiWA);
			ans = Math.min(ans, Math.abs(x-y));
		}
		System.out.println(ans);
	}
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  string s;
  cin >> s;

  int a = 0;
  int b = 0;
  int c = 0;
  REP (i, 3) {
    if (s[i] == 'a') a++;
    else if (s[i] == 'b') b++;
    else if (s[i] == 'c') c++;
  }

  string ans;
  if (a == 1 && b == 1 && c == 1) ans = "Yes";
  else ans = "No";

  cout << ans << endl;
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
  int n;
  std::cin >> n;
  std::vector<long long> a(n);
  rep(i,n){
    std::cin >> a[i];
  }
  sort(all(a));
  reverse(all(a));
  long long ans=0;
  bool b=false;
  while(!b){
    long long tmp =0,tmp2;
    rep(i,a.size()){
      ans+=a[i]/n;
      tmp+=a[i]/n;
    }
    rep(i,a.size()){
      tmp2=a[i];
      a[i]=tmp2%n;
      a[i]+=tmp-tmp2/n;
    }
    b=true;
    rep(i,a.size()){
      if(a[i]>n-1) b=false;
    }
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
import copy 
N = int(input())
#*L, = map(str, input().split())
L = [int(input()) for i in range(N)]
#*L, = input().split()

#A1 = copy.copy(L)
#A2 = copy.copy(L)
#G = []
G = []
cnt = 0

def insertion_sort(A,n,g):
	global cnt
	for i in range(g,n):
		v = A[i]
		j = i - g
		while j>= 0 and A[j] > v:
			A[j+g] = A[j]
			j = j - g
			cnt += 1
		A[j+g] = v


def shell_sort(A,n):
	h = 1
	while True:
		if h > n:
			break
		G.append(h)
		h = 3*h + 1
		
	for i in reversed(range(len(G))):
		insertion_sort(A,n,G[i])

shell_sort(L,N)
print(len(G))
G = G[::-1]
print(*G)
print(cnt)
for i in L:
	print(i)






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

#define ll long long
using namespace std;
ll a[200001];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=a[n-1];
    int i=n-3,k=2;
    int j=n-2;
    while(i>=0){
        if(i>=1){
            ans+=2*a[j];
            i-=2;
            j--;
        }
        else{
            ans+=a[j];
            i--;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

const ll INF = 10000000000000000;

int main()
{
    int n;
    cin >> n;
    ll a[200001];
    ll s[200001];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
        s[i] = sum;
    }
    ll ans = INF;
    for(int i = 2; i < n - 1; i++){
        int m1 = upper_bound(s, s + i, s[i - 1] / 2) - s;
        int m2 = upper_bound(s + i, s + n, (s[n - 1] + s[i - 1]) / 2) - s;
        ll ma1, ma2;
        if(m1 == 0){
            ma1 = a[0];
        }
        else if(m1 == i - 1){
            ma1 = a[i - 1];
        }
        else{
            ma1 = min(s[m1], s[i - 1] - s[m1 - 1]);
        }
        if(m2 == i){
            ma2 = a[i];
        }
        else if(m2 == n - 1){
            ma2 = a[n - 1];
        }
        else{
            ma2 = min(s[m2] - s[i - 1], s[n - 1] - s[m2 - 1]);
        }
        ans = min(ans, max(ma1, ma2) - min(s[i - 1] - ma1, s[n - 1] - s[i - 1] - ma2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  int ans = min(a, k);
  k = max(0, k - a - b);
  printf("%d\n", ans - min(k, c));
  return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int mx = -1, smx = -1, mxi = -1;
  rep(i, n){
    int in;
    cin >> in;
    if(in > mx){
      smx = mx;
      mx = in;
      mxi = i;
    }else if(in > smx){
      smx = in;
    }
  }
  rep(i, n){
    if(i != mxi) cout << mx << endl;
    else cout << smx << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline

k = int(input())
n = 50
k_m_50 = k % 50
k_q_50 = k // 50

ans = [50]*50
for i in range(k_m_50, 50):
    ans[i] = 49 - k_m_50
for i in range(n):
    ans[i] += k_q_50
print(n)
print(*ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,n,m,l,r,s=0;
    cin>>n>>t;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(i>0)
        {
            s+=min(t,(l-r));
        }
        r=l;
    }
    s+=t;
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll x=(ll)1e18;
    int n;
    cin>>n;
    ll  a[n];
    f(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    if(a[0]==0){
        cout<<0<<endl;
        return 0;
    }
    ll prev=1;
    ll b=a[0];
    bool flag=0;
    f1(i,n){
        b*=a[i];
        prev*=a[i-1];
        if(b<0 ||b<prev || b>x){
            flag=1;
            cout<<-1<<endl;
            break;
        }
    }
    if(flag==0)cout<<b<<endl;

    return 0;
}



Measured memory_bytes: 4440
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;

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

int f(int a){
    if (a == 1){
        return 1;
    }
    
    return f(a-1) * a;
}

int main(){
    int n;
    cin >> n;
    double x[n], y[n];
    for (int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    int perm[n];
    rep(i, n) perm[i] = i;
    double ans = 0;
    do{
        double dis = 0;
        for (int i = 0; i < n - 1; i++){
            dis += sqrt((x[perm[i]] - x[perm[i+1]]) * (x[perm[i]] - x[perm[i+1]]) + (y[perm[i]] - y[perm[i+1]]) * (y[perm[i]] - y[perm[i+1]]));
        }
        ans += dis;
    }while(next_permutation(perm, perm + n));
    ans /= (double)(f(n));
    printf("%.10lf\n", ans);
}

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

bool is_cyclic(const graph& G) {
	int n = G.size();
	vector<bool> used(n), on(n);
	function<bool(int)> dfs = [&](int v) {
		used[v] = on[v] = true;
		for (int w : G[v]) {
			if (on[w]) return true;
			if (!used[w] && dfs(w)) return true;
		}
		on[v] = false;
		return false;
	};
	for (int i = 0; i < n; i++) {
		if (!used[i] && dfs(i)) return true;
	}
	return false;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, m;
	cin >> n >> m;
	graph G(n);
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		G[s].push_back(t);
	}
	puts(is_cyclic(G) ? "1" : "0");
	return 0;
}



Measured memory_bytes: 3188
a, b = input().split()
ab = int(a + b)
ans = 0
if 11 <= ab:
    ans += 1
if 22 <= ab:
    ans += 1
if 33 <= ab:
    ans += 1
if 44 <= ab:
    ans += 1
if 55 <= ab:
    ans += 1
if 66 <= ab:
    ans += 1
if 77 <= ab:
    ans += 1
if 88 <= ab:
    ans += 1
if 99 <= ab:
    ans += 1
if 1010 <= ab:
    ans += 1
if 1111 <= ab:
    ans += 1
if 1212 <= ab:
    ans += 1
print(ans)


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

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

		int k = sc.nextInt();
		String s = sc.next();


		if(s.length() <= k)
		{
			System.out.println(s);
		}
		else
		{
			System.out.println(s.substring(0, k) + "...");
		}

	}
}



Measured memory_bytes: 38644
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut g: Vec<Vec<Edge>> = vec![vec![]; n];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        g[a - 1].push(Edge::new(b - 1, 1));
        g[b - 1].push(Edge::new(a - 1, 1));
    }
    let dist: Vec<i32> = distance_nonweight(&g, 0);
    let mut ans: Vec<usize> = vec![0; n];
    for i in 1..n {
        for e in g[i].iter() {
            if dist[e.to] + 1 == dist[i] {
                ans[i] = e.to;
                break;
            }
        }
    }
    println!("Yes");
    for i in 1..n {
        println!("{}", ans[i] + 1);
    }
}

#[derive(Debug, Copy, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}
impl Edge {
    pub fn new(to: usize, cost: i64) -> Edge {
        Edge { to: to, cost: cost }
    }
}

fn distance_nonweight(graph: &Vec<Vec<Edge>>, start: usize) -> Vec<i32> {
    let mut res: Vec<i32> = vec![std::i32::MAX; graph.len()];
    res[start] = 0;
    let mut bfs: std::collections::VecDeque<usize> = std::collections::VecDeque::new();
    bfs.push_back(start);
    while !bfs.is_empty() {
        let now = bfs.pop_front().unwrap();
        for e in graph[now].iter() {
            if res[now] + 1 < res[e.to] {
                res[e.to] = res[now] + 1;
                bfs.push_back(e.to);
            }
        }
    }
    res
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 15708
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
    vector<int> edge;
    int par = 0;
    ldb dp1 = 0, e = 0;
    bool vi1 = 0, vi2 = 0;
}node_t;
vector<node_t> node;

ldb dfs(int x) {
    ldb sum = 0.0;
    ldb n = node[x].edge.size();
    ldb cnt = 0;
    for (int i = 0; i < n; i++) {
        int to = node[x].edge[i];
        if (node[to].vi1) continue;
        node[to].par = x;
        node[to].vi1 = true;
        sum += dfs(to) + 1;
        cnt++;
    }
    if (cnt == 0) node[x].dp1 = 0;
    else  node[x].dp1 = (double)sum / cnt;
    return node[x].dp1;

}

void dfs2(int y) {
    int par = node[y].par;
    ldb sp = node[par].edge.size();
    ldb sn = node[y].edge.size();
    if (y == 1) node[y].e = node[y].dp1;
    else {
        ldb temp = node[par].e * sp - node[y].dp1 - 1.0;
        if (temp == 0) node[y].e = (1.0 + (sn - 1.0) * node[y].dp1) / sn;
        else node[y].e = (temp / (sp - 1.0) + 1.0 + (sn - 1.0) * node[y].dp1) / sn;
    }
    for (int i = 0; i < sn; i++) {
        int to = node[y].edge[i];
        if (node[to].vi2) continue;
        node[to].vi2 = true;
        dfs2(node[y].edge[i]);
    }
}

int main() {
    int N;
    cin >> N;

    node = vector<node_t>(N + 1);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        cin >> u >> v;
        node[u].edge.push_back(v);
        node[v].edge.push_back(u);
    }

    node[1].vi1 = true;
    dfs(1);
    if (N > 1000) {
        node[1].vi2 = true;
        dfs2(1);
        for (int i = 1; i <= N; i++) {
            printf("%.15Lf\n", node[i].e);
        }
    }
    else {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                node[j].vi1 = false;
            }
            node[i].vi1 = true;
            printf("%.15Lf\n", dfs(i));
            
        }
    }
}

Measured memory_bytes: 26368
S=input()

count1 = 0
for i in range(len(S)):
    if i%2==0:
        if S[i]!="0":
            count1+=1
    else:
        if S[i]!="1":
            count1+=1

count2 = 0
for i in range(len(S)):
    if i%2==0:
        if S[i]!="1":
            count2+=1
    else:
        if S[i]!="0":
            count2+=1

print(min(count1,count2))

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> xx(n);
    vector<int> yy(n);
    vector<int> pp(n);
    int mx = 1;
    vector<long long> ans(n+1, 1e18);

    for (int i = 0; i < n; i++) {
        cin >> xx[i] >> yy[i] >> pp[i];
        mx *= 3;
    }

    vector<vector<int>> dx(n, vector<int>((1<<n), 1e9));
    for (int msk = 0; msk < (1<<n); msk++) {
        for (int i = 0; i < n; i++) {
            int x = xx[i];
            int curr = abs(x);
            for (int j = 0; j < n; j++) {
                if ((msk >> j) & 1) {
                    curr = min(curr, abs(x - xx[j]));
                }
            }
            dx[i][msk] = curr;
        }
    }

    vector<vector<int>> dy(n, vector<int>((1<<n), 1e9));
    for (int msk = 0; msk < (1<<n); msk++) {
        for (int i = 0; i < n; i++) {
            int y = yy[i];
            int curr = abs(y);
            for (int j = 0; j < n; j++) {
                if ((msk >> j) & 1) {
                    curr = min(curr, abs(y - yy[j]));
                }
            }
            dy[i][msk] = curr;
        }
    }

    for (int msk = 0; msk < mx; msk++) {
        int z = msk;
        int mskx = 0;
        int msky = 0;
        int k = 0;
        for (int i = 0; i < n; i++) {
            mskx *= 2;
            msky *= 2;
            if (z % 3 == 0) {
            } else if (z % 3 == 1) {
                mskx++;
                k++;
            } else {
                k++;
                msky++;
            }
            z /= 3;
        }
        long long cand = 0;
        for (int i = 0; i < n; i++) {
            cand += 1LL * pp[i] * min(dx[i][mskx], dy[i][msky]);
        }
        ans[k] = min(ans[k], cand);
    }

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

    return 0;
}


Measured memory_bytes: 7136
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S, T; cin >> S >> T;
    int ans = 0;
    rep (i, 0, S.size()) {
        if (S[i] == T[i]) ++ans;
    }
    cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1e9  //
#define INFLL 4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define PB(a) push_back(a)
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

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

int main() {
    ll n, k;
    cin >> n >> k;

    map<ll, ll> mp;

    repll(i, n + 1) mp[i] = 0;

    repll(i, n) {
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    ll count = 0;

    repll2(i, 1e5) {
        count += mp[i];
        if (count >= k) {
            cout << i << endl;
            return 0;
        }
    }

}



Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pa pair<int,int>
#define pii pair<ll,ll>
#define st first
#define nd second
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
set<int>pom;
int main()
{
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)
  {
    int a;
    cin>>a;
    pom.insert(a);
  }

  if (pom.size()==n)cout<<"YES";
  else cout<<"NO";
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N, K;
    cin >> N >> K;

    if (K == 0){
        cout << (N * N) << endl;
        return 0;
    }
    ll ans = 0;

    rep(i, K + 1, N + 1){
        ll tmp = ((N - K + 1) / i) * (i - K);
        ll tmp1 = min(((N - K  + 1) % i), i - K);
        ans += tmp + tmp1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))

a = [0] * N

num = N
for _ in range(N):
    d = 0
    num -= 1
    for i, c in enumerate(b):
        if c == i + 1:
            d = c
    if d == 0:
        a = [-1]
        break
    a[num] = d
    del b[d - 1]

for c in a:
    print(c)

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

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

using namespace std;

int main() {
  while(1){
    int m,nmin,nmax;
    cin>>m>>nmin>>nmax;
    if(!m)break;
    int gap = 0;
    int n = 0;
    vector<int> p(m);
    REP(i,m) cin>>p[i];
    for (int i = nmin; i <= nmax; ++i) {
      if (p[i-1]-p[i] >= gap) {
        gap = p[i-1] - p[i];
        n = i;
      }
    }
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		int[] antenas = {a,b,c,d,e};

		boolean connect = true;

		check : for(int i = 0; i< antenas.length-1; i++) {
			for(int j = i+1; j< antenas.length; j++) {
				if(antenas[j] - antenas[i] > k) {
					connect = false;
					break check;
				}
			}
		}

		String output = connect ? "Yay!" : ":(";

		System.out.println(output);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std ;
int main()
{
    string s ;
    int n,temp=0;
    cin >> n ;
    cin >> s ;
    for(int i=0;i<n-2;i++)
    {
        string x ="";
        for(int j=i;j<i+3;j++)
        {
            x+=s[j];
        }
        if(x=="ABC"){temp++;}
    }
    cout << temp << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int maxN = 1e5 + 10; 
int a[maxN];
int n;
vector<pii> w;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int pos = 0;
	int right = n;
	int left = 2;
	w.push_back(pii(pos,a[1]));
	int r,l;
	r = l = a[1];
	int len = 1;
	while(left < right)
	{
		if(abs(a[right] - r) + abs(a[right-1] - l) < abs(a[right] - l) + abs(a[right-1] - r))
		{
			l = a[right];
			w.push_back(pii(pos-len,a[right]));
			r = a[right - 1];
			w.push_back(pii(pos+len,a[right-1]));
		}
		else
		{
			r = a[right];
			w.push_back(pii(pos+len,a[right]));
			l = a[right - 1];
			w.push_back(pii(pos-len,a[right-1]));
		}
		right -= 2;
		len += 1;
		if(left >= right) break;
		if(abs(a[left] - r) + abs(a[left+1] - l) < abs(a[left] - l) + abs(a[left+1] - r))
		{
			l = a[left];
			w.push_back(pii(pos-len,a[left]));
			r = a[left + 1];
			w.push_back(pii(pos+len,a[left+1]));
		}
		else
		{
			r = a[left];
			w.push_back(pii(pos+len,a[left]));
			l = a[left + 1];
			w.push_back(pii(pos-len,a[left+1]));
		}
		left += 2;
		len += 1;
	}
	if(left == right)
	{
		if(abs(a[left] - l) > abs(a[left] - r))
		{
			l = a[left];
			w.push_back(pii(pos-len,a[left]));
		}
		else
		{
			r = a[left];
			w.push_back(pii(pos+len,a[left]));
		}
	}
	sort(w.begin(),w.end());
	ll ans1 = 0;
	for(int i=1;i<w.size();i++)
	{
		ans1 += (ll)abs(w[i].second - w[i-1].second);
	}
	
	w.clear();
	reverse(a+1,a+1+n);
	
	pos = 0;
	right = n;
	left = 2;
	w.push_back(pii(pos,a[1]));
	r = l = a[1];
	len = 1;
	while(left < right)
	{
		if(abs(a[right] - r) + abs(a[right-1] - l) < abs(a[right] - l) + abs(a[right-1] - r))
		{
			l = a[right];
			w.push_back(pii(pos-len,a[right]));
			r = a[right - 1];
			w.push_back(pii(pos+len,a[right-1]));
		}
		else
		{
			r = a[right];
			w.push_back(pii(pos+len,a[right]));
			l = a[right - 1];
			w.push_back(pii(pos-len,a[right-1]));
		}
		right -= 2;
		len += 1;
		if(left >= right) break;
		if(abs(a[left] - r) + abs(a[left+1] - l) < abs(a[left] - l) + abs(a[left+1] - r))
		{
			l = a[left];
			w.push_back(pii(pos-len,a[left]));
			r = a[left + 1];
			w.push_back(pii(pos+len,a[left+1]));
		}
		else
		{
			r = a[left];
			w.push_back(pii(pos+len,a[left]));
			l = a[left + 1];
			w.push_back(pii(pos-len,a[left+1]));
		}
		left += 2;
		len += 1;
	}
	if(left == right)
	{
		if(abs(a[left] - l) > abs(a[left] - r))
		{
			l = a[left];
			w.push_back(pii(pos-len,a[left]));
		}
		else
		{
			r = a[left];
			w.push_back(pii(pos+len,a[left]));
		}
	}
	sort(w.begin(),w.end());
	ll ans2 = 0;
	for(int i=1;i<w.size();i++)
	{
		ans2 += (ll)abs(w[i].second - w[i-1].second);
	}
	ll ans = max(ans1,ans2);
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1784