akhauriyash/Code-Regression huggingface dataset:
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 2e5+2;

ll n, k;
vl a(maxN);

bool check(ll mid)
{
    ll moves = 0;

    rep(i, 0, n) {
        int here = (a[i] + mid - 1) / mid;
        -- here;
        moves += here;
    }

    return moves <= k;
}

void solve()
{

    lscn(n); lscn(k);

    rep(i, 0, n) {
        lscn(a[i]);
    }

    ll lo = 1, hi = (ll) 1e9;
    ll ans = -1;


    while(lo <= hi) {
        ll mid = (lo + hi) / 2;
        if(check(mid)) {
            ans = mid; hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }

    lprin(ans);
}

int main()
{
    int t = 1;
    // scn(t);
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4692
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

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

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ld l;
    cin >> l;
    
    l /= 3;
    double ans = l * l * l;
    printf("%lf\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

long long int dp[50][51][2501];

long long int mod = 1e9+7;

int main(){
  
  long long int N, K;
  scanf("%lld%lld", &N, &K);
  
  // solve problem
  for(int j = 0; j < N; j++){
    for(int k = 0; k <= N*N; k++){
      dp[0][j][k] = 0;
    }
  }
  dp[0][0][0] = 1;
  dp[0][1][2] = 1;
  for(int i = 1; i < N; i++){
    for(int j = 0; j <= N; j++){
      for(int k = 2*j; k <= N*N; k++){
        dp[i][j][k] = (2*j+1)*dp[i-1][j][k-2*j];
        //dp[i][j][k] = (dp[i][j][k] + mod)%mod;
        if(j >= 1){
          dp[i][j][k] += dp[i-1][j-1][k-2*j];
          //dp[i][j][k] = (dp[i][j][k] + mod)%mod;
        }
        if(j < N){
          dp[i][j][k] += (j+1) * (j+1) * dp[i-1][j+1][k-2*j];
          //dp[i][j][k] = (dp[i][j][k] + mod)%mod;
        }
        dp[i][j][k] = (dp[i][j][k] + mod)%mod;
      }
    }
  }
  
  std::cerr << "Answer: " << std::endl;
  std::cout << dp[N-1][0][K] << std::endl;
  
  return 0;
  
}


Measured memory_bytes: 50048
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;


int cut(int a, int b) {//切り捨て
	return (a - a % b) / b;
}

int a, b;
int main() {
	cin >> a >> b;
	for (int i = 0; i <= 10000; i++) {
		if (cut(i * 0.08,1) == a && cut(i * 0.10,1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    long prev=0, h;
    for (int i=0; i<n; i++) {
        cin >> h;
        if (h < prev) {
            cout << "No\n";
            return 0;
        }
        prev = max(h-1, prev);
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLineInt();
            var s = ReadLine();

            var re = 0;

            for (int i = 0; i <= n - 3; i++) {
                if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
                    re++;
                }
            }

            Console.WriteLine(re);
            ReadLine();
        }

        //メモ

        //配列
            //降順
            //var sort = array.OrderBy(x => -x).ToArray();

            //合計値
            //array.Sum();

        //kのn乗
        //(int) Math.Pow(k, n);


        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
vector<pii> segmen;
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int a=0;a<m;a++)
	{
		int L, R;
		scanf("%d%d", &L, &R);
		segmen.pb(pii(L, R));
	}
	sort(segmen.begin(), segmen.end());
	int ans=1;
	int R=segmen[0].se;
	for(int a=1;a<segmen.size();a++)
	{
		if(segmen[a].fi >= R)
		{
			ans++;
			R=segmen[a].se;
		}
		else R=min(R, segmen[a].se);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    fore(i,0,n) cin >> v[i];
    sort(v.begin(), v.end());
    fore(i,0,n) cout << v[i];
    cout << endl;
}


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

using namespace std;

int main() {
  int a, b, c, k;

  cin >> a >> b >> c >> k;

  int maximo = max(max(a, b), c);

  for(int i = 0; i < k; i++) maximo*=2;

  cout << maximo + min(a, b) + min(max(a, b), c) << endl; 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int h[n+1];
  h[0] = 0;
  for(int i = 1; i <= n; i++)
    cin >>h[i];
  int dp[n+1];
  dp[0] = 0;
  dp[1] = 0;
  for(int i = 2; i <= n; i++){
    if(i == 2){
      dp[i] = abs(h[i] - h[i -1]) + dp[i-1];
      continue;
    }
    dp[i] = min(abs(h[i] - h[i -1]) + dp[i-1], abs(h[i] - h[i - 2]) + dp[i-2]);
  }
  cout<<dp[n]<<"\n";
  
}

Measured memory_bytes: 1024
A = gets.strip.to_i
B = gets.strip.to_i
C = gets.strip.to_i
X = gets.strip.to_i

c = 0

(0..A).each do |i|
  (0..B).each do |j|
    (0..C).each do |k|
      sum = (i * 500) + (j * 100) + (k * 50)
      c += 1 if sum.eql?(X)
    end
  end
end

puts c


Measured memory_bytes: 1788
while True:
    h,w = map(int, input().split()) 
    count = 0
    if h == 0 and w == 0:
        break
    for y in range(h):
        if y % 2 == 0:
            for y in range(w):
                if count % 2 == 0:
                    print('#', end="")
                else:
                    print('.', end="")
                count += 1
            print() 
        else:
            for y in range(w):
                if count % 2 == 0:
                    print('.', end="")
                else:
                    print('#', end="")
                count += 1
            print() 
        count = 0    
    print()


Measured memory_bytes: 7008
# frozen_string_literal: true

n = gets.to_i
a, b = Array.new(n) { gets.split.map(&:to_i) }.transpose
cnt = 0

a.zip(b).reverse_each do |i, j|
  tmp = (i + cnt) % j
  cnt += tmp == 0 ? 0 : j - tmp
end

puts cnt

Measured memory_bytes: 13308
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  COUT(ans);

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
int main() {
  string s;
  cin>>s;
  ll n=s.size();
  vec dp(300000);
  if(n==1)putout(1);
  if(n==2){
    if(s[0]==s[1])putout(1);
    else putout(2);
  }
  if(n==3){
    if(s[0]==s[1]||s[1]==s[2])putout(2);
    else putout(3);
  }
  else{
    dp[0]=1;
    if(s[0]==s[1])dp[1]=1;
    else dp[1]=2;
    if(s[0]==s[1]||s[1]==s[2])dp[2]=2;
    else dp[2]=3;
    Loop(i,3,n){
      if(s[i]==s[i-1])dp[i]=dp[i-3]+2;
      else dp[i]=dp[i-1]+1;
    }
    putout(dp[n-1]);
  }
}


Measured memory_bytes: 2948
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

int a[3];

int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <iomanip>

#define PI 3.14159265358979
#define DEG_TO_RAD(deg) (((deg) / 180 ) * PI)

using namespace std;

int main()
{
	double a, b, C;
	double S, L, h;
	double c;
	cin >> a >> b >> C;
	c = sqrt((a * a) + (b * b) - (2 * a * b * cos(DEG_TO_RAD(C))));
	S = a * b * sin(DEG_TO_RAD(C)) / 2;
	L = a + b + c;
	h = b * sin(DEG_TO_RAD(C));
	cout << fixed
		<< setprecision(8)
		<< S << endl
		<< L << endl
		<< h << endl;
	return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

ll p[maxN];
int main() {
	int x,y;
	scanf("%d %d",&x,&y);
	if(500 * x >= y)
	{
		puts("Yes");
	} 
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
 
public class Main {
    private static final int MOD = (int) 1e9 + 7;
 
    public static void main(String[] args) throws FileNotFoundException {
        //Scanner in = new Scanner(new File(args[0]));
        //PrintWriter out = new PrintWriter(new File(args[1]));
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
 
        int t = in.nextInt(), d = in.nextInt(), l = in.nextInt();
        while (t != 0 && d != 0 && l != 0) {
            long ans = 0;
            long last = Integer.MIN_VALUE;
            for (int i = 1; i <= t; i++) {
                if (in.nextInt() >= l) {
                    if (i <= last) {
                        ans += i + d - 1 - last;
                    } else {
                        ans += d;
                    }
                    last = i + d - 1;
                }
            }
          	if (last != Integer.MIN_VALUE && last > t) {
              ans -= last - t;
            }
            out.println(ans == 0 ? 0 : ans - 1);
 
            t = in.nextInt();
            d = in.nextInt();
            l = in.nextInt();
        }
 
 
        out.close();
    }
 
    private static class Task {
        int d, p;
 
        public Task(int d, int p) {
            this.d = d;
            this.p = p;
        }
    }
}


Measured memory_bytes: 243816
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val w = Array.fill(n)(sc.next())
  
  if (!isDup(w) && isChain(w)) print("Yes") else print("No")
  
  def isDup(words: Array[String]): Boolean = {
    val map  = words.groupMapReduce(identity)(_ => 1)(_ + _)
    map.exists{case (k, v) => v > 1}
  }
  
  def isChain(words: Array[String]): Boolean = {
    words.zip(words.tail).forall(x => x._1.last == x._2.head)
  }
}

Measured memory_bytes: 55844
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func mul(a, b [][]int) [][]int {
	n := len(a)
	m:=len(b)
	l:=len(b[0])

	// fmt.Println(n,m,l)

	c:=make([][]int, n)
	for i:=0;i<n;i++ {
		c[i] = make([]int, l)
		for j:=0;j<m;j++{
			for k:=0;k<l;k++ {
				// fmt.Println(i,j,k)
				c[i][k] += a[i][j] * b[j][k]
			}
		}
	}
	return c
}

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

	n, _ := nextInt()
	m, _ := nextInt()
	l, _ := nextInt()

	// fmt.Println(n, m, l)

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			a[i][j], _ = nextInt()
		}
	}
	b := make([][]int, m)
	for i := 0; i < m; i++ {
		b[i] = make([]int, l)
		for j := 0; j < l; j++ {
			b[i][j], _ = nextInt()
		}
	}

	c := mul(a, b)

	// fmt.Println(a)
	// fmt.Println(b)
	for i:=range c{
		fmt.Println(stringifyArray(c[i]))
	}
}



Measured memory_bytes: 1780
#include <iostream>

using namespace std;
int x[200010];
long long ans = 1,mod = 1000000007,j = 0;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	for(i=0;i<n;i++){
		j++;
		if(x[i]==2*j - 2){
			(ans *= j) %= mod;
			j--;
		}
	}
	while(j){
		(ans *= j) %= mod;
		j--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
while True:
  n=int(input())
  if n==0:
    break
  elif n==1 or n==2:
    print(1)
  else:
    A=[0]*(n+1)
    A[0]=1
    A[1]=1
    A[2]=2
    for i in range(3,n+1):
      A[i]=A[i-1]+A[i-2]+A[i-3]
    print(A[n]//3650+1)


Measured memory_bytes: 5596
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vi prime(50000+1, 1);
	prime[0] = prime[1] = 0;
	FOR(i, 2, sqrt(50000)+1) {
		if(prime[i]) {
			for(int j = i*2; j <= 50000; j += i) {
				prime[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n, n) {
		int m = n/2;
		int ans = 0;
		FOR(i, 2, m) {
			if(prime[i] && prime[n-i]) {
				ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>
//#include <string.h>

int main(void){
  
  int a,b,t = 0;
  int count=0;
 
  scanf("%d %d %d", &a, &b, &t);

  /*
	for(int i=0;i<=t+0.5;i++){
      if(i%a==0){
        count=count+b;
      }
    }
  */
  
  
  printf("%d", (t/a)*b);

  return 0;
}

  



Measured memory_bytes: 1704
#include<stdio.h>

void trace(int A[], int N){
  int i;
  for( i = 0; i < N; i++ ){
    if(i > 0)printf(" ");
	       printf("%d",A[i]);
  }
  printf("\n");
}

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

int main(){
  int N, i, j;
  int A[100];

  scanf("%d", &N);
  for( i = 0; i < N; i++) scanf("%d", &A[i]);

  trace(A, N);
  insertionSort(A, N);

  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>

using namespace std;

int main(){
	int H,W,cou[26]={};
	cin >> H >> W;
	string s;
	for(int i=0;i<H;i++){
		cin >> s;
		for(int j=0;j<s.size();j++){
			cou[s[j]-'a']++;
		}
	}
	int cnt1=0,cnt2=0,cnt4=0;
	for(int i=0;i<26;i++){
		if(cou[i]%2!=0)cnt1++;
		if(cou[i]%4>1)cnt2++;
	}
    if(cnt1 > 1 || cnt1 == 1 && H * W == 0) {
        cout << "No" << endl;
    }else {
		int area =0;
		if(H%2!=0){
			area+=W/2;
		}
		if(W%2!=0){
			area+=H/2;
		}
		if(area<cnt2){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
	return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#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) FOR(i, n, 0);

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

  int n, m, x, y; cin >> n >> m >> x >> y;
  vector<int> a(n);
  vector<int> b(m);

  REP(i, n) {
    cin >> a[i];
  }

  REP(i, m) {
    cin >> b[i];
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  FOR(i, x+1, y+1) {
    if(a[n-1] < i && i <= b[0]) {
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int n, k, ans = 0;
    cin>>n;
    map<int,int> m;
    set<int> s;
    int a[n+4];
    f(i,n)cin>>a[i],s.insert(a[i]),m[a[i]]++;
    for(auto it = s.begin(); it != s.end(); it++)ans += (m[*it] * (m[*it] - 1) / 2);
    for(int i = 0; i < n; i++){
    cout<<(ans - (m[a[i]] * (m[a[i]] - 1) / 2) + ((m[a[i]] - 2) * (m[a[i]] - 1) / 2))<<endl;
    //cout<<i<<" "<<a[i]<<" "<<m[a[i]]<<" hi\n";
    }
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	using bulbs=bitset<1000>;
	int n,m,q;
	while(cin>>n>>m>>q,n){
	    vl s(q);
	    vector<bulbs> b(q);
	    bulbs tmp;
	    rep(i,q){
      	    string S,B;
      	    cin>>S>>B;
      	    s[i]=stoll(S,nullptr,2);
      	    b[i]=bulbs(B);
      	    if(i>0){
      	        //s[i]^=s[i-1];
      	        auto tmp2=b[i];
      	        b[i]^=tmp;
      	        tmp=tmp2;
      	    }else{
      	        tmp=b[i];
      	    }
      	    //cout<<bitset<11>(s[i]).to_string()<<":"<<b[i].to_string()<<endl;
	    }
	    string ans(m,'?');
		string d="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		rep(i,m){
			bulbs mask;
			mask[m-i-1]=true;
			ll S=(1ll<<36)-1; auto B=~bulbs();
			rep(j,q){
				if((b[j]&mask).any()){
					S&=s[j];
					B&=b[j];
				}else{
					S&=~s[j];
					B&=~b[j];
				}
			}
			//cout<<pii(p,i)<<bulbs(S).to_string()<<","<<B<<endl;
			if(__builtin_popcountll(S)==1){
				int index=n-1-__builtin_ctzll(S);
				d[index]='_';
				rep(j,m){
					bulbs mask2; mask2[m-j-1]=true;
					if((B&mask2).any())ans[j]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"s[index];
				}
				rep(j,q){
					s[j]&=~S;
					b[j]&=~B;
				}
			}
		}
        if(count(all(d),'_')==n-1){
			rep(i,n){
				if(d[i]!='_'){
					rep(j,m){
						if(ans[j]=='?') ans[j]=d[i];
					}
					break;
				}
			}
        }
	    cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 3296
# input
N = int(input())
SA = [str(input()) for i in range(N)]

# process
cities = list(set([x.split()[0] for x in SA]))
cities.sort()

for y in cities:
    each_SA = []
    for i in SA:
        if i.split()[0] == y:
            each_SA.append(i)
    each_points = [int(x.split()[1]) for x in each_SA]
    each_points.sort(reverse=True)
    for j in each_points:
        print(SA.index(y + ' ' + str(j)) + 1)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> words(n);

    string prev = "";
    for (int i = 0; i < n; ++i) {
        string w; cin >> w;
        bool rule1 = 0 == prev.size() || prev[prev.size() - 1] == w[0];
        bool rule2 = find(words.begin(), words.end(), w) == words.end();
        if (rule1 && rule2) {
            words.push_back(w);
            prev = w;
        } else {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import collections


class Node(object):

  def __init__(self):
    self.edges = set()
    self.distance = 1


def main():
  N = int(input())
  nodes = [Node() for _ in range(N)]

  if N == 0:
    print('Second', flush=True)
    return
  elif N == 1:
    print('First', flush=True)
    return

  for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].edges.add(nodes[b - 1])
    nodes[b - 1].edges.add(nodes[a - 1])

  leaves = collections.deque(n for n in nodes if len(n.edges) == 1)

  while True:
    leaf = leaves.popleft()
    parent = leaf.edges.pop()

    if len(parent.edges) == 1:
      size = leaf.distance + parent.distance
      break

    parent.distance = max(parent.distance, leaf.distance + 1)
    parent.edges.remove(leaf)

    if len(parent.edges) == 1:
      leaves.append(parent)

  if size % 3 == 2:
    print('Second', flush=True)
  else:
    print('First', flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 94824
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n;
int v[11][2];
int main(void){
  v[0][0] = 2;
  v[0][1] = 3;
  v[1][0] = 5;
  v[1][1] = 3;
  v[2][0] = -1;
  v[2][1] = 4;
  v[3][0] = 2;
  v[3][1] = -1;
  v[4][0] = 1;
  v[4][1] = 5;
  v[5][0] = 3;
  v[5][1] = 2;
  string s;
  while(cin >> s && s != "#"){
    n = 0;
    for(int i = 0; i < (int)s.size(); i++){
      n = v[n][s[i]-'0'];
      if(n < 0) break;
    }
    if(n == 5) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1180
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A, B, K = map(int, input().split())

    taka = max(0, A - K)
    aoki = 0 if min(A + B - K, B) < 0 else min(A + B - K, B)
    print(taka, aoki)


main()


Measured memory_bytes: 2940
def is_not_isolated(s_list, i, j):
    map_char_to_bool = {'.': False, '#': True}
    not_isolated = False
    for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)):
        try:
            not_isolated = not_isolated or map_char_to_bool[s_list[i+di][j+dj]]
        except IndexError:
            pass
    return not_isolated

H, W = [int(elem) for elem in input().split(' ')]
s_list = [list(input()) for _ in range(H)]
assert len(s_list) == H
assert len(s_list[0]) == W

for i in range(len(s_list)):
    for j in range(len(s_list[0])):
        if s_list[i][j] == ".":
            continue
        else:
            if not is_not_isolated(s_list, i, j):
                print("No")
                exit(0)
else:
    print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long L = Long.parseLong(sc.next());
		long R = Long.parseLong(sc.next());
		sc.close();
		long mod = 2018;
		long cal = 0;
		for(long i = L;i <= R;i++) {
			for(long j = i+1;j <=R;j++) {
				cal = (i * j)%2019;
				if(cal < mod) {
					mod = cal;
				}else if(cal == 0) {
					System.out.println(0);
					return;
				}
			}
		}
		System.out.println(mod);
	}
}

Measured memory_bytes: 23252
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int cnt = 1;
        if(a != 0)
            System.out.printf("Case %d: %d%n",cnt, a);
        while(a != 0){
            a = sc.nextInt();
            if(a == 0) break;
            cnt++;
            System.out.printf("Case %d: %d%n",cnt, a);
        }
        sc.close();
    }
}



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

int main() {
	int n; string s;
	cin >> n >> s;

	vector<int> val(n, 0);
	forn(i, n-1) val[i+1] = val[i] + 32 - __builtin_clz((i+1) & (-i-1));

	int total = 0;
	forn(i, n) total ^= (s[i] - '1') * int(val[n-1] == val[n-i-1] + val[i]);
	if(s.find('2') != string::npos) total &= 1;
	cout << total << "\n";
}


Measured memory_bytes: 5252
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

	int max = 19999;
	rep (i, n) {
		int c, t;
		cin >> c >> t;
		if (t <= T) chmin(max, c);
	}
	if (max == 19999) cout << "TLE" << endl;
	else cout << max << endl;
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine()); 
            string[] input = Console.ReadLine().Split(' ');

            int max = 0;
            int cnt = 0;

            for(int i = 0; i < n ; i++)
            {
                int h = Int32.Parse(input[i]);
                if( h >= max)
                {
                    cnt++;
                    max = h;
                }
            }

            Console.WriteLine(cnt);
        }      
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
			
		for(int i=0;i<n;i++){
			double xa = sc.nextDouble();
			double ya = sc.nextDouble();
			double xb = sc.nextDouble();
			double yb = sc.nextDouble();
			double xc = sc.nextDouble();
			double yc = sc.nextDouble();
			
			double a = 2*(xb-xa);
			double b = 2*(yb-ya);
			double c = xa*xa - xb*xb + ya*ya - yb*yb;
			double d = 2*(xc-xa);
			double e = 2*(yc-ya);
			double f = xa*xa - xc*xc + ya*ya - yc*yc;
			
			double xp = (b * f - c * e) / (e * a - b * d);
		    double yp = (d * c - a * f) / (e * a - d * b);   
		    double r = Math.sqrt((xa-xp)*(xa-xp)+(ya-yp)*(ya-yp));
		    System.out.printf("%.3f %.3f %.3f\n", xp, yp, r);
		}
	}	
}

Measured memory_bytes: 20500
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] a = new int[9];
		for(int i=0 ; i<n;i++) {
			int x = stdIn.nextInt();
			if(x/400<=7) {
				a[x/400]++;
			}
			else {
				a[8]++;
			}
		}
		int i=0;
		int range = 0;
		while(i<8) {
			if(a[i++]>0) {
				range++;
			}
		}
		int min = range;
		int max = range + a[8];
		if(range==0) {
			min = 1;
			max = a[8];
		}
		System.out.println(min+" "+max);
	}
}


Measured memory_bytes: 21844
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void writeAns(long[][] l) {
    writeln(l.length);
    foreach(li; l) {
        writeln(li[0], " ", li[1]);
    }
}

void main(){
    auto n = readLong();
    auto a = readLongs();
    if(a.all!("a == 0")) {
        writeln(0);
        return;
    }
    long[][] ans;
    size_t mxi, mni;
    foreach(i; iota(n)) {
        if(a[mxi] < a[i]) {
            mxi = i;
        }
        if(a[mni] > a[i]) {
            mni = i;
        }
    }
    if(a[mxi] * a[mni] < 0) {
        if(abs(a[mxi]) > abs(a[mni])) {
            foreach(i; iota(n)) {
                if(a[i] < 0) {
                    a[i] += a[mxi];
                    ans ~= [mxi+1, i+1];
                }
            }
        } else {
            foreach(i; iota(n)) {
                if(a[i] > 0) {
                    a[i] += a[mni];
                    ans ~= [mni+1, i+1];
                }
            }
        }
    }
    auto mx = reduce!max(a);
    auto mn = reduce!min(a);
    if(mn >= 0) {
        foreach(i; iota(n-1)) {
            ans ~= [i+1, i+2];
        }
    } else {
        foreach(i; iota(n-1).retro) {
            ans ~= [i+2, i+1];
        }
    }
    writeAns(ans);

}



Measured memory_bytes: 256
K,N = map(int,(input().split()))
MOD = 10**9+7
core = [0]*(N+1)
tr = [0]*(N+1)

for i in range(1,N+1):
    core[i] = N//i

for i in range(1,N+1)[::-1]:
    if core[i] == 1:
        tr[i] = 1
    else:
        tr[i] = pow(core[i],K,MOD)
        now = i
        r = 2
        while now*r <= N:
            tr[i] -= tr[now*r]
            r += 1

ans = 0
for i in range(1,N+1):
    ans += i * tr[i]
    ans %= MOD

print(ans)

Measured memory_bytes: 69668
#include <iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
int aa[1000][1000]={};
int main()
{
    int  i=0,j=0,n=0,a=0,b=0,c=0,d=0;


    cin >> n;
    for(i=0;i<n;i++){
        d=0;
        cin >> a >> b >> c;
        if(a>b&&a>c){
            if((a*a-(b*b+c*c)==0)){
                cout << "YES" << endl;
            }
            else cout << "NO" << endl;

        }
        else if(b>c){
            if((b*b-(a*a+c*c)==0)){
                cout << "YES" << endl;
            }
            else cout << "NO" << endl;
        }
        else{
            if((c*c-(b*b+a*a)==0)){
                cout << "YES" << endl;
            }
            else cout << "NO" << endl;
        }
    }

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50;

int n,mcnt,del[N];
multiset<int> adj[N]; 
struct P { int x,y; } ; 

queue<P> q;
map<P,int> e;
P makePair(int x,int y){ return x>y?(P){y,x}:(P){x,y}; }
bool operator<(const P &a,const P &b){ return a.x==b.x?a.y<b.y:a.x<b.x; } 

void merge(int x,int y){
	for(int d:adj[y]){
		if(d!=x){
			adj[x].insert(d); 
			adj[d].insert(x); 
			if(++e[makePair(x,d)]==2){
				q.push(makePair(x,d)); 
			}
		}
		if(e.count(makePair(y,d)))e.erase(e.find(makePair(y,d))); 
	}
	del[y]=true;
	adj[x].erase(y); 
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin); 
#endif
	read(n);
	rep(i,1,2*n-2){
		int u,v; 
		read(u);
		read(v); 
		Pr("u=%d,v=%d\n",u,v); 
		adj[u].insert(v); 
		adj[v].insert(u); 
		if(++e[makePair(u,v)]==2){
			q.push(makePair(u,v)); 
		}
	}
	Pr("read end.\n");
	//for(auto t:e)Pr("(%d,%d):%d\n",t.first.x,t.first.y,t.second);  
	while(!q.empty()){
		auto t=q.front(); 
		q.pop(); 
		Pr("Merge %d,%d\n",t.x,t.y); 
		if(del[t.x]||del[t.y])continue;
		if(adj[t.x].size()>adj[t.y].size()){
			merge(t.x,t.y); 
		}else{
			merge(t.y,t.x); 
		}
		++mcnt;
	}
	puts(mcnt==n-1?"YES":"NO"); 
	return 0;
}


Measured memory_bytes: 83712
n = int(input())

t , a = map(int, input().split())

h = [int(i) for i in input().split()]

dif_m = float("inf")
dif_h = 0
dif_n = 0

for i in range(n):
    dif_h = abs (a - (t - h[i] * 0.006))
    if dif_m > dif_h:
        dif_m = dif_h
        dif_n = i + 1
    
print(dif_n)

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

int gcd(int a,int b){
	while(1){
		if(a<b)swap(a,b);
		if(!b)break;
		a%=b;
	}
	return a;
}

int main(){
	long long int a,b;
	while(cin>>a>>b){
		long long int ans = gcd(a,b);
		cout<<ans<<" "<<(a*b)/ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif


int N, M;

int C[100001];
int main() {
	cin >> N >> M;
	REP(i, 0, 2 * M) {
		int a;
		cin >> a;
		++C[a];
	}
	YESNO(all_of(C, C + N + 1, [](int n) {return n % 2 == 0; }));
	return 0;
}


Measured memory_bytes: 640
def yymm_or_mmyy(s):

    ans = ""
    flag1 = False
    flag2 = False

    for i in range(1, 13):
        if s[0:2] == str(i).zfill(2):
            flag1 = True
        if s[2:4] == str(i).zfill(2):
            flag2 = True

    if flag1 and flag2:
        ans = "AMBIGUOUS"
    elif flag1:
        ans = "MMYY"
    elif flag2:
        ans = "YYMM"
    else:
        ans = "NA"

    return ans

def main():
    s = str(input())
    print(yymm_or_mmyy(s))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#define RG register
using namespace std;
const int N=1e4+10;
int n,k,num[N],ans,tot;
char ss[13];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
priority_queue<int> pn;
int main()
{
//	freopen("Problem Committee.in","r",stdin);
	read(n,k);
	for(RG int i=1;i<=n;i++)
	{
		scanf("%s",ss);
		num[ss[0]-'A']++;
	}
	for(RG int i=0;i<26;i++) if(num[i]) pn.push(num[i]);
	while(pn.size()>=k)
	{
		int cnt=0;
		for(RG int i=1;i<=k;i++) 
		{
			int tt=pn.top();pn.pop();
			if(tt-1) num[++cnt]=tt-1;
		}
		for(RG int i=1;i<=cnt;i++) pn.push(num[i]);
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

ll f(ll x, ll c, ll d){
  ll lcm = (c*d)/__gcd(c, d);
  ll res = x;
  res -= x/c;
  res -= x/d;
  res += x/lcm;
  return res;
}
  
int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll ans = f(B, C, D) - f(A-1, C, D);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X, T;
    cin >> N >> X >> T;
    cout << ((N + X - 1) / X) * T << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //MaxNumを使い回すことで計算を抑える
        MaxNum = max(MaxNum, A[i]);
        ans += MaxNum - A[i];
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4036
n = int(input())
ans = True
for k in range(1, 500):
    if n == k * (k - 1) / 2:
        ans = False
        break
if ans:
    print('No')
    exit()
print('Yes')
print(k)
val = 1
ans_list = [[] for _ in range(k)]
for i in range(k - 1):
    for j in range(i + 1, k):
        ans_list[i].append(val)
        ans_list[j].append(val)
        val += 1
for a in ans_list:
    print(*([len(a)] + a))

Measured memory_bytes: 14092
while True:
    try:
        (H,W)  =  map(int,input().split())
    except:
        exit
    
    if (H == 0 and W == 0):
         break

    s1 = "#" * W
    
    if ( W >= 3 ):
        s2 = "#" + ("." * ( W -2 ) ) + "#"
    else:
        s2 = "#" * W

    print (s1)
    for i in range(0,H-2):
        print(s2)
    print(s1)
    print("")



Measured memory_bytes: 5612
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let ab: Vec<u32> = read_vec();
    let a = ab[0];
    let b = ab[1];

    let sa: Vec<String> = (0..b).map(|_| a.to_string()).collect();
    let sa = sa.connect("");

    let sb: Vec<String> = (0..a).map(|_| b.to_string()).collect();
    let sb = sb.connect("");

    println!("{}", if sa < sb { sa } else { sb });
}


Measured memory_bytes: 4352