akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

struct rg {
	int t1;
	int t2;
	rg (int v1, int v2) {
		t1 = v1;
		t2 = v2;
	}
};

bool cmp(const rg& a, const rg& b) {
	return a.t1 < b.t1;
}

int main() {

	int N, C, K;
	cin >> N >> C >> K;

	list<rg> v;
	int t;
	for (int i = 0; i < N; i++) {
		cin >> t;
		v.push_back(rg(t, t + K));
	}

	v.sort(cmp);

	int ans = 0;
	int val = 0;
	rg dv(0, 0);
	while (v.size() != 0) {
		ans += 1;
		dv = v.front();
		v.pop_front();
		val = 1;
		while (v.size() != 0 && v.front().t1 <= dv.t2 && val < C) {
			v.pop_front();
			val += 1;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6744
#include<iostream>
using namespace std;
const int maxN = 100;
int a[maxN+2], n;
bool chk(int x, int y)
{
	for(int i = 1; i < n; i++)
		if(a[i] < a[i-1])
			return swap(a[x],a[y]),0;
	return 1;
}
int b[maxN+2];
bool proc()
{
	int cnt = 0, c1, c2;
	for(int i = 1; i < n; i++)
		if(a[i] < a[i-1])
		{
			++cnt;
			c1 = c2;
			c2 = i;
		}
	if(!cnt)
		return true;
	if(cnt > 2)
		return false;
	if(cnt == 1)
	{
		swap(a[c2],a[c2-1]);
		return chk(c2,c2-1);
	}
	swap(a[c1-1],a[c2]);
	return chk(c1-1,c2);
}
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	if(proc())
		cout << "YES" << '\n';
	else
		cout << "NO" << '\n';
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    s = str(input())
    
    res = 0
    for i in range(1000):
        t = str(i).zfill(3)
        pos = 0
        for j in s:
            if t[pos] == j:
                pos += 1
            if pos == 3:
                res += 1
                break
    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40924
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace msol2020
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_msol2020A();
            Console.Out.Flush();
        }

        public static void solve_msol2020B()
        {
        }

        public static void solve_msol2020A()
        {
            int x = Convert.ToInt32(Console.ReadLine());
            int q = 8;
            for (int i = 400; i <= 1800; i += 200)
            {
                if (i <= x && i + 199 >= x)
                {
                    Console.WriteLine(q);
                    break;
                }
                q--;
            }

        }
    }
}

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

int const MAX = 100005;
int S[MAX];

int main() {
    int N, M, a;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a);
        S[i+1] = (S[i] + a) % M;
    }
    map<int, int> m;
    long long ans = 0;
    for (int i = 0; i <= N; i++) {
        ans += m[S[i]];
        m[S[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
 
int main() {
	int n;
    float t,a,h;
    cin >> n >> t >> a;

    float minDiff = 1000;
    float thisT;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> h;
        thisT = t-h*0.006;
        if(abs(a-thisT) < minDiff){
            minDiff = abs(a-thisT);
            ans = i+1;
        }
    }

    cout << ans << endl;
};

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n;
  cin >> n;
  cout << n * n * n << endl;


  return 0;
}



Measured memory_bytes: 3096
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int n;

    cin >> n;
    cout << n / 2 - (!(n % 2)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <cmath>
#include <climits>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<pair<ll,ll>> C;
    ll a,b;
    REP(i,N){
        cin >> a >> b;
        C.push_back({a,b});
    }

    sort(C.begin(), C.end());

    ll ans=0, res=0;

    REP(i,N){
        if(C[i].second>M){
            ans+=C[i].first*M;
            break;
        }else{
            res+=C[i].second;
            ans+=C[i].first*C[i].second;
            M-=C[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  char a,b;
  cin >> a >> b;
  if((a=='H' && b=='H') || (a=='D' && b=='D')){
    cout << 'H' << endl;
  }else{
    cout << 'D' << endl;
  }
  return 0;
}

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

/**
 *
 * @author bhatti
 */
public class Main{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Together.together(args);
                
    }
    
}


/**
 *
 * @author bhatti
 */
class Together {
    
    public static void together(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, Integer> m = new HashMap<>();
        for(int i = 0 ; i < N ; ++i){
            int a = sc.nextInt();
            if(m.containsKey(a)){
                m.put(a, m.get(a) + 1);
            }else{
                m.put(a, 1);
            }
        }
        
        int max = -1;
        
        for(int k : m.keySet()){
            int tmp = 0; 
            tmp += m.containsKey(k - 1) ? m.get(k - 1) : 0;
            tmp += m.get(k);
            tmp += m.containsKey(k + 1) ? m.get(k + 1) : 0;
            max = Math.max(max, tmp);
        }
        
        System.out.println(max);
    }
        
}

Measured memory_bytes: 61000
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		long result = 0;
		for (int i = 0; i < s.length(); i++) {
			String str = s.charAt(i) + "";
			result += Integer.valueOf(str);
		}

		System.out.println(result % 9 == 0 ? "Yes" : "No");

	}
}


Measured memory_bytes: 51872
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();

        long[] s = new long[A];
        long[] t = new long[B];
        long[] X = new long[Q];

        for(int i = 0; i < A; i++){  s[i] = sc.nextLong(); }
        for(int i = 0; i < B; i++){  t[i] = sc.nextLong(); }
        for(int i = 0; i < Q; i++){  X[i] = sc.nextLong(); }


        for(int i = 0; i < Q; i++) {
            long min = Long.MAX_VALUE;
            long x = X[i];

            // 8パターンの内、最小のものを調べる
            // <- 神社, -> 寺
            min = Math.min(search(x, s, "left", t, "right"), min);

            // <- 神社, <- 寺
            min = Math.min(search(x, s, "left", t, "left"), min);

            // -> 神社, -> 寺
            min = Math.min(search(x, s, "right", t, "right"), min);

            // -> 神社, <- 寺
            min = Math.min(search(x, s, "right", t, "left"), min);

            // <- 寺, -> 神社
            min = Math.min(search(x, t, "left", s, "right"), min);

            // <- 寺, <- 神社
            min = Math.min(search(x, t, "left", s, "left"), min);

            // -> 寺, -> 神社
            min = Math.min(search(x, t, "right", s, "right"), min);

            // -> 寺, <- 神社
            min = Math.min(search(x, t, "right", s, "left"), min);

            out.println(min);
        }
    }

    public static long search(long start_point, long[] first_search_array, String first_direction, long[] second_search_array, String second_direction) {
        long cost = Long.MAX_VALUE;
        int first_iter_add = 0;
        int second_iter_add = 0;

        if(first_direction.equals("left")){ first_iter_add = -1; }
        if(second_direction.equals("left")){ second_iter_add = -1; }

        //out.println(start_point + "," + Arrays.toString(first_search_array) + "," + first_direction + "," + Arrays.toString(second_search_array) + "," + second_direction);

        int first_iter = binarySearch(first_search_array, start_point) + first_iter_add;
        //out.println("=>" + first_iter + "," + first_iter_add);
        if (first_iter >= 0 && first_iter < first_search_array.length) {
            long first = first_search_array[first_iter];
            //out.println("==>" + first);
            int second_iter = binarySearch(second_search_array, first) + second_iter_add;
            //out.println("===>" + second_iter);
            if (second_iter >= 0 && second_iter < second_search_array.length) {
                long second = second_search_array[second_iter];
                //out.println("====>" + second);
                cost = Math.abs(first - start_point) + Math.abs(second - first);
            }
        }
        return cost;
    }


    // https://qiita.com/taskie/items/b4e45e2005aa38e90bcb
    public static int binarySearch(long[] array, long num){
        int result = Arrays.binarySearch(array, num);
        return (result >= 0) ? result : ~result;
    }
}


Measured memory_bytes: 98580
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n,m,x;
  cin>>n>>m>>x;
  vector<vector<ll>> text(n);
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < m+1; ++j)
    {
      ll tmp;
      cin>>tmp;
      text[i].push_back(tmp);
    }
  }
  ll ans=mod;
  for (int i = 0; i < (1<<n); ++i)
  {
    ll cost=0;
    vector<ll> understand(m,0);
    for (int j = 0; j < n; ++j)
    {
      if((i>>j)&1)
      {
        cost+=text[j][0];
        for (int k = 1; k < text[j].size(); ++k)
        {
          understand[k-1]+=text[j][k];
        }
      }
    }
    bool flag=true;
    for (int j = 0; j < understand.size(); ++j)
    {
      if(x>understand[j]) flag=false;
    }
    if(flag) ans=ans>cost? cost:ans;
  }
  if(ans==mod) cout<<-1<<endl;
  else cout<<ans;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;
using Graph = vector<vector<int>>;

signed _main(){
  int X; cin >> X;
  for(int i=-1000;i<=1000;i++){
    for(int j=-1000;j<=1000;j++){
      if(i*i*i*i*i-j*j*j*j*j==X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#define MAX_SIZE 101

int solve(char s[], int n) {
    int i;
    if(n & 1) return 0;
    for(i = 0; s[i] == s[n / 2 + i]; i ++);
    
    return i == n / 2;
}

int main() {
    int n, result;
    char s[MAX_SIZE];
    
    scanf("%d\n", &n);
    gets(s);

    result = solve(s, n);

    if (result)
        puts("Yes");
    else
        puts("No");
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b,c,d;
   scanf("%d%d",&a,&b);
  if(a>b){
    c=a;
    a=b;
    b=c;
  }
    d=a%b;
    while(d!=0){
      a=b;
      b=d;
      d = a%b;
    }
    printf("%d",b);
    /* if(a<b&&1<=a&&b<=1000000000){
      c=b;
      b=a;
      a=c;
    }
    d=b%a;
    while(d!=0){
      b=a;
      a=d;
      c = a%d;
    }
    printf("%d",a);*/
    printf("\n");
    return 0;
}



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

#define int long long

using P = pair<int, int>;

int N;
vector<int> C;
vector<int> G[1001];

const int INF = 1e9;

int cost[1001][1001];
int dp[1001];

int dfs(int pre, int v) {  
  if ( dp[v] >= 0 ) return dp[v];
  int ret = 0;  
  for ( int u : G[v] ) {    
    if ( u == pre ) continue;
    if ( C[v] ) {
      ret = INF;      
    } else {
      ret += dfs(v, u);
    }
  }

  if ( G[v].size() == 1 && v != 0 ) {
    if ( C[v] ) ret = INF;
    else ret = 0;
  }

  int c = INF;
  if ( pre != -1 ) c = cost[pre][v];
  // cout << pre << " " << v << " " << ret << " " << c << endl;
  return dp[v] = min(ret, c);  
}

signed main() {
  cin >> N;

  C = vector<int>(N, 0);  
  for ( int i = 1; i < N; i++ ) {
    cin >> C[i];
  }

  for ( int i = 0; i < N-1; i++ ) {
    int u, v, p;
    cin >> u >> v >> p;
    cost[u][v] = p;
    cost[v][u] = p;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  fill_n(dp, 1001, -1);

  cout << dfs(-1, 0) << endl;  
  
  return 0;
}



Measured memory_bytes: 8500
#include <stdio.h>
#define pi 3.141592653589

int main(){
  double r;
  double s,c;

  scanf("%lf",&r);

  s = (double)r*r*pi;
  c = (double)2*r*pi;
  printf("%f %f\n",s,c);

  /*int FILE *fp;
  fp = fopen ("filename.txt","r");
  if (fp!=NULL)
  {
    fscanf(fp,"Some String\n", &var);
    fclose (fp);
  }*/
}



Measured memory_bytes: 2040
n = int(input())
l = [0 for i in range(10**4+1)]
for x in range(1,10**2+1):
  for y in range(1,10**2+1):
    for z in range(1,10**2+1):
      t = x**2+y**2+z**2+x*y+y*z+z*x
      if t<=10**4:
        l[t] += 1
for i in range(1,n+1):
  print(l[i])

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

    ll i,j,x,y,z,count=100000000000,sum=0,n,ans=0;
    cin>>n;
    ll a[n];
    rep(i,n)
    {
        cin>>a[i];
    }
    sort(a,a+n);

    for(j=a[n-1]; j>=a[0]; j--)
    {

        ll mid=j;
        rep(i,n)
        {
            ans=ans+((a[i]-mid)*(a[i]-mid));
        }

        count=min(count,ans);
        ans=0;

    }

    cout<<count<<endl;

    return 0;
}






Measured memory_bytes: 3592
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}
func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

// ax+by=gcd(a,b)
func extgcd(a, b int) (x, y int) {
	y = 1
	x = 0
	for u, v := 1, 0; a != 0; {
		q := b / a
		u, x = x - q * u, u
		v, y = y - q * v, v
		a, b = b - q * a, a
	}

	return
}

func modinv(a, m int) int {
	x, _ := extgcd(a, m)
	return (m + x % m) % m
}

func fact(n, mod int) int {
	ret := 1
	for n > 1 {
		ret = ret * n % mod
		n--
	}
	return ret
}

type P struct {
	c,s,f int
}

func maxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

const C = 100000
var prime [C + 1]bool
var sum[C + 2]int

func init() {
	for i := 2; i <= C; i++ {
		prime[i] = true
	}
	for i := 2; i <= C; i++ {
		if prime[i] {
			for j := i * 2; j <= C; j += i {
				prime[j] = false
			}
		}
	}
	for i := 3; i <= C; i++ {
		if prime[i] && prime[i/2+1] {
			sum[i] = 1
		}
		sum[i] += sum[i-1]
	}
}

func main() {
	io := NewIo()
	defer io.writer.Flush()

	n := io.NextInt()

	for i := 0; i < n; i++ {
		l := io.NextInt()
		r := io.NextInt()
		ans := sum[r] - sum[l-1]
		io.PrintLn(ans)
	}

}

Measured memory_bytes: 6784
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String input[] = new String[2];
            HashSet<String> map = new HashSet<String>();
            int N = Integer.parseInt(br.readLine());
            StringBuilder ans = new StringBuilder();
            for(int i = 0; i < N; i++){
            	input = br.readLine().split("\\s+");
                if("insert".equals(input[0])) {
                	map.add(input[1]);
                } else {
                	if (map.contains(input[1])) {
                		ans.append("yes\n");
                	} else {
                		ans.append("no\n");
                	}
                }
            }
            System.out.print(ans.toString());
    }
}


Measured memory_bytes: 323988
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
long long X;
long long sz[51];
long long p[51];
int main(){
  int i, j, k;
  long long res=0;
  rd(N);
  rd(X);
  sz[0] = p[0] = 1;
  for(i=1;i<N+1;i++){
    sz[i] = 3 + 2*sz[i-1];
    p[i] = 1 + 2*p[i-1];
  }
  while(N){
    X--;
    if(X==0){
      break;
    }
    if(X < sz[N-1]){
      N--;
      continue;
    }
    X -= sz[N-1];
    res += p[N-1];
    if(X==0){
      break;
    }
    X--;
    res++;
    if(X==0){
      break;
    }
    if(X < sz[N-1]){
      N--;
      continue;
    }
    X -= sz[N-1];
    res += p[N-1];
    if(X==0){
      break;
    }
    X--;
    if(X==0){
      break;
    }
  }
  if(X==1){
    res++;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N;
// ll X;
// 
// ll sz[51], p[51];
// 
// {
//   int i, j, k;
//   ll res = 0;
// 
//   rd(N,X);
// 
//   sz[0] = p[0] = 1;
//   rep(i,1,N+1){
//     sz[i] = 3 + 2sz[i-1];
//     p[i] = 1 + 2p[i-1];
//   }
// 
//   while(N){
//     X--;
//     if(X==0) break;
// 
//     if(X < sz[N-1]){ N--; continue; }
// 
//     X -= sz[N-1];
//     res += p[N-1];
//     if(X==0) break;
// 
//     X--;
//     res++;
//     if(X==0) break;
// 
//     if(X < sz[N-1]){ N--; continue; }
//     X -= sz[N-1];
//     res += p[N-1];
//     if(X==0) break;
// 
//     X--;
//     if(X==0) break;
//   }
//   if(X==1) res++;
// 
//   wt(res);
// }


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

using namespace std;

int main(){
  int N = 5;
  int ABCDE[N];
  for(int i=0; i<N; i++){
  	cin >> ABCDE[i];
  }
  int thr; cin >> thr;
  bool flag = true;
  for(int i=0; i<N; i++){
  	for(int j=i+1; j<N; j++){
    	if(ABCDE[j] - ABCDE[i] > thr) flag = false;
    }
  }
  if(flag){cout << "Yay!" << endl;}
  else{ cout << ":(" << endl;}
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, T;
  cin >> N >> T;

  int A[101010], max = 0;
  priority_queue<int, vector<int>, greater<int>> que;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    que.push(A[i]);

    if (i != 0) {
      chmax(max, A[i] - que.top());
    }
  }

  int cont = 0;
  priority_queue<int, vector<int>, greater<int>> q;
  for (int i = 0; i < N; i++) {
    q.push(A[i]);
    int temp = A[i] - q.top();
    if (temp == max) {
      cont++;
    }
  }

  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
  vector<int> antennas(5);
  vector<int> dis(10);
  int i, j;
  int k;

  for(i=0; i<5; i++)
    cin >> antennas[i];
  cin >> k;

  for(i=0; i<5; i++)
    for(j=i; j<5; j++)
      dis[i] = abs(antennas[i]- antennas[j]);

  for(i=0; i<10; i++)
    if(dis[i] > k){
      break;
    }

  if(i == 10)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;

  return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin>>N;
  vector<int> d(N);
  rep(i,N) cin>>d.at(i);
  sort(d.begin(),d.end());
  int L=d.at(N/2-1),R=d.at(N/2);
  (R-L)?cout<<R-L<<endl:cout<<0<<endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int orders[] = new int[5];
      	int diff;
      	int final_diff = 0;
      	int answer = 0;
      
      	for(int i = 0; i < 5; i++){
          orders[i] = sc.nextInt();
          diff = 10 - orders[i] % 10;
          if(diff == 10) diff = 0;
          if(final_diff < diff) final_diff = diff;
          orders[i] += diff;
        }
      
      	for(int order:orders){
          answer += order;
        }
      
      	answer -= final_diff;
 		
      	System.out.println(answer);
        
	}
}

Measured memory_bytes: 35728
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 3000
double dp[MAXN][MAXN]; //何枚投げて何枚表か
double p[MAXN];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    for (int i = 2; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
        }
    }
    int m = n / 2;
    double x = 0;;
    for (int i = m + 1; i <= n; i++) {
        x += dp[n][i];
    }
    cout << setprecision(10) << x << endl;
    return 0;
}

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

using namespace std;

int main() {
	
	int a[2000];
	int z, w, n;
	cin >> n >> z >> w;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	if (n == 1) cout << abs(a[0] - w) << endl;
	else cout << max(abs(a[n - 1] - w), abs(a[n - 1]-a[n - 2])) << endl;

} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int a,b,c,k,memo; cin>>a>>b>>c>>k;
  string s;
  
  while(a>=b){
    b*=2;
    k--;
  }
  while(b>=c){
    c*=2;
    k--;
  }
  
  if(a<b && b<c  && k>=0)s="Yes";
  else s="No";
  
  cout<<s<<endl;
  
  

  //string s; cin>>s;
  //cout<< <<endl;
}


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


int main(){
    vector<int> A;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    int dan = 1;
    for(int j=0;j<n-1;j++){
        if(A.at(j) < A.at(j+1)){
            dan++;
        }
    }
    cout << dan << '\n';
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() {
  int H,K,W;
  cin >> H >> W >> K;
  vector< string > S(H);
  REP(i,H) cin >> S[i];

  int ans = 1000000;
  REP(i, 1 << (H-1) ) {
    int cn = 0;
    vector< int > cut(H,0);
    int hn = 0;
    REP(j,H-1) {
      if ( (i & ( 1 << j)) != 0 ) {
        hn++;
        cn++;
      }
      cut[j+1] = hn;
    }
    bool imp = false;
    vector< int > cnt(hn+1, 0);
    int xn = 0;
    REP(x,W) {
      REP(y,H) {
        if (S[y][x] == '1' ) cnt[ cut[y] ]++;
      }
      xn++;
      REP(k,hn+1) {
        if ( cnt[k] > K ) {
          if ( xn == 1 ) { imp = true; cn = 1000000; break; }
          cn++;
          REP(l, hn+1) cnt[l] = 0;
          x--;
          xn = 0;
          break;
        }
      }
      if ( imp ) break;
    }
//    cout << i << " : " << cn << endl;
    ans = min(ans, cn);
  }
  cout << ans << endl;
}


  

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
int ans[114514];
vector<P> e[114514];
void dfs(int s){
    for(int i=0;i<e[s].size();i++){
        P p=e[s][i];
        if(ans[p.first]!=INF)continue;
        if(p.second%2==0){
            ans[p.first]=ans[s];
        }else{
            ans[p.first]=(ans[s]+1)%2;
        }
        dfs(p.first);
    }
}
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v,w;
        cin>>u>>v>>w;
        e[u-1].push_back(P(v-1,w));
        e[v-1].push_back(P(u-1,w));
    }
    for(int i=0;i<n;i++)ans[i]=INF;
    ans[0]=0;
    dfs(0);
    for(int i=0;i<n;i++)cout<<ans[i]<<endl;
    return 0;
}


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

int main() {
  int c[3][3];
  for(int i = 1; i < 4; i++) {
    for(int j = 1; j < 4; j++) {
      cin >> c[i][j];
    }
  }
  
  bool can = false;
  int a[4],b[4];
  a[4] = b[4] = 0;
  for(int i = 0; i < 101; i++) {  
    a[1] = i;
    b[1] = c[1][1] - a[1];
    a[2] = c[2][1] - b[1];
    b[2] = c[1][2] - a[1];
    a[3] = c[3][1] - b[1];
    b[3] = c[1][3] - a[1];
    
    if(c[1][1] == a[1] + b[1] && c[1][2] == a[1] + b[2] && c[1][3] == a[1] + b[3] &&
       c[2][1] == a[2] + b[1] && c[2][2] == a[2] + b[2] && c[2][3] == a[2] + b[3] &&
       c[3][1] == a[3] + b[1] && c[3][2] == a[3] + b[2] && c[3][3] == a[3] + b[3]) {
      cout << "Yes" << endl;
      can = true;
      break;
    }
  }
  
  if(!can) {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d,e,g,p,q,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> a >> b >> c >> d;
    if( (c + b -1)/b <= (a + d -1)/d) cout << "Yes";
        else cout << "No";
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;

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

  map<int, int> num;
  int now = N;
  for( int i = 2; i <= sqrt(N); i++ ){
    int cnt = 0;
    while( now > 1 && now%i == 0 ){
      now /= i;
      cnt++;
    }
    if( cnt > 0 ) num[i] = cnt;
  }
  if( now != 1 ) num[now] = 1;

  int ans = 0;
  for( auto p : num ){
    int cnt = 1;
    int A = p.second;
    while( A >= cnt ){
      A -= cnt;
      cnt++;
    }
    ans += (cnt-1);
  }
  cout << ans << endl;


}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO
  int age, cost;
  cin >> age >> cost;

  if(age <= 5) cout << 0;
  else if(age <= 12) cout << cost / 2;
  else cout << cost;

  return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
 int q,p,w[1000001],u[1000001],o;
 string a;
 int main()
 {
     cin>>a;
     for (int i=0;i<a.size();i++)
     {
         if (a[i]=='C') 
         {
             p++;
             u[p]=i+1;
         }
         else if (a[i]=='F')
         {
            q++;
             w[q]=i+1;
         }
     }
     if (q>=1 && p>=1)
     {
     for (int i=1;i<=p;i++)
     {
         for (int j=1;j<=q;j++)
         {
             if (u[i]<w[j])
             {
                 o=1;
             }
         }
     }
     if (o==1) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;  
     }
     else cout<<"No"<<endl;
 }

Measured memory_bytes: 2304
#include<stdio.h>
#define N 100000
#define NIL -1

typedef struct {
  int p;
  int left;
  int right;
}Node;

Node T[N];
int depth[N],height[N];

void Depth(int u,int d){
  if(u==NIL)return;
  depth[u]=d;
  Depth(T[u].left,d+1);
  Depth(T[u].right,d+1);
}

int Sibling(int u){
  if(T[u].p==NIL)return NIL;
  if(T[T[u].p].left!=u && T[T[u].p].left!=NIL)
    return T[T[u].p].left;
  if(T[T[u].p].right!=u && T[T[u].p].right!=NIL)
    return T[T[u].p].right;
  return NIL;
}

int Height(int u){
  int h1,h2;
  h1=h2=0;
  if(T[u].left!=NIL)
    h1=Height(T[u].left)+1;
  if(T[u].right!=NIL)
    h2=Height(T[u].right)+1;
  return height[u]=(h1>h2) ? h1 : h2;
}

void print(int id){
  int deg;
  printf("node %d: parent = %d, sibling = %d, ",id,T[id].p,Sibling(id));
  if(T[id].left!=NIL)deg++;
  if(T[id].right!=NIL)deg++;
  printf("degree = %d, depth = %d, height = %d, ",deg,depth[id],height[id]);
  if(T[id].p==NIL) printf("root\n");
  else if(T[id].left==NIL && T[id].right==NIL)
    printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int left,right,v,n,root=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=T[i].left=T[i].right=NIL;
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&left,&right);
    T[v].left=left;
    T[v].right=right;
    if(left!=NIL) T[left].p=v;
    if(right!=NIL) T[right].p=v;
  }
  
  for(i=0;i<n;i++)
    if(T[i].p==NIL)
      root=i;
  

  Depth(root,0);
  Height(root);

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



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int g = a[0];
  rep(i, n) g = __gcd(g, a[i]);
  if(g != 1) {
    cout << "not coprime" << endl;
    return 0;
  }
  vector<int> min_fact(1000005, -1);
  for(ll i = 2; i <= 1000000; ++i) {
    for(ll j = 1; i*j <= 1000000; ++j) {
      if(min_fact[i*j] == -1) min_fact[i*j] = i;
    }
  }

  set<int> all_div;
  rep(i, n) {
    set<int> divs;
    while(a[i] != 1) {
      int div = min_fact[a[i]];
      divs.insert(div);
      a[i] /= div;
    }
    for(auto add : divs) {
      if(all_div.find(add) != all_div.end()) {
        cout << "setwise coprime" << endl;
        return 0;
      }
      all_div.insert(add);
    }
  }
  cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 11124
from collections import deque
import sys
readline = sys.stdin.readline
N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
    u, v = map(int, readline().split())
    G[u-1].append(v-1)
S, T = map(int, readline().split())
S -= 1; T -= 1

INF = 10**9
U = [[INF]*N for i in range(3)]
U[0][S] = 0
que = deque([(S, 0)])
while que:
    v, t = que.popleft()
    u = (t+1) % 3
    d = U[t][v]
    if t == 2:
        d += 1
    Uu = U[u]
    for w in G[v]:
        if Uu[w] != INF:
            continue
        que.append((w, u))
        Uu[w] = d
print(U[0][T] if U[0][T] < INF else -1)

Measured memory_bytes: 57904
#include<bits/stdc++.h>
using namespace std;
int n,m,mn[55],a[55],b[55],c[55],d[55];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i-1],&b[i-1]);
		mn[i-1]=1e9;
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&c[i-1],&d[i-1]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(abs(a[i-1]-c[j-1])+abs(b[i-1]-d[j-1])<mn[i-1]){
				mn[i-1]=abs(a[i-1]-c[j-1])+abs(b[i-1]-d[j-1]);
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(abs(a[i-1]-c[j-1])+abs(b[i-1]-d[j-1])==mn[i-1]){
				printf("%d\n",j);
				break;
			}
		}
	}
}

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

using namespace std;
//using namespace std::chrono;

#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<long long>

typedef long long ll;
typedef double ld;

struct Pt {
    ld x, y;
};

ld getDist(Pt o, Pt a) {
    ld X = (o.x - a.x)*(o.x-a.x);
    ld Y = (o.y-a.y)*(o.y-a.y);
    return sqrt(X + Y);
}

vector<Pt> v;
int n;

ld getRadius (ld x, ld y) {
    ld maxi = -1000;
    Pt p1; p1.x = x; p1.y = y;
    for(int i = 0; i<n; i++){
        ld dist = getDist(p1, v[i]);
        maxi = max(maxi, dist);
    }
    return maxi;
}

ld getY(ld x){
    ld leY = 0.0, riY = 1000.0;
    for(int i = 0; i<2000; i++) {
         ld mid1 = leY + (riY-leY)/3;
         ld mid2 = riY - (riY-leY)/3;
         if (getRadius(x, mid1) < getRadius(x, mid2))
            riY = mid2;
         else
            leY = mid1;
    }
    return (leY + riY) / 2;
}

ld getAns(){
    ld leX = 0.0, riX = 1000.0;
    for(int i = 0; i<2000; i++) {
         ld mid1 = leX + (riX-leX)/3;
         ld mid2 = riX - (riX-leX)/3;
         if (getRadius(mid1, getY(mid1)) < getRadius(mid2, getY(mid2)))
            riX = mid2;
         else
            leX = mid1;
    }
    return (leX + riX) / 2;
}

void print(vi v){
    cout<<"Contents of vector:\n";
    for(auto x : v) cout<<x<<" ";
    cout<<endl<<endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
    //ifstream cin("input.txt"); ofstream cout("output.txt");///cia failai

    //int T; cin>>T;
    int T = 1;

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

        for(int i = 0; i<n; i++) {
            Pt p;
            cin>>p.x>>p.y;
            v.push_back(p);
        }

        ld X = getAns();

        Pt answer;
        answer.x = X; answer.y = getY(X);

        //cout<<fixed<<setprecision(15)<<"("<<answer.x<<", "<<answer.y<<")"<<endl;

        cout<<fixed<<setprecision(15)<<getRadius(answer.x, answer.y)<<endl;

    }


}


Measured memory_bytes: 3780
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val n = readInt()
    val s = mutableMapOf<String, Int>()
    for (i in 0 until n) {
        val result = readString()
        s[result] = s[result]?.plus(1) ?: 1
    }
    val statuses = listOf("AC", "WA", "TLE", "RE")
    for (status in statuses) {
        println("$status x ${s[status] ?: 0}")
    }
}

Measured memory_bytes: 59344
//AtCoder ABC100 A - Happy Birthday!
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B; cin>>A>>B;
    bool ans=(A<=8&&B<=8);
    cout<<(ans?"Yay!":":(")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i=0;i<N;i++)
using namespace std;

int main(void){
    
    //int N,M;
    //std::vector<int> A;//a_i=A.at(i)
    string A,X,C;
    cin>>A>>X>>C;
    cout<<"A"<<X[0]<<"C"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;


int main(){
	ll n,k;
	cin>>n>>k;
	ll r,s,p;
	cin>>r>>s>>p;
	string t,s1;
	cin>>t;
	for(ll i=0; i<n; i++){
		if(t[i]=='r') s1+='p';
		else if(t[i]=='s') s1+='r';
		else if(t[i]=='p') s1+='s';
	}
	for(ll i=0; i<n; i++){
		if(i>=k){
			if(t[i]==t[i-k] && s1[i]==s1[i-k]){
				s1[i]=t[i];
			}
		}
	}
	for(ll i=0; i<n; i++){
		if(i>=k){
			if(t[i]!=s1[i]){
				if(s1[i]=='p') ans+=p;
				else if(s1[i]=='r') ans+=r;
				else if(s1[i]=='s') ans+=s;
			}
		}
		else {
				if(s1[i]=='p') ans+=p;
				else if(s1[i]=='r') ans+=r;
				else if(s1[i]=='s') ans+=s;
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(3*n);
    rep(3*n) cin >> a[i];

    priority_queue<ll, vector<ll>, greater<ll> > que1;
    priority_queue<ll> que2;
    vector<ll> sum1(n+1, 0), sum2(n+1, 0);
    rep(n){
        que1.push(a[i]);
        que2.push(a[2*n+i]);
        sum1[0] += a[i];
        sum2[n] += a[2*n+i];
    }

    reppp(i, n, 2*n){
        que1.push(a[i]);
        sum1[i-n+1] = sum1[i-n] + a[i] - que1.top();
        que1.pop();
        que2.push(a[3*n-i-1]);
        sum2[2*n-i-1] = sum2[2*n-i] + a[3*n-i-1] - que2.top();
        que2.pop();
        /* はまり込んでしまった誤答
        if(a[idx1] - a1 >= a2 - a[idx2]){
            que1.push(a[idx1++]);
            que1.pop();
        }else{
            que2.push(a[idx2--]);
            que2.pop();
        }
        */
    }

    ll ans = LLONG_MIN;
    rep(n+1){
        ans = max(ans, sum1[i]-sum2[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5996
N = gets.to_i
h_list = gets.split.take(N).map(&:to_i)
ans = 1
c = (1..(N - 1)).count do |i|
  n = h_list[i]
  (0...i).all? do |j|
    m = h_list[j]
    m <= n
  end
end
ans += c
puts ans


Measured memory_bytes: 1788