akhauriyash/Code-Regression huggingface dataset:
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aaa := getIntList(scanner)
	sums := make([]int64, n+2)
	for i := 0; i < n; i++ {
		sums[i+1] = sums[i] + int64(aaa[i])
	}
	sums[n+1] = sums[n]
	min := sums[n]
	for i := 3; i < n; i++ {
		l := 0
		r := i
		half := sums[i-1]
		for l < r {
			m := (l + r) / 2
			if sums[m]*2 < half {
				l = m + 1
				continue
			}
			r = m
		}
		forward := l
		if 1 < l && sums[l]*2-half > half-sums[l-1]*2 {
			forward--
		}
		l = i
		r = n + 1
		half = (sums[n] - sums[i-1])
		for l < r {
			m := (l + r) / 2
			if (sums[m]-sums[i-1])*2 < half {
				l = m + 1
				continue
			}
			r = m
		}
		back := l
		if i < l && (sums[l]-sums[i-1])*2-half > half-(sums[l-1]-sums[i-1])*2 {
			back--
		}
		ch := chokudai(forward, i, back, sums)
		if min > ch {
			min = ch
		}
	}
	fmt.Println(min)
}

func chokudai(forward int, center int, back int, sums []int64) int64 {
	l := make(SortBy, 4)
	l[0] = sums[forward]
	l[1] = sums[center-1] - sums[forward]
	l[2] = sums[back] - sums[center-1]
	l[3] = sums[len(sums)-1] - sums[back]
	sort.Sort(l)
	return l[3] - l[0]
}

type SortBy []int64

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


Measured memory_bytes: 24960
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int x;
	cin >> x;

	vector<Int> p{ 100,101,102,103,104,105 };
	vector<Int> dp(2e5);//dp[i]:i円を作れるなら1
	dp[0] = 1;

	for (Int i = 0; i < 1e5+1000; i++) {
		if (dp[i]==0) {
			continue;
		}
		for (Int j = 0; j < 6; j++) {
			dp[i + p[j]] = 1;
		}
	}

	if (dp[x]) {
		cout << 1 << "\n";
	}
	else {
		cout << 0 << "\n";
	}

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cins(int, n, x);
    auto y = x;
    Sort(y);
    
    for(auto e : x) Cout((e <= y[n/2-1]) ? y[n/2] : y[n/2-1]);
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
 
const int mod = 998244353;
const int mnx = 3e5 + 9;
 
int n;
ll a, b, m;
ll fac[mnx];
ll invfac[mnx];
 
ll getPow(ll x, ll y) {
    ll res = 1;
    while( y ) {
        if(y&1) res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}
 
ll getC(int x, int y) {
    return fac[x] * invfac[y] % mod * invfac[x - y] % mod;
}
 
int main() {
    cin >> n >> a >> b >> m;
    fac[0] = 1;
    for(int i=1; i<mnx; i++)
        fac[i] = fac[i - 1] * i % mod;
    invfac[mnx - 1] = getPow(fac[mnx - 1],mod - 2);
    for(int i=mnx-2; i>=0; i--) invfac[i] = invfac[i + 1] * (i + 1) % mod;
    ll ans = 0;
    for(int i=0; i<=n; i++)
        if(a * i <= m && (m - a * i) % b == 0 && (m - a * i) / b <= n) {
            int j = (m - a * i) / b;
            ans += (getC(n, i) % mod * getC(n, j) % mod) % mod;
            ans %= mod;
        }
    cout << ans << '\n';
}

Measured memory_bytes: 4992
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	k, x := nextInt(), nextInt()
	res := ""

	for i := x-k+1; i < x+k; i++ {
		res += strconv.Itoa(i)
		if i != x+k-1 {
			res += " "
		}
	}
	fmt.Println(res)
}

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

int main() {
  string a;
  cin >> a;
  int result = 700;
  for (int i = 0; i < a.size(); i++ ) {	
    if (a.at(i) == 'o') {
  	  result += 100;
    }
  }
  cout << result << endl;
}


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

int main() {

    string s;
    int k;
    cin >> s >> k;

    rep(i, min((size_t)k, s.length())){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }    
    }
    cout << "1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  Pi M_PI
using namespace std;
#define int long long
typedef complex <double> P;
double dot(P a,P b){return real(conj(a)*b);}
double cross(P a,P b){return imag(conj(a)*b);}
const double EPS  = 1e-8;

int ccw(P a,P b,P c){
  b-= a;
  c-=a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS ) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool check(P a,P t,double d,P h){
  if(abs(t-h) > abs(a)) return 0;
  h-=t;
  d/=2;
  d*= Pi/180;
  P A = a * P(cos(d),sin(d));
  P B = a * conj(P(cos(d),sin(d)));
  return ccw(P(0,0),A,h)!=1&&ccw(P(0,0),B,h)!=-1;
}

signed main(){
  while(1){
    int H,R;
    cin>>H>>R;
    if(!H&&!R)return 0;

    P house[101];
    for(int i=0;i<H;i++){
      double x,y;
      cin>>x>>y;
      house[i] = P(x,y);
    }

    int U,M,S;
    double du,dm,ds;
    cin>>U>>M>>S>>du>>dm>>ds;

    P UME[11],MO[11],SA[11];
    for(int i=0;i<U;i++){
      double x,y;
      cin>>x>>y;
      UME[i] = P(x,y);
    }

    for(int i=0;i<M;i++){
      double x,y;
      cin>>x>>y;
      MO[i] = P(x,y);
    }

    for(int i=0;i<S;i++){
      double x,y;
      cin>>x>>y;
      SA[i] = P(x,y);
    }

    int cnt[101]={};
    for(int i=0;i<R;i++){
      double w,d;
      cin>>w>>d;
      w*=Pi/180;
      P a = P(cos(w),sin(w))*d;
    
      for(int j=0;j<H;j++){
	bool flg = check(a,P(0,0),du,house[j]);
	for(int k=0;k<U;k++)flg &= !check(a,UME[k],du,house[j]);
	for(int k=0;k<M;k++)flg &= !check(a,MO[k],dm,house[j]);
	for(int k=0;k<S;k++)flg &= !check(a,SA[k],ds,house[j]);
	cnt[j] += flg;
      }
    }

    int mx = 0;
    for(int i=0;i<H;i++)mx = max(mx,cnt[i]);

    if(mx==0) {cout<<"NA"<<endl;continue;}

    int f=0;
    for(int i=0;i<H;i++){
      if(cnt[i] == mx) {
	if(f)cout<<" ";
	f = 1;
	cout<<i+1;
      }
    }
    cout<<endl;
  }
  
    
  return 0;
}

Measured memory_bytes: 3480
N = input()
n = N[len(N)-1]
if n =="2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n =="8":
    print("pon")
else:
    print("bon")



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

long long n;
vector<long long> a;

long long solve();
long long calc(int u, int d, int lef);

int main() {
  cin >> n;
  a.resize(n);
  for (auto& p : a) cin >> p;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  stack<long long> len, id;
  len.push(0);
  a.push_back(0);
  ++n;
  for (int i = 0; i < n; ++i) {
    int nextid = i;
    while (a[i] < len.top()) {
      nextid = id.top();
      res = max(res, len.top() * (i - id.top()));
      len.pop();
      id.pop();
    }
    if (a[i] > len.top()) {
      len.push(a[i]);
      id.push(nextid);
    }
  }
  return res;
}



Measured memory_bytes: 5308
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if (n == m) {
      System.out.println("Yes");
    } else { 
      System.out.println("No");
    } 
  }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main() {
	int N, M;
	int a[50], b[50];
	int count[51];
	cin >> N >> M;
	for (int i = 1; i <= 50; ++i) {
		count[i] = 0;
	}
	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i];
		count[a[i]]++;
		count[b[i]]++;
	}
	for (int i = 1; i <= N; ++i) {
		cout << count[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A=sc.nextInt();
    int B=sc.nextInt();
    int ans=0;
    int cnt=1;
    while(cnt<B) {
      cnt--;
      cnt+=A;
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
map<string, int> m;
int mx = 0;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
    mx = max(mx, m[s]);
  }
  for (pair<string, int> i : m) {
    if (i.second == mx) {
      cout << i.first << endl;
    }
  }
}

Measured memory_bytes: 23808
L, R = map(int, input().split())

if (R - L + 1) >= 2019:
    print(0)
else:
    ans = float("inf")
    for i in range(L, R + 1):
        for j in range(L, R + 1):
            if i == j:
                continue
            else:
                ans = min(ans, (i * j) % 2019)
    print(ans)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(void){
  int coin[18],dp[301]={0},n;

  for(int i=0;i<18;i++)coin[i]=i*i;

  dp[0]=1;

    for(int i=1;i<18;i++)
      for(int j=1;j<301;j++)
	if(j>=coin[i])dp[j]+=dp[j-coin[i]];

  while(cin >> n,n){
    cout << dp[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    ll d,x,y,ans=0;
    scanf("%d%lld",&n,&d);
    while(n--){
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d) ans++;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
vector<int>a;
vector<int>b;
vector<int>used;
int ans = 0;
int verp = 1;
int n, m;
void bfs(int x) {
	if (verp == n) {
		ans++;
		return;
	}
	for (int i = 0; i < m; ++i) {
		if (a[i] == x && used[b[i]] == 0) {
			used[b[i]] = 1;
			verp++;
			bfs(b[i]);
			used[b[i]] = 0;
			verp--;
		}
		else if (b[i] == x && used[a[i]] == 0) {
			used[a[i]] = 1;
			verp++;
			bfs(a[i]);
			used[a[i]] = 0;
			verp--;
		}
	}
	return;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int tmpa, tmpb;
		cin >> tmpa >> tmpb;
		tmpa--; tmpb--;
		a.push_back(tmpa);
		b.push_back(tmpb);
		used.push_back(0);
	}
	used[0] = 1;
	bfs(0);
	cout << ans << endl;
	return 0;
}

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


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


int main() {

    int k, x;
    cin >> k >> x;
    int ans = 500 * k;
    if(ans>=x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
li=[a,b,c]
li=sorted(li,reverse=True)

if(li[0]*2-li[1]-li[2])%2==0:
    ans=(li[0]*2-li[1]-li[2])//2
else:
    ans=(li[0]*2-li[1]-li[2])//2+2
print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

const ll mod = 1000000007;
//const ll mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1]=='<')s+='>';
    if(s[0]=='>')s='<'+s;
    ll len = s.size();
    ll l=1,r=1;
    ll ans = 0;
    rep(i,len-1){
        if(s[i]=='<'&&s[i+1]=='<'){
            l++;
        }   
        if(s[i]=='<'&&s[i+1]=='>'){
            ll j = 1;
            while(s[i+j]==s[i+j+1]&&i+j+1<len){
                r++;
                j++;
            }
            ll a = max(r,l);
            ll b = min(r,l);
            ans += a*(a+1)/2;
            ans += b*(b-1)/2;
            i=i+r;
            r=1;
            l=1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1412
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt64()
	a := nextInt64()
	b := nextInt64()
	var ans int64
	ans = (n / (a + b)) * a
	if n%(a+b) > a {
		ans += a
	} else {
		ans += n % (a + b)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int A, B;
  scanf("%d %d", &A, &B);

  int max=A+B;
  if (A-B>max) {
    max=A-B;
  }
  if (A*B>max) {
    max=A*B;
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 128
// C - Special Trains
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vector<tuple<int,int,int>> CSF;
	int c,s,f;
	rpz(i, N-1){
		cin>>c>>s>>f;
		CSF.emplace_back(c,s,f);
	}

	rpz(i, N-1){
		int ans = 0;
		tie(c,s,f) = CSF[i];
		ans = s + c;
		rp(j, i+1, N-1){
			int c2,s2,f2; tie(c2,s2,f2) = CSF[j];
			int ss = (ans + f2 - 1) / f2 * f2;
			ss = max(ss, s2);
			ans = ss + c2;
		}
		cout<< ans <<endl;
	}
	cout<< 0 <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <sstream>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    string s[n];
    map<string,int> ans;
    for(int i=0;i<n;i++){
        cin>>s[i];
        ans[s[i]]++;
    }

    cout<<"AC x "<<ans["AC"]<<endl;
    cout<<"WA x "<<ans["WA"]<<endl;
    cout<<"TLE x "<<ans["TLE"]<<endl;
    cout<<"RE x "<<ans["RE"]<<endl;
}

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

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<string>
#include<math.h>
#include<vector>

using namespace std;

typedef long long ll;
typedef pair<int,int> pa;

#define fst first 
#define snd second

const int maxn=1500005,maxm=2100;
const double pi=acos(-1.0);
const ll mod=1000000007;

int w,h,x,y;

int main()
{
	//ios_base::sync_with_stdio(false);
	int i,j,k;
	scanf("%d %d %d %d",&w,&h,&x,&y);
	double a=0.5*w*h;
	printf("%.9lf %d\n",a,(x*2==w&&y*2==h?1:0));
	return 0;
}

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

char map[100000];
int ans = 0;

int main() {
	cin >> map;
	for (int i = 0; i < 100000; i++) {
		if (map[i] != map[i + 1] && (map[i + 1] == 'W' || map[i + 1] == 'B'))ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    double r;
    cin >> r;
    double pi= 3.1415926535;
    cout << 2 * r * pi << endl;
    return 0;
}

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

int main()
{
	int k, a, b;
	cin >> k >> a >> b;

	/*for (int i = a; a <= b; i++)
	{
		if (i % k == 0 && i / k != 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}*/

	for (int i = 0; i <= 1000; i++)
	{
		if ((a <= (i * k)) && ((i * k) <= b))
		{
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int p[n];
    int ans = 0;
    rep(i, n) {
        cin >> p[i];
    }

    for(int i = 1; i <= n-2; i++) {
        if( (p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1]) ) {
            ans++;
        }
    }

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

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


int main(void){
    int dictionaly_size;
    while(true){
        cin >> dictionaly_size;
        if(dictionaly_size == 0){
            break;
        }
        map<char, char> change;
        for(int i = 0; i < dictionaly_size; i++){
            char key, value;
            cin >> key >> value;
            change[key] = value;    
        }

        int word_count;
        cin >> word_count;
        string words(word_count, ' ');
        //cout << words.size();
        
        char tmp;
        for( string::iterator itr = words.begin(); itr != words.end(); itr++){
            cin >> tmp;
            map<char, char>::iterator itr_m = change.find(tmp);
            if( itr_m != change.end() ){
             *itr = itr_m->second;
            }else{
                *itr = tmp;
            }

        }
        cout << words << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#define NIL -1
#define MAX 100
int s[MAX], h[MAX], r[MAX][MAX];
void G(int c, int v);
int main(){
  int i, j, n, c;

  scanf("%d", &n);
  for(i = 1; i <= n; i++){
    h[i] = 10000;
    for(j = 1; j <= n; j++){
      r[i][j] = 0;
    }
  }
  for (i = 1; i <= n; i++){
    scanf("%d", &c);
    scanf("%d", &s[c]);
    for(j = 1; j <= s[c]; j++){
      scanf("%d", &r[c][j]);
    }
  }
  G(1, 0);
  for(i = 1; i <= n; i++){
    if(h[i] == 10000){
      h[i] = NIL;
    }
    printf("%d %d", i, h[i]);
    puts("");
  }
  return 0;
}
void G(int c, int v){
  int i;
  h[c] = v;
  for (i = 1; i <= s[c]; i++){
    if (h[r[c][i]] > v){
      G(r[c][i], v + 1);
    }
  }
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scn = new Scanner(System.in);
    int a = scn.nextInt();
    int b = scn.nextInt();
    String s;
    if(a+b==15){
      s = "+";
    }else if(a*b==15){
      s = "*";
    }else{
      s = "x";
    }
    System.out.println(s);
  }
}


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

int count(int begin , int end){  
	return end - begin +1;
}
int main(){
  int s;
  cin >> s;
  int res=0;
  for (int i = 0; i < s; i++){		
    int beginNum,endNum;
    cin >>beginNum >> endNum;
 	int len =count(beginNum,endNum);
    res+=len;
  }
	cout <<res<<endl; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    */
	while (1) {
		int n; scanf("%d", &n); if (n == 0) break;
		vector<vector<int>> vs(n, vector<int>(5)); for (int i = 0; i < n; i++) for (int j = 0; j < 5; j++) scanf("%d", &vs[i][j]);
		int res = 0;
		while (1) {
			bool flag = true;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 3; j++) {
					if (vs[i][j] != -1 && vs[i][j] == vs[i][j + 1] && vs[i][j + 1] == vs[i][j + 2]) {
						if (j + 3 < 5 && vs[i][j + 2] == vs[i][j + 3]) {
							if (j + 4 < 5 && vs[i][j + 3] == vs[i][j + 4]) {
								for (int k = 0; k < 5; k++) res += vs[i][k], vs[i][k] = -1;
							}
							else {
								for (int k = 0; k < 4; k++) res += vs[i][j + k], vs[i][j + k] = -1;
							}
						}
						else {
							for (int k = 0; k < 3; k++) res += vs[i][j + k], vs[i][j + k] = -1;
						}
						flag = false;
					}
				}
			}
			if (flag) break;
			for (int j = 0; j < 5; j++) {
				for (int i = n - 1; i >= 0; i--) {
					if (vs[i][j] != -1) {
						for (int k = i; k < n - 1; k++) {
							if (vs[k + 1][j] == -1) {
								vs[k + 1][j] = vs[k][j];
								vs[k][j] = -1;
							}
						}
					}
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
	/*
		おまじないを使ったらscanfとprintf関連注意！！！！！！！！！！！！
	*/
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,ans;
  cin >> A;
  ans=0;

    if(A%9==0)
    {

      A=A/9;
    }
  else
  {
    if(A%8==0)
    {

      A=A/8;
    }
    else
    {
      if(A%6==0)
      {
        A=A/6;
      }
      else
      {
        if(A%4==0)
        {
          A=A/4;
        }
        else
        {
    if(A%2==0)
    {

      A=A/2;
    }
  else
  {
    if(A%3==0)
    {

      A=A/3;
    }   
    else
    {
    if(A%5==0)
    {

      A=A/5;
    }
      else
      {
    if(A%7==0)
    {

      A=A/7;
    }
      }
    }
  }
        }
      }
    }
  }
  if(A%9==0)
    {

      A=A/9;
    }
  else
  {
    if(A%8==0)
    {

      A=A/8;
    }
    else
    {
      if(A%6==0)
      {
        A=A/6;
      }
      else
      {
        if(A%4==0)
        {
          A=A/4;
        }
        else
        {
    if(A%2==0)
    {

      A=A/2;
    }
  else
  {
    if(A%3==0)
    {

      A=A/3;
    }   
    else
    {
    if(A%5==0)
    {

      A=A/5;
    }
      else
      {
    if(A%7==0)
    {

      A=A/7;
    }
      }
    }
  }
        }
      }
    }
  }
 
    if(A==1)ans=1;

  
  if(ans==1)cout << "Yes" << endl;
  if(ans==0)cout << "No" << endl;
}

Measured memory_bytes: 3640
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
tmp = 10000
for a_ in a:
    ans += b[a_ - 1]
    if tmp + 1 == a_:
        ans += c[a_ - 2]
    tmp = a_

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int[] dishes = new int[5];
    int sum = 0;
    int fraction = 0; //端数：fraction
    
    for (int i = 0; i < dishes.length; i++) {
        dishes[i] = sc.nextInt();
        sum += ceil(dishes[i]);
        fraction = Math.max(fraction, amari(dishes[i]));
    }
    System.out.println(sum - fraction);

  }
  
  public static int ceil(int src) {
      if ((src % 10) != 0) {
          return (src / 10 + 1) * 10;
      } else {
          return src;
      }
  }
  
  public static int amari(int src) {
      if ((src % 10) == 0) {
          return 0;
      } else {
          return 10 - src % 10;
      }
  }
  
}

Measured memory_bytes: 21712
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;

  lll x,k,d;

  cin >> x >> k >> d ;

  lll ret = 0;

  x = abs(x);
  

  lll prevNum;
  prevNum = abs(x) / d;
  //cout << "prevNum:" <<prevNum  << endl;

  if(prevNum >= k){
    //cout << "short" << endl;
    ret = x - (k * d);
  }
  else if((k - prevNum) % 2 == 0){
    ret = x - (d * prevNum);
  }
  else{
    ret = abs(x - (d * prevNum) - d);
  }
    


  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3544
def main():
    a,b,c,n=map(int,input().split())
    res = 0
    l = [a,b,c]
    l.sort()
    for i in range(n // l[2]+1):
        for j in range(n//l[1]+1):
            if n < l[2]*i+l[1]*j:
                break
            if (n - l[2] * i - l[1] * j ) % l[0] == 0:
                res += 1
    print(res)

main()

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

int main() {
  string s;
  cin >> s;
  bool flg = true;
  if(s[2] != s[3]){
    flg = false;
  }
  if(s[4] != s[5]){
    flg = false;
  }
  if(flg){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val arr = arrayOf(0,2,0,1,0,1,0,0,1,0,1,0)
    println(if (arr[a-1] == arr[b-1]) "Yes" else "No")
}




Measured memory_bytes: 29344
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
vector<vector<int> > nx_init(const string &str, char basis = 'a', int char_sz = 26) {
  int n = str.size();
  vector<vector<int> > nx(n, vector<int>(char_sz, n));
  nx[n - 1][str[n - 1] - basis] = n - 1;
  for (int i = n - 2; i >= 0; --i) {
    REP(j, char_sz) nx[i][j] = nx[i + 1][j];
    nx[i][str[i] - basis] = i;
  }
  return nx;
}

int main() {
  int n; cin >> n;
  string s; cin >> s;
  auto nx = nx_init(s, '0', 10);
  int ans = 0;
  REP(i, 10) REP(j, 10) REP(k, 10) {
    int pos = nx[0][i];
    if (pos >= n - 1) continue;
    pos = nx[pos + 1][j];
    if (pos >= n - 1) continue;
    pos = nx[pos + 1][k];
    if (pos < n) ++ans;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pb push_back
using namespace std;

int main(void){
  int n,a;
  cin>>n>>a;
  cout<<n*n-a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b; 
int main()
{
	cin>>a>>b;
	if(a>0)cout<<"Positive";
    else if(a==0||(a<0 && b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
	return 0;
}


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


int main() {
	int a, b;
	cin >> a >> b;
	char a1 = '0' + a, b1 = '0' + b;
	string s1 = "";
	string s2 = "";
	while(b-- > 0) {
		s1 += a1;
	}
	while(a-- > 0) {
		s2 += b1;
	}

	if(s1.compare(s2) < 0)
	cout<<s1;
	else if(s2.compare(s1) < 0) 
		cout<<s2;
	else
		cout<<s1;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

vector<bool> prime;
void primeinit(int N){
    if(N+1>prime.size()){
        prime.resize(N+1,true);
    } 
    prime[0] = false;
    prime[1] = false;
    for(int i=2; i*i<=N;i++) if(prime[i]) for(int j=2; i*j<=N;j++) prime[i*j]=false;
}

int main(void){
    int X;
    cin >> X;
    primeinit(200000);
    for(int i=X;i<=200000;i++){
        if(prime[i]){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import numpy as np

N, L = [int(i) for i in input().split()]

t = np.zeros(2)
t[0] = L
t[1] = L+N-1
sum_all = (2*L+N-1)*N/2


if t[0]*t[1] <= 0:
	print(int(sum_all))
else:
	print(int(sum_all-t[np.argmin(np.abs(t))]))


Measured memory_bytes: 20508
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
pair< V<>, V< pair<int, int> > > lowlink(const VV<>& g, V<>& ord, V<>& low, int r = 0) {
  int n = g.size();
  ord.assign(n, -1); // pre-order
  low.assign(n, -1); // 後退辺を高々1回通って到達できる頂点のordのmin
  V<> articulation_points;
  V< pair<int, int> > bridges;
  int t = 0;
  auto dfs = [&](const auto& dfs, int v, int p) -> void {
    ord[v] = low[v] = t++;
    int d = 0;
    bool f = false;
    for (int w : g[v]) if (w != p) {
      if (ord[w] == -1) {
        dfs(dfs, w, v);
        low[v] = min(low[v], low[w]);
        f |= ord[v] <= low[w];
        if (ord[v] < low[w]) bridges.emplace_back(minmax(v, w));
        ++d;
      } else {
        low[v] = min(low[v], ord[w]);
      }
    }
    if (v == r and d >= 2 or v != r and f) {
      articulation_points.push_back(v);
    }
  };
  dfs(dfs, r, -1);
  sort(begin(articulation_points), end(articulation_points));
  sort(begin(bridges), end(bridges));
  return {articulation_points, bridges};
}
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VV<> g(n);
  while (m--) {
    int s, t; cin >> s >> t;
    g[s].push_back(t);
    g[t].push_back(s);
  }
  V<> ord, low;
  for (int v : lowlink(g, ord, low).first) {
    cout << v << '\n';
  }
}


Measured memory_bytes: 4620
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int x;
  cin >> x;
  for (int i = 0; i < 10011; i++) {
    if (100 * i <= x && x <= 100 * i + 5 * i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	vector<int> dp(n,INT_MAX);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	dp[0] = 0;
	for (int i = 1; i < n; i++)
		for (int j = i - 1; j >= max(i - k, 0); j--)
			dp[i] = min(dp[i], dp[j] + abs(v[i] - v[j]));
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, d;
    cin >> n >> d;
    if (n % ((2 * d) + 1) == 0) {
        cout << n / ((2 * d) + 1) << endl;
    }
    else {
        cout << n / ((2 * d) + 1) + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Nmax 100008
ll n,m,x,y ,k,e,r,a,b,nb,q,c,test;
ll t[Nmax], bi[Nmax]  ;
long double h,l;
string s , s1 ;

int main()
{
    cin>> n>> k>> q ;
    int t[n] ; for(int i = 0 ; i<n ; i++) t[i] = k ;
    for(int i= 0 ; i<q ; i++ ){
        cin>> x ;
        bi[x-1]++ ;
    }
    for(int j = 0 ; j<n ; j++) {
            if (t[j]-q+bi[j]>0) cout << "Yes" ;
            else cout<< "No" ; cout <<endl ;
        }
}


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

long long calc(string s){
  long long val = stoll(s);
  for(int i=1;i<s.length();i++){
    string sf = s.substr(0,i);
    val += stoll(sf)*pow(2,(s.length()-i-1));
    string ss = s.substr(i,s.length()-1);
    val += calc(ss);
  }
  return val;
}

int main()
{
  string s;
  cin >> s;
  cout << calc(s) << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<lint, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 100005;

int n, m, k;
lint dp[305][MAXN];
int a[MAXN];

int main(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	for(int i=1; i<=k; i++){
		deque<pi> dq;
		dp[i][0] = -1e18;
		for(int j=1; j<=n; j++){
			while(!dq.empty() && dq.front().second < j - m){
				dq.pop_front();
			}
			while(!dq.empty() && dq.back().first < dp[i-1][j-1]){
				dq.pop_back();
			}
			dq.push_back(pi(dp[i-1][j-1], j-1));
			dp[i][j] = dq.front().first + 1ll * a[j] * i;
		}
	}
	cout << *max_element(dp[k], dp[k] + n + 1) << endl;
}


Measured memory_bytes: 237200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        if ( num < 1 || num > 100) {
            System.exit(-1);
        }
        System.out.println(num * (num + 1) / 2);
    }
}

Measured memory_bytes: 9552
from itertools import *
from heapq import *

def comp(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

def comp3(a,b,c):
  return 

def comp3(i,j,k,a,b,c):
  m = max(i,j,k)
  n = min(i+len(a),j+len(b),k+len(c))
  return all(len({x,y,z}-{"?"}) <= 1 for x,y,z in zip(a[m-i:n-i],b[m-j:n-j],c[m-k:n-k]))

def _merge_mid(a,b):
  la, lb = map(len,[a,b])
  for i in range(la-lb+1):
    if comp(a[i:],b):
      yield i

def merge_mid(a,b):
  return list(_merge_mid(a,b))

def _merge_right(a,b):
  la, lb = map(len,[a,b])
  for i in range(max(la-lb+1, 1),la):
    if comp(b, a[i-la:]):
      yield i
  yield la

def merge_right(a,b):
  return list(_merge_right(a,b))

class K(int):
  def __new__(cls, *args, **kwargs):
    cb = kwargs.pop("cb")
    i = int.__new__(cls, *args, **kwargs)
    i.cb = cb
    return i

def min_merge(a,b,c):
  keys = sorted([a,b,c],key=len,reverse=True)
  len_keys = list(map(len, keys))
  mid = {(i,j):merge_mid(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  right = {(i,j):merge_right(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  
  for i in mid[0,1]:
    for j in mid[0,2]:
      if j+len_keys[2] <= i or i+len_keys[2] <= j or (j-i in mid[1,2] or j-i in right[1,2] or i-j in right[2,1]):
        return len_keys[0]
  
  def candicates(a,b,c):
    return chain(
      (K(i+len_keys[b], cb=lambda:(
       (mid[a,c] and mid[a,c][0]+len_keys[c] <= i) or (mid[b,c] and len_keys[a] <= i+mid[b,c][-1]) or 
       any((i-j in right[c,b] if i>j else j-i in mid[b,c]) and comp3(0,i,j,keys[a],keys[b],keys[c]) for j in dropwhile((i-len_keys[c]).__gt__, mid[a,c]+right[a,c]))
      )) for i in dropwhile((len_keys[c]-len_keys[b]+1).__gt__, right[a,b])),
      (K(min(i+next(dropwhile((len_keys[a]-i+1).__gt__, y))+len_keys[b] for i in x), cb=lambda:True) for (x, y) in [sorted((right[a,c], right[c,b]), key=len)]),
    )
  
  can = merge(*(candicates(x,y,z) for x,y,z in permutations(range(3),3)))
  
  for k in can:
    if k.cb():
      return k
  
  return sum(len_keys)

a=input()
b=input()
c=input()

print(min_merge(a,b,c))



Measured memory_bytes: 3376
#include <iostream>

using namespace std;

int main(void){
    int a,b,i;
    long ca,cb;
    cin >> a >> b;
    ca=a;
    cb=b;
    for(i=b;i>1;i--)
        ca=ca*10+a;
    for(i=a;i>1;i--)
        cb=cb*10+b;
    if(ca>cb)
        cout << ca;
    else
        cout << cb;
    
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, L; cin >> N >> L;
    int sum = 0;
    rep(i, N) sum += L + i;
    int tmp = INF, aji = 0;
    rep(i, N) {
        if (abs(L+i) < tmp) {
            tmp = abs(L+i);
            aji = L+i;
        }
    }
    cout << sum - aji << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(X,Y):
  if X < Y:
    tmp = X
    X = Y
    Y = tmp
  if Y == 0:
    return 0
  while X % Y != 0:
    r = X % Y
    X = Y
    Y = r
  return Y
T = int(raw_input())
Q = [map(int, raw_input().split()) for _ in range(T)]
for q in Q:
  A,B,C,D = q
  if B > A:
    print 'No'
  elif B > D:
    print 'No'
  elif B <= C:
    print 'Yes'
  else:
    A = A%B
    D = D%B
    g = gcd(B,D)
    maximum = A if g == 0 else B-g+A%g
    if maximum > C:
      print 'No'
    else:
      print 'Yes'
     


Measured memory_bytes: 2692
scr = []
for x in range(51):
    scr.append(list(map(int, input().split())))
    if scr[x][0] == -1 and scr[x][1] == -1 and scr[x][2] == -1:
        break
ans = []

for x in range(len(scr)-1):
    if scr[x][0] == -1 or scr[x][1] == -1:
        ans.append("F")
    elif scr[x][0] + scr[x][1] >= 80:
        ans.append("A")
    elif scr[x][0] + scr[x][1] >= 65:
        ans.append("B")
    elif scr[x][0] + scr[x][1] >= 50:
        ans.append("C")
    elif scr[x][0] + scr[x][1] >= 30 and scr[x][2] >= 50:
        ans.append("C")
    elif scr[x][0] + scr[x][1] >= 30 and scr[x][2] < 50:
        ans.append("D")
    elif scr[x][0] + scr[x][1] < 30:
        ans.append("F")

for x in range(len(ans)):
    print(ans[x])



Measured memory_bytes: 5608
n = int(input())
a = list(map(int, input().split()))

dup = sum(a) - n * (n + 1) // 2
d1 = a.index(dup)
d2 = a.index(dup, d1 + 1)

N = n + 1
Ndup = d1 + n - d2

MOD = 10 ** 9 + 7

def power(x, n):
    ans = 1
    while n:
        if n % 2 == 1:
            ans = (ans * x) % MOD
        x = (x * x) % MOD
        n //= 2
    return ans

# fack[k]: kの階乗
fact = [0 for i in range(N + 1)]
fact[0] = 1
for i in range(1, N + 1):
    fact[i] = (fact[i - 1] * i) % MOD

# inv[k]: kの階乗の逆元
inv = [0 for i in range(N + 1)]
inv[N] = power(fact[N], MOD - 2) % MOD
for i in range(N - 1, -1, -1):
    inv[i] = (inv[i + 1] * (i + 1)) % MOD

def comb(n, r):
    if n < r:
        return 0
    else:
        return (fact[n] * inv[n - r] * inv[r]) % MOD

for k in range(1, N + 1):
    C = comb(N, k)
    Cdup = comb(Ndup, k - 1)
    print((C - Cdup) % MOD)


Measured memory_bytes: 16484
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, K, c;
    string s;
    cin >> n >> K >> c >> s;
    int L[K], R[K];
    for(int i=0, cur=0; cur<K;){
        if(s[i] == 'x') ++i;
        else{
            L[cur++] = i;
            i += c+1;
        }
    }
    for(int i=n-1, cur=K-1; cur>=0;){
        if(s[i] == 'x') --i;
        else{
            R[cur--] = i;
            i -= c+1;
        }
    }
    rep(i, K)if(L[i] == R[i]) printf("%d\n", L[i]+1);
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    string A; 
    cin>>A;
    vl alph(26, 0);
    long all = A.size() * (A.size()- 1) / 2;
    REP(i, 0, A.size()){
        alph[A[i] - 'a']++;
    }
    long ans = all;
    REP(i, 0, 26){
        ans -= alph[i] * (alph[i] - 1) /2;
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
	int x[2];
	cin >> x[0] >> x[1];
	int idx[2];

	for(int i = 0; i<2; i++){
		if(x[i] == 2) idx[i] = 3;
		else if(x[i] == 4 || x[i] == 6 || x[i] ==  9 || x[i] == 11) idx[i] = 2;
		else idx[i] = 1;
	}

	cout << ((idx[0] == idx[1])? "Yes" : "No") << endl;
	
	return 0;
}

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

int main(){
	ll a,b,c;
	scanf("%I64d%I64d%I64d",&a,&b,&c);
	if(a%2==0 || b%2==0 || c%2==0){
		puts("0");
	}else{
		printf("%lld\n",min(a*b,min(b*c,a*c)));
	}
	return 0;
} 

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

int main(void) {
    string S;cin>>S;
    if (S[0] == '1') cout << 9;
    else cout << 1;
    if (S[1] == '1') cout << 9;
    else cout << 1;
    if (S[2] == '1') cout << 9;
    else cout << 1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if((A-B)>=C){cout << 0 <<endl;}
  if((A-B)<C){cout << C-(A-B) << endl;}
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,k; cin  >>n>>k;
   for(ll i=0;i<n+1;i++){
     for(ll j=0;j<n+1;j++){
       if(i+j<=n&&i*10000+j*5000+(n-i-j)*1000==k){
         cout <<i<<" "<<j<<" "<<n-i-j<<endl;
         return 0;
       }
     }
   }
  cout <<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner scanner = new Scanner(System.in);

		String temp = scanner.nextLine();
		int s = 0;

		for(int i = 0; i < temp.length();i++) {

			String t = String.valueOf(temp.charAt(i));
			s += Integer.parseInt(t);

		}

		if(Integer.parseInt(temp) % s == 0) {

			System.out.println("Yes");

		}else {

			System.out.println("No");

		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define N (1000010)
using namespace std;
long long n,a[N];
int main()
{
	cin>>n;
	for (int i=1; i<=n; ++i)
		cin>>a[i],a[i]-=i;
	sort(a+1,a+n+1);
	int mid=(1+n)>>1;
	if (n%2)
	{
		long long ans=0;
		for (int i=1; i<=n; ++i)
			ans+=abs(a[i]-a[mid]);
		cout<<ans;
		return 0;
	}
	else
	{
		long long x=a[mid],y=a[mid+1];
		long long z=(x+y)/2;
		long long ans=0;
		for (int i=1; i<=n; ++i)
			ans+=abs(a[i]-z);
		cout<<ans;
	}
	
}

Measured memory_bytes: 1792