akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
#define int long long
const int N=1e6+5;
int n,pre[N],suf[N];
struct node{
	int x,y;
}a[N];
bool cmp(node a,node b)
{
	if(a.x==b.x)return a.y<b.y;
	return a.x<b.x;
}
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	int mi=1e18,ma=0;
	for(int i=1;i<=n;i++)
	{
		a[i].x=read();a[i].y=read()+1;
		mi=min(mi,a[i].y);
		ma=max(ma,a[i].x);
	}
	int ans=max(mi-ma,0ll)+a[1].y-a[1].x;
	for(int i=2;i<=n;i++)ans=max(ans,max(mi-ma,0ll)+a[i].y-a[i].x);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)pre[i]=max(pre[i-1],a[i].x);
	suf[n+1]=1e18;
	for(int i=n;i;i--)suf[i]=min(suf[i+1],a[i].y);
	for(int i=1;i<n;i++)
		ans=max(ans,max(mi-pre[i],0ll)+max(suf[i+1]-ma,0ll));
	cout<<ans;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto a = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR (a, 0, (b))
#define CEIL(a, b) ((a) + (b)-1) / (b)
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, true : false;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << mt(__VA_ARGS__) << "] "
template <typename T>
struct IsC {
  template <typename C>
  static char test(typename C::const_iterator*);
  template <typename C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream&, const C&);
template <typename T1, typename T2>
ostream& operator<<(ostream&, const pair<T1, T2>&);
template <typename... T> using TS = tuple_size<tuple<T...>>;
template<size_t idx, typename... T>
typename enable_if<TS<T...>::value == idx + 1, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return o << ", " << get<idx>(t) << ')';
}
template<size_t idx, typename... T>
typename enable_if<0 < idx && idx + 1 < TS<T...>::value, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << ", " << get<idx>(t), t);
}
template<size_t idx = 0, typename... T>
typename enable_if<1 < TS<T...>::value && !idx, ostream&>::type
operator<<(ostream& o, const tuple<T...>& t) {
  return operator<<<idx + 1>(o << '(' << get<idx>(t), t);
}
template<typename T>
ostream& operator<<(ostream& o, const tuple<T>& t) {
  return o << get<0>(t);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p) {
  return o << mt(p.fi, p.se);
}
template <typename C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '[';
  for (auto it = c.cbegin(); it != c.cend(); ++it)
    o << *it << (next(it) != c.cend() ? ", " : "");
  return o << ']';
}
template <typename T>
void tprint(vector<vector<T>>& v, size_t width = 0, ostream& o = cerr) {
  if (!DEBUG) return;
  for (const auto& vv : v) {
    for (const auto& i : vv) o << setw(width) << i;
    o << endl;
  }
}

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

  ll n, k; cin >> n >> k;

  vector<ll> as(n); F0R (i, n) cin >> as[i];

  ll l = 1, r = 1e9;
  while (l < r) {
    ll mid = (l + r) / 2;
    ll cnt = 0;
    for (ll i : as) {
      cnt += (i + mid - 1) / mid - 1;
    }
    if (cnt <= k) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 4712
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()

	ans := ""

	for ; n > 0; n = (n - 1) / 26 {
		ans = string(97+(n-1)%26) + ans
	}

	fmt.Println(ans)
}

// util
// *   math/simple

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

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1772
s = int(input())
ansli = [s]
flg = True
cnt = 2
def f(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return (3*n)+1
cnt = 2
cur = s
while flg:
    cur = f(cur)
    if cur in ansli:
        print(cnt)
        flg = False
    else:
        ansli.append(cur)
        cnt += 1

Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    x, y = LI()
    print(x+y//2)
    return

#B
def B():
    return

#C
def C():
    n, m = LI()
    py = LIR(m)
    pya = py[::1]
    py.sort(key=lambda x: x[1])
    city = [1 for i in range(n)]
    dicity = {}
    for p, y in py:
        dicity[(p,y)] = city[p-1]
        city[p-1] += 1    
    for p, y in pya:
        a = "00000" + str(p)
        a = a[-6:]
        b = "00000" + str(dicity[(p, y)])
        b = b[-6:]
        print(a+b)

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    n--;
    vector<char>s;
    s.push_back('a'+(n%26));
    n/=26;
    while(n)
    {
        n--;
        s.push_back('a'+(n%26));
        n/=26;
    }
    for (ll i=0;i<s.size();i++)
        cout << s[s.size()-1-i];
    cout << endl;
	return 0 ; 
}


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

int H, W;
const int MAX_HW = 100 + 10;
char a[MAX_HW][MAX_HW];

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0;  j < W; j++) {
            cin >> a[i][j];
        }
    }
    
    for (int j = 0; j <= W+1; j++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        cout << "#";
        for (int j = 0; j < W; j++) {
            cout << a[i][j];
        }
        cout << "#" << endl;
    }
    for (int j = 0; j <= W+1; j++) {
        cout << "#";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

using ll = long long;

int main() {
    int N, K;
    std::cin >> N >> K;

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

    int ans = 0;
    for (int l = 0; l < K + 1; l++) {
        for (int r = 0; r < K - l + 1; r++) {
            //操作が上限に達した
            if (l + r > N)continue;
            //消せる回数
            int d = K - l - r;
            //今のスコア
            int n = 0;
            //取り出した数字
            std::vector<int> s;
            for (int i = 0; i < l; i++) {
                n += a[i];
                s.emplace_back(a[i]);
            }
            for (int i = 0; i < r; i++) {
                n += a[N - i - 1];
                s.emplace_back(a[N - i - 1]);
            }
            std::sort(s.begin(), s.end());
            for (int i = 0; i < d; i++) {
                if (i >= s.size())break;
                if (s[i] > 0)break;
                n -= s[i];
            }
            ans = std::max(n, ans);
        }
    }

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


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

long long cnt;
int l,A[1000000],n,Gsize;
int * G;

void insertionSort(int A[], int n, int g){
  int i,j,v;
  for(i=g;i<=n-1;i++) {
    v=A[i];
    j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[], int n) {
  int i=0,j,h;
  for(h=1;;) {
    if(h>n) break;
    G[i++]=h;
     h=h*3+1;
  }
  Gsize=i;
  for(i=Gsize-1;i>=0;i--) {
    insertionSort(A,n,G[i]);
  }
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  G=(int *)malloc(sizeof(int)*n);
  cnt = 0;
  shellSort(A,n);
  printf("%d\n",Gsize);
  for(i=Gsize-1;i>=0;i--) {
    printf("%d",G[i]);
    if(i){
      printf(" ");
    }
  }
  printf("\n" );
  printf("%lld\n", cnt);
  for (i=0;i<n;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}

Measured memory_bytes: 4512
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cassert>

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

using namespace std;

int h,w,e[10][10];

int main() {
  while( cin >> h >> w, h|w ) {
    rep(i,h) rep(j,w) cin >> e[i][j];
    int maxi = 0;
    rep(y1,h) if( y1+2 < h ) {
      rep(x1,w) if( x1+2 < w ) {
	REP(y2,y1+2,h) {
	  REP(x2,x1+2,w) {
	    int high = -1;
	    int lowe = 12345678;
	    int score = 0;
	    REP(y,y1,y2+1) {
	      REP(x,x1,x2+1) {
		if( y == y1 || y == y2 || x == x1 || x == x2 ) lowe = min(lowe,e[y][x]);
		else high = max(high,e[y][x]);
	      }
	    }
	    if( high >= lowe ) continue;
	    REP(y,y1,y2+1) {
	      REP(x,x1,x2+1) {
		if( y == y1 || y == y2 || x == x1 || x == x2 ) ;
		else { score += ( lowe - e[y][x] ); }
	      }
	    }	    
	    maxi = max(maxi,score);
	  }
	}
      }
    }




    cout << maxi << endl;
  }
  return 0;
}

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

int main()
{
int X;
int A;
int B;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> X;
	cin >> A;
	cin >> B;

	cout << ( X - A ) % B << endl;

	return 0;
}






Measured memory_bytes: 256
#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>







struct gcdExtnd
{
	ll x,y,g;
	ll gcd(ll a,ll b)
	{
		if(b==0)
		{
			x=1;
			y=0;
			return a;
		}
		g=gcd(b,a%b);
		ll t=y;
		y=x-(a/b)*y;
		x=t;
		return g;
	}
};


ll invrsMod(ll a, ll m)
{
	gcdExtnd o;
	ll g=o.gcd(a,m);
	ll x=(o.x)%m;
	if(x<0)x+=m;
	return x;
}






const int M = 998244353, N = 2e5 + 10;
ll n, m, k, fct[N], invrsFct[N], res;






ll pw(ll b, ll p)
{
	if(p == 0)return 1;
	ll ret;
	ret = pw(b, (p / 2));
	ret = (ret*ret) % M;
	if(p % 2 == 1)ret = (ret*b) % M;
	return ret;
}





ll mul(ll a, ll b)
{
	a %= M;
	b %= M;
	return (a*b) % M;
}




void solve()
{
	cin >> n >> m >> k;
	fct[0] = 1;
	invrsFct[0] = 1;
	for(ll i = 1; i <= n; i++)
	{
		fct[i] = (fct[i - 1] * i) % M;
		invrsFct[i] = invrsMod(fct[i], M);
	}
	res = 0;
	for(int i = 0; i <= k; i++)
	{
		res = (res + mul(mul(mul(mul(fct[n - 1], invrsFct[i]), invrsFct[n - 1 - i]), m), pw(m - 1, n - i - 1))) % M;
	}
	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: 6728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    ll ans=2*k;
    rep(i,0,n-1){
        if(s[i]=='L'){
            if(i==0)continue;
            if(s[i-1]=='L')ans++;
        }else{
            if(i==n-1)continue;
            if(s[i+1]=='R')ans++;
        }
    }
    Min(ans,n-1);
    cout<<ans<<endl;
    return 0;
}

/*

#define N 200005
ll n;
ll a[N];

ll ret[N][2];
void cal(){
    set<l_l>s;
    memset(ret,-1,sizeof(ret));
    rep(i,0,n-1){
        while(!s.empty()){
            l_l t=*s.begin();
            if(t.first<a[i]){
                ret[t.second][0]=i;
                s.erase(t);
            }
        }
        s.insert(l_l(a[i],i));
    }
    rep(i,0,n-1){
        
    }
}

int main(){fastio
    
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    ll dp[n][4];
    cal();
    rep(i,0,n-1)rep(j,0,1){
        dp[i][j]=ret[i][j];
    }
    reverse(a,a+n);
    cal();
    rep(i,0,n-1)rep(j,0,1){
        dp[i][j+2]=ret[i][j];
    }
    reverse(a,a+n);
    
    
    
    return 0;
}
 */













Measured memory_bytes: 512
using System;

namespace _0112
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int j = int.Parse(Console.ReadLine());
                if (j == 0)
                {
                    break;
                }
                int[] X = new int[j];
                for (int i = 0; i < j; i++)
                {
                    X[i] = int.Parse(Console.ReadLine());
                }
                Array.Sort(X);
                long now = 0;
                long output = 0;
                for (int i = 0; i < j - 1; i++)
                {
                    now += X[i];
                    output += now;
                }
                Console.WriteLine(output);
            }
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  
  //ボタン情報をえる
  vector<int> button(N);
  for (int i=0;i<N;i++){
    cin >> button.at(i);
  }
  
  //押していく
  int A=1;
  for (int i=0;i<N;i++){
    A = button.at(A-1);
    if (A == 2){
      cout << i+1 << endl;
      break;
    }
  }
   if (A != 2){
     cout << -1 << endl;
   }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    if(x==(2*n -1) || x==1)printf("No\n");
    else
    {
        printf("Yes\n");
        for(int i=1, j=2; i<=2*n -1; i++)
        {
            if(i==n-1)printf("1\n");
            else if(i==n)printf("%d\n", x);
            else if(i==n+1)printf("%d\n", 2*n - 1);
            else
            {
                if(j==x)j++;
                printf("%d\n", j);
                j++;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

const int MOD = 1e9+7;

ll modpow(ll n, ll p, ll m) {
    ll res = 1;
    while(p>0){
        if(p%2==1) res = (res * n) % m;
        n = (n * n) % m;
        p /= 2;
    }
    return res;
}

ll modinv(ll n, ll mod){
    return modpow(n, mod-2, mod);
}

ll nck(ll n, ll k, ll mod) {
    ll x=1, y=1;
    rep(i, k) {
        x = x*(n-i)%mod;
        y = y*(i+1)%mod;
    }
    return x * modinv(y, mod) % mod;
}

int main(){
    ll n, a, b; cin>>n>>a>>b;
    ll ans = modpow(2, n, MOD);
    ans -= 1;
    ans -= nck(n, a, MOD);
    ans -=  nck(n, b, MOD);
    cout << (ans+MOD*2)%MOD <<endl;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int fl = 0;
    while (a > 0 && c > 0) {
        if (!fl)
            c -= b;
        else
            a -= d;
        fl ^= 1;
    }
    puts(a > 0 ? "Yes" : "No");
}


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

int main()
{
   int  d;
   cin >> d;
   vector<int> c(26);
   vector<vector<int>> s(d,vector<int>(26));
   vector<int> t(d);
   vector<int> last(26,0);
   rep(i,26) cin >> c[i];
   rep(i,d) rep(j,26) cin >> s[i][j];
   rep(i,d) cin >> t[i];

   int ans = 0;
   rep(i,d)
   {
      int type = t[i] -1;
      ans += s[i][type];
      last[type] = i+1;
      rep(j,26) ans -= c[j] * (i+1 - last[j]);

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


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var w = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            var totalWeight = w.Sum();
            
            var s = new List<int>();
            s.Add(0);
            foreach(var x in w)
            {
                s.Add(s.Last()+x);
            }
            s.RemoveAt(0);

            var ans = s.Select(x => Math.Abs(totalWeight - x - x)).Min();
            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define int long long

int32_t main()
{
    int temp; cin>>temp;
    if(temp/100<=12&&temp/100>=1) //MMYY
    {
        if(temp%100>=1)
        {
            if(temp%100<=12)cout<<"AMBIGUOUS";
            else cout<<"MMYY";
        }
        else cout<<"MMYY";
    }
    else if(temp%100<=12&&temp%100>=1) //YYMM
    {
        if(temp/100>=1)
        {
            if(temp/100<=12)cout<<"AMBIGUOUS";
            else cout<<"YYMM";
        }
        else cout<<"YYMM";
    }
    else
    {
        cout<<"NA";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int cost[1001][1001];

int min(int k,int l){
    if(k>l) return l;
    else return k;
}

int min3(int k,int l,int m){
    int n = min(k,l);
    return min(n,m);
}

void pre(std::string& s1,std::string& s2,int size1,int size2){
    for(int i=0;i<=size1;i++){
        cost[i][0] = i;
    }
    for(int i=0;i<=size2;i++){
        cost[0][i] = i;
    }
}

void ED(std::string& s1,std::string& s2,int size1,int size2,int i,int j){
    if(s1[i-1] == s2[j-1]){
        cost[i][j] = cost[i-1][j-1];
    }else{
        cost[i][j] = min3(cost[i][j-1],cost[i-1][j],cost[i-1][j-1])+1;
    }
}

int main(){
    std::string s1,s2;
    std::cin >> s1;
    std::cin >> s2;
    int size1 = s1.size(),size2 = s2.size();
    pre(s1,s2,size1,size2);
    for(int i=1;i<=size1;i++){
        for(int j=1;j<=size2;j++){
            ED(s1,s2,size1,size2,i,j);
        }
    }
    
    /*for(int i=0;i<=size1;i++){
        for(int j=0;j<=size2;j++){
            std::cout << cost[i][j] << ' ';
        }
        std::cout << '\n';
    }*/
    std::cout << cost[size1][size2] << '\n';
    
    return 0;
}
    



Measured memory_bytes: 7132
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, K;
	cin >> N >> K;
	int res = INT_MAX;
	for (int bit = 0;bit < (1 << N);bit++) {
		int x = 1;
		int cpy = bit;
		REP(i, N) {
			if (cpy & 1) x *= 2;
			else x += K;
			cpy /= 2;
		}
		res = min(res, x);
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string ss;
    cin>>ss;
    if(ss[2]==ss[3]&&ss[4]==ss[5])
        puts("Yes");
    else
        puts("No");
    return 0;
}


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

int main()
{
	string a;
	while(cin>>a)
	{
		if(a[0]=='S')
		{
			cout<<"Cloudy\n";
		}
		else if(a[0]=='R')
		{
			cout<<"Sunny\n";
		}
		else
		{
			cout<<"Rainy\n";
		}
	}
	return 0;
}

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

using namespace std;

const int Max_N(2050);
const int MOD(924844033);
typedef long long int LL;

inline int Mult(const int &a, const int &b)
{
	return static_cast<int>(static_cast<LL>(a) * static_cast<LL>(b) % static_cast<LL>(MOD));
}

inline void update(int &a, const int &b)
{
	((a += b) >= MOD) ? (a -= MOD) : 0;
}

int N, K, Ans[Max_N], ANS, Fac[Max_N];
int M, V[Max_N], F[Max_N][Max_N][2][2];

//考虑容斥
//强制选一些点不合法
//在mod K意义下dp
//F[i][j][a][b]表示dp到第i个数，选了j个不合法，V[i]是否可用，V[i + 1]是否可用 

int main()
{
	scanf("%d%d", &N, &K);
	Fac[0] = 1;
	for (int i = 1;i <= N;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Ans[0] = 1;
	for (int m = 1;m <= K;++m)
	{
		M = 0;
		for (int i = m;i <= N;i += K)
			V[++M] = i;
		memset(F[1], 0, sizeof(F[1]));
		if (M == 1)
			F[1][0][1][0] = 1;
		else
		{
			F[1][0][1][1] = 1;
			F[1][1][1][0] = 1;
			for (int i = 2;i <= M;++i)
			{
				memset(F[i], 0, sizeof(F[i]));
				for (int j = 0;j <= i - 1;++j)
					for (int a = 0;a <= 1;++a)
						for (int b = 0;b <= 1;++b)
						{
							update(F[i][j][b][(i + 1) <= M], F[i - 1][j][a][b]);
							if (a)
								update(F[i][j + 1][b][(i + 1) <= M], F[i - 1][j][a][b]);
							if (i + 1 <= M)
								update(F[i][j + 1][b][0], F[i - 1][j][a][b]);
						}
			}
		}
		for (int j = N;j >= 0;--j)
			for (int k = 1;k <= M && k <= j;++k)
			{
				int Ret(0);
				for (int a = 0;a <= 1;++a)
					update(Ret, F[M][k][a][0]);
				update(Ans[j], Mult(Ans[j - k], Ret));
			}
	}
	for (int i = 0;i <= N;++i)
	{
		Ans[i] = Mult(Ans[i], Fac[N - i]);
		if (i & 1)
			update(ANS, (-Ans[i] % MOD + MOD) % MOD);
		else
			update(ANS, Ans[i]);
	}
	printf("%d", ANS);
	return 0;
}

Measured memory_bytes: 65664
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a < b) {
        while (b) printf("%d",a),b--;
        printf("\n");
    } else {
        while(a) printf("%d",b),a--;
        printf("\n");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M, count = 0;
  int *A;
  cin >> N >> M;
  
  A = new int[M];
  
  for(int i = 0; i < M; i++){
    cin >> A[i];
  }
  
  for(int i = 0; i < M; i++){
    count += A[i];
  }
  
  if(count <= N) cout << N-count << endl;
  else cout << -1 << endl;
  
  delete[] A;
  return 0;
}

Measured memory_bytes: 3664
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    int A, B, T;
    cin >> A >> B >> T;
    cout << (int)((T+0.5)/A)*B << endl;
    return 0;
}


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

int n, x, s;
int main()
{
	int i, t;
	cin >> n >> x;
	for (i = 1; i <= n; i++) {
		scanf("%d", &t);
		s += t;
		if (s > x) break;
	}
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
//#define int long long
#define endl '\n'
#define INF 1000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	int n = s.size();
	int tmp = 0;
	vector<int> sum(n + 1);
	rep(i, n) {
		tmp ^= (1 << (s[i] - 'a'));
		sum[i + 1] = tmp;
	}
	vector<int> ans(n + 1, INF); ans[0] = 0;
	vector<int> mp(1 << 26);
	rep(i, n) {
		rep(j, 26) {
			if ((sum[i + 1] ^ (1 << j)) == 0 || mp[sum[i + 1] ^ (1 << j)] != 0) {
				chmin(ans[i + 1], mp[sum[i + 1] ^ (1 << j)] + 1);
			}
		}
		if (sum[i + 1] == 0 || mp[sum[i + 1]] != 0) chmin(ans[i + 1], mp[sum[i + 1]] + 1);
		if (sum[i + 1] != 0) {
			if (mp[sum[i + 1]]) chmin(mp[sum[i + 1]], ans[i + 1]);
			else mp[sum[i + 1]] = ans[i + 1];
		}
	}
	cout << ans[n] << endl;
}

Measured memory_bytes: 264340
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
}


Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
d=0
for i in range(n):
  c=int(input())
  d+=c
  if c%10==0:
    a.append(c)
  else:
    b.append(c)
b.sort()
if d%10==0 and b:
  print(d-b[0])
elif d%10==0:
  print(0)
else:
  print(d)

Measured memory_bytes: 9096
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
    P[i]--;
  }
  vector<int64_t> C(N);
  rep(i, N) cin >> C[i];

  int64_t answer = INT64_MIN;
  rep(i, N) {
    int cur = i;
    int64_t loop_sum = 0;
    int64_t count = 0;
    for (int64_t k = 0; k < K; ++k) {
      cur = P[cur];
      loop_sum += C[cur];
      answer = max(answer, loop_sum);
      count++;
      if (cur == i) break;
    }
    if (K <= count) continue;

    int64_t tmp_sum = 0;
    int p = i;
    rep(j, count) {
      p = P[p];
      tmp_sum += C[p];
      int64_t tmp_ans = tmp_sum;
      if (loop_sum > 0) {
        int64_t loop_num = (K - (j + 1)) / count;
        tmp_ans += (loop_sum * loop_num);
      }
      answer = max(answer, tmp_ans);
    }
  }
  cout << answer << endl;
  return 0;
}


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

int main() {
	int N;

	cin >> N;
	int ans = 0;
	int prev = -1;
	int count = 0;

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (prev == -1) {
			count = 1;
			prev = a;
		}
		else if (a == prev) {
			count++;
		}
		else {
			ans += count / 2;
			count = 1;
			prev = a;
		}
	}

	ans += count / 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())
p = 10**9+7


def comb(n, a):
    ans = 1
    for i in range(1, a + 1):
        ans = ans * (n - i + 1) * pow(i, p - 2, p) % p
    return ans


ans = (pow(2, n, p)-1-comb(n, a)-comb(n, b)) % p
print(ans)


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  cout << n/3 << endl;

  





  return 0;
}

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

using namespace std;

const double eps = 1e-9;
bool equal(double a, double b){ return abs(a-b) < eps;}

//ベクトル演算
struct V{
    double x, y;
    V(double x=0, double y=0): x(x), y(y){}
    V operator+(const V& p) const {return V(x+p.x, y+p.y);}
    V operator-(const V& p) const {return V(x-p.x, y-p.y);}
    V operator*(double a) const {return V(x*a, y*a);}
    double sqrNorm() const {return x*x + y*y;}
    double norm() const {return sqrt(sqrNorm());}
    //時計回りに90度回転
    V rotate90() const {return V(y, -x);}
};

// 円の計算
struct Circle{
    //ベクトルの中心座標o,半径をｒでもつ
    V o; double r;
    Circle(V o=V(), double r=0): o(o), r(r){}

    //交点計算 cross ponit
    vector<V> xp(const Circle& c){
        V v = c.o - o;
        //まず距離を求める
        double l = v.norm();
        //中心が重なってるなら交点なし
        if(equal(l, 0)){
            return {};
        }
        //ちょうど直線になっている。交点が一つのみ。 
        if(equal(l+r+c.r, max({l,r,c.r})*2)){
            if( equal(l+r, c.r)){
                return {o - v*(r/l)};
            }
            else{
                return {o + v*(r/l)};
            }
        }
        //三角形が成り立たないので、交点なし
        //三角形の成り立つ条件は　三辺の和 >= 最大辺の2倍
        if(l+r+c.r < max({l, r, c.r})*2){
            return {};
        }

        double x = (l*l + r*r - c.r*c.r) / (2*l);
        //アフファの長さ
        double y = sqrt(r*r - x*x);
        V mid = o + v*(x/l);
        v = v.rotate90();
        return {mid + v*(y/l), mid - v*(y/l)};
    }
    //点が円の中に入っているのか
    bool isInside(const V& p) const {
        //点と中心の距離がr以下ですか？ epsで境界も含むようにする。
        return (p-o).norm() < r+eps;
    }
};

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

    if( k==1){
        cout << 0 << endl;
        return 0;
    }
    vector<Circle> c(n);
    for(int i=0; i<n; ++i){
        cin >> c[i].o.x >> c[i].o.y >> c[i].r;
    }

    double l = 0, r = 400000;
    //二部探索
    //doubleで二分探索するとwhiledだと収束せずに無限ループするので、回す回数を固定する。
    for(int ti=0; ti<100; ++ti){
        //時間をｘとする
        double x = (l+r)/2;
        //候補点
        vector<V> ps;
        //中心の点
        for(int i=0; i<n; ++i) ps.push_back(c[i].o);
        //交点
        for(int i=0; i<n; ++i){
            for(int j=0; j<i; ++j){
                Circle a = c[i], b = c[j];
                a.r = x/a.r;
                b.r = x/b.r;
                //ベクトルのベクトル（0 or 1 0r 2個のベクトルがはいっている）
                auto tmp = a.xp(b);
                ps.insert(ps.end(), tmp.begin(), tmp.end());
            }
        }
        bool ok = false;
        for( V p : ps){
            int cnt = 0;
            for(int ci =0; ci<n; ++ci){
                Circle nc = c[ci];
                nc.r = x/nc.r;
                if(nc.isInside(p)){
                    cnt++;
                }
            }
            if(cnt >= k){
                ok = true;
            }
        }
        if(ok){
            r = x;
        }else{
            l = x;
        }
    }

    printf("%.10f\n", r);
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

vi a;

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

	set<string> s;

    int n; cin >> n;
    map<string, int> m;
    string t;
    int Max = 0;
    for (int i = 0; i < n; i++) {
        cin >> t;
        m[t]++;
        s.insert(t);
    }

    for (string x : s) {
        Max = max(Max, m[x]);
    }

    for (string x : s) {
        if (m[x] == Max) cout << x << endl;
    }
}


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

int main() {
    int a, b, c;
  	cin >> a >> b >> c;
    bool flag = false;
    if (a == b + c) {
        flag = true;
    } else if (a + b == c) {
        flag = true;
    } else if (a + c == b) {
        flag = true;
    }

    if (flag) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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

int num ;
int count = 0 ;

int main()
{
	while( cin >> num )
	{
		if( num <= 36 )
		{
			for( int a = 0 ; a <= 9 ; a ++ )
			{
				for( int b = 0 ; b <= 9 ; b ++ )
				{
					for( int c = 0 ; c <= 9 ; c ++ )
					{
						for( int d = 0 ; d <= 9 ; d ++ )
						{
							if( (a+b+c+d) == num )
							{
								count ++ ;
							}
						}
					}
				}
			}
		}
		cout << count << endl ;

		count = 0 ;
	}

	return 0 ;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;int main(){long long int a[200000],mini=100000000000,n,sum1=0,sum2=0;cin>>n;for(int i=0;i<n;i++){cin>>a[i];sum1+=a[i];}for(int i=n-1;0<i;i--){sum1-=a[i];sum2+=a[i];if(abs(sum1-sum2)<mini){mini=abs(sum1-sum2);}}cout<<mini<<endl;return 0;}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
#define INF 1e+10
#define EPS 1e-10
#define EQ(a,b) (abs(a-b)<EPS)

//誤差を考慮して足し算
double add(double a,double b){
	if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{//2次元ベクトル
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	double dot(P p){//内積
		return add(x*p.x,y*p.y);
	}
	double det(P p){//外積
		return add(x*p.y,-y*p.x);
	}
	bool equal(P p){
		return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y) < EPS*EPS;
	}
};
//線分p1-p2上に点qがあるか判定
bool on_seg(P p1,P p2,P q){
	return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
//直線p1-p2と直線q1-q2の交点
P intersection(P p1,P p2,P q1,P q2){
	return p1+(p2-p1)*( (q2-q1).det(q1-p1)/(q2-q1).det(p2-p1) );
}

//線分p1-p2と線分q1-q2が交差するか
bool intersecting(P p1,P p2,P q1,P q2){
	if(on_seg(p1,p2,q1)||on_seg(p1,p2,q2)||on_seg(q1,q2,p1)||on_seg(q1,q2,p2))return true;
	if((p1-p2).det(q1-q2)==0 )return false;//平行
	P a=intersection(p1,p2,q1,q2);
	return on_seg(p1,p2,a) && on_seg(q1,q2,a);
}
P rotate(P p,double rad){
	double s=sin(rad),c=cos(rad);
	return P(c*p.x-s*p.y, s*p.x+c*p.y);
}
double dist(P p,P q){
	p = p-q;
	return sqrt(p.x*p.x+p.y*p.y);
}

//円同士の交点を計算
pair<P,P> circle_intersection(double x1,double y1,double r1,double x2,double y2,double r2){
	double rad = atan2(y2-y1,x2-x1);
	x2 -= x1;
	y2 -= y1;
	P tmp = rotate(P(x2,y2),-rad);
	x2 = tmp.x;
	y2 = tmp.y;
	double x = (r1*r1-r2*r2+x2*x2)/(2*x2);
	if(abs(r1) < abs(x))return make_pair(P(0,0),P(0,0));//交点なし
	double y = sqrt(r1*r1-x*x);
	return make_pair( P(x1,y1)+rotate(P(x,y),rad) ,  P(x1,y1)+rotate(P(x,-y),rad) );
}


int main(){
	int n,ans;
	double x[100],y[100],r[100];
	double d[200][200];
	vector<P> v;
	vector<pair<P,P> > line;
	vector<int> L;
	while(cin>>n&&n){
		for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i];
		for(int i=0;i<200;i++)for(int j=0;j<200;j++)d[i][j]=INF;
		line.clear();
		v.clear();
		v.push_back(P(x[0],y[0]));
		L.clear();
		L.push_back(-1);
		for(int i=0;i<n-1;i++){
			pair<P,P> a = circle_intersection(x[i],y[i],r[i],x[i+1],y[i+1],r[i+1]);
			v.push_back(a.first);
			v.push_back(a.second);
			L.push_back(i);L.push_back(i);
			line.push_back(a);
		}
		v.push_back(P(x[n-1],y[n-1]));
		L.push_back(n-1);
		for(int i=0;i<v.size();i++){
			for(int j=i+1;j<v.size();j++){
				int k;
				for(k=L[i]+1;k<L[j];k++){
					if(!intersecting(v[i],v[j],line[k].first,line[k].second))
						break;
				}
				if(k>=L[j])//間の交点間の線分全てと交差する
					d[i][j]=d[j][i]=dist(v[i],v[j]);
			}
		}
		
		for(int k=0;k<v.size();k++)
			for(int i=0;i<v.size();i++)
				for(int j=0;j<v.size();j++)
					d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
		printf("%.4f\n",d[0][v.size()-1]);
	}
	return 0;
}

Measured memory_bytes: 1688
// In God We Trust


# include <bits/stdc++.h>

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
#include <algorithm>


using namespace std;




signed main()
{
  long long n;
  cin >> n;
  long long ans = n / 10;
  long long backup = ans;
  
  while(backup)
    backup /= 5, ans += backup;
  
  if (n & 1)
    cout << 0;
  else
    cout << ans;
  
}


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

vector<int>graph[200005];
bool visited[200005];

int dfs(int i) {
	int count =1;
	visited[i] = true;
	for(auto child: graph[i]) {
		if(!visited[child]) {
			count+=dfs(child);	
		}
	}
	return count;
}

int main() {
	int n, m;
	cin>>n>>m;
	for(int i=0; i<m; i++) {
		int u, v;
		cin>>u>>v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	
	for(int i=0; i<200005; i++)
		visited[i] = false;
	
	int res = 0;
	for(int i=1; i<=n; i++) {
		if(!visited[i]) {
			res = max(res, dfs(i));
		}
	}
	
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 24124
#include <bits/stdc++.h>
using namespace std;
const int MAX = 30;
const int NIL = -1;

struct Node {int parent, left, right;};
struct Node T[MAX];
int n, D[MAX], H[MAX];

int getSibling(int u) {
  int p = T[u].parent;
  if (p == NIL) return NIL;
  if (u == T[p].left) return T[p].right;
  return T[p].left;
}

int getDegree(int u) {
  int ret = 0;
  if (T[u].left != NIL) ret++;
  if (T[u].right != NIL) ret++;
  return ret;
}

void setDeth(int u, int d) {
  D[u] = d;
  if (T[u].left != NIL) setDeth(T[u].left, d + 1);
  if (T[u].right != NIL) setDeth(T[u].right, d + 1);
}

int setHeight(int u) {
  int ret = NIL;
  if (T[u].left != NIL) ret = max(ret, setHeight(T[u].left));
  if (T[u].right != NIL) ret = max(ret, setHeight(T[u].right));
  if (ret == NIL) ret = 0;
  else ret++;
  H[u] = ret;
  return ret;
}

void print(int u) {
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "sibling = " << getSibling(u) << ", ";
  cout << "degree = " << getDegree(u) << ", ";
  cout << "depth = " << D[u] << ", ";
  cout << "height = " << H[u] << ", ";

  if (T[u].parent == NIL) cout << "root" << endl;
  else if (getDegree(u) == 0) cout << "leaf" << endl;
  else cout << "internal node" << endl;
}

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  for (int i = 0; i < n; i++) {
    int u, l, r;
    cin >> u >> l >> r;
    if (l != NIL) {
      T[u].left = l;
      T[l].parent = u;
    }
    if (r != NIL) {
      T[u].right = r;
      T[r].parent = u;
    }
  }

  int root = NIL;
  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      root = i;
      break;
    }
  }
  setDeth(root, 0);
  setHeight(root);

  for (int i = 0; i < n; i++) print(i);
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;
typedef pair<P, P> PP;
typedef pair<P, int> setP;


void solve()
{
	long long X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<long long> A(X);
	vector<long long> B(Y);
	vector<long long> C(Z);
	for (int i = 0; i < X; ++i)
	{
		cin >> A[i];
	}
	for (int i = 0; i < Y; ++i)
	{
		cin >> B[i];
	}
	for (int i = 0; i < Z; ++i)
	{
		cin >> C[i];
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	sort(B.begin(), B.end());
	reverse(B.begin(), B.end());
	sort(C.begin(), C.end());
	reverse(C.begin(), C.end());
	long long maxVal = A[0] + B[0] + C[0];

	priority_queue<PP> pque;
	pque.push(PP(P(maxVal, 0), P(0, 0)));
	int cnt = 0;
	set<setP> Set;
	Set.insert(setP(P(0, 0), 0));
	while (cnt < K)
	{
		PP pp = pque.top();
		pque.pop();
		cout << pp.first.first << endl;
		if (pp.first.second + 1 < X)
		{
			if (Set.find(setP(P(pp.first.second + 1, pp.second.first), pp.second.second)) == Set.end())
			{
				pque.push(PP(P(pp.first.first - (A[pp.first.second] - A[pp.first.second + 1]), pp.first.second + 1), P(pp.second.first, pp.second.second)));
				Set.insert(setP(P(pp.first.second + 1, pp.second.first), pp.second.second));
			}
		}
		if (pp.second.first + 1 < Y)
		{
			if (Set.find(setP(P(pp.first.second, pp.second.first + 1), pp.second.second)) == Set.end())
			{
				pque.push(PP(P(pp.first.first - (B[pp.second.first] - B[pp.second.first + 1]), pp.first.second), P(pp.second.first + 1, pp.second.second)));
				Set.insert(setP(P(pp.first.second, pp.second.first + 1), pp.second.second));
			}
		}
		if (pp.second.second + 1 < Z)
		{
			if (Set.find(setP(P(pp.first.second, pp.second.first), pp.second.second + 1)) == Set.end())
			{
				pque.push(PP(P(pp.first.first - (C[pp.second.second] - C[pp.second.second + 1]), pp.first.second), P(pp.second.first, pp.second.second + 1)));
				Set.insert(setP(P(pp.first.second, pp.second.first), pp.second.second + 1));
			}
		}
		++cnt;
	}
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long i64;
i64 p10[25],D,ans=0,ms[25],t1[25],t0[25];
i64 abs(i64 x){return x>0?x:-x;}
void dfs(int n,int w,i64 v,i64 c){
	if(abs(v)>ms[w])return;
	if(w==n/2){
		ans+=~n&1?10*c:c;
		return;
	}
	for(int i=-9;i<=9;++i){
		dfs(n,w-1,v-i*(p10[w]-p10[n-w]),c*(w==n?t1[i+9]:t0[i+9]));
	}
}
int main(){
	for(int i=0;i<=9;++i)
	for(int j=0;j<=9;++j){
		++t0[j-i+9];
		if(i)++t1[j-i+9];
	}
	p10[0]=1;
	for(int i=1;i<20;++i)p10[i]=p10[i-1]*10;
	scanf("%lld",&D);
	for(int i=1;i<=17;++i){
		for(int j=i;j>i/2;--j)ms[j]=(p10[j]-p10[i-j])*9;
		ms[i/2]=0;
		for(int j=i/2+1;j<=i;++j)ms[j]+=ms[j-1];
		dfs(i,i,D,1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
from math import floor
N = int(input())

def doit(tmp):
	xmin = tmp / 1.08
	xmax = (tmp + 1) / 1.08

	if floor(xmin) == xmin:
		return(int(xmin))
	if floor(xmax) == xmax:
		return(":(")
	else:
		if floor(xmin) == floor(xmax):
			return(":(")
		if floor(xmin) < floor(xmax):
			return(floor(xmax))

print(doit(N))

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

int main(){
    int N;
    cin >> N;
    vector<int> p;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    sort(p.begin(),p.end());
    int cost = 0;
    for(int i = 0; i < N-1; i++){
        cost += p[i];
    }
    cost += p[N-1] / 2;
    cout << cost << endl;
    
    return 0;
}

Measured memory_bytes: 512
def f():
 for c in range(n):
  for d in a[c+1:]:
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    if[d[p[0]],d[p[5]]]==a[c][::5]:
     f=[d[i]for i in p[1:5]]*2
     for k in range(4):
      if f[k:k+4]==a[c][1:5]:return"No"
 return"Yes"
n=int(input())
a=[input().split()for _ in[0]*n]
for b in a:b[3:5]=b[4],b[3]
print(f())


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int A[60],n;
const int MOD = 1e9+7;
long long ans;
int main(){
  cin >> n;
  for (int i = 0; i < n; i++){
  	long long a;
  	cin >> a;
  	for (int  j = 0; (1LL << j) <= a; j++)
  		if ((1LL << j) & a)
  		A[j]++;
  }
  for (int i = 0;i < 60; i++)
  ans = (ans + 1ll*A[i]*(n-A[i])%MOD*((1LL<<i)%MOD)%MOD)%MOD;
  cout << ans;
  return 0;
}

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

int main() {
    int L,R;
    cin >> L >> R;
    if((R - L) >= 2019){
        cout << 0 << endl;
        return 0;
    } 

    long long minval = 5000;
    for(int i=L;i<R;i++)
        for(int j=i+1;j<=R;j++){
            minval = min(minval, ((long long)i*(long long)j)%2019);
        }
    
    cout << minval << endl;
    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int cnt=0;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        if(h >= k) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,i;
  scanf("%d %d", &a, &b);
  
  if(a <= b){
    for(i=0;i<b;i++) printf("%d", a);
  }else{
    for(i=0;i<a;i++) printf("%d", b);
  }
}

Measured memory_bytes: 128