akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
using namespace std;


const int N = 3e5 + 10;
ll k, ans;

int main(int argc, char** argv) {
    cin>>k;
    ans = pow(k / 2, 2);
    if (k & 1)ans += k / 2;
    cout << ans;
    return 0;
}

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

int main(void){
    int n;
    scanf("%d", &n);
    int list[5] = {3 * 5 * 7, 3 * 5 * 11, 3 * 5 * 13,
                (int)pow(3, 3) * 5, (int)pow(3, 3) * 7};
    int i, ans = 0;
    for(i = 0; i < 5; i++){
        if(n >= list[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	io := NewIo()
	defer io.Flush()

	for {
		N := io.NextInt()
		if N == 0 {
			break
		}
		set := make([]map[int]struct{}, N)
		for i := 0; i < N; i++ {
			set[i] = make(map[int]struct{})
			M := io.NextInt()
			for j := 0; j < M; j++ {
				p := io.NextInt()
				set[i][p] = struct{}{}
			}
		}
		K := io.NextInt()
		l := make([]int, K)
		for i := 0; i < K; i++ {
			l[i] = io.NextInt()
		}

		ans := 0
	FOR_OUTER:
		for i := 0; i < N; i++ {
			for j := 0; j < K; j++ {
				if _, f := set[i][l[j]]; f == false {
					continue FOR_OUTER
				}
			}
			switch ans {
			case 0:
				ans = i + 1
			default:
				ans = -1
			}
		}
		if ans > 0 {
			io.Println(ans)
		} else {
			io.Println(-1)
		}
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



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

int main() {
  int n,x,y;
  cin >> n >> x;
  vector<int> a(n);
  y = 0;
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    y += a.at(i);
  }
  x = x - y;
  sort(a.begin(), a.end());
  int count = 0;
  count = x/a.at(0);
  
  cout << count + n << endl;
}


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

const int N = 5005;
const int md = 1e9 + 7;
const int inv2 = 5e8 + 4;

int n, m;
string s;
int f[N][N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> s;
	m = s.size();

	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		f[i][0] = (f[i-1][0] + f[i-1][1]) % md; 
		for (int j = 1; j <= n; ++j) {
			f[i][j] = (f[i-1][j+1] + f[i-1][j-1] * 2LL % md) % md;
		}
	}

	int inv = 1;
	for (int i = 1; i <= m; ++i) inv = 1LL * inv * inv2 % md;
	cout << 1LL * f[n][m] * inv % md << endl;
}

Measured memory_bytes: 98048
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(s, l) substr(s, (s) + (l) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!((n) % 2))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define str string
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<str>

using namespace std;

// clang-format on

main {
  int N, T;
  cin >> N >> T;
  int t[N];
  rep(i, N) cin >> t[i];
  int c = T;
  loop(i, 1, N) c += min(T, t[i] - t[i - 1]);
  cout << c << endl;
  bye;
}


Measured memory_bytes: 1792
n = int(input())
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for _ in range(n):
    ch, rank = input().split()
    cards[pattern.index(ch)][int(rank)-1] = True

for i in range(4):
    for j in range(13):
        if not cards[i][j]:
            print(pattern[i], j+1)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
const int mod=1e9+7;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    ll ans=0;
    ll q=0;
    ll p=0;
    rep(i,n-1){
        sum-=a[i];
        if(sum<0)sum+=mod;
        ans+=(a[i]*sum)%mod;
    }
    cout<<ans%mod;
    }

Measured memory_bytes: 4800
N, M = map(int, input().split())
p, S = [0]*M, [0]*M
for i in range(0,M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if S[i] == "WA":
        res[p[i]-1][1] = res[p[i]-1][1]+1
    elif res[p[i]-1][0] != -1:
        s, t = s+1, t+res[p[i]-1][1]
        res[p[i]-1][0] = -1
print(s, t)

Measured memory_bytes: 26612
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
const uli mod=1e9+7;
uli f[mx][2];
int nxt[mx][2]; 
uli x[mx];
int main(){
  int n;
  uli step[2];
  scanf("%d %lld %lld",&n,step,step+1); 
  for(int i=1;i<=n;i++)scanf("%lld",x+i);
  sort(x,x+n+1);
  nxt[n][0]=nxt[n][1]=1;
  for(int i=n-1;i>=0;i--){
    for(int it=0;it<2;it++){
      nxt[i][it]=1;
      if(x[i+1]-x[i]>=step[it]){
        nxt[i][it]+=nxt[i+1][it];
      }
    }
  }
  x[0]=-2e18;
  sort(x,x+n+1);
  f[n+1][0]=f[n+1][1]=1;
  for(int i=n;i>=1;i--){
    for(int b=0;b<2;b++){
      int idx=lower_bound(x,x+n+1,x[i-1]+step[b])-x;
      if(idx==i){
        f[i][b]+=f[i+1][b];
        f[i][b]+=f[i+1][b^1];
      }
      else if(nxt[i][b^1]>=idx-i){
        f[i][b]+=f[idx][b^1];
      }
      f[i][b]%=mod;
    }
  }
  printf("%lld\n",f[1][0]);
  return 0;
}


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

int main() { 	
  int N,N_num,x;
  x=1;
  	cin >> N;
  int a=N;
  while(a!=0){
        a /= 10;
        N_num++;
    	x=x*10;
    }
	int b=N;
  int c;
  int d;
  int d_1;
if(N_num%2==1){  
  c=b*10/x;
   d=b-x*c/10;

}else{
    c=b*10/x;
   d=b-x*c/10;
   c=b*10/x;
   d=b-x*c/10;
} 
	int ans;
  int s=1;
	int ss=1;
  for(int i=1;i<=N_num;i+=2){
  	if(i==N_num){
      while(c>1){
      ans+=s;
        c--;
      }
    ans+=d+1;
    }else{
    ans+=9*s;
    }
    ss+=99*s;
    s=s*100;
    
  }
  
 
cout << ans <<endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1; i<n; i++)
	{
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

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

int LSearch(int nA[], int n, int nKey)
{
	int i = 0;
	nA[n] = nKey;
	while (nA[i] != nKey)
	{
		i++;
	}
	return i != n;
}

int main()
{
	int nA[10001] = { 0 };
	int n = 0, q = 0, nSum = 0, nKey = 0;
	cin >> n;
	int ni = 0;
	while (cin >> nA[ni], ni != (n - 1))
	{
		ni++;
	}

	cin >> q;
	for (ni = 0; ni < q; ni++)
	{
		cin >> nKey;
		if (LSearch(nA, n, nKey))
		{
			nSum++;
		}
	}
	cout << nSum << endl;
	return 0;
}


Measured memory_bytes: 3128
M = 1000000
s = int(input())

memo = [False]*(M+1)
ans = -1
cnt = 1
while True:
    if memo[s]:
        ans = cnt
        break
    else:
        memo[s] = True
        cnt += 1
        if s % 2 == 0:
            s //= 2
        else:
            s = s * 3 + 1
print(ans)


Measured memory_bytes: 10868
# input
n, k, q = map(int, input().split())
a = []
for i in range(q):
  a.append(int(input()))
cnts = [0 for i in range(n)]
  
# main
for i in range(q):
  cnts[a[i]-1] += 1

# output
for d in cnts:
  if k > q - d:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 8640
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------
// べき乗を計算　指数を計算
ll llpow(ll a, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// main -----------------------------------------------

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

    string ans = "";
    while(true){
        n --;
        ans += char(n % 26 + 'a');
        n /= 26;
        if(n == 0){
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
def resolve():
    import sys
    input = sys.stdin.readline

    s = input().rstrip()
    t = input().rstrip()

    ans = len(t)
    for i in range(len(s)-len(t)+1):
        count = len(t)
        for j in range(len(t)):
            if s[i+j] == t[j]:
                count -= 1
        if count < ans:
            ans = count


    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 67580
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool a=false,b=false;
  if(s.size()%2==0){
    a=true;
  }
  if(s[0]==s[s.size()-1]){
    b=true;
  }
  if(a^b){
    cout << "Second" << endl;
  }
  else{
    cout << "First" << endl;
  }
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')



A, B, N = MI()

x = min(N, B - 1)
ans = A * x // B - A * (x // B)
print(ans)

Measured memory_bytes: 61796
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  string result;
  for (const char c : s) {
    if (c == 'B') {
      if (!result.empty()) {
        result.pop_back();
      }
    } else {
      result.push_back(c);
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define en end()
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+7;
int t,j,cs=0,n,a,b,i,dxx[]={1,0,0,-1},dyy[]={0,-1,1,0},k,m,cnt[N],prime[N];
bool mark[N];

void seive(){
    prime[k++]=2;
    for(i=3;i<N;i+=2){
        if(!mark[i]){
            prime[k++]=i;
            for(j=3*i;j<N;j+=2*i){
                mark[j]=1;
            }
        }
    }
}
int main()
{
    cin>>n;
    int ar[n];
    rep(i,n-1) cin>>ar[i];

    seive();
    //for(i=0;i<100;i++) cout<<prime[i]<<endl;
    for(i=0;i<n;i++){
        int a=ar[i];
        if(a==1) cnt[1]=1;
        for(j=0;prime[j]*prime[j]<=a && j<k;j++){
            if(a%prime[j]==0){
                while(a%prime[j]==0)
                    a/=prime[j];
                cnt[prime[j]]++;
               // cout<<prime[j]<<endl;
            }
        }
        if(a>1) cnt[a]++;
    }
   // for(i=0;i<N;i++) if(cnt[i]) cout<<i<<" "<<cnt[i]<<endl;
    int mx=*max_element(cnt,cnt+N);
    if(mx==1) cout<<"pairwise coprime"<<endl;
    else if(mx<n) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;

}



Measured memory_bytes: 12596
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, 100001)
	sum := 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		a[tmp] += 1
		sum += tmp
	}
	var q int
	fmt.Scan(&q)
	var ans []int
	for i := 0; i < q; i++ {
		var b, c int
		fmt.Scan(&b, &c)
		cnt := a[b]
		a[b] = 0
		a[c] += cnt
		sum += cnt * (c - b)
		ans = append(ans, sum)
	}
	len := len(ans)
	for i := 0; i < len; i++ {
		fmt.Print(ans[i])
		fmt.Print("\n")
	}
}


Measured memory_bytes: 8820
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;
vector<int> to[100050];
vector<int> cost[100050];
vector<int> ans(100050,-1);

void dfs(int start){
 for(int i=0; i<to[start].size();i++){
  if(ans[to[start][i]]==-1){
   ans[to[start][i]]=(ans[start]+cost[start][i])%2;
   dfs(to[start][i]);
  }
 }
}

int main(void){
 int N;
 int u,v,w;
 
 cin>>N;
 for(int i=0; i<N-1;i++){
  cin>>u>>v>>w;
  to[u].push_back(v);
  to[v].push_back(u);
  cost[u].push_back(w);
  cost[v].push_back(w);
 }
 ans[1]=0;
 dfs(1);

 for(int i=1;i<=N;i++)cout<<ans[i]<<endl; 
 return 0;
}

Measured memory_bytes: 13696
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

ve = Counter(V[0::2]).most_common(2)
vo = Counter(V[1::2]).most_common(2)

# 最頻出が偶奇のリストでそれぞれ異なるときは、それぞれを最頻出で置き換える
if ve[0][0] != vo[0][0]:
    print(n - ve[0][1] - vo[0][1])
else:
    # 最頻出の数が1種類のみのとき
    if len(ve) == 1 or len(vo) == 1:
        print(n // 2)
    else:
        # 偶奇の最頻出が同じ時、偶奇の最頻出ともう片方の二番目の最頻出の合計が大きい方を
        # 書き換え回数として使用する
        print(n - max(ve[0][1] + vo[1][1], ve[1][1] + vo[0][1]))


Measured memory_bytes: 15588
#include <stdio.h>

int main(){

	int A,B;

	scanf("%d %d",&A,&B);

	if(A==1){A=14;}
	if(B==1){B=14;}

	if(A>B){printf("Alice\n");}
	else if(A<B){printf("Bob\n");}
	else{printf("Draw\n");}

	return 0;
}

Measured memory_bytes: 128
a=list(map(int,input().split()))
if all([x in a for x in [4,6,9,11]]):
  s='Yes'
  print(s)
  exit()
if 2 in a:
  s='No'
elif sum([x in a for x in [4,6,9,11]])==1:
  s='No'
else:
  s='Yes'
print(s)


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

using namespace std;

const int N=1e5+10;

int n,a[2][N];
int main(){
        cin>>n;
        for(int j=0;j<=1;j++)
                for(int i=1;i<=n;i++) cin>>a[j][i];
        long long sum=0;
        for(int i=1;i<=n;i++){
                int val=-(a[0][i]-a[1][i]);
                if (val>0) val>>=1;
                sum+=val;
        }
        //cout<<sum<<'\n';
        cout<<((sum>=0)?"Yes":"No");
}


Measured memory_bytes: 384
#include <iostream>
 
using namespace std;
 
struct Vector {
        double x;
        double y;
};
 
bool is_c_inner(double xa, double ya, double xb, double yb, double xc, double yc, double xd, double yd) {
    Vector ab = Vector{xb - xa, yb - ya};
    Vector bc = Vector{xc - xb, yc - yb};
 
    Vector bd = Vector{xd - xb, yd - yb};
    Vector dc = Vector{xc - xd, yc - yd};
 
    Vector da = Vector{xa - xd, ya - yd};
    Vector ac = Vector{xc - xa, yc - ya};
 
    double cross_product_1 = ab.x * bc.y - ab.y * bc.x;
    double cross_product_2 = bd.x * dc.y - bd.y * dc.x;
    double cross_product_3 = da.x * ac.y - da.y * ac.x;
 
    return (cross_product_1 >=  0 && cross_product_2 >=  0 && cross_product_3 >=  0) ||
            (cross_product_1 <=  0 && cross_product_2 <=  0 && cross_product_3 <=  0);
}
 
int main() {
    double xa, ya, xb, yb, xc, yc, xd, yd;
    string result;
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd) == 8) {
        if(is_c_inner( xa, ya, xb, yb, xc, yc, xd, yd)
                || is_c_inner(xb, yb, xc, yc, xd, yd, xa, ya)
                || is_c_inner(xc, yc, xd, yd, xa, ya, xb, yb)
                || is_c_inner(xd, yd, xa, ya, xb, yb, xc, yc)
                ) {
            result = "NO"; // no convex
        } else {
            result = "YES"; //convex
        }
        cout << result << endl;
    }
    return 0;
}

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

#define pb push_back
#define S second
#define F first
#define sz size()
#define eps 0.000001
#define oo 2000000007
#define endl '\n'
#define bg begin()
#define nd end()
#define up upper_bound
#define lw lower_bound
#define debug(x) #x << " = " << x << "; "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
string abc = "abcdefghijklmnopqrstuvwxyz";


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int mat[n][3];
	int dp[n+1][3];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin >> mat[i][j];
			dp[n][j] = 0;
		}
	}
	for(int i = n - 1; i >= 0; i--){
		for(int j = 0; j < 3; j++){
			dp[i][j] = 0;
			for(int k = 0; k < 3; k++){
				if(j != k) dp[i][j] = max(dp[i][j], mat[i][j] + dp[i + 1][k]);
			}
		}
	}
	int best = 0;
	for(int i = 0; i< 3; i++) best = max(best, dp[0][i]);
	cout << best << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int x, ans;
	cin >> x;
	cout << krag(sqrt(2 * x + 0.25) - 0.5) << endl;
}



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

signed main(){
	int n,m;
	cin>>n;
	vector<int>a(n);
	r(i,n)cin>>a[i];
	cin>>m;
	vector<int>b(m);
	r(i,m)cin>>b[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	cout<<includes(a.begin(),a.end(),b.begin(),b.end())<<endl;
}


Measured memory_bytes: 5936
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;
 
#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair
 
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
 
#define left(x) x * 2
#define right(x) x * 2 + 1
 
#define meme(a, b, c) fill(a + 1, a + 1 + b, c)
 
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))
 
#define move(s) s = "#" + s
 
#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)
 
#define eprintf(...) fprintf(stderr, __VA_ARGS__);
 
void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}
 
const int N = 4e7 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);
 
#define ll long long

#define int ll

main () {
    to_pray();
 
    int n;
    cin >> n;
    
    int ans = 0;
    
    if (n & 1)
    	return cout << 0, 0;
    
    while(n > 0) {
    	n /= 5;
    	ans += n / 2;
    }
    
    cout << ans;
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl
const int mod=1e9+7;
const int nf=1e9+7;

//const int maxn=



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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

	int size,k;cin>>size;string s;
	cin>>s>>k;
	for(int i=0;i<size;i++)
	{
		if(!(s[i]==s[k-1]))
			s[i]='*';
	}cout<<s<<endl;


    return 0;
}


Measured memory_bytes: 256
io = STDIN
n,$ww=io.gets.chomp.split.map(&:to_i)
$hash=Hash.new{|h,k|h[k]=[]}
n.times do
  w,v=io.gets.chomp.split.map(&:to_i)
  $hash[w]<<v
end
$hash.keys.each do |k|
  $hash[k].sort!.reverse!
end
$hh={}  #count per weight
$hash.each do |k,v|
  $hh[k]=v.size
end
def value(counts)
  $hash.keys.zip(counts).inject(0) do |s,x|
    weight,cnt=x
    s +=$hash[weight][0,cnt].inject(:+) unless cnt==0
    s
  end
end
$ans=0
weights=$hh.keys
def calc(weights,counts,wsum)
  return  if wsum>$ww
  www=weights.clone
  weight = www.shift
  if weight
    if $hh[weight]==0
      calc(www,counts+[0],wsum)
    else
      (0..$hh[weight]).each do |i|
        calc(www,counts+[i],wsum+weight*i)
      end
    end
  else
    $ans=[value(counts),$ans].max
  end
end
calc(weights,[],0)
p $ans

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j=0,k=0;
    for(i=0;i<3;i++){
    scanf("%d",&a);
    if(a==5) j++;
    else if(a==7) k++;
    }
    if(j==2 & k==1) printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define mod 1000000007
#define PI acos(-1)
int main()
{
	IOS
	int a[5],i;
	int ans;
	for(i=0;i<5;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		ans=i+1;
	}
	cout<<ans;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int n,m,a,b,x[1000],k=0,c=0,t,i,j;
	scanf("%d %d", &n, &m);
	for(i=0; i<m; i++)
	{
		scanf("%d %d", &a, &b);
		if(n>a)
		x[i]=n-a;
		else
		{
			x[i]=1000;
			k++;
		}
	}
	if(k<m-1)
	{
		for(i=0; i<m-1; i++)
		{
			for(j=m-1; j>=i+1; j--)
			{
				if(x[j]<x[j-1])
				{
					t=x[j];
					x[j]=x[j-1];
					x[j-1]=t;
				}
			}
		}
		i=0;
		while(k<m-1)
		{
			k++;
			c+=x[i];
			i++;
		}
	}
	printf("%d\n", c);
	
	return 0;
}


Measured memory_bytes: 2052
/*
https://drken1215.hatenablog.com/entry/2020/03/23/002300
https://www.hamayanhamayan.com/entry/2020/03/22/231629
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int H,W,K,res=1<<29;
    cin>>H>>W>>K;
    vector<string> S(H);
    rep(i,H)cin>>S[i];
    for(int bit=0;bit<(1<<(H-1));bit++){
        bool gok=true;
        int N=0;
        vi ord(H,0);//横線において、区切る物をcoする累積和を行うことで、面積分けをしている。
        rep(i,H-1){
            if(!(bit&(1<<i)))ord[i+1]=ord[i];
            else ord[i+1]=ord[i]+1,++N;
            //cout<<"ord:"<<ord[i+1]<<" N:"<<N<<" ";
        }
        //cout<<endl;
        int add=0;
        vi nums(N+1,0);
        rep(i,W){//縦ごとのカウント
            vi one(N+1,0);
            bool ok=true;
            rep(j,H){
                //ord[j]とすることで、横線の単位では異なっていても、同じエリアということでカウントできる。
                one[ord[j]]+=S[j][i]-'0';
                nums[ord[j]]+=S[j][i]-'0';
                if(one[ord[j]]>K)gok=false;
                if(nums[ord[j]]>K)ok=false;
                //cout<<"j:"<<j<<" one:"<<one[ord[j]]<<" nums:"<<nums[ord[j]]<<" ";
            }/*
            cout<<i<<endl;
            cout<<"one :";
            for(auto x:one)cout<<x<<" ";
            cout<<endl<<"nums:";
            for(auto x:nums)cout<<x<<" ";
            cout<<endl;
            */
            //oneでは縦列のみのカウントだが、numsでは、Kを超えるまでのカウントを保持している。
            //そのため、K>one[ord[j]] の時nums=oneでリセットしている。
            if(!ok)++add,nums=one;
        }
        if(gok)chmin(res,N+add);
    }

    cout<<res<<endl;

    return 0;
}

//a=97,z=122

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

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll> cnt(100001,0);
    rep(i,n) {
        ll a; 
        cin >> a;
        ans += a;
        cnt.at(a)++;
    }
    
    int q; 
    cin >> q;
    rep(i,q) {
        ll b, c;
        cin >> b >> c;
        if(cnt.at(b) != 0) {
            ans += (c-b)*cnt.at(b);
            cnt.at(c) += cnt.at(b);
            cnt.at(b) = 0;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
typedef vector <int> v;
v x[2],y[2];
int mp[1000][1000],w,h;

void saiki(int x,int y){
  int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
  mp[y][x]=1;
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(nx>=0&&ny>=0&&nx<=w&&ny<=h&&!mp[ny][nx])saiki(nx,ny); 
  }
}

int compress(v &x1,v &x2){
  vector <int> xs;

  for(int i=0;i<x1.size();i++)
    for(int j=-1;j<=1;j++){
      int tx1=x1[i]+j,tx2=x2[i]+j;
      xs.push_back(tx1);
      xs.push_back(tx2);
    }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  
  for(int i=0;i<x1.size();i++){
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
    x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
  }
  return xs.size()+1;
}

int main(){
  int n;
  while(cin>>n,n){;
    x[0].clear(),x[1].clear(),y[0].clear(),y[1].clear();
    for(int i=0,x1,x2,y1,y2;i<n;i++){
      cin>>x1>>y1>>x2>>y2;
      x1*=2,y1*=2,x2*=2,y2*=2;
      x[0].push_back(x1),x[1].push_back(x2);
      y[0].push_back(y1),y[1].push_back(y1);
      //
      x[0].push_back(x1),x[1].push_back(x2);
      y[0].push_back(y2),y[1].push_back(y2);
      //
      x[0].push_back(x1),x[1].push_back(x1);
      y[0].push_back(y2),y[1].push_back(y1);
      //
      x[0].push_back(x2),x[1].push_back(x2);
      y[0].push_back(y2),y[1].push_back(y1);
    }

    w=compress(x[0],x[1]),h=compress(y[0],y[1]);
    
    memset(mp,0,sizeof(mp));
    for(int i=0;i<x[0].size();i++)
      for(int j=y[0][i];j<y[1][i]+1;j++)
	for(int k=x[0][i];k<x[1][i]+1;k++)mp[j][k]=1;

    int ans=0;
    for(int i=0;i<=h;i++)
      for(int j=0;j<=w;j++)
	if(!mp[i][j]) ans++,saiki(j,i);

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

Measured memory_bytes: 7676
#include<stdio.h>

int main(){
    char s[100001];
    int rst[2] = {-1,-1};
    long a = 0;
    s[2] = '\0';
    scanf("%s", s);
    do{
        if(s[a] == s[a+1]){
            rst[0] = a+1;
            rst[1] = a+2;
        }
        else if(s[a] == s[a+2]){
            rst[0] = a+1;
            rst[1] = a+3;
        }
        a++;
    }while((rst[0] == -1) && s[a+2] != '\0');
    printf("%d %d", rst[0], rst[1]);
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -Wno-tabs #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	n <- readLn
	putStrLn $ if n == 1
		then "0"
		else "1"



Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N, L;
int main(void){
    cin >> N >> L;
    int total = 0;
    REP(i,N) total += L + i;
    int m = INF;
    int res = 0;
    REP(i,N){
        if(abs(L+i) < m){
            m = abs(L+i);
            res = total - (L+i);
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
int main(void) {
  
  int N,B[100];
  
  scanf("%d", &N);
  for(int i = 0; i < N - 1; i++)  {
    scanf("%d", &B[i]);
  }
  
  int sum = 0;
  sum += B[0];
  for(int i = 0; i < N - 2; i++) {
    if (B[i] <= B[i+1]) {
      sum += B[i];
    } else if (B[i] > B[i+1]) {
      sum += B[i+1];
    }
  }
  sum += B[N-2];
  
  printf("%d\n", sum);
  
  return 0;
  
}


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

using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long> v(5);
	for (int i = 0; i < 5; i++) {
		cin >> v[i];
	}

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

	cout << 4+(n+v[0]-1)/v[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 1005
const ll MOD=1e9+7;
using namespace std;

int main() {
  int N;
  string s;
  cin >> s;
  int zero=0,one=0;
  rep(i,s.size()){
    if(s[i]=='0') zero++;
    else one++;
  }
  if(one>=zero) cout << 2*zero << endl;
  else cout << 2*one << endl; 
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
int main(void){
    int n;
    scanf("%d",&n);
    int x[n],y[n];
    int i;
    for(i=0;i<=n-1;i++){
        scanf("%d",&x[i]);
        //printf("%d ",x[i]);
    }
    //printf("\n");
    for(i=0;i<=n-1;i++){
        scanf("%d",&y[i]);
        //printf("%d ",y[i]);
    }
    //printf("\n");
    
    double sum,ans,p;
    sum=0.0;
    for(i=0;i<=n-1;i++){
        sum=sum+fabs((double)x[i]-(double)y[i]);
    }
    ans=sum;
    printf("%f\n",ans);
    
    p=1.0/2.0;
    sum=0.0;
    for(i=0;i<=n-1;i++){
        sum=sum+pow(fabs((double)x[i]-(double)y[i]),2.0);
    }
    ans=pow(sum,p);
    printf("%lf\n",ans);
    
    p=1.0/3.0;
    sum=0.0;
    for(i=0;i<=n-1;i++){
        sum=sum+pow(fabs((double)x[i]-(double)y[i]),3.0);
    }
    ans=pow(sum,p);
    printf("%lf\n",ans);
    
    double max=fabs((double)x[0]-(double)y[0]);
    for(i=0;i<=n-1;i++){
        if(max<=fabs((double)x[i]-(double)y[i])){
            max=fabs((double)x[i]-(double)y[i]);
        }
    }
    ans=max;
    printf("%lf\n",ans);
    
    return 0;
}

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

vector<vector<int> > tree;
vector<int> path, tin, tout, sz;
int timer = 0, N;

void dfs(int u, int par) {
    tin[u] = ++timer;
    sz[u] = 1;
    for(auto&v:tree[u]) {
        if(par == v) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
    tout[u] = timer;
}

void find(int u, int par) {
    path.push_back(u);
    for(auto&v:tree[u]) {
        if(v==par) continue;
        if(tin[v] <= tin[N] && tout[N] <= tout[v]) {
            find(v, u);
        }
    }
}


int main () {
    scanf("%d", &N);
    tree.resize(N+1);
    for(int i=1;i<=N-1;i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    tin = tout = sz = vector<int> (N+1, 0);
    
    dfs(1, 0);
    find(1, 0);
    
    int len = (int)path.size();
    int s = path[len/2+len%2];
    
    
    if(sz[s] < sz[1] - sz[s]) {
        cout << "Fennec";
    } else {
        cout << "Snuke";
    }
    
    return 0;
}


Measured memory_bytes: 13820
N = int(input())
A = [int(i) for i in input().split()]
en = 0
con = True
while con :
	en += 1
	for i in range(N) :
		if A[i] % 2 == 0 :
			A[i] = int( A[i] / 2 ) 
		else :
			en -= 1
			con = False
			break
print(en)

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

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        bool flag = true;
        for (int j = 0; j < i; j++) {
            if (H[j] > H[i]) {
                flag = false;
            }
        }
        if (flag) {
            ans++;
        }
    }
    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;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> ls(n), rs(n);
    rep(i,n) cin >> ls[i] >> rs[i];
    sort(ls.begin(), ls.end());
    sort(rs.begin(), rs.end());
    int ans = 0;
    if (n%2 == 1) {
      int l = ls[n/2];
      int r = rs[n/2];
      ans = r-l+1;
    }
    else {
      int l = ls[n/2-1] + ls[n/2];
      int r = rs[n/2-1] + rs[n/2];
      ans = r-l+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, P> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-11;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int gcd(int p, int q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

int main() {
    int n ,ans = 0;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        ans = gcd(a, ans);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int INF = 1e9 + 5;

int cost[20], n, m, x;
int skill[20][20];

int minCost(vector<int> curr, int curr_cost, int index, bool ok) {
    if (ok) {
        return curr_cost;
    }
    if (index > n) {
        return INF;
    }
    
    int cost1 = 0, cost2 = 0;
    cost1 = minCost(curr, curr_cost, index + 1, ok);
    
    ok = 1;
    for (int i = 0; i < m; i++) {
        curr[i] += skill[index][i];
        if (curr[i] < x)
            ok = 0;
    }
    if (ok) {
        cost2 = curr_cost + cost[index];
    }
    else {
        cost2 = minCost(curr, curr_cost + cost[index], index + 1, ok);
    }
    return min(cost1, cost2);
    
}

int main() {
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++) {
        cin >> cost[i];
        for (int j = 0; j < m; j++) {
            cin >> skill[i][j];
        }
    }
    vector<int> curr(m, 0);
    int ans = minCost(curr, 0, 0, 0);
    if (ans == INF) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, 0, R)
    {
        cin >> r[i];
        --r[i];
    }
    sort(r.begin(), r.end());
    vector<vector<ll>> dist(N);
    rep(i, 0, N) dist[i].assign(N, INT_MAX);
    int A, B, C;
    rep(i, 0, M)
    {
        cin >> A >> B >> C;
        --A; --B;
        dist[A][B] = dist[B][A] = C;
    }

    rep(k, 0, N) rep(i, 0, N) rep(j, 0, N)
    {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
    }

    ll ans = INT_MAX;
    do
    {
        ll tmp = 0;
        rep(i, 0, R - 1)
        {
            tmp += dist[r[i]][r[i + 1]];
        }
        chmin(ans, tmp);
    }
    while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}


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

int main()
{
    int X, Y;
    cin >> X >> Y;
    bool flag = 0;
    int a = 0;
    for (int i = X; i >= 0; i--)
    {
        if (2 * i + 4 * a == Y)
        {
            flag = 1;
            break;
        }
        a++;
    }
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3596
N = int(input())
Ai = list(map(int,input().rstrip().split(" ")))
Bi = list(map(int,input().rstrip().split(" ")))
Ci = list(map(int,input().rstrip().split(" ")))
previous = -100
satisfied = 0
for current in Ai:
  satisfied += Bi[current - 1]
  if current == previous + 1:
    satisfied += Ci[previous - 1]
  previous = current
print(satisfied)

Measured memory_bytes: 3064
n = int(input())
v = list(map(int,input().split()))

v = sorted(v)
# print(v)
def dfs (l):
    if len(l)==1:
         return l[0]
    num = (l[0]+l[1])/2.0
    l = l[2:]
    # print(l)
    l.append(num)
    # print(l)
    l = sorted(l)
    return dfs(l)



print(dfs(v))

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int A, B;
    cin >> A >> B;
    
    int n = 0;
    while (n*A-(n-1) < B) {
        n++;
    }
    print(n);
}

signed main() {
    solve();
}


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

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define int ll
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).last()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

vll adj[MAXN];
ll vis[MAXN], in[MAXN];
vll top;
ll idx, last, timer;

void dfs(ll i) {
	vis[i] = 1;
	in[i] = timer++;
	top.pb(i);

	for(auto x: adj[i]) {
		if(vis[x]) {
			last = in[i];
			idx = in[x];
			return;
		}
		else {
			dfs(x);
		}
	}
}

void solve() {
	ll n,m;
	cin >> n >> m;

	FOR(i, 1, n + 1) {
		ll x; cin >> x;
		adj[i].pb(x);
	}
	
	dfs(1);

	ll done = idx;
	ll rem = m - done;

	rem %= (last - idx + 1);
	if(m <= done) cout << top[m] << "\n";
	else cout << top[done + rem] << "\n";
	
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 49920
using System;
class pro
{
  static void Main()
  {
    int n=int.Parse(Console.ReadLine());
    Console.WriteLine(Luca(n));
  }
  static long Luca(int n)
  {
    long prev1=2;
    long prev0=1;
    long now=0;
    if(n==0)
      return 2;
    else if(n==1)
      return 1;
    else
    {
      for(int i=2;i<=n;i++)
      {
        var result=prev0+prev1;
        prev1=prev0;
        prev0=result;
        now=result;
      }
      return now;
    }
  }
}

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

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

    int N, L, sum_L = 0;
    cin >> N >> L;
    rep(i, N) sum_L += L+i;
    if (L>0) {
        sum_L -= L;
    }
    else if (L+N-1 < 0) {
        sum_L -= L+N-1;
    }
    cout << sum_L << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int n;
	cin >> n;
	n %= 10;
	
	if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else if (n == 3) cout << "bon" << endl;
	else cout << "hon" << endl;
	return 0;
}

Measured memory_bytes: 3620