akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var curr1 = Convert.ToInt32(input[0]);
        var curr2 = Convert.ToInt32(input[1]);
        var price = Convert.ToInt32(input[2]);
        if (curr1 + curr2 >= price) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 11220
/*
author: orthodoxparadox
27-Aug-2018
12:41:50
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ") 
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}
#else
#define dbg(...)
#endif

int __gcd(int a, int b)
{
	return b ? __gcd(b, a%b) : a;
}

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();
	int n, x;
	cin >> n >> x;
	cout << 3*(n - __gcd(n, x));

	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}

Measured memory_bytes: 256
// abc070_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b,c,d,ans;
  cin>>a>>b>>c>>d;
  ans=min(b,d)-max(a,c);
  if (ans>0) {
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, k, c = map(int, input().split())
s = list(input())

R = []
p = 0
for _ in range(k):
    while s[p] == 'x':
        p += 1
    R.append(p)
    p += c + 1

L = []
p = n - 1
for _ in range(k):
    while s[p] == 'x':
        p -= 1
    L.append(p)
    p -= c + 1

L = list(reversed(L))

for i in range(k):
    if R[i] == L[i]:
        print(R[i] + 1)


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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

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

    string s;
    cin >> s;
    const int N = s.size();

    vector<int> prev(26, 0);
    vector<int> now(26, 0);
    vector<int> value(N);
    for (int i = 0; i < N; i++) {
        now[s[i] - 'a'] = (prev[s[i] - 'a'] + 1) % 2;
        for (int j = 0; j < 26; j++) {
            value[i] += (int)now[j] << j;
        }
        prev = now;
    }
    int sum = 0;
    for (int i = 0; i < 26; i++) {
        sum += prev[i];
    }
    if (sum <= 1) {
        cout << 1 << endl;
        return 0;
    }

    const int maximum = 1 << 26;
    vector<int> minimum(maximum, INF<int>);
    minimum[0] = 0;
    for (int i = 0; i < N; i++) {
        const int v = value[i];
        int u = v;
        int mini = minimum[v];
        for (int d = 0; d < 26; d++) {
            if ((v >> d) & 1) {
                u = v - (1 << d);
            } else {
                u = v + (1 << d);
            }
            mini = min(mini, minimum[u] + 1);
        }
        minimum[v] = min(minimum[v], mini);
    }
    cout << minimum[value[N - 1]] << endl;


    return 0;
}


Measured memory_bytes: 263572
package main

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

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

func next() string {
	return reader.next()
}

func nextInt() int {
	i, err := strconv.Atoi(reader.next())
	if err != nil {
		panic(err)
	}
	return i
}

func nextLine() string {
	return reader.nextLine()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func main() {
	_, A, B := nextInt(), nextInt(), nextInt()
	S := nextLine()
	passed, rankB := 0, 0
	for _, r := range S {
		ans := "No"
		switch r {
		case 'a':
			if passed < A+B {
				ans = "Yes"
				passed++
			}
		case 'b':
			rankB++
			if passed < A+B && rankB <= B {
				ans = "Yes"
				passed++
			}
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var h = p[0];
		var w = p[1];
		var mat = new int[10, 10];
		var a = new int[h, w];
		
		for(int i = 0; i < 10; i++)
		{
			p = Input().ToInt();
			for(int j = 0; j < 10; j++)
			{
				mat[i, j] = p[j];
			}
		}
		
		
		for(int i = 0; i < 10; i++)
		{
			for(int j = 0; j < 10; j++)
			{
				for(int k = 0; k < 10; k++)
				{
					mat[j, k] = Math.Min(mat[j, k], mat[j, i] + mat[i, k]);
				}
			}
		}
		long wa = 0;
		for(int i = 0; i < h; i++)
		{
			p = Input().ToInt();
			for(int j = 0; j < w; j++)
			{
				if(p[j] == -1)
					continue;
				wa += mat[p[j], 1];
			}
		}
		
		Console.WriteLine(wa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 13228
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define repi(i,j,n) for(int i=j;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int compare_intr(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}


int main (void)
{
  int n,k;
  scanf("%d\n",&n);
  scanf("%d\n",&k);
  int num=1;
  rep(i,n)
  {
    if(num*2<num+k)
    {
      num*=2;
    }
    else
    {
      num+=k;
    }
  }
  printf("%d",num);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(std::vector<std::string> c){
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

int main(){

    std::vector<std::string> c(3);
    for(int i = 0 ; i < 3 ; i++){
        std::cin >> c[i];
    }
    solve(std::move(c));
    return 0;
}



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

using namespace std;

typedef long long ll;

#define INF 10000000
#define mp make_pair
#define fi first
#define se second

ll lcm(ll a,ll b){
    ll g = __gcd(a,b);
    return a*(b/g);
}

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    ll ans = 1LL;
    ll sk;
    for(int j = 0;j<n;j++){
        cin >> sk;
        ans = lcm(ans,sk);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s_list = [int(input()) for nesya in range(n)]
total = sum(s_list)
s_list.sort()
t = 0
if total%10 != 0:
  print(total)
else:
  for s in s_list:
    if s%10 != 0:
      print(total-s)
      break
    t += 1
if t == n:
  print(0)


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

#include <iostream>
#include <vector>

std::unordered_map<long, long> mp;
std::vector<int> v;

int main(void) {
  long n;
  long a;
  long q;
  long b,c;
  long long sum = 0;

  scanf("%ld", &n);

  for (long i = 0; i < n; i++) {
    scanf("%ld" , &a);
    mp[a]++;
    sum+=a;
  }

  scanf("%ld", &q);

  for (long i = 0; i < q; i++) {
    scanf("%ld %ld", &b, &c);
    if(mp[b] != 0){
      sum = sum - (mp[b] * b) + (c * mp[b]);
      mp[c] += mp[b];
      mp[b] = 0;
    }
    printf("%lld\n", sum);
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    vector<int> ck(26, 0);
    int ans = 1001001001;
    rep(i, s.size()) ck[s[i] - 'a']++;

    rep(i, 26)
    {
        if (ck[i] == 0)
        {
            cout << (char)(i + 'a') << endl;
            return (0);
        }
    }
    cout << "None" << endl;
    return (0);
}


Measured memory_bytes: 3752
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int H = 0;
  int count = 0;
  for (int i=0; i<N;i++) {
    int height = 0;
    cin >> height;
    if (height >= H) {
      count++;
      H = height;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
T = [list(s[i] for s in S) for i in range(N)]

def check(B):
    b = B-N
    for i in range(N):
        si = S[i]
        ti = T[b+i]
        if any(si[b+j] != ti[j] for j in range(i)):
            return 0
    return 1

ans = 0
for i in range(N):
    ans += N*check(i)
print(ans)


Measured memory_bytes: 3828
import java.awt.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        // write your code here
        Scanner sc = new Scanner(System.in);

        // abc61 c
        int n = sc.nextInt();
        long k = sc.nextLong();
        PriorityQueue<Point> queue = new PriorityQueue<>((Comparator.comparingInt(a -> a.x)));

        for (int i = 0; i < n; i++) {
            queue.add(new Point(sc.nextInt(), sc.nextInt()));
        }

        long count = 0;
        for (int i = 0; i < n; i++) {
            Point p = queue.poll();
            count += p.y;
            if (count >= k) {
                System.out.println(p.x);
                return;
            }
        }
    }
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

void dfs(int i,int p,vector<vector<int>>& edges,vector<P>& val,vector<bool>& c) {
    if (p != -1) {
        val[i].first = max(val[i].first,val[p].first-1);
        val[i].second = min(val[i].second,val[p].second+1);
        if (val[i].first < val[p].first-1 && val[i].second > val[p].second+1) return;
    }
    for (int j : edges[i]) if (j != p) {
        if (!c[j]) dfs(j,i,edges,val,c);
        else if (val[i].first-1 > val[j].first || val[i].second+1 < val[j].second || val[i].first%2 == val[j].first%2) {
            cout << "No" << endl;
            exit(0);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<bool> c(n,false);
    vector<int> sup(n,1e7),inf(n,-1e7);
    vector<vector<int>> edges(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        scanf("%d%d", &u, &v);
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    int k;
    cin >> k;
    vector<P> ls(k);
    for (int i = 0;i < k;++i) {
        int v,p;
        cin >> v >> p;
        v--;
        c[v] = true;
        sup[v] = inf[v] = p;
        ls[i] = P(p,v);
    }
    priority_queue<P> q;
    for (int i = 0;i < k;++i) q.push(ls[i]);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        for (int i : edges[p.second]) {
            if (!c[i] && p.first-1 > inf[i]) {
                q.push(P(p.first-1,i));
                inf[i] = p.first-1;
            }
            if (c[i] && (p.first-1 > inf[i] || p.first%2 == inf[i]%2)) {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    priority_queue<P,vector<P>,greater<P>> r;
    for (int i = 0;i < k;++i) r.push(ls[i]);
    while (!r.empty()) {
        P p = r.top();
        r.pop();
        for (int i : edges[p.second]) {
            if (!c[i] && p.first+1 < sup[i]) {
                r.push(P(p.first+1,i));
                sup[i] = p.first+1;
            }
            if (c[i] && (p.first+1 < sup[i] || p.first%2 == sup[i]%2)) {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 0;i < n;++i) cout << sup[i] << endl;
    return 0;
}

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

#define ll long long

const int inf = 1e9+5;

int main() {
  int n, k = 2; cin >> n;
  vector<int> h(n);
  for(int &x:h) cin >> x ;
  vector<int> dp(n, inf); dp[0] = 0;
  
  for(int i=0; i<n; i++){
    for(int j = i+1; j<=i+k; j++){
      if(j<n){
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
      }
    }
  }

cout << dp[n-1] << "\n" ;

}
  

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int n, m, s, t;
vector<long> dist1(100005);
vector<long> dist2(100005);
vector<long> u(100005);
vector<long> v(100005);
vector<long> a(100005);
vector<long> b(100005);
vector<vector<pair<long, long>>> graph(100005);

void dijkstra1(long s) {
  priority_queue<pair<long,long>, vector<pair<long, long>>, greater<>> queue;
  queue.push(make_pair(s, 0));
  while (!queue.empty()) {
    pair<long, long> p = queue.top();
    queue.pop();
    long start = p.first;
    long d = p.second;
    if (d > dist1.at(start)) {
      continue;
    }
    for (auto e : graph.at(start)) {
      long end = e.first;
      long train = e.second;
      long cost = a.at(train);
      if (dist1.at(end) > d + cost) {
        dist1.at(end) = d + cost;
        // cout << "yen: pos: " << end << " cost: " << dist1.at(end) << endl;
        queue.push(make_pair(end, dist1.at(end)));
      }
    }
  }
}

void dijkstra2(long t) {
  priority_queue<pair<long,long>, vector<pair<long, long>>, greater<>> queue;
  queue.push(make_pair(t, 0));
  while (!queue.empty()) {
    pair<long, long> p = queue.top();
    queue.pop();
    long start = p.first;
    long d = p.second;
    if (d > dist2.at(start)) {
      continue;
    }
    for (auto e : graph.at(start)) {
      long end = e.first;
      long train = e.second;
      long cost = b.at(train);
      if (dist2.at(end) > d + cost) {
        dist2.at(end) = d + cost;
        // cout << "snuke: pos: " << end << " cost: " << dist2.at(end) << endl;
        queue.push(make_pair(end, dist2.at(end)));
      }
    }
  }
}

int main() {
  cin >> n >> m >> s >> t;
  for (int i=1; i<=m; i++) {
    cin >> u.at(i) >> v.at(i) >> a.at(i) >> b.at(i);
  }

  for (int i=1; i<=m; i++) {
    graph.at(u.at(i)).push_back(make_pair(v.at(i), i));
    graph.at(v.at(i)).push_back(make_pair(u.at(i), i));
  }

  for (int i=1; i<=n; i++) {
    dist1.at(i) = LONG_MAX;
    dist2.at(i) = LONG_MAX;
  }
  dist1.at(s) = 0;
  dist2.at(t) = 0;

  dijkstra1(s);
  dijkstra2(t);

  vector<long> dvec(n+1);
  for (int i=1; i<=n; i++) {
    dvec.at(i) = dist1.at(i) + dist2.at(i);
  }
  for (int i=n-1; i>=1; i--) {
    dvec.at(i) = min(dvec.at(i), dvec.at(i+1));
  }
  long init = 1;
  for (int i=1; i<=15; i++) {
    init *= 10;
  }
  for (int i=1; i<=n; i++) {
    cout << init-dvec.at(i) << endl;
  }
}


Measured memory_bytes: 20420
import sys
import math

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def gcd(a, b):
	return math.gcd(a, b)
	
def is_pc(al):
	mm=((10**6)+5)
	dd = [0]* mm
	kk = [-1]* mm
	
	for v in al:
		dd[v] += 1
	
	for i, _ in enumerate(kk):
		if i <= 1:
			continue
		if kk[i]==-1:
			n=1
			nd = 0
			while i*n < mm:
				kk[i*n]=1
				nd += dd[i*n]
				n+=1
		if nd >= 2:
			return False
	return True

def main():
	n = int(input())
	#b , c = tin()
	#s = input()	
	al = lin()
	
	pc = 'pairwise coprime'
	sc = 'setwise coprime'
	nc = 'not coprime'
	if is_pc(al):
		return pc
	v=al[0]
	for vv in al:
		v = gcd(v, vv)
	if v == 1:
		return sc
	return nc
	
				
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
	int w,h,x,y,r;

	cin>>w>>h>>x>>y>>r;
	
	if((r<=x && r<=y) && (x<=(w-r) && y<=(h-r)))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int dp[2][2][2];
int main()
{
	long long n;
	int now=0,to=1,nv,rv,h;
	scanf("%lld",&n);
	memset(dp,0,sizeof(dp));
	dp[now][0][0]=1;
	for(int i=0;i<=59;i++)
	{
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				if(dp[now][j][k])
				{
					nv=((n>>i)&1);
					for(int z=0;z<3;z++)
					{
						rv=((z+k)&1);
						h=(z+k)>>1;
						if(rv<nv)
							(dp[to][0][h]+=dp[now][j][k])%=mod;
						else if(rv==nv)
							(dp[to][j][h]+=dp[now][j][k])%=mod;
						else if(rv>nv)
							(dp[to][1][h]+=dp[now][j][k])%=mod;
					}
					dp[now][j][k]=0;
				}
		swap(now,to);
	}
	printf("%d",dp[now][0][0]);
	return 0;
}

Measured memory_bytes: 256
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    int ans = b/a;
    cout<<min(ans,c);
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, D, X, A[100];

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

    cin >> N >> D >> X;
    rep(i, N) {
        cin >> A[i];
        X += 1 + (D - 1) / A[i];
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
//__professor_
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define ub upper_bound
#define lb lower_bound
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define test ll t;cin>>t;while(t--)
#define mod 1000000007
#define inf 1000000000000000001
const double pi =3.141592653589793238463;
using namespace std;

int main()
{
	FAST;
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
	cin>>arr[i];
	ll dp[n];
	memset(dp,0,sizeof(dp));
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);

	for(ll i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}

	cout<<dp[n-1]<<endl;

	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}
	
	const int MAX=1000100;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
	ll x,y;
	cin >> x >> y;
	if((x+y)%3!=0){
		cout << 0 << endl;
		return 0;
	}
	ll vv=(x+y)/3;
	x-=vv;
	y-=vv;
	COMinit();

	cout << COM(x+y,x) << endl;
	



}

Measured memory_bytes: 23680
import math

abx = input().split()
a, b, x = int(abx[0]), int(abx[1]), int(abx[2])

area = x / a

ans = 0

if area >= a * b /2:
    ans = math.degrees(math.atan2(2 * b - (2 * area / a), a))
else:
    ans = math.degrees(math.atan2(b, 2 * area / b))

print(ans)

Measured memory_bytes: 3064
a=[]
a<<STDIN.gets.to_i
m = 0

while true do
  if a[-1] % 2 == 0
    m = a[-1] / 2
  else
    m = a[-1] * 3 + 1
  end
  break if a.index(m) != nil
  a << m
end

puts a.size + 1



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a,b) memset(a,b,sizeof(a))
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e6+10;
const int mod=1e9+7;
const int maxm=1e3+10;
using namespace std;
int a[maxn];
int main(int argc, char const *argv[])
{
    #ifndef ONLINE_JUDGE
        // freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
        srand((unsigned int)time(NULL));
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]&1)
            continue;
        else
        {
            if(a[i]%5&&a[i]%3)
                flag=1;
        }
    }
    if(flag)
        cout<<"DENIED"<<endl;
    else
        cout<<"APPROVED"<<endl;
    #ifndef ONLINE_JUDGE
        cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" s.\n";
    #endif
    return 0;
}

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

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

  int K;
  cin >> K;

  vector<string> cs;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 1; j <= K && i + j <= S.size(); j++) {
      cs.push_back(S.substr(i, j));
    }
  }

  sort(cs.begin(), cs.end());
  unique(cs.begin(), cs.end());

  cout << cs[K-1] << endl;
}


Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

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

    sort(P,P+N);
    sum -= P[N-1]/2;
    cout << sum <<endl;

}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	ll X, K; cin >> X >> K;
	
	vll datl(K+1), datr(K+1);
	vll low(K+1);
	vll R(K+1);
	
	datl[0] = 0, datr[0] = X;
	low[0] = 0, R[0] = 0;
	for (int i = 1; i <= K; i++) {
		cin >> R[i];
		ll diff = R[i] - R[i-1];
		tie(datl[i], datr[i], low[i]) = tie(datl[i-1], datr[i-1], low[i-1]);
		if (i & 1) {
			datl[i] -= diff;
			datr[i] -= diff;
		} else {
			datl[i] += diff;
			datr[i] += diff;
		}
		if (datl[i] < 0) {
			low[i] = min(low[i] - datl[i], X);
			datl[i] = 0;
		}
		datr[i] = max(0ll, datr[i]);
		datr[i] = min(X, datr[i]);
		datl[i] = min(X, datl[i]);
	}
		
	int Q;
	cin >> Q;
	while (Q--) {
		ll t, a;
		ll pos;
		cin >> t >> a;
		pos = --upper_bound(begin(R), end(R), t) - begin(R);
		a = max(min(a, low[pos] + datr[pos] - datl[pos]), low[pos]);
		ll x = datl[pos] + (a - low[pos]);
		ll diff = t - R[pos];
		if (pos & 1) x = min(x + diff, X);
		else x = max(x - diff, 0ll);
		cout << x << el;
	}

	return (0);
}


Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 100000007
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 61
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define mat vector<vector<T>>
#define T long long
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define cld complex<long double>
using namespace std;
const int N = 100005;
vector<int> f(N);
int x,k;

int ct = 0;
int botv=0,bot=0,topv,top, dir = -1;
int ind = 0;

inline void jto(int time){
		int t = time - ct;
		if(dir == 1){
			topv += t;			
			botv += t;
			if(topv > x){top -= topv-x;topv=x;}
			if(botv > x){bot = x;botv=x;}
		}
		else{
			topv -= t;			
			botv -= t;
			if(botv < 0){bot += -botv;botv=0;}
			if(topv < 0){top = 0; topv = 0;}
		}
		ct = time;
}

int main(){
	fast_io();
	cin >> x >> k;
	cu(i,0,k)cin >> f[i];
	topv = top = x;

	int q,t,a;cin >> q;
	while(q--){
		cin >> t >> a;	
		while(ind < k && f[ind] < t){
			jto(f[ind++]);
			dir *= -1;
		}
		jto(t);
		if(a <= bot){
			cout << botv << '\n';
		}
		else if(a >= top){
			cout << topv << '\n';
		}
		else{
			cout << a - bot + botv << '\n';
		}
	}
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } }

int main(void) {
	LL N;
	cin >> N;

	vector<LL> A(N);
	rep(i, N) cin >> A[i];

	vector<LL> ruiseki_l(N+2);
	ruiseki_l[1] = A[0];
	ruiseki_l[2] = gcd(A[0],A[1]);
	for (LL i = 2; i < N; i++) {
		ruiseki_l[i + 1] = gcd(ruiseki_l[i], A[i]);
	}
	vector<LL> ruiseki_r(N+2);
	ruiseki_r[N] = A[N - 1];
	ruiseki_r[N - 1] = gcd(A[N - 1], A[N - 2]);
	for (LL i = N - 3; i >= 0; i--) {
		ruiseki_r[i + 1] = gcd(ruiseki_r[i + 2], A[i]);
	}
	
	LL ans = 0;
	for (LL i = 0; i < N; i++) {
		chmax(ans, gcd(ruiseki_l[i], ruiseki_r[i + 2]));
	}
	cout << ans << endl;
	
	return 0;
}

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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 100000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int N,H;
int a[100000],b[100000];
int am;
void solve(){
	sort(b,b+N);
	int ans=0;
	int p=N-1;
	while(H>0){
		if(b[p]>am){
			H-=b[p];
			p--;
			ans++;
		}
		else{
			ans=ans+H/am;
			if(H%am!=0) ans++;
			H=0;
		}
	}
	s(ans);
}

int main(){
	cin>>N>>H;
	rep(i,N) {
		cin>>a[i]>>b[i];
		chmax(am,a[i]);
	}
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  int t[n+1];
  int x[n+1];
  int y[n+1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for(int i = 1; i <= n; i++){
    cin >> t[i] >> x[i] >> y[i];
    if(t[i]-t[i-1]< abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]) || (x[i]+y[i]+t[i])%2!=0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    if (S.size() < T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    vector<string> ans;

    for (int s = 0; s < S.size() - T.size() + 1; s++) {
        for (int t = 0; t < T.size(); t++) {
            bool isHatena = S[s + t] == '?';
            bool SequalT  = S[s + t] == T[t];
            if (t == T.size() - 1 && (isHatena || SequalT)) {
                string a = S.substr(0, s) + T + S.substr(s + T.size());
                replace(a.begin(), a.end(), '?', 'a');
                ans.push_back(a);
            }
            if (isHatena || SequalT)
                continue;
            else
                break;
        }
    }
    if (ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        sort(all(ans));
        cout << ans[0] << endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int IINF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

// Geometric Library
#include <complex>
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
typedef complex<double> P;
typedef vector<P> G;
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
	bool operator < (const P& a, const P& b) {
		//return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
		if(imag(a) < imag(b))
			return true;
		if(imag(a) == imag(b) && real(a) < real(b))
			return true;
		return false;
	}
}
double cross(const P& a, const P& b) { return imag(conj(a)*b); }
double dot(const P& a, const P& b) { return real(conj(a)*b); }
struct L : public vector<P> {
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0) return +1; // counter clockwise
	if (cross(b, c) < 0) return -1; // clockwise
	if (dot(b, c) < 0) return +2; // c--a--b on line
	if (norm(b) < norm(c)) return -2; // a--b--c on line
	return 0;
}
P crosspoint(const L &l, const L &m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
	return m[0] + B / A * (m[1] - m[0]);
}
G convex_cut(const G& g, const L& l) {
	G Q;
	for (int i = 0; i < g.size(); ++i) {
		P A = curr(g, i), B = next(g, i);
		if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
		if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
		Q.push_back(crosspoint(L(A, B), l));
	}
	return Q;
}
double area2(const G& g) {
	double A = 0;
	for (int i = 0; i < g.size(); ++i) 
		A += cross(curr(g, i), next(g, i));
	return A / 2.0;
}

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


	int n;
	while(cin >> n, n) {
		vector<G> v(n+2);
		REP(i, 4) {
			REP(j, n) {
				double in; cin >> in;
				if(i == 0)
					v[0].pb(P(0, in));
				else if(i == 1)
					v[n+1].pb(P(1, in));
				else if(i == 2)
					v[j+1].pb(P(in, 0));
				else if(i == 3)
					v[j+1].pb(P(in, 1));
			}
		}
		REP(i, n)
			REP(j, n)
				v[i+1].pb(crosspoint(L(v[i+1][0], v[i+1][1]), L(v[0][j], v[n+1][j])));
		v[0].pb(P(0, 0)); v[0].pb(P(0, 1));
		v[n+1].pb(P(1, 0)); v[n+1].pb(P(1, 1));
		REP(i, n+2)
			sort(v[i].begin(), v[i].end());
		double ans = 0;
		REP(i, n+1) {
			REP(j, n+1) {
				G g;
				g.pb(v[i][j]);
				g.pb(v[i+1][j]);
				g.pb(v[i+1][j+1]);
				g.pb(v[i][j+1]);
				ans = max(ans, area2(g));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
// https://atcoder.jp/contests/abc131/tasks/abc131_e
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    // スター型のとき最大値になる
    // (n - 1) C 2 よりも大きければ不成立
    int cnt = (n - 1) * (n - 2) / 2 - k;
    if (cnt < 0) {
        cout << "-1\n";
        return 0;
    }

    // 1を中心としたスター型のグラフを生成する
    vector<pii> v;
    for (int i = 2; i <= n; i++) {
        v.push_back(pii(1, i));
    }
    // 頂点を接続することで2頂点の組み合わせを減らす
    for (int i = 2; i <= n && cnt > 0; i++) {
        for (int j = i + 1; j <= n && cnt > 0; j++) {
            v.push_back({i, j});
            cnt--;
        }
    }
    cout << v.size() << "\n";
    for (auto &x : v) {
        cout << x.first << " " << x.second << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())

low = 1
high = N
for i in range(M) :
    l, r = map(int,input().split())
    low = max(low, l)
    high = min(high, r)

if high - low + 1 > 0 :
    print(high - low + 1)
else :
    print(0)


Measured memory_bytes: 3064
X, N = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
min_diff = float('inf')
for i in range(0, 102):
    if i in a:
        continue
    if (abs(i - X) < min_diff) or (abs(i - X) == min_diff and i < ans):
        min_diff = abs(i - X)
        ans = i
print(ans)


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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

ll powMod(ll n, ll p) {
    if (p < 0) return 0;
    else if (p == 0) return 1;
    else if (p & 1) return n * powMod(n, p - 1) % MOD;
    else {
        ll half = powMod(n, p >> 1) % MOD;
        return (half * half) % MOD;
    }
}

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    int len = s.length();
    vll a(len);
    vll c(len);
    vll ql(len);
    vll qr(len);
    for (int i = 0; i < len - 1; ++i) {
        if (s[i] == 'A') a[i + 1] = a[i] + 1;
        else a[i + 1] = a[i];
        if (s[i] == '?') ql[i + 1] = ql[i] + 1;
        else ql[i + 1] = ql[i];
    }
    for (int i = len - 1; i > 1; --i) {
        if (s[i] == 'C') c[i - 1] = c[i] + 1;
        else c[i - 1] = c[i];
        if (s[i] == '?') qr[i - 1] = qr[i] + 1;
        else qr[i - 1] = qr[i];
    }
    for (int i = 1; i < len - 1; ++i) {
        if (s[i] == 'B' || s[i] == '?') {
            ll t1 = (a[i] * c[i] % MOD) * (powMod(3, ql[i]) * powMod(3, qr[i]) % MOD) % MOD;
            ll t2 = (a[i] * qr[i] % MOD) * (powMod(3, ql[i]) * powMod(3, qr[i] - 1) % MOD) % MOD;
            ll t3 = (c[i] * ql[i] % MOD) * (powMod(3, qr[i]) * powMod(3, ql[i] - 1) % MOD) % MOD;
            ll t4 = (ql[i] * qr[i] % MOD) * (powMod(3, ql[i] - 1) * powMod(3, qr[i] - 1) % MOD) % MOD;
            ans += (t1 + t2 + t3 + t4) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    bool bad = false;
    rep1(i,1,4){
        if(s[i-1] == s[i]) bad = true;
    }
    if(bad) cout << "Bad" <<endl;
    else cout << "Good" <<endl;

    return 0;
}

Measured memory_bytes: 256
(
    (stdin.ReadLine() |> int),
    (stdin.ReadLine() |> fun x -> ("0 " + x).Split(' ') |> Array.map int),
    (stdin.ReadLine() |> fun x -> ("0 " + x).Split(' ') |> Array.map int)
)
|> fun (n, a1, a2) ->
    [1..n]
    |> Seq.fold (fun (upperTotal, lowerTotal) i ->
        upperTotal + a1.[i]
        |> fun nextUpperTotal -> (
            nextUpperTotal,
            (max nextUpperTotal lowerTotal) + a2.[i]
        )
    ) (0, 0)
    |> fun (_, ret) -> ret
|> printfn "%d"


Measured memory_bytes: 12124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

  string s;
  getline(cin,s);
  // cout<<s;
   
   cout<<s[0];
   for(int i=0;i<s.length();++i){
       if(s[i]==' ')
         cout<<s[i+1];
   }

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

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

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

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

  int n, k; cin >> n >> k;
  vector<P> a(n);
  REP(i, n) {
    cin >> a[i].fi;
    a[i].se = i;
  }

  sort(ALL(a));
  reverse(ALL(a));
  vi ans;
  REP(i, n) {
    ans.pb(a[i].se);
    a[i].fi--;
  }
  P prev = a[n-1];
  a.pop_back();

  REP(i, k) {
    sort(ALL(a));
    reverse(ALL(a));
    REP(j, n-1) {
      if(a[j].fi == 0) {
        cout << -1 << endl;
        return 0;
      } else {
        ans.push_back(a[j].se);
        a[j].fi--;
      }
    }
    P tmp = a[n-2];
    a.pop_back();
    a.push_back(prev);
    prev = tmp;
  }

  cout << ans.size() << endl;
  REP(i, SZ(ans)) {
    cout << ans[i]+1;
    if(i == SZ(ans)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}


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

int main() {
	int n;

	cin >> n;
	if (n % 1110 < 10)
		cout << "Yes" << endl;
	else
	{
		n %= 1000;
		if (n % 111 == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}


Measured memory_bytes: 256
s = input()
t = input()
ans = 'UNRESTORABLE'
r = []

for i in range(len(s)):
    cnt = 0
    idx = i
    for j in range(len(t)):
        if s[idx] == t[j] or s[idx] == "?":
            cnt += 1
        else:
            break
        if cnt == len(t):
            r.append((s[:i]+t+s[idx+1:]).replace('?','a'))
        if idx+1 <= len(s)-1:
            idx += 1
        else:
            break

if len(r) == 0:
    print(ans)
else:
    print(sorted(r)[0])

Measured memory_bytes: 3064