akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include<math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
ll mod=1e9+7;

int main(){
	int a,p; cin >>a>>p;
	cout << (3*a+p)/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) {
	if (a == 0) {
		return b;
	}
	else {
		return gcd(b%a, a);
	}
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		ll q, w, e, r;
		scanf("%lld %lld %lld %lld", &q, &w, &e, &r);
		if (q < w)
			puts("No");
		else if (w > r)
			puts("No");
		else
		{
			ll ch = (q - e) / w;
			if ((q - e) % w != 0)
				ch++;
			if (ch*w > q)
				puts("No");
			else
			{
				q -= (ch*w);
				ll o = r%w;
				if (o == 0)
				{
					puts("Yes");
					continue;
				}
				ll x = (e - q) / o;
				x++;
				ll p = gcd(o, w);
				if ((e < x*o+q&&x*o+q < w))
					puts("No");
				else {
					if (p < w - e)
						puts("No");
					else
					puts("Yes");
				}
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int sum = 0;
		for (int i = 0; i < 3; i++)
			sum += in.nextInt();
		if (sum >= 22)
			System.out.println("bust");
		else
			System.out.println("win");
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  constexpr double PI = acos(-1);
  int r;
  cin>>r;
  cout<<fixed<<setprecision(10)<<2*r*PI<<endl;
  return 0;
}


Measured memory_bytes: 3800
// B - Kleene Inversion
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

int main(){
	ll N,K; cin>>N>>K;
	vector<ll> A(N);
	ll L = 0, M = 0;
	for(int i=0; i<N; i++) cin>>A[i];

	for(int i=0; i<N; i++)
		for(int j=0; j<N; j++){
			if(i!=j && A[i]>A[j]) M++;
			if(i+1<=j && A[i]>A[j]) L++;
		}

	ll KC2 = K%2? (K-1)/2: K/2;
	KC2 = K%2? KC2 * K % MOD: (K-1) * KC2 % MOD;

	ll a = L * K % MOD;
	ll b = M * KC2 % MOD;
	cout<< (a+b) % MOD << endl;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  //"strconv"
)

func main() {
  var (
    nums string
    white string
  )

  fmt.Scan(&nums)
  //n := len(nums)
  for i:=range(nums) {
    if i%2==0{
      white += "0"
    } else {
      white += "1"
    }
  }

  dif_w:=0
  dif_b:=0
  for i:=range(nums) {
    if nums[i:i+1] != white[i:i+1] {
      dif_w += 1
    } else {
      dif_b += 1
    }
  }

  if dif_w > dif_b {
    fmt.Println(dif_b)
  } else {
    fmt.Println(dif_w)
  }

}


Measured memory_bytes: 12032
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	d := make([][]int, 10)
	for i := 0; i < len(d); i++ {
		d[i] = make([]int, 10)
	}

	for i := 1; i <= n; i++ {
		t := i
		digits := []int{}
		for t > 0 {
			digits = append(digits, t%10)
			t /= 10
		}
		x := digits[0]
		y := digits[len(digits)-1]
		d[x][y]++
	}

	ans := 0
	for x := 0; x <= 9; x++ {
		for y := 0; y <= 9; y++ {
			ans += d[x][y] * d[y][x]
		}
	}

	stdout.Println(ans)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define debug(s) cout << #s << " = " << s << endl
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	string s;
	cin >> s;
	ll ans = 0;
	int post = s.length()-1;
	for(int i=s.length()-1;i>=0;i--){
		if(s[i] == 'B'){
			ans += post - i;
			post--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}


void calculate(){
    int N,M;
    cin >> N >> M;
    if(N % 2 == 1){
        int count = M;
        for(int r = 1,l = N;r < l;r++,l--){
            cout << r << " " << l << '\n';
            count--;
            if(count == 0){
                break;
            }
        }
    }else{
        int count = M;
        bool one_time = true;
        for(int l = 1,r = N;l < r;l++,r--){
            if(one_time and r - l <= N / 2){
                r--;
                one_time = false;
            }
            cout << l << " " << r << '\n';
            count--;
            if(count == 0){
                break;
            }
        }
    }
}

int main(int,char**){
    calculate();    
}





Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, k, before_loop, loop_len;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> tmp;
  vector<bool> f(n, false);
  vector<ll> l(n + 1, -1);
  REP(i, n) {
    ll c;
    cin >> c;
    a.at(i) = c - 1;
  }

  tmp.push_back(0);
  f.at(0) = true;
  for (int i = 1; i <= n; i++) {
    tmp.push_back(a.at(tmp.at(i - 1)));
    if (f.at(tmp.at(i))) {
      break;
    }
    f.at(tmp.at(i)) = true;
  }

  loop_len = distance(find(ALL(tmp), tmp.at(tmp.size() - 1)), tmp.end())-1;
  before_loop = distance(tmp.begin(), find(ALL(tmp), tmp.at(tmp.size() - 1)));
  copy(find(ALL(tmp), tmp.at(tmp.size() - 1)), tmp.end()-1, l.begin());

/*
  cout << "tmp:" << " ";
  for(auto x:tmp) { cout << x << " "; }
  cout << "\nf: ";
  for(auto x:f) { cout << x << " "; }
  cout << "\nl: ";
  for(auto x:l) { cout << x << " "; }
  cout << "\nbefore_loop: ";
  cout << before_loop << "\n";
  cout << "loop_len :" << loop_len << "\n";
*/

  if (k >= before_loop){
    cout << l.at((k - before_loop) % loop_len) + 1 << "\n";

  }
  else
    cout<<tmp.at(k)+1<<"\n";
}


Measured memory_bytes: 8512
#include <stdio.h>
#include <string.h>
int R(char arr[], int n, int k, int index);
int main()
{
    char arr[100001] = {0};
    scanf("%s", arr);
    int len = strlen(arr);
    int k;
    scanf("%d", &k);
    int ch_move[100001] = {0};
    //printf("%d", len);
    for (int i=0; i<len; i++)
    {
        if (arr[i] == 'a')
            ch_move[i] = 0;
        else
            ch_move[i] = 26 - (arr[i] - 'a');
        //printf("%d ", ch_move[i]);
    }
    int i = 0;
    while (k && i < len)
    {
        k = R(arr, ch_move[i], k, i);
        i++;
    }
    k = k % 26;
    arr[i-1] = arr[i-1] + k;
    puts(arr);


    return 0;
}
int R(char arr[], int n, int k, int index)
{
    if (n > k)
        return k;
    arr[index] = 'a';
    return (k - n);
}


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

int main () {
    int N, A[100];
    int count = 0;
    
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    
    for(int i = 0; i < (N - 1); i++) {
        for(int j = (N - 1); j > i; j--) {
            if(A[j] < A[j - 1]) {
                int k = A[j];
                A[j] = A[j - 1];
                A[j - 1] = k;
                count++;
            }
        }
    }

    for(int i = 0; i < N; i++) {
        if(i < N-1) cout << A[i] << " ";
        else cout << A[i] <<"";
    }
    cout << endl;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3112
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int x, y;
  ci(x, y);
  rep(i, x + 1){
    if(i * 2 + (x - i) * 4 == y){
      co("Yes");
      rt 0;
    }
  }
  co("No");
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll D, N;
  cin >> D >> N;

  ll ans = (N == 100) ? 101 : N;
  if (D == 0) {
    cout << ans;
  } else {
    REP(i, D) { ans *= 100; }
    cout << ans;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    string s;
    cin >> s;
    if(s == "AAA" | s == "BBB"){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-10**18]*(N+1)
dp[0] = 0

for i in range(N):
    for Ai in A:
        if i+nums[Ai]<=N:
            dp[i+nums[Ai]] = max(dp[i+nums[Ai]], dp[i]+1)

ans = []
now = N

for i in range(dp[N]):
    for Ai in A:
        if now-nums[Ai]>=0 and dp[now-nums[Ai]]==dp[N]-i-1:
            now -= nums[Ai]
            ans.append(str(Ai))
            break

print(''.join(ans))

Measured memory_bytes: 74040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//下ごしらえ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] A = new int [n][m];
		int[] b = new int[m];

		//Aの中身をインプット
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				A[i][j]=sc.nextInt();
			}
		}
		//bの中身をインプット
		for(int i=0;i<m;i++) {
			b[i]=sc.nextInt();
		}

		//計算の実行
		for(int i=0;i<n;i++) {
			int c=0;
			for(int j=0;j<m;j++) {
				c += (A[i][j]*b[j]);
			}
			System.out.println(c);
		}
	}

}



Measured memory_bytes: 40612
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  double l;
  int a,b,c=0,d=0,e=0;
  while(scanf("%d,%d",&a,&b)!=EOF){
    c+=a*b;
    d+=b;
    e++;
  }
  l=(double)d/e+0.5;
  cout<<c<<endl<<(int)l<<endl;
}

Measured memory_bytes: 3132
//#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 101
#define INF (int)1e9
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
 
int mp[inf][inf],sum[inf][inf],f[inf][inf][inf];
int n,m;
 
int getsum(int l1,int l2,int r1,int r2){
    return sum[r1][r2]-sum[l1-1][r2]-sum[r1][l2-1]+sum[l1-1][l2-1];
}
 
int main(){
    rd(n) rd(m)
    char ch;
    int ex,ey;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            ch=getchar();
            while (ch!='o' && ch!='.' && ch!='E'){
                ch=getchar();
            }
            if (ch=='o'){
                mp[i][j]=1;
            }
            else if (ch=='E'){
                ex=i,ey=j;
            }
        }
    }
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            sum[i][j]=mp[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
        }
    }
    int ans=0;
    for (int i=0;ex-i>=1;i++){
        for (int j=0;ex+j<=n;j++){
            int l1=max(ex-i,j+1),r1=min(ex+j,n-i);
            if (l1>r1){
                continue;
            }
            for (int k=0;ey-k>=1;k++){
                for (int l=0;ey+l<=m;l++){
                    int l2=max(ey-k,1+l),r2=min(ey+l,m-k);
                    if (l2>r2){
                        continue;
                    }
                    ans=max(ans,f[j][k][l]);
                    if (i+j<n-ex){
                        f[j+1][k][l]=max(f[j+1][k][l],f[j][k][l]+getsum(ex+j+1,l2,ex+j+1,r2));
                    }
                    if (k+l<ey-1){
                        f[j][k+1][l]=max(f[j][k+1][l],f[j][k][l]+getsum(l1,ey-k-1,r1,ey-k-1));
                    }
                    if (k+l<m-ey){
                        f[j][k][l+1]=max(f[j][k][l+1],f[j][k][l]+getsum(l1,ey+l+1,r1,ey+l+1));
                    }
                    if (i+j<ex-1){
                        f[j][k][l]=max(f[j][k][l],f[j][k][l]+getsum(ex-i-1,l2,ex-i-1,r2));
                    }
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

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

    vector<int> a(1 << n);
    vector<int> m(1 << n);
    vector<int> t(1 << n);
    vector<int> s(1 << n);

    for (auto& i : a)
        cin >> i;
    
    REP (i, 1 << n)
    {
        t[i] = a[i];
        s[i] = i;

        if (!i)
            continue;
        
        set<pair<int, int>> b;
        b.emplace(t[i], s[i]);
        
        for (int j = 1; j <= i; j <<= 1)
        {
            int k = i & ~j;
            if (k == i)
                continue;
            b.emplace(t[k], s[k]);
        }

        auto it = b.rbegin();

        t[i] = it->first;
        s[i] = it->second;

        m[i] = max((++it)->first + t[i], m[i - 1]);
        
        cout << m[i] << endl;
    }

	return 0;
}


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

char lowcmp[26]="abcdefghijklmnopqrstuvwxyz";
char upcmp[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long mod=1000000007;
int max(int A,int B){return A>B?A:B;}
int min(int A,int B){return A<B?A:B;}
void swap(int *A,int *B){int T;T=*A;*A=*B;*B=T;}
int gcd(int A,int B){return min(A,B)==0?max(A,B):gcd(min(A,B),max(A,B)%min(A,B));}
int lcm(int A,int B){return A*B/gcd(A,B);}
int ntoi(char C){return C-'0';}
int ltoi(char C){return C-'a';}
int utoi(char C){return C-'A';}
int AscendingSort(const void *A,const void *B){return *(int*)A>*(int*)B?1:0;}
int DescendingSort(const void *A,const void *B){return *(int*)A<*(int*)B?1:0;}

int main(void){
    long long ans=0,tmp=0;
    char s[200020];
    scanf("%s",s);
    for (int i=0; i<strlen(s); i++){
        if (s[i]=='B'){
            tmp++;
        }
        if (s[i]=='W'){
            ans+=tmp;
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}


Measured memory_bytes: 384
n=int(input())
ans=0
arr=list(map(int,input().split()))
pos=[0]*(n+1)
for i in range(n):
  pos[arr[i]]=i
l=[i for i in range(n+1)]
r=[i for i in range(n+1)]
for i in range(n,0,-1):
  idx=pos[i]
  tl,tr=l[idx],r[idx]
  ans+=i*(idx-tl+1)*(tr-idx+1)
  l[tr+1]=tl
  r[tl-1]=tr
print(ans)

Measured memory_bytes: 36904
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let d = nextIntArray()
    d.sort((a,b) => a-b)
    let v = d[n/2]
    let prev = d[n/2-1]
    console.log(v-prev)
}
Main()



Measured memory_bytes: 39940
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int x,y,i,j,count;
    int l;
    count = 0;
    int count2 = 0;
    char S[256];
    scanf("%d %d",&x,&y);
    for (i = 0; i <= x; i++){
        scanf("%d",&l);
        count = count + l;
        count2++;
        if (y < count){
            break;
        }
    }
    //scanf("%s",S);
    printf("%d",count2);
    //printf("%s",S);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"
#define mod 1000000007
#define boro 200007
vector< vector<data_type> > adjlist(boro);
bitset <boro>is_visited;
data_type weight[boro];
data_type c=0;
void dfs(data_type a)
{
    if(is_visited[a])
        return;
        c++;
    is_visited[a]=1;
    for(auto i:adjlist[a])
        if(is_visited[i]==0)
            dfs(i);

}
int main()
{
   data_type n,m,x,y,ans=0;
   cin>>n>>m;
   while(m--)
   {
      cin>>x>>y;
      adjlist[x].push_back(y);
      adjlist[y].push_back(x);
   }
   for(int i=1;i<=n;i++)
   {
      if(is_visited[i])
         continue;
      c=0;
      dfs(i);
      ans=max(ans,c);
   }
   cout<<ans<<endl;

    return 0;

}



Measured memory_bytes: 23500
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
// #define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

// 約数列挙
vector<long long> divisor(long long n){
    vector<long long> div;
    for(long long i = 1; i*i <= n; i++){
        if(n%i == 0){
            div.push_back(i);
            if(i*i != n) div.push_back(n/i);
        }
    }
    sort(div.begin(), div.end());
    return div;
}

int main() {
    ll n; cin >> n;
    Vl div = divisor(n);
    ll ans = 0;
    rep(i, 0, sz(div)){
        ll m = div[i] - 1;
        if(m == 0) continue;
        if(n/m == n%m) ans += m;
    }
    co(ans);

    return 0;
}
 
 


Measured memory_bytes: 3656
n, k = map(int, input().split())
s = list(input())
s = list((map(int, s)))
tipS = []
cnt = 1
ans = 0
zeroInd = []
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        tipS.append([s[i], cnt])
        cnt = 1
tipS.append([s[-1], cnt])
total_sum = [0] * len(tipS)
total_sum[0] += tipS[0][1]
for i in range(len(tipS)):
    if tipS[i][0] == 0:
        zeroInd.append(i)
    if i != 0:
        total_sum[i] += tipS[i][1] + total_sum[i-1]
if len(zeroInd) != 0:
    start = zeroInd[0]
tmp_cnt = 0
tmp = 0
tmp2 = 0
before = 0
#print(total_sum)
for i in range(len(tipS)):

    if tipS[i][0] == 0:
        tmp_cnt += 1


        if tmp_cnt > k:
            ans = max(tmp, ans)
            #print("ans: {}".format(ans))
            tmp -= (total_sum[start] - before)
            before = total_sum[start]
            #print("minus{}".format(tmp))
            tmp += tipS[i][1]
            tmp_cnt -= 1
            tmp2 += 1
            start = zeroInd[tmp2]

        else:
            tmp += tipS[i][1]


    else:
        tmp += tipS[i][1]
    #print("tmp_cnt: {}".format(tmp_cnt))
    #print("tmp: {}".format(tmp))

ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 61176
r, c = gets.split.map(&:to_i)
sx, sy = 0, 0
gx, gy = r-1, c-1

maze = []
r.times{ maze << gets.chomp.split('') }
ss = Array.new(r).map{ Array.new(c, nil)}

nxy = [[0,1], [1, 0], [0, -1], [-1, 0]]
qs = [[sx, sy]]
ss[sx][sy] = 0

while q = qs.shift
  next_count = ss[q[0]][q[1]] + 1
  nxy.each{|n|
    np = [n[0]+q[0], n[1]+q[1]]
    next if np[0] < 0 || r-1 < np[0] || np[1] < 0 || c-1 < np[1]
    next if maze[np[0]][np[1]] == '#'
    next unless ss[np[0]][np[1]].nil?
    ss[np[0]][np[1]] = next_count
    qs << np
  }
  break if ss[gx][gy]
end

if qs.size.zero?
  p -1
else
  sharp_count = maze.inject(0){|s, m| s + m.select{|e| e == '#'}.size }
  p r * c - sharp_count - ss[gx][gy] - 1
end


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int n, a;
int x[55];
ll dp[55][55][2555] = {0};

int main () {
  cin >> n >> a;
  rep(i,n) cin >> x[i];

  dp[0][0][0] = 1;
  rep(j,55) {
    rep(k,55) {
      rep(s,2555) {
        if (j >= 1 && s-x[j-1]<0) {
          dp[j][k][s] = dp[j-1][k][s];
        }
        if (j >= 1 && k >= 1 && s-x[j-1]>=0) {
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]];
        }
      }
    }
  }

  ll ans = 0;
  FOR(k,1,n+1) {
    ans += dp[n][k][k*a];
  }

  cout << ans << endl;
}

Measured memory_bytes: 59520
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
#define LD_OUT setprecision(12) << fixed
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	ll A , B;
	cin >> A >> B;
	if(abs(A-B) < 2) return cout << "Brown\n" , 0;
	cout << "Alice\n";
	return 0;
}


Measured memory_bytes: 256
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#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>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    ll maxlen = 0;
    rep(i, S.size()) {
        for(int j = i; j < S.size(); ++j) {
            bool flag = false;
            string tmp = S.substr(i, j-i+1);
            rep(k, tmp.size()) {
                if (tmp[k] != 'A' & tmp[k] != 'C' & tmp[k] != 'G' & tmp[k] != 'T') {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                maxlen = max(maxlen, (ll)tmp.size());
            } 
        }
    }
    print(maxlen);
    return 0;
}


Measured memory_bytes: 256
// 別解 https://atcoder.jp/contests/abc167/submissions/13117364

use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [Usize1; n],
    };

    let kn = k.next_power_of_two().trailing_zeros() as usize;
    let mut tbl = vec![vec![n; n]; kn + 1];
    for j in 0..n {
        tbl[0][j] = a[j];
    }
    for i in 1..=kn {
        for j in 0..n {
            tbl[i][j] = tbl[i - 1][tbl[i - 1][j]];
        }
    }

    let mut c = 0;
    for i in 0..=kn {
        if (k >> i) & 1 == 1 {
            c = tbl[i][c];
        }
    }
    let ans = c + 1;
    println!("{}", ans);
}


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

int main(){
	long long n;
	cin >> n;
	vector<long long> a(n,0),b(n,0);
	
	for(long long i=0;i<n;i++){
		cin >> a[i];
		b[i]=a[i];
	}
	sort(b.begin(),b.end(),greater<long long>());
	
	for(long long i=0;i<n;i++){
		if(a[i]!=b[0]){
			cout << b[0] << endl;
		}else{
			cout << b[1] << endl;
		}
	}

	return 0;
}


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

using namespace std;

using int64 = long long;

int N, W[100000], Q;
vector< int > g[100000];
int dep[100000];
int64 sub[100000];
int64 heavy[3][100000];
const int LOG = 20;

int par[LOG][100000];
int64 sz[LOG][100000];

void predfs(int idx, int p, int d) {
  par[0][idx] = p;
  dep[idx] = d;
  sub[idx] += W[idx];
  for(auto &to : g[idx]) {
    if(to == p) continue;
    predfs(to, idx, d + 1);
    sub[idx] += sub[to];
    if(heavy[0][idx] < sub[to]) {
      heavy[2][idx] = heavy[1][idx];
      heavy[1][idx] = heavy[0][idx];
      heavy[0][idx] = sub[to];
    } else if(heavy[1][idx] < sub[to]) {
      heavy[2][idx] = heavy[1][idx];
      heavy[1][idx] = sub[to];
    } else if(heavy[2][idx] < sub[to]) {
      heavy[2][idx] = sub[to];
    }
  }
}

void dfs(int idx, int p) {
  for(auto &to : g[idx]) {
    if(to == p) continue;
    dfs(to, idx);
    sz[0][to] = heavy[heavy[0][idx] == sub[to]][idx];
  }
}

int lca(int x, int y) {
  if(dep[x] > dep[y]) swap(x, y);
  for(int i = LOG - 1; i >= 0; i--) {
    if((dep[y] - dep[x]) >> i & 1) y = par[i][y];
  }
  if(x == y) return x;
  for(int i = LOG - 1; i >= 0; i--) {
    if(par[i][x] != par[i][y]) {
      x = par[i][x];
      y = par[i][y];
    }
  }
  return par[0][x];
}

int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    scanf("%d", &W[i]);
  }
  for(int i = 1; i < N; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x, --y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  predfs(0, -1, 0);
  dfs(0, -1);
  for(int i = 0; i + 1 < LOG; i++) {
    for(int j = 0; j < N; j++) {
      if(par[i][j] == -1) par[i + 1][j] = -1;
      else par[i + 1][j] = par[i][par[i][j]];
      if(par[i + 1][j] == -1) continue;
      sz[i + 1][j] = max(sz[i][j], sz[i][par[i][j]]);
    }
  }

  int64 all = accumulate(W, W + N, 0LL);

  scanf("%d", &Q);
  while(Q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    if(dep[a] > dep[b]) swap(a, b);
    int p = lca(a, b);

    int64 ret = 0;
    if(p != a) {

      bool ng[3] = {};
      ret = max(ret, heavy[0][a]);
      ret = max(ret, heavy[0][b]);

      for(auto c : {a, b}) {
        int xx = dep[p] + 1;
        for(int i = LOG - 1; i >= 0; i--) {
          if(((dep[c] - xx) >> i) & 1) {
            ret = max(ret, sz[i][c]);
            c = par[i][c];
          }
        }
        for(int i = 0; i < 3; i++) {
          if(ng[i]) continue;
          if(sub[c] == heavy[i][p]) {
            ng[i] = true;
            break;
          }
        }
      }
      for(int i = 0; i < 3; i++) {
        if(ng[i]) continue;
        ret = max(ret, heavy[i][p]);
      }
    } else if(p != b) {
      ret = max(ret, heavy[0][b]);
      int c = b;
      int xx = dep[a] + 1;
      for(int i = LOG - 1; i >= 0; i--) {
        if(((dep[c] - xx) >> i) & 1) {
          ret = max(ret, sz[i][c]);
          c = par[i][c];
        }
      }
      ret = max(ret, sz[0][c]);
    } else {
      ret = max(ret, heavy[0][p]);
    }

    printf("%lld\n", max(ret, all - sub[p]));
  }
}




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

using namespace std;

#define ll long long
#define ull unsigned long long
#define re register
#define il inline
#define inf 0x3f3f3f

const int N = 3e5 + 5;
int n, s[N];
long long ans;

void init() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= 2 * n; ++i)
    scanf("%d", &s[i]);
  sort(s + 1, s + 2 * n + 1);
}

void work() {
  int i;
  for (i = 1; i <= 2 * n; ++i)
    ans += 1LL * (i - 1) * s[i];
  printf("%.12lf\n", 1.0 * ans / (2 * n - 1));
}

int main() {
  init();
  work();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, m;
   cin >> n >> m;
   rep(i, 0, m) {
      int a;
      cin >> a;
      n -= a;
   }
   if (n < 0) n = -1;
   cout << n << endl;
   return 0;
}

Measured memory_bytes: 3640
N, Q = map(int, input().split())
edges = [[] for i in range(N+1)]
ans = [None for i in range(N+1)]
points = [[] for i in range(N+1)]

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

for i in range(Q):
  p, x = map(int, input().split())
  points[p].append(x)

def dfs(u):
  visited = set()
  stack = [(u, -1, 0)]

  while stack:
    u, parent, point = stack.pop()
    visited.add(u)

    for p in points[u]:
      point += p

    ans[u] = point

    for edge in edges[u]:
      if edge not in visited:
        stack.append((edge, u, point))

dfs(1)
print(*ans[1:])

Measured memory_bytes: 95012
#include<iostream>
using namespace std;
int main(){
int N;
cin>>N;
int a[2][N];
for(int i=0;i<2;i++){
  for(int j=0;j<N;j++){
    cin>>a[i][j];
  }
}
int res;
int temp;
int s=a[0][0];
for(int j=0;j<N;j++)s+=a[1][j];
res=temp=s;
for(int j=0;j<N-1;j++){
temp+=a[0][j+1]-a[1][j];
res=max(res,temp);
}
cout<<res;
return 0;
}

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

using namespace std;
using ll = long long;

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

double dp[305][305][305];
int n;
double solve(int i, int j, int k) {
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  // if (i == 0 && j == 0 && k == 0) return 0.0;

  double res = 0;
  if (i > 0) res += solve(i - 1, j, k) * i;
  if (j > 0) res += solve(i + 1, j - 1, k) * j;
  if (k > 0) res += solve(i, j + 1, k - 1) * k;
  res += n;
  res *= 1.0 / (i + j + k);

  return dp[i][j][k] = res;
}

int main() {
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int one = 0, two = 0, thr = 0;
  rep(i, n) {
    if (a[i] == 1) ++one;
    if (a[i] == 2) ++two;
    if (a[i] == 3) ++thr;
  }

  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0.0;

  double ans = solve(one, two, thr);
  printf("%.10f\n", ans);
  return 0;
}


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

int main(){
    int l;
    cin >> l;
    long double ans = l * l * l /27.0;
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    unsigned long long a;
    unsigned long long b = 0;
    cin >> a;
    for (int i = 1; i <= a; i++){
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        b += i;
    }
    cout << b;
}

Measured memory_bytes: 3636
s=input()

p1 = s[0]
p2 = s[1]

if p1==p2:
    print(1,2)
else:
    flag=True
    for i in range(2,len(s)):
        if p1==s[i]:
            print(i-1,i+1)
            flag=False
            break
        elif p2==s[i]:
            print(i,i+1)
            flag=False
            break
        p1=s[i-1]
        p2=s[i]

    if flag:
        print(-1,-1)

Measured memory_bytes: 3188
use std::error::Error;
use std::io::{self, BufRead};

fn main() {
    run().unwrap()
}

fn run() -> Result<(), Box<Error>> {
    let stdin = io::stdin();
    let mut stdin = stdin.lock().lines();
    let (n, x) = {
        let line = stdin.next().unwrap()?;
        let mut it = line.split_whitespace().map(|s| s.parse::<usize>());
        (it.next().unwrap()?, it.next().unwrap()? as u32)
    };

    let ingradients = stdin
        .take(n)
        .map(|s| -> Result<u32, Box<Error>> { Ok(s?.parse::<u32>()?) })
        .collect::<Result<Vec<_>, _>>()?;

    let rem = x - ingradients.iter().sum::<u32>();

    println!(
        "{}",
        ingradients.len() as u32 + rem / ingradients.into_iter().min().unwrap()
    );

    Ok(())
}


Measured memory_bytes: 4352
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int K=scan.nextInt();
    int X=scan.nextInt();
    for(int i=X-K+1;i<X+K;i++){
      System.out.print(i+" ");
    }
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll getDig(ll n) {
    ll res = 0;
    while (n > 0) {
        n /= 10;
        res++;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = INF;
    rep(a, 1, (ll)sqrt(n)+1) {
        if (n % a == 0) {
            ll b = n / a;
            chmin(ans, max(getDig(a), getDig(b)));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int inputValue = Integer.parseInt(br.readLine());
		String[] inputData = br.readLine().split(" ");
		Integer [] number = new Integer[inputValue];

		for(int i = 0; i < inputData.length; i++){
			number[i] = Integer.parseInt(inputData[i]);
		}

		for(int i = number.length-1; i >= 1; i--){
			sb.append(number[i] + " ");
		}
		sb.append(number[0]);
		System.out.println(sb);
	}

}

Measured memory_bytes: 24096
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,fix[200005];
vector <long long> v[200005];
void dfs(long long k,long long a)
{
           if(fix[k]==1) return;
           fix[k]=1;
           if(a==4) { cout<<"YES"; exit(0); }
           for(long long j=0;j<v[k].size();j++)
           {
                      dfs(v[k][j],a+1);
           }
}
int main()
{
           for(long long i=1;i<=4;i++)
           {
                      cin>>a>>b;
                      v[a].push_back(b);
                      v[b].push_back(a);
           }
           dfs(1,1);
           cout<<"NO";
}

Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

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

  map<char, int> m{};

  for (int i = 0; i < 4; i++) {
    m[s[i]]++;
  }

  for (int i = 0; i < 4; i++) {
    if (m[s[i]] != 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int64_t,int64_t>;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        int a;
        cin >> a;
        if (a % 2 != 0){
            continue;
        }
        else if (a % 3 == 0){
            continue;
        }
        else if(a % 5 == 0){
            continue;
        }
        else {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;

}

Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long min = 1+a;
		for(int i = 2; i <= Math.sqrt(a); i++) {
          	double c = a%i;
			if(c==0) {
				long d = a/i;
				long tmp = d+i;
				if(tmp<min) {
					min = tmp;
				}
			}
		}
		System.out.println(min-2);
	}

}


Measured memory_bytes: 25044
n, q = map(int, input().split())
s = "#" + input() + "#"
TD = [list(input().split()) for _ in range(q)]
TD = [(t, -1) if d == "L" else (t, 1) for t, d in TD]

def test(i, end):
  color = s[i]
  for t, d in TD:
    if t == color:
      i += d
      if i == end:
        return True
      color = s[i]
  else:
    return False
  
# 左に落ちるゴーレムの数(left)を探す
ng = n + 1
ok = 0
while abs(ok - ng) > 1:
  m = (ok + ng) // 2
  if test(m, 0):
    ok = m
  else:
    ng = m
left = ok

# 右に落ちるゴーレムの数(right)を探す
ng = 0
ok = n + 1
while abs(ok - ng) > 1:
  m = (ok + ng) // 2
  if test(m, n + 1):
    ok = m
  else:
    ng = m
right = ok

ans = right - left - 1
print(ans)

Measured memory_bytes: 41392
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

X = [[] for i in range(N)]
k = 0
for i in range(M):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)
    k += 1

if k % 2:
    print(-1)
else:
    ANS = []
    P = [-1] * N
    Q = [(-1, 0)]
    done = [0] * N
    C = [0] * N
    R = []
    while Q:
        pre, i = Q.pop()
        if done[i]:
            C[i] += 1
            if pre >= 0:
                ANS.append((i, pre))
            continue
        done[i] = 1
        R.append(i)
        for a in X[i]:
            if a != P[i]:
                P[a] = i
                X[a].remove(i)
                Q.append((i, a))

    for i in R[1:][::-1]:
        if C[i] % 2:
            ANS.append((i, P[i]))
        else:
            ANS.append((P[i], i))
            C[P[i]] += 1
    for a, b in ANS:
        print(a+1, b+1)

Measured memory_bytes: 71456
//
// Created by Hideaki Imamura on 2020-03-21.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
const ll mod = 1000000007;

inline ll take_mod(ll a) {
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b) {
    return take_mod(a + b);
}

inline ll sub(ll a, ll b) {
    return take_mod(a - b);
}

inline ll mul(ll a, ll b) {
    return take_mod(a * b);
}

inline ll mod_pow(ll x, ll n) {
    ll res = 1LL;
    while (n > 0) {
        if (n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x) {
    return mod_pow(x, mod - 2);
}

int N;
vector<ll> A;

vector<l_l> prime_factorize(ll n) {
    vector<l_l> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n!= 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<ll> num(1000010, 0);
    for (int i = 0; i < N; ++i) {
        auto ps = prime_factorize(A[i]);
        for (auto p : ps) num[p.first] = max(num[p.first], p.second);
    }

    ll lcm = 1;
    for (int v = 2; v < 1000010; ++v) {
        lcm = mul(lcm, mod_pow(v, num[v]));
    }

    ll ans = 0;
    for (auto a: A) {
        ans = add(ans, mul(lcm, mod_inv(a)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<cmath>
#include<string>
#include<iomanip>
#include <numeric>
#include <limits>
using namespace std;

int main()
{
long long x,y,z,p=0,l; cin>>x>>y>>z;
l=z;
while(l+y+z<=x)
{
    p++; l+=y+z;
}
cout<<p;
return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

#define N 31

int main(void) {
	int i;
	int dp[N] = {0};
	
	dp[0] = 1;
	for(i = 0; i < N; i++) {
		if (i + 1 < N) dp[i + 1] += dp[i];
		if (i + 2 < N) dp[i + 2] += dp[i];
		if (i + 3 < N) dp[i + 3] += dp[i];
	}
	
	while(1) {
		int n;
		scanf("%d", &n);
		if (n == 0) break;
		printf("%d\n", (dp[n] / 3650) + 1);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
bool check(char* S, int p) {
	int h = p / 2;
	rep(i, 0, h) {
		if (S[i] != S[h + i]) {
			return false;
		}
	}
	return true;
}
int main() {
	char S[201]; cin >> S;

	int p = 0;

	rep(i, 0, 201) {
		if (S[i] == '\0') {
			p = i;
			break;
		}
	}

	S[--p] = '\0';

	while (true) {
		if (p % 2 != 0) {
		}
		else {
			if (check(S, p)) {
				cout << p << endl;
				return 0;
			};
		}
		S[--p] = '\0';
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int> > w(n);
    REP(i,n){
        int a,b;
        cin>>a>>b;
        w[i]=make_pair(b,a);
    }

    sort(ALL(w));

    int t=0;
    bool f=1;
    REP(i,n){
        t+=w[i].second;
        if(t>w[i].first){
            f=0;
            break;
        }
    }

    cout<<(f? "Yes":"No")<<endl;

	return 0; 
}


Measured memory_bytes: 1792