akhauriyash/Code-Regression huggingface dataset:
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}

typedef long long int ll;
#define int ll
#define endl '\n'
const ll mod =1e9+7;
const ll MAX_NODES =200001;
const ll MAX_LOG =50;
const ll inf = 1e18+123;
const int maxn = 200001;
int vis[101];
int32_t main()
{

   IOS
    int n,m;
    cin>>n>>m;
    int h[n+1];
    int g[n+1];
    memset(g,-1,sizeof(g));
    for(int i =1;i<=n;i++){
      cin>>h[i];
    }
    for(int i = 1;i<=m;i++){
      int u,v;
      cin>>u>>v;
      g[u] = max(g[u],h[v]);
      g[v] = max(g[v],h[u]);
    }
    int ans = 0;
    for(int i = 1;i<=n;i++){
      if(h[i]>g[i])
        ans++;
    }
    cout<<ans<<endl;
} 


Measured memory_bytes: 5212
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect

Mod=998244353

n=int(input())
d=list(map(int,input().split()))
c=Counter(d)
ans=1
if d[0]!=0:
  print(0)
  exit()
for i in c:
  if i==0:
    if c[i]!=1:
      print(0)
      exit()
  else:
    if i-1 not in c:
      print(0)
      exit()
    else:
      ans*=pow(c[i-1],c[i],Mod)
      ans%=Mod
print(ans)

Measured memory_bytes: 90748
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    stdin.byLine().map!(s=>s.array().split(",")).array().filter!(a=>a[1].to!real()/a[2].to!real()^^2>=25)().map!(a=>a[0]).join("\n").writeln();
}

Measured memory_bytes: 1128
import java.util.*;

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

        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=0;
        if(a+b==3)c=3;
        if(a+b==4)c=2;
        if(a+b==5)c=1;
        System.out.println(c);
    }
}


Measured memory_bytes: 21204
//https://atcoder.jp/contests/abc156/tasks/abc156_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}

constexpr ll MOD=1e9+7;

//https://firiexp.github.io/library/library/modint.html
template<uint32_t M = 1000000007>
struct modint{
    using u64 = std::uint_fast64_t;
    u64 val;
    modint(): val(0){}
    template<typename T>
    modint(T t){t %= (T)M; if(t < 0) t += (T)M; val = t;}

    modint pow(ll k) const {
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T t){t %= (T)M; if(t < 0) t += (T)M; val = t; return *this;}
    modint inv() const {return pow(M-2);}
    modint& operator+=(modint a){val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){if(val < a.val) val += M-a.val; else val -= a.val; return *this;}
    modint& operator*=(modint a){val = (u64)val*a.val%M; return *this;}
    modint& operator/=(modint a){return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){return modint(M-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
    constexpr u64 &value() noexcept { return val; }
    constexpr const u64 &value() const noexcept { return val; }
    friend ostream& operator<<(ostream& os, const modint& dt){
        os<<dt.val;
        return os;
    }
};
using mint = modint<MOD>;

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll n; cin>>n;
    ll a,b; cin>>a>>b;

    auto COM = [](ll nn, ll aa)->ll{
        mint u(1),s(1);
        FOR(i,0,aa){
            u *= (nn-i);
            s *= (i+1);
        }
        mint r =  u / s;
        return r.val; 
    };


    mint v(2);
    v = v.pow(n);
    v -= 1;

    mint aa = COM(n,a);
    mint bb = COM(n,b);

    v -= aa;
    v -= bb;

    cout<<v<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#define Find order_of_key
#define at find_by_order
#define x first
#define y second
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)cout<<k<<endl;
	else if(k<=a+b)cout<<a<<endl;
	else cout<<a-(k-a-b)<<endl;
	return 0;
}

Measured memory_bytes: 3652
import math
from fractions import Fraction
N = int(input())

pt = [0] * N
pa = [0] * N

for i in range(N):
    t, a = map(int, input().split())
    if i == 0:
        pt[i] = t
        pa[i] = a
    else:
        #最小単位というかなんというか
        n = max(math.ceil(Fraction(pt[i-1],t)), math.ceil(Fraction(pa[i-1],a)))
        pt[i] = n*t
        pa[i] = n*a

print(pt[-1]+pa[-1])

Measured memory_bytes: 5044
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
	int x,a,b;cin>>x>>a>>b;
	int A=x-a,B=x-b;
	if(A<0) A=0-A;
	if(B<0) B=0-B;
	cout<<(A<=B ? "A":"B")<<endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
def inpl(): return [int(i) for i in input().split()]

X = int(input())
K = int(input())
r = [0] + inpl()
stu = [()]*(K+1)
stu[0] = (X, 0, 0)
for i, v in enumerate(r[1:], 1):
    s, t, u = stu[i-1]
    if i%2:
        rs = r[i-1] - r[i]
        ap = - rs - t
        if ap >= s:
            stu[i] = 0, 0, 0
        elif ap >= u:
            stu[i] = s, t+rs, ap
        else:
            stu[i] = s, t+rs, u
    else:
        rs = r[i] - r[i-1]
        ap = X - rs - t
        if ap >= s:
            stu[i] = s, t+rs, u
        elif ap >= u:
            stu[i] = ap, t+rs, u
        else:
            stu[i] = X, 0, X
Q = int(input())
for _ in range(Q):
    ti, a = inpl()
    x = bisect.bisect_right(r, ti)
    ti -= r[x-1]
    s, t, u = stu[x-1]
    if a >= s:
        R = s + t
    elif a >= u:
        R = a + t
    else:
        R = u + t
    if x % 2:
        print(max(0, R - ti))
    else:
        print(min(X, R + ti))

Measured memory_bytes: 21972
package main

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

var sc = bufio.NewScanner(os.Stdin)

// H =height/witdh
var H int

// W =height/witdh
var W int

func main() {
	scanInit()

	H = nextInt()
	W = nextInt()
	s := nextGrid(H, W)

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == "." {
				s[i][j] = getBombnum(i, j, s)
			}
		}
	}

	DBGprintGrid(s)

}

// DBGprintGrid print the grid
//! DBG
func DBGprintGrid(g [][]string) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Printf("\n")
	}
}
func getBombnum(i, j int, s [][]string) string {
	cnt := 0

	// 上段
	if i > 0 && j > 0 {
		if s[i-1][j-1] == "#" {
			cnt++
		}
	}
	if i > 0 {
		if s[i-1][j] == "#" {
			cnt++
		}
	}
	if i > 0 && j < W-1 {
		if s[i-1][j+1] == "#" {
			cnt++
		}
	}
	// 中段
	if j > 0 {
		if s[i][j-1] == "#" {
			cnt++
		}
	}
	if j < W-1 {
		if s[i][j+1] == "#" {
			cnt++
		}
	}
	// 下段
	if i < H-1 && j > 0 {
		if s[i+1][j-1] == "#" {
			cnt++
		}
	}
	if i < H-1 {
		if s[i+1][j] == "#" {
			cnt++
		}
	}
	if i < H-1 && j < W-1 {
		if s[i+1][j+1] == "#" {
			cnt++
		}
	}

	return fmt.Sprintf("%d", cnt)
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextGrid(a int, b int) [][]string {
	mat := make([][]string, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]string, b)
		tmp := nextStr()
		mat[i] = strings.Split(tmp, "")
	}
	return mat
}


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

int main(){
long long N,K;
cin>>N>>K;    
vector<int>test(N);
 for(int i=0;i<N;i++){
  cin>>test.at(i);
 }
 sort(test.begin(), test.end(),greater<int>());
 int ans=0;
 for(int i=0;i<K;i++){
  ans=ans+test.at(i);
 }

 
cout<<ans<<endl;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;

namespace ABC136_C
{
    class Program
    {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split();

            string ans = "Yes";
            List<int> list = new List<int>();
            list.Add(int.Parse(input[0]));

            int maxNumber = list[0];
            for(int i = 1; i < n; i++) {
                list.Add(int.Parse(input[i]));

                if(maxNumber < list[i]) {
                    maxNumber = list[i];
                }

                if(maxNumber - 1 > list[i]) {
                    ans = "No";
                    break;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 29660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
  return;
}

int main() {
  char A,B,C; cin>>A>>B>>C;
  if(A=='R'){
    if(B=='R'){
      if(C=='R') cout<<3;
      else cout<<2;
    }
    else{
      cout<<1;
    }
  }
  else{
    if(B=='R'){
      if(C=='R') cout<<2;
      else cout<<1;
    }
    else if(C=='R') cout<<1;
    else cout<<0;
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL MOD=1e9+7;
LL dp[4021][4021];
LL A[200001];
LL B[200001];

LL C[10021];
LL rC[10021];
LL reverse(LL x){
	LL temp=MOD-2;
	LL now=x;
	LL ans=1;
	while(temp!=0){
		if(temp%2==1){
			ans*=now;
			ans%=MOD;
		}
		now*=now;
		now%=MOD;
		temp/=2;
	}
	return ans;
}
void init(){
	C[0]=1;
	REP(i,10010){
		if(i==0)continue;
		C[i]=C[i-1]*i;
		C[i]%=MOD;
	}
	REP(i,10010){
		rC[i]=reverse(C[i]);
	}
}
int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i]>>B[i];
		dp[2000-A[i]][2000-B[i]]++;		
	}
	init();
	REP(i,4010){
		REP(j,4010){
			if(i!=0){
				dp[i][j]+=dp[i-1][j];
				dp[i][j]%=MOD;
			}
			if(j!=0){
				dp[i][j]+=dp[i][j-1];
				dp[i][j]%=MOD;
			}
		}
	}
	LL ans=0;
	REP(i,N){
		ans+=dp[2000+A[i]][2000+B[i]];
		ans%=MOD;
		//cout<<2000+A[i]<<" "<<2000+B[i]<<" "<<dp[2000+A[i]][2000+B[i]]<<endl;;
		LL temp=C[2*A[i]+2*B[i]];
		temp*=rC[2*A[i]];
		temp%=MOD;
		temp*=rC[2*B[i]];
		temp%=MOD;
		ans+=(MOD-temp);
		ans%=MOD;
	}
	cout<<(ans*reverse(2))%MOD<<endl;
}

Measured memory_bytes: 129536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
int N;
  ll count,countmae;
 cin >> N;
  count=0;
  vector<int> vec(N);
  for (int i = 0; i < N; ++i) cin >> vec[i];
  for (int j = 0; j < N-1; ++j){
  if(vec.at(j)>vec.at(j+1)){
    countmae =count;
    count=(vec.at(j)-vec.at(j+1))+countmae;
    vec.at(j+1)=vec.at(j);
    
  }
  }
  cout << count << endl;
}

Measured memory_bytes: 3976
s = input()
# 1. Sは回文である。
rs = s[::-1]
q1 = 0
if s == rs:
  q1 = 1
# print("q1=",q1)
# 2. Nを Sの長さとするとき、Sの 1文字目から (N−1)/2
#    文字目まで(両端含む)からなる文字列は回文である。
n = len(s)
h = int((n-1)/2)
# print("n,h=",n,h)
s1 = s[:h:]
# print("s1=",s1)
rs1 = s1[::-1]
q2 = 0
if (s1 == rs1):
  q2 = 1
# print("q2=",q2)
# 3. Sの (N+3)/2文字目から N文字目まで
#    (両端含む)からなる文字列は回文である。
n = len(s)
h = int((n+2)/2)
# print("n,h=",n,h)
s2 = s[h::]
# print("s2=",s2)
rs2 = s2[::-1]
q3 = 0
if (s2 == rs2):
  q3 = 1
# print("q3=",q3)
if q1 == 1 and q2 == 1 and q3 ==1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
r, g, b, n = gets.split.map(&:to_i)
r, g, b = [r, g, b].sort!.reverse!

ans = 0

0.upto(n / r) do |x|
  balls = r * x
  next if balls > n
  if balls == n
    ans += 1
    next
  end

  0.upto(n / g) do |y|
    balls = r * x + g * y
    next if balls > n
    if balls == n
      ans += 1
      next
    end

    rest = n - balls
    ans += 1 if rest % b == 0
  end
end

puts ans


Measured memory_bytes: 1788
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int d, n;
    cin >> d >> n;

    int res = 1;
    for (int i = 0; i < d; ++i) {
        res *= 100;
    }
    if (n == 100) {
        ++n;
    }   
    res *= n;

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<int> dp(n, INF);
	dp[0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 1; j <= k; ++j) {
			if (i + j < n) {
				dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
			} else {
				break;
			}
		}
	}
	cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mo 1000000007

using namespace std;

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

int add(int a,int b)

{
    a%=mo;
    b%=mo;
    return (a+b)%mo;
}

int mul(int a,int b)
{
    a%=mo;
    b%=mo;
    return (a*b)%mo;
}


int32_t main()
{
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    //let's begin
    long long n;
    cin>>n;
    vector<long long> dp(3);
    for(int days=0;days<n;days++)
    {
        vector<long long> curr_dp(3,0);
        vector<long long> cost(3);
        for(int i=0;i<3;i++)
        {
            cin>>cost[i];
        }
        for(int i=0;i<3;++i)
        {
            for(int j=0;j<3;++j)
            {
                if(i!=j)
                {
                    curr_dp[j]=max(curr_dp[j],dp[i]+cost[j]);
                }
            }
        }
       dp=curr_dp;
    }
    cout<<max(dp[0],max(dp[1],dp[2]))<<"\n";
 	return 0;   
}

Measured memory_bytes: 256
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [0] * (m + 1)
    for i in range(m):
        c[i+1] = c[i] + b[i]

    s = 0
    ans = 0
    for i in range(n+1):
        lft = 0
        rgt = m+1
        while rgt - lft > 1:
            mid = (lft + rgt) // 2
            if s + c[mid] <= k:
                lft = mid
            else:
                rgt = mid
        ans = max(ans, i + lft)
        if i < n:
            s += a[i]
        if s > k:
            break
    print(ans)

main()


Measured memory_bytes: 42108
<?php
/**
 * ABC122
 * B - ATCoder
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

$S = trim(fgets(STDIN));
$max = 0;
$length = strlen($S);
for ($left = 0; $left < $length; $left++) {
    for ($right = $left; $right < $length; $right++) {
        for ($i = $left; $i <= $right; $i++) {
            if (! in_array($S[$i], ['A', 'G', 'C', 'T'], true)) {
                continue 2;
            }
        }
        $max = max($max, $right - $left + 1);
    }
}
echo $max, PHP_EOL;


Measured memory_bytes: 4604
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<ctime>

using namespace std;

typedef long long LL;
const int MX=211;
const LL A[65]={0,0,0,1,2,4,7,11,18,29,47,76,116,188,299,457,738,1116,1898,2863,4580,7192,11266,17450,29302,43417,70260,108168,177299,271977,424553,688860,1067143,1727627,2628546,4494749,6533606,10396103,17042248,24940788,41151771,62502284,101045962,163624265,248705141,410323314,669284262,1032224761,1596203570LL,2482015025LL,3945430889LL,6206382434LL,10347315646LL,15153735045LL,23518168549LL,37249419965LL,58532880409LL,96540747097LL,155889322842LL,236068838564LL,364188525731LL,598004044095LL,927656514301LL,1451223365341LL};
LL dp[MX][MX],S[MX][MX];
LL cal1(int s[],int t[],int ls,int lt){
	for(int i=0;i<ls;i++)dp[i][0]=(s[i]==t[0]),S[i][0]=dp[i][0];
	for(int i=1;i<ls;i++)S[i][0]+=S[i-1][0];
	for(int i=1;i<lt;i++)S[0][i]=S[0][i-1];
	for(int j=1;j<lt;j++)
		for(int i=1;i<ls;i++)
			dp[i][j]=(s[i]==t[j]?S[i-1][j-1]:0),
			S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]+dp[i][j];
	return S[ls-1][lt-1];
}
LL cal(int s[],int l){
	LL ans=0LL;
	for(int i=1;i<l;i++)ans+=cal1(s,s+i,i,l-i);
	return ans;
}
int ANS[MX],L;
void wk(LL n,int alp){
	if(!n)return;
	int len=upper_bound(A,A+63,n)-A-1;
	static int ans[MX];
	LL ansv=0;
	for(int i=1;i<=300;i++){
		static int s[MX];
		for(int j=0;j<len;j++)s[j]=rand()%3+alp;
		LL t=cal(s,len);
		if(t<=n&&t>ansv){
			ansv=t;
			memcpy(ans,s,sizeof(int)*len);
		}
	}
	memcpy(ANS+L,ans,sizeof(int)*len);L+=len;
	//for(int i=0;i<len;i++)printf("%d ",ans[i]);
	wk(n-ansv,alp+3);
}
int main(){
	//freopen("tbl.out","w",stdout);
	srand(time(0));
	LL n;scanf("%lld",&n);
	wk(n,1);
	printf("%d\n",L);
	for(int i=0;i<L;i++)printf("%d ",ANS[i]);
	puts("");
	/*
	for(int n=1;n<=63;n++){
		double sum=0.0;
		for(int i=1;i<=1000;i++){
			static int s[MX];
			for(int j=0;j<n;j++)s[j]=rand()%3+1;
			//printf("%lld ",cal(s,n));
			sum+=cal(s,n);
		}
		sum/=1000;
		printf("%.0f,",sum);
	}
	*/
	//while(1);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){

    int N,L;
    cin >> N >>L;

    vector<string> S(N);

    rep(i,0,N) {
        cin >> S[i];
    }
    sort(S.begin(),S.end());

    rep(i,0,N) {
        cout << S[i];
    }
    cout << endl;

}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TenkaBeginner2019C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            S += "#";

            //.の数の把握
            int countWhite = CountChar(S, '.');
            int countBlack = 0;

            int ans = int.MaxValue;
            for(int k = 0; k <= N; k++)
            {
                int ansCand = countWhite + countBlack;
                if (S[k] == '.')
                {
                    countWhite--;
                }
                else
                {
                    countBlack++;
                }
                if (ansCand < ans) ans = ansCand;
            }
            
            Console.WriteLine(ans);
            Console.ReadKey();
        }

        //static void Main(string[] args)
        //{
        //    int N = int.Parse(Console.ReadLine());
        //    string S = Console.ReadLine();
        //    S += "#";

        //    int ans = int.MaxValue;
        //    for (int k = 0; k <= N; k++)
        //    {
        //        int countW = CountChar(S.Substring(0, k).ToString(), '#');
        //        int countB = CountChar(S.Substring(k).ToString(), '.');
        //        int countSum = countW + countB;

        //        if (ans > countSum) ans = countSum;
        //    }

        //    Console.WriteLine(ans);
        //    Console.ReadKey();
        //}

        static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 16604
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
const int N=100010;
int a[N],b[N],n,K,c1,c2;
signed main() {
	read(n); read(K);
	for(int i=1;i<=n;i++) {
		int x; read(x);
		if(x<0) a[++c1]=x;
		else if(x>0) b[++c2]=x;
		else --K;
	}
	int ans=INF;
	if(!c1) {
		printf("%d\n",b[K]);
	} else if(!c2) {
		reverse(a+1,a+c1+1);
		printf("%d\n",abs(a[K]));
	} else {
		for(int i=max(1,c1-K+1);i<=c1;i++) {
			int left=c1-i+1;
			if(K-left>c2) break;
			// printf("%d %d\n",b[K-left],abs(a[i])*2);
			ans=min(ans,min(b[K-left]+abs(a[i])*2,b[K-left]*2+abs(a[i])));
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = [int(i) for i in input().split()]
l,r,num,ans = 0,0,0,0
while r<n:
	if num^a[r]==num+a[r]: num,r,ans = num+a[r],r+1,ans+r-l+1
	else: l,num = l+1,num-a[l]
print(ans)

Measured memory_bytes: 24584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b;
  c = a + b;
  
  if (c % 2 == 0) 
    cout << c / 2 << endl;
  else 
    cout << c / 2 + 1 << endl;
}

Measured memory_bytes: 256
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e2 + 5;
const ll MOD = 2e5 + 5;
const double ext = 1e-6;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	while (cin >> n) {
		string s;
		map<string, int>vot;
		int ma = -INF;
		_for(i, 0, n) {
			cin >> s;
			if (!vot.count(s))vot[s] = 1;
			else ++vot[s];
			ma = max(ma, vot[s]);
		}
		for (auto it : vot) {
			if (it.second == ma)cout << it.first << endl;
		}
	}
	return 0;
}

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

using namespace std;
#define MX 1e5+1
#define pb push_back
#define prr pair<int,int> 
#define int long long


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    int n,k;
    cin>>n>>k;
    int arr[n];
    int ans=0;
    
    int a1,a2;
    for(int i=0;i<k;i++){
        cin>>arr[i];
        
        
    }
    int diff=0;
    for(int i=0;i<k;i++){
        if(i==0){
            a1=arr[k-1]-arr[0];
            a1=n-a1;
            diff=max(diff,a1);
        }
        a1=arr[i]-arr[i-1];
        diff=max(diff,a1);
    }

    ans=n-diff;
    cout<<ans;
    
    

    
}



















Measured memory_bytes: 3328
stack = [n for n in input().split(' ')]
ans = []
for n in stack:
    if n == '+':
        temp = ans[-1] + ans[len(ans)-2]
        ans.pop()
        ans[-1] = temp
    elif n == '-':
        temp =  ans[len(ans)-2] - ans[-1]
        ans.pop()
        ans[-1] = temp
    elif n == '*':
        temp = ans[len(ans)-2]  * ans[-1]
        ans.pop()
        ans[-1] = temp
    elif n == '/':
        temp = ans[len(ans)-2] / ans[-1]
        ans.pop()
        ans[-1] = temp
    else:
        ans.append(int(n))
print(ans[0])

Measured memory_bytes: 7756
#include <iostream>

int main()
{
    int A, B;   // 初期座標 
    int V, W;   // 速度 
    int T;      // 時間 
    std::cin >> A >> V;
    std::cin >> B >> W;
    std::cin >> T;

    bool isYes = false;
    long long dist = abs(A-B);
    long long veloc = abs(V-W);

    // case:1 直線で追いつける
    {
        if((V > W) && (dist <= veloc * T))
        {
            isYes = true;
        }
    }
/*
    // case:2 壁際までもつれ込む 
    // 追いつけていない？ 
    if(isYes != true)
    {
        // 壁際までいける？ 
        if(dist - std::min(V,W) <= std::min(V, W) * T)
        {
            // 追っ手を飛び越せる？ 
            if(W > 2*V + 1)
            {
                isYes = true;
            }
        }
    }
*/
    if(isYes == true)
    {
        std::cout << "YES" << std::endl;
    }
    else
    {
        std::cout << "NO" << std::endl;
    }
    

    return 0;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  int cnt = 0;
  map<int, int> mp;
  for(int i=0;i<n;++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  for(int i=0;i<n;++i) {
    mp[b[i]] = i;
  }
  for(int i=0;i<n;++i) {
    if(mp[a[i]] % 2 && (i % 2 == 0)) {
      cnt++;
    }
  }
  // printv(a);
  // printv(b);
  cout << cnt << endl;

}


Measured memory_bytes: 5760
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly char End = (char)('z' + 1);

    public void Solve()
    {
        var S = Reader.String().ToCharArray();
        int K = Reader.Int();

        for (int i = 0; i < S.Length - 1 && K > 0; i++)
        {
            if (S[i] > 'a' && K >= End - S[i])
            {
                K -= End - S[i];
                S[i] = 'a';
            }
        }
        S[S.Length - 1] = (char)('a' + (S[S.Length - 1] - 'a' + K) % 26);

        Console.WriteLine(new string(S));
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 4184
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









const int N = 110;
int n, k, res, d, a;
bool b[N];




void solve()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)b[i] = false;
	for(int i = 1; i <= k; i++)
	{
		cin >> d;
		for(int i = 1; i <= d; i++)
		{
			cin >> a;
			b[a] = true;
		}
	}
	res = 0;
	for(int i = 1; i <= n; i++)if(!b[i])res++;
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3608
function main()
  
  N = parse(Int,readline())
  a = map(x -> parse(Int,x), split(readline()))
  
  dict = Dict()
  
  for i in a
    dict[i] = get(dict,i,0) + 1
  end

  ans = 0
  
  for i in keys(dict)
    if dict[i] < i
      ans += dict[i]
    elseif dict[i] > i
      ans += dict[i] - i
    end
  end

  println(ans)
  
end

main()

Measured memory_bytes: 168172
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int max = 0;
		int nowsize = 0;
		int i = 1;
		int[][] map = new int[101][51];
		while (scanner.hasNext()) {

			StringTokenizer tokenizer = new StringTokenizer(scanner.nextLine(),
					",");
			int size = tokenizer.countTokens();
			for (int j = 1; tokenizer.hasMoreTokens(); j++) {
				if (nowsize < size) {
					map[i][j] = Math.max(map[i - 1][j - 1], map[i - 1][j])
							+ Integer.parseInt(tokenizer.nextToken());
				} else {
					map[i][j] = Math.max(map[i - 1][j], map[i - 1][j + 1])
							+ Integer.parseInt(tokenizer.nextToken());
				}
				max = Math.max(max, map[i][j]);
				
			}
			nowsize = size;
			i++;

		}
		System.out.println(max);

	}

}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ver = 1;
  for(int i = 0; i < n - 1; i++)
  {
    if(s[i] != s[n - 2 - i]) ver = 0;
  }
  if(s[0] == '0' || s[n - 1] == '1' || ver == 0)
  {
    cout << "-1" << endl;
    return 0;
  }
  s[n - 1] = '1';
  vector<int> p(n, 0);
  for(int i = 0, j = 0; i < n; i = j)
  {
    for(j = i + 1; j < n && s[j] == '0'; j++);
    if(j == n) break;
    for(; i < j; i++)
    {
      p[i] = j;
    }
  }
  for(int i = 0; i < n - 1; i++)
  {
    cout << i + 1 << " " << p[i] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 2000
#!/usr/bin/env python
"""AtCoder Beginner Contest 170: C - Forbidden List
https://atcoder.jp/contests/abc170/tasks/abc170_c
"""


def main():
    X, N = list(map(int, input().split()))
    Ps = list(map(int, input().split()))

    ans = X
    min_diff = float('inf')
    for d in range(102):
        if d in Ps:
            continue

        v = abs(X - d)
        # print('d({}), v({})'.format(d, v))
        if v < min_diff:
            min_diff = v
            ans = d

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N;
	cin>>N;
	vector<string>S(N);
	vector<vector<int>>C(26,vector<int>(N));
	vector<int>ans(26);
	for(int i=0;i<N;i++)
	{
		cin>>S[i];
		for(int j=0;j<S[i].size();j++)C[S[i][j]-'a'][i]++;
	}
	for(int i=0;i<26;i++)
	{
		int mini=51;
		for(int j=0;j<N;j++){
			mini=min(mini,C[i][j]);
		}
		ans[i]=mini;
	}
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<ans[i];j++)cout<<char(i+'a');
	}
}

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

const long long int MOD = 1e9 + 7;
long long int dp[1001];
int cnt[1001];
bool isprime[1001];
vector <int> prime;

void eratos()
{
	memset(isprime,true,sizeof(isprime));

	for(int i=2;i<=1000;i++)
	{
		if(isprime[i])
		{
			for(int j=2*i;j<=1000;j+=i)
			{
				isprime[j] = false;
			}
			prime.push_back(i);
		}
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	eratos();

	memset(cnt,0,sizeof(cnt));

	for(int i=1;i<=n;i++)
	{
		int x = i;
		for(int j=0;j<prime.size();j++)
		{
			while(1)
			{
				if(x%prime[j]!=0)
				{
					break;
				}
				x/=prime[j];
				cnt[prime[j]]++;
			}
		}
	}

	long long int res = 1;
	for(int j=0;j<prime.size();j++)
	{
		res = (res)*(cnt[prime[j]]+1);
		res%=MOD;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(s[k-1]=='A')s[k-1]='a';
    if(s[k-1]=='B')s[k-1]='b';
    if(s[k-1]=='C')s[k-1]='c';
    PUTS(s);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

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;
}

using type = pair<int, long long>;
using event = pair<long long, type>;

int main() {
	int N, Q; cin >> N >> Q;
	vector<event> v;
	for (int i = 0; i < N; i++) {
		int s, t, x; cin >> s >> t >> x;
		v.push_back({ s - x,type(-1,x) });
		v.push_back({ t - x,type(0,x) });
	}
	for (int i = 0; i < Q; i++) {
		int d; cin >> d;
		v.push_back({ d,type(1,i) });
	}
	sort(v.begin(), v.end());
	vector<long long>res(Q);
	multiset<long long> se;
	for (auto p : v) {
		long long x = p.first;
		int type = p.second.first;
		long long val = p.second.second;
		if (type == -1)se.insert(val);
		else if (type == 0)se.erase(se.lower_bound(val));
		else res[val] = (se.empty() ? -1 : *(se.begin()));
	}
	for (auto v : res)cout << v << endl;
}





Measured memory_bytes: 26728
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 8;
const int INF = 10 * N;

int d[N];
vector<pair<int, int>> g[N];

int dij(int st, int en) {
	fill(d, d + N, INF);
	d[st] = 0;
	deque<int> q;
	q.push_back(st);
	while (!q.empty()) {
		int v = q.front();
		q.pop_front();
		for (auto t : g[v]) {
			if (d[t.first] > d[v] + t.second) {
				d[t.first] = d[v] + t.second;
				if (t.second) q.push_back(t.first);
				else q.push_front(t.first);
			}
		}
	}
	return d[en];
}

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


	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		g[i].push_back({(i * 10) % n, 0});
		g[i].push_back({(i + 1) % n, 1});
	}
	cout << dij(1, 0) + 1 << endl;
}


Measured memory_bytes: 6272
import math

N = int(input())
xys = [tuple(map(int, input().split())) for _ in range(N)]

if N == 2:
    print(0.5)
    print(0.5)
    exit()

outside = [min(range(N), key = lambda i: xys[i])]

go_back_to_while = False
while outside:
    i = outside[-1]
    x1, y1 = xys[i]
    for j in range(N):
        if j in outside:
            continue
        x2, y2 = xys[j]
        sign = 0
        for k, (x3, y3) in enumerate(xys):
            if k == i or k == j:
                continue
            tmp = (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)
            if tmp == 0:
                if x1 < x3 < x2 or x1 > x3 > x2 or y1 < y3 < y2 or y1 > y3 > y2:
                    if k in outside:
                        outside.remove(k)
                        outside.append(j)
                        go_back_to_while = True
                        break
                elif x1 < x2 < x3 or x1 > x2 > x3 or y1 < y2 < y3 or y1 > y2 > y3:
                    break
                else:
                    outside.pop() #remove i
                    go_back_to_while = True
                    break
            elif tmp > 0:
                if sign == 0:
                    sign = +1
                elif sign == -1:
                    break
                else:
                    continue
            else:
                if sign == 0:
                    sign = -1
                elif sign == +1:
                    break
                else:
                    continue
        else:
            outside.append(j)
            break
        if go_back_to_while:
            go_back_to_while = False
            break
    else: #when not found appropriate j
        break #get out of while True


ans = [0.0] * N

for i in range(-1, len(outside) - 1):
    x1, y1 = xys[outside[i-1]]
    x2, y2 = xys[outside[i]]
    x3, y3 = xys[outside[i+1]]
    v1x, v1y = x2 - x1, y2 - y1
    v2x, v2y = x3 - x2, y3 - y2
    dot = v1x * v2x + v1y * v2y
    len1 = (v1x ** 2 + v1y ** 2)
    len2 = (v2x ** 2 + v2y ** 2)
    ans[outside[i]] = math.acos( max(-1.0, min(1.0, dot / math.sqrt(len1 * len2))) ) / (2 * math.pi)

for a in ans:
    print('{:.20f}'.format(a))


Measured memory_bytes: 3192
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<complex>
using namespace std;
typedef complex<double> qua;
void solve(qua a,qua b,qua c)
{
    b-=a,c-=a;
    qua ans=c*conj(b);
    if(ans.imag()>0) printf("COUNTER_CLOCKWISE\n");
    else if(ans.imag()<0) printf("CLOCKWISE\n");
    else if(ans.real()<0) printf("ONLINE_BACK\n");
    else if(abs(c)>abs(b)) printf("ONLINE_FRONT\n");
    else printf("ON_SEGMENT\n");
}
int main()
{
    double x1,y1,x2,y2,x3,y3;
    int m;
    scanf("%lf%lf%lf%lf%d",&x1,&y1,&x2,&y2,&m);
    while(m--)
    {
        scanf("%lf%lf",&x3,&y3);
        solve(qua(x1,y1),qua(x2,y2),qua(x3,y3));
    }
}



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

typedef long long ll;
 
const ll M = (long long) 1e9+7;
 
vector<ll> fac(2000001); 
vector<ll> ifac(2000001); 
 
 
ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){ 
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b<0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return (tmp * fac[a]) % M;
}
 
int main()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<2000000; i++){
        fac[i+1] = fac[i]*(i+1) % M; 
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; 
    }

    ll S;
    cin >> S;
 
    ll n = S/3ll;
    ll ans=0ll;

    for(int i=1; i<=n; i++){

        ll Srest = S - 3ll * i;

        ans += comb( Srest+i-1, i-1 )%M;
        ans %= M;

        //cout << "i, ans, Srest " << i << " " << ans << " " << Srest << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 34256
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define parr[1] push_back
#define pii pair<int,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)

const double pi = acos(-1.0);
const int maxn = (i64)2e5+5;

int arr[105];
int main()
{
    //freopen("input.txt","r",stdin);
    int n,cost = 10000000;
    cin >> n;
    for(int i = 0 ; i<n ; i++)
    {
        cin>>arr[i];
    }

    for(int i = 1 ; i<=100 ; i++)
    {
        int c = 0;
        for(int j = 0 ; j<n ; j++)
        {
            c = c + (abs(arr[j]-i)*abs(arr[j]-i ));
        }
        if(c<cost) cost = c;
    }
    cout<<cost;



return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, a, b; cin >> n >> a >> b;

  if(a + b > n+1 || a * b < n){
    cout << -1 << endl;
    return 0;
  }
  vector<int> v;
  int kill = a * b - n;
  for(int i = 0; i < a*b; i+=b){
    for(int j = i+b; j > i; j--){
      v.push_back(j);
      if(kill >= b-1){
        kill -= b-1;
        break;
      }else if(kill > 0 && kill < b-1){
        j -= kill;
        kill = 0;
      }
    }
  }

  map<int, int> mp;
  int num = v.size();
  for(int i = 0; i < v.size(); i++){
    mp[v[i]] = -1;
  }
  for(auto p = mp.rbegin(); p != mp.rend(); p++){
    p->second = num--;
  }
  for(int i = 0; i < v.size(); i++){
    cout << mp[v[i]] << " ";
  }
  cout << endl;

  return 0;
}


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

int main() {
  int i, j, t, x, N;
  t = 0; x = 0; j = 1;
  cin >> N;
  vector<int> a(N);

  for(i = 0; i < N; i++){
    cin >> a.at(i);
  }

  for(i = 0; i < N; i++){
    j = a.at(j-1);
    t++;
    if(j == 2){
      x++;
      break;
    }
  }

  if(x == 0){ cout << "-1" << endl;}
  else{ cout << t << endl;}
}

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

int main() {
    long long X; cin >> X;
    long long A, B;
    for (A = -150; A <= 150; A++) {
        for  (B = -150; B <= 150; B++) {
            if (pow(A, 5) - pow(B, 5) == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main(){
    long long a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 764
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,_,k=map(int,input().split())
    if k<=a:
        print(k)
    elif k>a and k<=a+b:
        print(a)
    else:
        print(a-(k-a-b))
if __name__=='__main__':
    main()

Measured memory_bytes: 9180
n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            sm = []
            for x, y, z in xyz:
                sm.append((-1) ** i * x + (-1) ** j * y + (-1) ** k * z)
            sm.sort()
            mx = abs(sum(sm[:m]))
            ans = max(ans, mx)

print(ans)


Measured memory_bytes: 3316
def solve(n, stone_heights):
  if n == 0 or n == 1: return 0
  if n == 2:
    return abs(stone_heights[1] - stone_heights[0])
  cost_arr = [0, abs(stone_heights[1] - stone_heights[0])]
  i = 2
  while i < n:
    cost_to_i_from_1_stone_before = abs(stone_heights[i] - stone_heights[i - 1])
    cost_to_i_from_2_stones_before = abs(stone_heights[i] - stone_heights[i - 2])
    if cost_to_i_from_2_stones_before + cost_arr[i - 2] <= cost_to_i_from_1_stone_before + cost_arr[i - 1]:
      cost_arr.append(cost_to_i_from_2_stones_before + cost_arr[i - 2])
    else:
      cost_arr.append(cost_to_i_from_1_stone_before + cost_arr[i - 1])
    i += 1
  return cost_arr[-1]

n = int(input())
stone_heights = list(map(int,input().rstrip().split(' ')))
print(solve(n, stone_heights))


Measured memory_bytes: 20520
using System;

namespace ABC158b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            long N = long.Parse(s[0]);
            long A = long.Parse(s[1]);
            long B = long.Parse(s[2]);

            if (A == 0)
            {
                Console.WriteLine(0);
                return;
            }

            long t = N / (A + B);
            long C1 = t * A;

            long v = N % (A + B);

            long C2 = v;
            if (v >= A)
            {
                C2 = A;
            }
            Console.WriteLine(C1 + C2);
        }
    }
}


Measured memory_bytes: 13140