akhauriyash/Code-Regression huggingface dataset:
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        y: i64,
    }
    for i10000 in 0..n + 1 {
        for i5000 in 0..(n - i10000) + 1 {
            let i1000 = n - i10000 - i5000;
            if i1000 < 0 {
                continue;
            }
            if i10000 * 10000 + i5000 * 5000 + i1000 * 1000 == y {
                println!("{} {} {}", i10000, i5000, i1000);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>

template <typename T>
void in(T& x) {
    std::cin >> x;
}

template <typename T>
void out(const T H) {
    std::cout << (H);
}

template <typename T1, typename... T2>
void out(const T1 H, const T2... T) {
    std::cout << (H) << " "; out(T...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& v) {
    return os << v.first << " " << v.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    int n = (int) v.size();
    for (int i = 0; i < n - 1; ++i) os << v[i] << ' ';
    return os << v[n - 1];
}

template <typename T>
void eout(const char *s, const T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, const T1 H, const T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define err(args...)      eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()
#define lla(v)            (v).rbegin(), (v).rend()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

const int INF           = 2147483647;
const long long int LNF = 9223372036854775807LL;

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N  = 505050;
const int MD = 1000*1000*1000 + 7;

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

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}

int solve() {
    inn(n);
    std::unordered_map<std::string, int> m;
    ll ans = 0;
    rep(i, n) {
        std::string s; in(s);
        std::sort(all(s));
        ans += m[s];
        ++m[s];
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
int main()
{ 
long long int n,k=0,count=0;
cin>>n;
vector<int>v;
vector<int>v1;
while(n--){
    int x,y;
    cin>>x>>y;
    v.push_back(x);
    v1.push_back(y);
    if(count>=3)
    k=1;
    if(x==y){
        count++;
    }
    else{
        count=0;
    }
}
if(count>=3)
k=1;
if(k){
cout<<"Yes";
}

else{
cout<<"No";
}
}

Measured memory_bytes: 3632
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int flag[1000005];

const int M = 1000000;
void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    int g = 0;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        g = gcd(g, a[i]);
    }
    if (g != 1) {
        printf("not coprime\n"); return;
    }

    vector<vector<int> >  z(M+1);
    for (i = 2; i <= M; i++) {
        int j = i;
        while (j <= M) {
            z[j].push_back(i);
            j += i;
        }
    }

    for (i = 0; i < n; i++) {
        if (a[i]) {
            int k;
            for (k = 0; k < (int)z[a[i]].size(); k++) {
                int tmp=z[a[i]][k];
                if (flag[tmp]) {
                    printf("setwise coprime\n"); return;
                }
                flag[tmp] = 1;
            }
        }
    }
    printf("pairwise coprime\n");
    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 117440
def parent(i):
    return i // 2


def left(i):
    return 2 * i


def right(i):
    return 2 * i + 1


H = int(input())
A = [None] * (H + 1)

_ = list(map(int, input().split()))
A[1:] = _

for i in range(1, H+1):
    output = 'node {}: key = {}, '.format(i, A[i])

    if parent(i) != 0:
        output += 'parent key = {}, '.format(A[parent(i)])

    if left(i) <= H:
        output += 'left key = {}, '.format(A[left(i)])

    if right(i) <= H:
        output += 'right key = {}, '.format(A[right(i)])

    print(output)



Measured memory_bytes: 5628
package main

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

func main() {
	sc := NewScanner()

	a := float64(sc.ReadInt())
	b := float64(sc.ReadInt())
	h := sc.ReadInt()
	m := sc.ReadInt()

	minutes := (float64)(60*h + m)

	theta := math.Remainder((11.0/360)*minutes, 60) * math.Pi

	c := math.Sqrt(a*a + b*b - 2.0*a*b*math.Cos(theta))

	fmt.Println(c)
}

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

// *   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: 1756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    while(1){
        int n; cin >> n;
        if(n==0) break;
        vector<int> v(n);
        ll sum=0;
        for(int i=0;i<n;i++){
            cin >> v[i];
            sum+=v[i];
        }
        double ave=(double)sum/n;
        int cnt=0;
        for(int i=0;i<n;i++){
            if(v[i]<=ave) cnt++;
        }
        cout << cnt << endl;
    }

}


Measured memory_bytes: 3116
A = int(input())  # 500円玉の枚数
B = int(input())  # 100円玉の枚数
C = int(input())  # 50円玉の枚数
X = int(input())  # 合計X円にしたい

ans = 0
for a in range(min(A+1, X//500+1)):
    x = X - 500 * a
    for b in range(min(B+1, X//100+1)):
        xx = x - 100 * b
        if (xx/50).is_integer() and xx//50 <= C and xx//50 >= 0:
            ans += 1
            
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int X, K;
	cin >> X >> K;
	if (X * 500 >= K) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define long long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;
int n,x,a[200010],ok[200010];
void input()
{
    cin>>n>>x;
}

void solve()
{
	if (x==1 or x== 2*n-1)
	{
		cout<<"No"; return;
	}

    a[n]= x; a[n-1]= x-1; a[n+1]= x+1;
    if (n>2)
	{
		if (x!= 2) a[n-2]= x-2;
		else a[n-2]= x+2;
	}

    up(i,n-2,n+1) ok[a[i]]= 1;
    int cur= 1;
    up(i,1,2*n-1)
     if (!a[i])
	 {
	 	while (ok[cur]) cur++;
	 	a[i]= cur; ok[cur]= 1;
	 }
	 cout<<"Yes"<<endl;
	 up(i,1,2*n-1) cout<<a[i]<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive

    #ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
	  #endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 3072
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define debug(x) cout
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size)
#define all(x) x.begin(),x.end()
#define rep(i,a,n) for (int i=(a);i<(n);++i)
#define per(i,a,n) for (int i=(n)-1;i>=(a);--i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
inline ll read() {
  ll x=0, f=1; char ch=getchar();
  while (ch<'0'||ch>'9') f=(ch=='-')?-1:1, ch=getchar();
  while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0', ch=getchar();
  return x*f;
}
inline void fileio() {
  freopen("t.in","r",stdin);
  //freopen("t.out","w",stdout);
}
//Produced By MiracleEEEE
//head
const int N=1e5+5;
int cnt[N];
int mx,n;
int a[N];
int main()
{
  scanf("%d",&n);
	int cnt=0;
	rep(i,1,n+1) a[i]=read();
	rep(i,1,n+1) {
		if (a[i]==i) {
			swap(a[i],a[i+1]);
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 512
A, B, C = sorted(list(map(int, input().split())))

d = C - B
A += d
B += d


if (B - A) % 2 == 0:
    ans = d + (B - A) // 2
else:
    ans = d + (B - A + 1) // 2 + 1
print(ans)

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K & 1) {
    ll nA = B + C;
    ll nB = A + C;
    cout << nA - nB << endl;
  } else {
    cout << A - B << endl;
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=1e5+5;
int nxt[N][26],pos[26];
char s[N],t[N];
int main() {
    scanf("%s%s",s+1,t);
    int n=strlen(s+1);
    int m=strlen(t);
    for(int j=0;j<26;j++) pos[j]=n+1;
    for(int i=n;~i;i--) {
        for(int j=0;j<26;j++) nxt[i][j]=pos[j];
        if(i) pos[s[i]-'a']=i;
    }
    long long ans=0;int p=0;
    for(int i=0;i<m;i++) {
        int v=t[i]-'a';
        if(nxt[p][v]<=n) {
            ans+=nxt[p][v]-p;
            p=nxt[p][v];
        }
        else {
            ans+=n-p;
            p=0;
            if(nxt[p][v]>n) return !printf("-1");
            ans+=nxt[p][v]-p;
            p=nxt[p][v];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 10624
#include<stdio.h>
 
int main()
{
  char str[6];
  int flag = 0;
  
  scanf("%s", str);
  
  if(str[2] == str[3] && str[4] == str[5])
  {
    flag = 1;
  }
  
  if(flag == 1)
    printf("Yes\n");
  
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    T operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class U>
class Input<vector<U>> {
public:
    vector<U> operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    vector<U> operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class T>
T input() {
    Input<T> i{};
    return i();
}

using ll = long long;
using ull = unsigned long long;

int main() {
    auto n = input<size_t>();
    auto s = input<string>();
    size_t c = 0;
    for (size_t i = 0; i < 1000; ++i) {
        auto a = to_string(i);
        while (a.size() < 3)
            a.insert(begin(a), '0');
        size_t b = 0;
        for (size_t j = 0; j < s.size(); ++j) {
            if (s[j] == a[b])
                ++b;
            if (b == a.size())
                break;
        }
        if (b == a.size())
            ++c;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();

		Map<Integer, List<String>> map = new HashMap<>();

		for (int i=0; i < M; i++) {
			int p = scan.nextInt();
			String S = scan.nextLine();
			List<String> tmpL = map.get(p);
			if (tmpL == null) {
				tmpL = new ArrayList<>();
			}
			tmpL.add(S);
			map.put(p, tmpL);
		}

		int acCnt = 0;
		int waCnt = 0;
		for (int p : map.keySet()) {
			int tmpWaCnt = 0;
			List<String> tmpL = map.get(p);
			for (String str : tmpL) {
				if (str.trim().equals("AC")) {
					acCnt++;
					waCnt += tmpWaCnt;
					break;
				}
				else if (str.trim().equals("WA")) {
					tmpWaCnt++;
				}
			}
		}
		System.out.println(acCnt + " " + waCnt);
	}
}


Measured memory_bytes: 170108
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

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

    if (b < a) swap(a, b); //! make sure a <= b
    string ans;
    rep(i, b) {
        ans += to_string(a);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){
	int N;
	scanf("%d", &N);
	if (N < 1000){
		printf("ABC\n");
	}
	else{
		printf("ABD\n");
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  ll N,D;
  cin>>N>>D;
  int A[N][D];
  rep(i,N) rep(j,D) cin>>A[i][j];
  int B[150]={};
  rep(i,150) B[i]=i*i;
  ll ans=0;
  rep(i,N) rep(j,N){
    if(i!=j){
      ll dis=0;
      rep(k,D) dis+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
      rep(k,150) if(dis==B[k]) ans++;
    }
  }
  cout<<ans/2<<endl;
}

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

int main() {
  vector<char>raw(5);
  for(int i = 0;i<4;i++){
    cin >> raw.at(i);
  }
  if(raw.at(0)==raw.at(1) && raw.at(1)==raw.at(2))
    cout<<"Yes"<<endl;
  
  else if(raw.at(1)==raw.at(2) && raw.at(2)==raw.at(3))
    cout<<"Yes"<<endl;
  
  else
    cout<<"No"<<endl;
      
}


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

int sumofdigits(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }

  return sum;
}//各桁の和を計算する関数
 
int main() {
  
  int N,L,snake=0;

  cin >> N >> L;

  vector<string> S(N);

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

  sort(S.begin(),S.end());
  
  for(int i=0;i<N;i++){
    cout << S.at(i);
  }
 
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 256
N, M = (int(i) for i in input().split())
a = []
b = []
for i in range(N):
    data = list(input())
    a.append(data)
for i in range(M):
    data = list(input())
    b.append(data)

#N=4
#M=2
#a=[['a','s','a','s'],['a','a','s','s'],['s','a','a','s'],['s','a','a','a']]
#b=[['s','a'],['a','s']]

L = N-M

def check(i,j):
    ans=True
    for line in range(M):
        if (ans==False):
            break
        for row in range(M):
            if (a[i+line][j+row]!=b[line][row]):
                ans=False
                break
    return ans

ans=False
for i in range(L+1):
    if(ans==True):
        break
    for j in range(L+1):
        ansnow=check(i,j)
 #       print(ansnow,i,j)
        if(ansnow==True):
            ans=True
            break
if(ans==True):
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3064
while n = gets.to_i
  break if n == 0
  sum = Array.new(n+1) { Array.new(n+1,0) }
  ret = 0
  n.times do |i|
    mtx = gets.split("").map{|s| s == "."}
    (n+1).times do |j|
      sum[i][j+1] = mtx[j] ? [sum[i][j], sum[i-1][j], sum[i-1][j+1]].min + 1 : 0
    end
    ret = [ret,sum[i].max].max
  end
  p ret
end

Measured memory_bytes: 40368
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int h, w;
	cin >> h >> w;
	vs board(h);
	vvi data(h, vi(w, 0));
	rep(i, h) {
		cin >> board.at(i);
	}
	vi dx = { -1,0,1,-1,1,-1,0,1 };
	vi dy = { -1,-1,-1,0,0,1,1,1 };
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (board.at(i).at(j) == '#') {
				data.at(i).at(j) = -99;
				for (int k = 0; k < 8; k++) {
					if (!(i + dy.at(k) < 0 || i + dy.at(k) > h - 1 || j + dx.at(k) < 0 || j + dx.at(k) > w - 1)) {
						data.at(i + dy.at(k)).at(j + dx.at(k))++;
					}
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (data.at(i).at(j) < 0) {
				cout << "#";
			}
			else {
				cout << data.at(i).at(j);
			}
		}
		cout << endl;
	}
	return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// ouls
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, N);

  vector<i64> p(N + 10);
  reps(i, 1, N) {
    input(p[i]);
  }

  i64 res = 0;
  reps(i, 1, N - 1) {
    if (p[i] == i) {
      swap(p[i], p[i+1]);
      ++res;
    }
  }

  for (int i = N; i >= 1; --i) {
    if (p[i] == i) {
      swap(p[i], p[i-1]);
      ++res;
    }
  }

  outl(res);
  return 0;
}


Measured memory_bytes: 1024
A, B, C = map(int, input().split())
K = int(input())

cnt = 0
while A >= B:
    B *= 2
    cnt += 1
# print(A, B, C)
while B >= C:
    C *= 2
    cnt += 1
# print(A, B, C, cnt)
if cnt <= K:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9160
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
vector<vector<int>> tree;
vector<int> diff;
int n, q;


void f(int node, int prev = -1) {
    int base = prev == -1 ? 0 : diff[prev];
    diff[node] = base + diff[node];
    for (int c : tree[node]) {
        if (c == prev) continue;
        f(c, node);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    tree = vector<vector<int>>(n, vector<int>());
    diff = vector<int>(n, 0);
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    REP(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        diff[p] += x;
    }
    f(0);
    REP(i, n - 1) {
        cout << diff[i] << " ";
    }
    cout << diff[n - 1] << endl;
}


Measured memory_bytes: 23552
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

bool dfs(vector<vector<char>>&cam, int s, int t) {
	int size = cam.size();
	int size1 = cam[s].size();
	int count = 0;
	for (int i = max(0, s - 1); 
		i< min(s + 2, size); i++) {
		if (cam[i][t] == '#') {
			count++;
		}
	}
	for (int i = max(t - 1, 0);
		i< min(t + 2,size); i++) {
		if (cam[s][i] == '#'&&i!=t) {
			count++;
		}
	}
	if (count >= 2) {
		return true;
	}
	else {
		return false;
	}
}
int main() {
	int n;
	cin >> n;
	int ans = 1e9;
	rep(i, n + 1) {
		int t = i;
		int cc = 0;
		while (t > 0) {
			cc += t % 6;
			t /= 6;
		}
		t = n - i;
		while (t > 0) {
			cc += t % 9;
			t /= 9;
		}
		ans = min(ans, cc);

	}
	cout << ans << endl;


}

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

int N;
const int MAX_N = 2.0e5 + 10;
int A[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int plus[N];
    int minus[N];
    for (int i = 0; i < N; i++) {
        plus[i] = (i+1) + A[i];
        minus[i] = (i+1) - A[i]; 
    }

    map<int, ll> mp_p;
    map<int, ll> mp_m;
    for (int i = 0; i < N; i++) {
        mp_p[plus[i]]++;
        mp_m[minus[i]]++;
    }

    ll ans = 0;
    for (auto itr = mp_p.begin(); itr != mp_p.end(); itr++) {
        int key = itr->first;
        ll val_p = itr->second;
        ll val_m = mp_m[key];
        ans += val_p * val_m;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 40240
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  const N = Number(inp.shift())
  inp = inp.map(r => r.split(' ').map(n => Number(n)))

  let sum = 0
  for (let i = 0; i < N; i++) {
    for (let j = 0; j < N; j++) {
      const x = Math.pow(inp[i][0] - inp[j][0], 2)
      const y = Math.pow(inp[i][1] - inp[j][1], 2)
      sum += Math.sqrt(x + y)
    }
  }
  console.log(sum / N / (N - 1) * (N - 1))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a>b)
        cout << "a > b" << endl;
    else if(a<b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3092
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] line1 = br.readLine().split(" ");
    int k = Integer.parseInt(line1[0]);
    int n = Integer.parseInt(line1[1]);
    
    String[] data = br.readLine().split(" ");
    int[] an = new int[n];
    for (int i=0; i<n; i++){
      an[i] = Integer.parseInt(data[i]);
    }
    int maxDistance = k-(an[n-1]-an[0]);
    for (int i=1; i<n; i++){
      int i1 = an[i] - an[i - 1];
      if (maxDistance< i1){
        maxDistance = i1;
      }
    }
    System.out.println(k-maxDistance);
  }
}


Measured memory_bytes: 49656
// atcoder/abc051/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    const int N = 100 + 3;
    int g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, 1 << 28);

    using E = struct {
      int src, dst, cost;
    };
    vector<E> es(m);
    each (e, es) {
      cin >> e.src >> e.dst >> e.cost;
      --e.src;
      --e.dst;
      g[e.src][e.dst] = g[e.dst][e.src] = e.cost;
    }

    for (int k = 0; k < N; ++k) {
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
          setmin(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }

    int cnt = 0;
    each (e, es) cnt += (g[e.src][e.dst] != e.cost);
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll>>      vpll;
typedef		vector<ll>      vll;


int main()
{
 //O_O ;
  string s;
  cin>>s;
  ll l=s.length();
  for(ll i=0;i<l;i++)
    cout<<"x";

    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

struct Edge {
  int dst;
  ll cost;
  Edge(int d, ll c) : dst(d), cost(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void dijkstra(int s, Graph& g, vector<ll>& dist) {
  using Info = pair<ll, int>;
  // init
  dist.assign(g.size(), INFL);
  dist[s] = 0;
  priority_queue<Info, vector<Info>, greater<Info>> pq;
  pq.emplace(0, s);
  //
  // main
  while (!pq.empty()) {
    ll d = pq.top().first;
    int v = pq.top().second;
    pq.pop();
    if (dist[v] < d) continue;
    for (Edge e : g[v]) {
      if (dist[e.dst] > dist[v] + e.cost) {
        dist[e.dst] = dist[v] + e.cost;
        pq.emplace(dist[e.dst], e.dst);
      }
    }
  }
  //
}

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

  Graph g(n);
  int l, r;
  ll c;
  rep(i, 0, m) {
    cin >> l >> r >> c;
    --l, --r;
    g[l].emplace_back(r, c);
  }
  rep(i, 0, n - 1) { g[i + 1].emplace_back(i, 0); }
  vector<ll> dist;
  dijkstra(0, g, dist);
  if (dist[n - 1] == INFL)
    cout << -1;
  else
    cout << dist[n - 1];
  return 0;
}


Measured memory_bytes: 12104
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


s = int(input())
nums = [s]
while True:
    s = f(s)
    if s in nums:
        print(len(nums) + 1)
        break
    else:
        nums.append(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    double a, b;
  	cin >> a >> b;
    int answer = -1;
    int answerbegin = (int)(a/0.08 +0.9);
    int answerend = (int)((a+1)/0.08 +0.9);
    bool br = false;
    for(int i=answerbegin; i<answerend; i++){
        for(int j=0; j<10; j++){
            if( i==(10*b+j) ){
                answer = i;
                br = true;
                break;
            }
        }
        if(br) break;
    }
    cout << answer;

}

Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>

using namespace std;
#define ll long long
#define REP(i,e,s) for(register ll i=e; i<=s; i++)
#define DREP(i,e,s) for(register ll i=e; i>=s; i--)
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define int ll

int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=400+10,MOD=1e9+7;

int a[MAXN],b[MAXN],_pow[MAXN][MAXN],sum[MAXN][MAXN],f[MAXN][MAXN];

signed main() {
	int n=read(),c=read();
	REP(i,1,n) a[i]=read();
	REP(i,1,n) b[i]=read();
	
	REP(i,1,400) {
		_pow[i][0]=1;
		REP(j,1,400) _pow[i][j]=(_pow[i][j-1]*i)%MOD;
	}

	REP(i,1,400) REP(j,0,400) sum[i][j]=(sum[i][j]+sum[i-1][j]+_pow[i][j])%MOD;
	f[0][0]=1;	
	REP(i,1,n) REP(j,0,c) REP(k,0,j) f[i][j]=(f[i][j]+f[i-1][j-k]*(sum[b[i]][k]-sum[a[i]-1][k]+MOD)%MOD)%MOD;
	
	printf("%lld",f[n][c]);
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,y=0;
	cin>>a>>b;
	if(a%3==0)
	y++;
	if(b%3==0)
	y++;
	if((a+b)%3==0)
	y++;
	if(y==0)
	cout<<"Impossible"<<endl;
	else
	cout<<"Possible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    set<char> st;
    rep(i,0,3)st.insert(s[i]);
    if(st.size()==1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 200100

ll n;
ll a[MAX],b[MAX];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	For(i,0,n) cin>>a[i];
	For(i,0,n) cin>>b[i];
	
	priority_queue<pii> rem;
	For(i,0,n){
		if(a[i]>b[i]){
			cout<<-1<<endl;
			return 0;
		}else if(b[i]>a[i]) rem.push({b[i],i});
	}

	ll ans = 0;

	while(rem.size()>0){
		ll i = rem.top().se;rem.pop();
		ll x = (i-1+n)%n , y = (i+1)%n;
		ll k = (b[i]-a[i])/(b[x]+b[y]);

		if(k==0){
			cout<<-1<<endl;return 0;
		}

		b[i] -= k*(b[x]+b[y]);

		if(a[i]>b[i]){
			cout<<-1<<endl;
			return 0;
		}else if(b[i]>a[i]) rem.push({b[i],i});
		ans+=k;
	}

	cout<<ans<<endl;



























	
}

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

int main() {
  int n,m,buf;
  cin >>n;
  int t[n];
  for (int i=0;i<n;i++) {
    cin>>buf;
    t[i]=buf;
  }
  cin >> m;
  int p[m],x[m];
  for (int i=0;i<m;i++) {
    cin>>buf;
    p[i]=buf;
    cin>>buf;
    x[i]=buf;
  }
  int org_sum=0,d=0;
  for (int i=0;i<n;i++) org_sum+=t[i];
  for (int i=0;i<m;i++) {
    buf=p[i];
    d=t[buf-1] - x[i];
    cout << org_sum - d << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




















 
int main(){
    ll n, x;
    cin >> n >> x;
    ll cnt = 1, now = 0;
    REP(i, n){
        ll l;
        cin >> l;
        now += l;
        if(now <= x) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef int ll;
inline char gc(){
	static char buf[1<<14],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++;
}
inline ll read(ll &x){
	x=0;bool f=1;char c=gc();
	for(;!isdigit(c);c=gc()){if(c=='-')f^=1;if(c==-1)return-1;}
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);x=f?x:-x;
	return 1;
}
#define pc putchar
inline void wr(ll x){
	if(x<0)pc('-'),x=-x;
	if(x>9)wr(x/10);pc(x%10|48);
}
const ll N=1e5+10;
ll n,fa[N];
map<ll,ll>vis[N];
queue<pair<ll,ll> >Q;
set<ll>s[N];
inline ll fid(ll x){return fa[x]==x?x:fa[x]=fid(fa[x]);}
int main(){
	read(n);
	for (ll i=1,x,y;i<=2*n-2;++i){
		read(x),read(y);
		++vis[x][y],++vis[y][x];
		if (vis[x][y]==2) Q.push(make_pair(x,y));
		s[x].insert(y);
		s[y].insert(x);
	}
	for (ll i=1;i<=n;++i) fa[i]=i;
	while (!Q.empty()){
		pair<ll,ll>A=Q.front();Q.pop();
		ll x=fid(A.first),y=fid(A.second);
		if (x==y) continue;
		if (s[x].size()>s[y].size()) swap(x,y);
		s[x].erase(y);//s[y].erase(x);
		for (set<ll>::iterator it=s[x].begin();it!=s[x].end();++it){
			ll i=*it;
			s[i].erase(x);
			s[i].insert(y),s[y].insert(i);
			++vis[y][i],++vis[i][y];
			if (vis[y][i]==2) Q.push(make_pair(y,i));
		}
		s[x].clear();
		fa[x]=y;
	}
	for (ll i=1;i<=n;++i) if (fid(i)!=fid(1)) return puts("NO"),0;
	puts("YES");
	return 0;
}

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

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

int main() {
    // 整数
    Bint a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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

typedef long long ll;
typedef long double ld;
//#define int ll
//#define endl '\n'

// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// print number in binary -> cout << bitset<20>(n);

const int N=100010,M=2,inf=1e9;
int n,m;
int a[N],dp[N];

main(){
	cin.tie(0);cin.sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<n;++i)cin>>a[i];
	for(int i=0;i<n;++i)dp[i]=inf;
	dp[0]=0;
	for(int i=0;i<n;++i)
		for(int j=1;j<=m;++j)
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4412
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double a = r*r*Math.PI;
        double b = r*2*Math.PI;
        System.out.printf("%.10f %.10f",a,b);
    }
}



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

int main()
{
  int N,W;scanf("%d %d",&N,&W);
  int v[N],w[N];
  for(int i=0;i<N;i++)scanf("%d %d",&v[i],&w[i]);
  vector<vector<int>> dp(N+1,vector<int>(W+1,0));
  for(int i=0;i<N;i++)for(int j=0;j<=W;j++)
  {
    dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
    if(j+w[i]<=W)dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
  }
  printf("%d\n",dp[N][W]);
}


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

using namespace std;

int main(void){
//string S;
int N, M;
cin >> N;
cin >> M;

vector<int> p(M);
vector<string> s(M);
vector<int> mis(N, 0);

for(int i = 0; i < M; i++){
  cin >> p[i];
  cin >> s[i];
}

int penal = 0;
int ac = 0;
unordered_map<int, bool> mp;

for(int i = 0; i < M; i++){
  if(mp.find(p[i]) == mp.end()) mp[p[i]] = false;
}

for(int i = 0; i < M; i++){
  if(s[i] == "WA" && mp.find(p[i])->second == false) mis[p[i]]++;
  if(s[i] == "AC" && mp.find(p[i])->second == false){
     mp[p[i]] = true;
     penal += mis[p[i]];
     ac++;
  }
}
cout << ac << " " << penal << endl;

return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------


//main
//------------------------------------------
signed main(){
  int N, K;
  cin >> N >> K;
  int mx = (N-1)*(N-2)/2;
  if(mx<K){
    cout << -1 << endl;
    return 0;
  }

  VP ans;
  //ウニを作る
  REP(i, N-1){
    ans.pb(PII(i+1, N));
  }
  //辺を追加
  int add = mx-K;
  VP edge;
  REP(i, N-1){
    REP(j, i){
      edge.pb(PII(i+1, j+1));
    }
  }
  REP(i, add) ans.pb(edge[i]);
  cout << ans.size() << endl;
  REP(i, ans.size()) cout << ans[i].fst << " " << ans[i].snd << endl;
  return 0;
}


Measured memory_bytes: 512