akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	fsc := NewFastScanner()
	S := fsc.Next()
	result := 0
	for i := 0; i < len(S); i++ {
		if S[i] == '1' {
			result++
		}
	}
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
N=int(input())
A=[Ai for Ai in map(int,input().split())]
B=[]
for i in range (N//2+1,N+1):
    if A[i-1]==1:
        B.append(i)

for i in range (1, N//2+1)[::-1]:
    A[i-1]=sum(A[i-1::i])%2
    if A[i-1]==1:
        B.append(i)

print(len(B))
print(' '.join(map(str,B)))


Measured memory_bytes: 18496
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char s[10][10];
int visit[10];
int ans=0,h,w,k,pp;
void dfs(int x,int y,int sum){
	int num=0;
	if(x==h&&y==w){
		if(pp-sum==k){
			ans++;
		}
		return ;
	}
	if(x==h){
		for(int i=0;i<h;i++){
			if(s[i][y]=='#'&&visit[i]==0){
				num++;
			}
		}
		dfs(x,y+1,sum+num);
		dfs(x,y+1,sum);
	}
	else{
		for(int i=0;i<w;i++){
			if(s[x][i]=='#'){
				num++;
			}
		}
		visit[x]=1;
		dfs(x+1,y,sum+num);
		visit[x]=0;
		dfs(x+1,y,sum);
	}
}
int main(){
	cin>>h>>w>>k;
	memset(visit,0,sizeof(visit));
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				pp++;
			}
		}
	}
	dfs(0,0,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            

            Console.WriteLine(n >= 30?"Yes":"No");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27468
#include<iostream>

using namespace std;

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int c = n - i - j;
		    if (i + j + c <= n && 0 <= c) {
				if (i * 10000 + j * 5000 + c * 1000 == y) {
					int a = i;
					int b = j;
					cout << a << ' ' << b << ' ' << c << endl;
					return 0;
				}
			}
		}
	}
	
	cout << "-1 -1 -1" << endl;
	

	return 0;
}

Measured memory_bytes: 256
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define Mx 1e10
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    	ll n,s=0,m=0,l,mx=0,x,i,t=0,j=0,k=0;
    	cin>>n>>l;
    	ll a[n],b[n];
    	f(i,n)
    	cin>>a[i];
    	f(i,n-1)
    	{
    	    b[i]=a[i]+a[i+1];
    	    if(b[i]>=l)
            {
                j=i;
                t=1;
            }
    	}
    	if(t==0)
            cout<<"Impossible\n";
        else{
            cout<<"Possible\n";
            f1(i,j)
            cout<<i<<endl;
            for(i=n-1;i>j;i--)
                cout<<i<<endl;
        }
}







Measured memory_bytes: 5152
#include<iostream>

using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    if(sx==tx){
        for(int i=0;i<ty-sy;i++){
            cout << 'U';
        }
        for(int i=0;i<ty-sy;i++){
            cout << 'D';
        }
        cout << 'L';
        for(int i=0;i<ty-sy;i++){
            cout << 'U';
        }
        cout << "RR";
        for(int i=0;i<ty-sy;i++){
            cout << 'D';
        }
        cout << 'L' << endl;
    }
    else if(sy==ty){
        for(int i=0;i<tx-sx;i++){
            cout << 'R';
        }
        for(int i=0;i<tx-sx;i++){
            cout << 'L';
        }
        cout << 'U';
        for(int i=0;i<tx-sx;i++){
            cout << 'R';
        }
        cout << "DD";
        for(int i=0;i<tx-sx;i++){
            cout << 'L';
        }
        cout << 'U' << endl;
    }
    else{
        for(int i=0;i<ty-sy;i++){
            cout << 'U';
        }
        for(int i=0;i<tx-sx;i++){
            cout << 'R';
        }
        for(int i=0;i<ty-sy;i++){
            cout << 'D';
        }
        for(int i=0;i<tx-sx;i++){
            cout << 'L';
        }
        cout << 'L';
        for(int i=0;i<ty-sy;i++){
            cout << 'U';
        }
        cout << 'U';
        for(int i=0;i<tx-sx;i++){
            cout << 'R';
        }
        cout << "RDR";
        for(int i=0;i<ty-sy;i++){
            cout << 'D';
        }
        cout << 'D';
        for(int i=0;i<tx-sx;i++){
            cout << 'L';
        }
        cout << "LU" << endl;
    }
}

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

int main (){
        long long N;
        cin >> N ;
        
        if( N %2 == 0){
            cout <<N<< endl;
        }else{
            cout <<2*N<< endl;
        }
        
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double ad = (h + m / 60.0) / 12.0 * 360, bd = m / 60.0 * 360,
                th = abs(ad - bd), thr;
    //th = h/12+m/60/12-m/60
    thr = th / 180.0 * M_PI;
    cout << setprecision(20) << sqrt(a * a + b * b - 2.0 * a * b * cosl(thr));
    return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
#define MOD 1000000007
#define MOD2 998244353

int sumOfDigits(int n){
    int ans = 0;
    while(n > 0){
        ans += n % 10;
        n /= 10;
    }
    return ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = sumOfDigits(n);
    if(n % ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
    if(a>0)cout<<"Positive";
    else if(a==0||(a<0&&b>0))cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive";
    else cout<<"Negative";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}
 
int main() {
  int n, k;
  cin >> n >> k;
  // mint ans = f(n);
  // ans -= 1;
  // ans -= choose(n,a);
  // cout << choose(n,b).x << endl;
  // ans -= choose(n,b);
  // cout << ans.x << endl;
  // return 0;
  //各Kについていくつ組み合わせが存在するか調べる　最小値と最大値が分かればその間の数は必ず作れる気がする 
  vector<mint> a(n + 1);
  vector<mint> b(n + 1);
  rep(i, n + 1)a[i] = i;
  for(int i = n; i > 0; i--)b[n - i] = i;
  mint ans = 0;
  for(int i = k; i <= n + 1; i++){
    mint min = ( a[0] + a[i - 1]) / 2;
    min *= i;
    mint max = (b[0] + b[i - 1]) / 2;
    max *= i;
    ans += max - min + 1;
  }
  cout << ans.x << endl;
}

Measured memory_bytes: 6424
#include<stdio.h>
int main(){
	int a,b,sum;
	int i;
	
	while(scanf("%d %d",&a,&b)!=EOF){
		sum=a+b;
		for(i=1;sum>=10;i++){
			sum/=10;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
	double l,r;
	int al=0,bl=0,cl=0,dl=0,ar=0,br=0,cr=0,dr=0;
	while(scanf("%lf%lf",&l,&r)!=EOF){
		if(l>=1.1){
			al++;
		}else if(l>=0.6){
			bl++;
		}else if(l>=0.2){
			cl++;
		}else{
			dl++;
		}
		if(r>=1.1){
			ar++;
		}else if(r>=0.6){
			br++;
		}else if(r>=0.2){
			cr++;
		}else{
			dr++;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",al,ar,bl,br,cl,cr,dl,dr);
	return 0;
}

Measured memory_bytes: 2696
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    a,b = [int(i) for i in N[l].split()]
    A = a
    B = b
    if(a<b):
        c = a
        a = b
        b = c

    while b > 0:
        nexta = b
        nextb = a % b
        a = nexta
        b = nextb

    g = a
    print(g, int(A*B/g))



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

struct Pair
{
int A;
int B;

	bool operator < ( const Pair &X ) const
	{
		return B == X.B ? A > X.A : B < X.B;
	}
};

Pair X[ 200010 ];

int main()
{
int i;
int N;
long long iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;

	for( i = 0; i < N; i++ )
	{
		cin >> X[ i ].A;
		cin >> X[ i ].B;
	}

	sort( X, X + N );

	iSum = 0;
	for( i = 0; i < N; i++ )
	{
		iSum += X[ i ].A;
		if( iSum > X[ i ].B )
		{
			cout << "No" << endl;

			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1920
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

ll b_p(ll b, ll p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p ^ 1));
    ll v = ml(b, p >> 1);
    return ml(v, v);
}

const int MAXN = 1e5 + 132;

bool was[MAXN];

void solve() {

    ll n, x, m;
    cin >> n >> x >> m;

    mod = m;

    ll len = 0;

    ll curr = x;
    ll cycle_val = 0;

    while (!was[curr]) {
        was[curr] = true;
        cycle_val += curr;
        ++len;
        curr = ml(curr, curr);
    }

    ll start = x;

    ll answr = 0;

    while (start != curr) {
        answr += start;
        start = ml(start, start);
        --len;
        --n;
    }
    cycle_val -= answr;

    ll cnt = n / len;
    answr += cnt * cycle_val;

    for (int i = 0; i < n % len; ++ i) {
        answr += curr;
        curr = ml(curr, curr);
    }

    cout << answr << "\n";
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main(){
	int a, b; cin >> a >> b;
        int  ans = (a-1)* (b-1);
	cout << ans << endl;
	
    return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

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

int main(){
	int n, four=0, two=0;
	scanf("%d", &n);
	REP(i, 0, n){
		int a;
		scanf("%d", &a);
		if(a%4==0) four++;
		else if(a%2==0) two++;
	}

	n -= four*2 + (four>0);
	if(n<=0) puts("Yes");
	else if(two>=n+(four>0)) puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {

  def loop(max:Int, sum:Int, i:Int):Int = {
    i match {
      case 0 => if( sum > max ) sum else max
      case i =>
        val m = readLine().toInt
        val (x,y) =
          if(sum < 0 && m > sum) (max,m)
          else if(m < 0 && sum > max) (sum,sum+m)
          else (max, sum+m)
        loop(x,y,i-1)
    }
  }

  def main(args: Array[String]) = {
    val b = new StringBuilder

    var n = readLine().toInt
    while(n!= 0) {
      b.append(loop(-100000, readLine().toInt, n-1).toString)
      b.append("\n")
      n = readLine().toInt
    }

    print(b.result)
  }
}

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

int main(int argc, char *argv[]) {
	std::string word1;
	std::string word2;
	std::string word3;

	std::cin >> word1;
	std::cin >> word2;
	std::cin >> word3;

	std::string answer;

	answer += word1[0] - 0x20;
	answer += word2[0] - 0x20;
	answer += word3[0] - 0x20;

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const int MAX_N=2e5+10;
PI seg0[2][MAX_N*4];
void modify(int l,int r,int pos,int v,int idx,PI* seg){
	if(l==r){
		seg[idx]=PI(v,l);
	}else{
		int mid=(l+r)>>1;
		if(pos<=mid)
			modify(l,mid,pos,v,idx<<1,seg);
		else
			modify(mid+1,r,pos,v,idx<<1|1,seg);
		seg[idx]=min(seg[idx<<1],seg[idx<<1|1]);
	}
}
PI query(int l,int r,int ql,int qr,int idx,PI* seg){
	if(l==ql && r==qr){
		return seg[idx];
	}
	int mid=(l+r)>>1;
	if(qr<=mid)
		return query(l,mid,ql,qr,idx<<1,seg);
	else if(ql>mid)
		return query(mid+1,r,ql,qr,idx<<1|1,seg);
	else{
		return min(query(l,mid,ql,mid,idx<<1,seg),query(mid+1,r,mid+1,qr,idx<<1|1,seg));
	}
}
struct Status{
	int l,r,v,pos;
	bool operator<(const Status& rhs) const{
		return v>rhs.v;
	}
};
int a[MAX_N],ans[MAX_N];
priority_queue<Status> pq;
int main(){
	memset(seg0,0x3f,sizeof seg0);
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		modify(0,n-1,i,a[i],1,seg0[i&1]);
	}
	PI res=query(0,n-1,0,n-1,1,seg0[0]);
	pq.push((Status){0,n-1,res.first,res.second});
	int p=0;
	while(!pq.empty()){
		Status now=pq.top();
		pq.pop();
		res=query(0,n-1,now.pos+1,now.r,1,seg0[(now.l+1)&1]);
		int l=now.pos,r=res.second;
		ans[p++]=a[l];
		ans[p++]=a[r];
		int ql=l+1,qr=r-1;
		if(ql<qr){
			res=query(0,n-1,ql,qr,1,seg0[ql&1]);
			pq.push((Status){ql,qr,res.first,res.second});
		}
		ql=now.l,qr=l-1;
		if(ql<qr){
			res=query(0,n-1,ql,qr,1,seg0[ql&1]);
			pq.push((Status){ql,qr,res.first,res.second});
		}
		ql=r+1,qr=now.r;
		if(ql<qr){
			res=query(0,n-1,ql,qr,1,seg0[ql&1]);
			pq.push((Status){ql,qr,res.first,res.second});
		}
	}
	for(int i=0;i<n;i++)
		printf("%d%c",ans[i],i==n-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> num(n, 0);
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		num[a - 1]++;
		num[b - 1]++;
	}

	for(int i = 0; i < n; i++) {
		cout << num[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
def main():
  N = int(input())
  xyz = list(map(int, input().split()))
  K = 1
  if 0 in xyz:
    K = 0
  else:
    for i in range(N):
      K = K * xyz[i]
      if K > 10 ** 18:
        K = -1
        break
  print(K)
main()

Measured memory_bytes: 84436
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 466
	#define mod 998244353ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

ll fac[sz],_fac[sz];
void init(){_fac[0]=fac[0]=1;rep(i,1,sz-1) _fac[i]=inv(fac[i]=fac[i-1]*i%mod);}
ll C(int n,int m){return n>=m&&m>=0?fac[n]*_fac[m]%mod*_fac[n-m]%mod:0;}

int n;
int a[sz],b[sz];
ll S;int sum;

ll dp[sz][sz][sz];

int main()
{
	file();
	init();
	read(n);
	rep(i,1,n) read(a[i],b[i]),S+=a[i],sum+=b[i];
	dp[0][0][0]=1;ll I=inv(S);
	rep(i,1,n) rep(j,0,S) rep(k,0,sum)
	{
		dp[i][j][k]=dp[i-1][j][k];
		if (j>=a[i]) 
			for (int t=0,cur=1;t<=min(b[i]-1,k);++t,cur=I*cur%mod*a[i]%mod) 
				(dp[i][j][k]+=mod-dp[i-1][j-a[i]][k-t]*C(k,t)%mod*cur%mod)%=mod;
	}
	chktime();
	ll ans=0;
	rep(j,0,S) rep(k,0,sum) (ans+=dp[n][j][k]*ksm(S*inv(j)%mod,k+1)%mod)%=mod;
	chktime();
	cout<<(mod-ans)%mod;
	return 0;
}

Measured memory_bytes: 682624
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	int N, K;
	int H[200000];

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	sort(H, H + N);

	long long ans = 0;
	for (int i = 0; i < N - K; i++) {
		ans += H[i];
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <atcoder/convolution>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<mint> a(n), b(m);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[i] = x;
  }
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    b[i] = x;
  }
  auto c = convolution(a, b);
  for (int i = 0; i < n + m - 1; i++) {
    printf("%d ", c[i].val());
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 19000
#include <bits/stdc++.h>
using namespace std;
void fail() { cout << -1 << endl; exit(0); }
int main() {
    int N, M; cin >> N >> M;
    vector<int> D(N); for (auto &d : D) cin >> d;
    vector<pair<int, int>> E(M);
    vector<int> C(M, -1);
    for (int i = 0; i < M; i++) {
        int u, v; cin >> u >> v; u--, v--;
        E[i] = make_pair(u, v);
    }
    vector<vector<pair<int, int>>> G(N);
    for (int i = 0; i < M; i++) {
        int u, v; tie(u, v) = E[i];
        G[u].emplace_back(v, i);
        G[v].emplace_back(u, i);
    }
    vector<int> done(N);
    vector<vector<int>> H(N);
    for (int i = 0; i < M; i++) {
        int u, v; tie(u, v) = E[i];
        if (D[u] == D[v] && !done[u] && !done[v]) {
            H[u].push_back(v);
            H[v].push_back(u);
            C[i] = D[u];
            done[u] = done[v] = D[u];
        }
    }
    vector<int> I(N); iota(begin(I), end(I), 0);
    sort(begin(I), end(I), [&](int i, int j) { return D[i] < D[j]; });
    for (int i : I) if (!done[i]) {
        for (auto p : G[i]) {
            int next, idx; tie(next, idx) = p;
            if (done[next] && done[next] <= D[i]) {
                H[i].push_back(next);
                H[next].push_back(i);
                C[idx] = D[i];
                done[i] = D[i];
                break;
            }
        }
        if (!done[i]) fail();
    }
    string S(N, '?');
    function<void(int, int)> recur = [&](int node, int t) {
        if (S[node] != '?') return;
        S[node] = "BW"[t];
        for (int next : H[node]) recur(next, !t);
    };
    for (int i = 0; i < N; i++) recur(i, 0);
    cout << S << '\n';
    for (auto c : C) {
        cout << (c == -1 ? (int)1e9 : c) << '\n';
    }
    return 0;
}


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

int main() {
  int a, b;
  char op;

  for (;;) {
    cin >> a >> op >> b;
    if (op == '?') {
      break;
    }

    int res = 0;
    switch (op) {
      case '+':
        res = a + b;
        break;
      case '-':
        res = a - b;
        break;
      case '*':
        res = a * b;
        break;
      case '/':
        res = a / b;
        break;
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
from collections import deque
n = int(input())
stone = [0]+list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
for a,b in ab:
  if stone[a] < stone[b]:
    graph[a].append(b)
    deg[b] += 1
  elif stone[a] > stone[b]:
    graph[b].append(a)
    deg[a] += 1
que = deque()
dp = [[] for i in range(n+1)]
wl = [0]*(n+1)
ans = []
for i in range(1,n+1):
  if deg[i] == 0:
    que.append(i)
    wl[i] = 0
while que:
  x = que.popleft()
  if dp[x]:
    if dp[x].count(0) >= 1:
      ans.append(x)
      wl[x] = 1
  for y in graph[x]:
    if deg[y]:
      dp[y].append(wl[x])
      deg[y] -= 1
    if deg[y] == 0:
      que.append(y)
ans.sort()
print(*ans)

Measured memory_bytes: 46576
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=(1<<18)+10,mod=998244353;
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int A[N],B[N],C[N];
int m,n;
void FWT(int *A,int f) {
	for(int l=1;l<n;l<<=1)
		for(int p=l<<1,i=0;i<n;i+=p)
			for(int j=0;j<l;++j) {
				int t1=A[i+j],t2=A[i+l+j];
				A[i+j]=(t1+t2)%mod;
				A[i+l+j]=(t1-t2+mod)%mod;
			}
	if(f==1) {
		int inv=Pow(n,mod-2);
		for(int i=0;i<n;++i) A[i]=A[i]*(ll)inv%mod;
	}
}
int main() {
	rd(m); n=(1<<m);
	int sum=0;
	for(int i=0;i<n;++i)
		rd(A[i]),sum+=A[i];
	sum=Pow(sum,mod-2);
	for(int i=0;i<n;++i)
		A[i]=A[i]*(ll)sum%mod;
	A[0]=(A[0]-1+mod)%mod;
	FWT(A,0);
//	for(int i=0;i<n;++i) printf("%d ",A[i]); puts("");
	B[0]=n-1;
	for(int i=1;i<n;++i)
		B[i]=mod-1;
	FWT(B,0);
	C[0]=0;
	for(int i=1;i<n;++i)
		C[i]=B[i]*(ll)Pow(A[i],mod-2)%mod;
	for(int i=1;i<n;++i)
		C[0]=(C[0]+mod-C[i])%mod;
	FWT(C,1);
	int tmp=C[0];
	for(int i=0;i<n;++i) printf("%d\n",C[i]);
	return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

void printv(vvi v){
	for(int i = 0; i < v.size(); i++){
		for(int j = 0; j < v.front().size(); j++){
			cout << v[i][j] << " ";
		}cout << endl;
	}
	return ;
}

int main() {
	
	int n,w; cin >> n >> w;
	vvi table(n,vi(w+1,0));

	vi val(n,0);
	vi wei(n,0);
	for (int i = 0; i < n; i++) {
		cin >> val[i] >> wei[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= w; j++) {
			if (i == 0 and j >= wei[i]) {
				table[i][j] = val[i];	
			}else if(i != 0 and j >= wei[i]) {
				table[i][j] = max(table[i-1][j],table[i-1][j-wei[i]] + val[i]);
			}else if(i != 0 and j < wei[i]) {
				table[i][j] = table[i-1][j];
			}
		}
	}
	
	//printv(table);
	cout << table[n-1][w] << endl;

	return 0;
}

Measured memory_bytes: 6740
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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 RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> b(n - 1);
		REP(i, n - 1) cin >> b[i];
		vector<int> a(n);
		a[0] = b[0];
		
		FOR(i, 1, n - 1) {
			a[i] = min(b[i], b[i - 1]);
		}
		a[n - 1] = b[n - 2];
		// dpite(ALL(a));
		int ans = 0;
		REP(i, n) {
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}


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

int a,b,maxn;

int main()
{
    scanf("%d%d",&a,&b);
    maxn=max(a+b,a-b);
    maxn=max(maxn,a*b);
    printf("%d\n",maxn);
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner jk = new Scanner(System.in);
		int k = jk.nextInt();
		int x = jk.nextInt();
		int i = x-k+1;
		int j = x+k-1;
		for (i=i; i<=j; i++)
		{
			System.out.print(i+" ");
		}
		System.out.println();
	}

}


Measured memory_bytes: 23636
G1 = [1,3,5,7,8,10,12]
G2 = [4,6,9,11]
x,y = map(int, input().split())

if x in G1 and y in G1:
  print('Yes')
elif x in G2 and y in G2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9104
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    int N,W;cin>>N>>W;
    int w[110],v[110];
    for(int i=1;i<=N;i++)cin>>w[i]>>v[i];

    mat dp(110,vec(100010));

    //初期化
    for(int j=0;j<=W;j++)dp[0][j]=0;
    for(int i=0;i<=N;i++)dp[i][0]=0;
    //漸化式
    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            if(w[i]>j)dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 87296
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    if(b - a <= 2){
        cout << k + 1 << endl;
        return 0;
    }
    if(k < a){
        cout << k + 1 << endl;
        return 0;
    }

    int ans = a;
    k -= (a - 1);
    ans += (k / 2) * (b - a);
    ans += k % 2;

    cout << ans << endl;

    return 0;
}


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

int main()
{
	int a, b, c, i, d;

	cin >> a >> b >> c;

	for (i = b; i <= c; i++) {
		d = i % a;
		if (d == 0) {
			cout << "OK";
			break;
		}
		else if (i == c && d != 0) {
			cout << "NG";
			break;
		}
	}


	return 0;
}

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

void print(vector<int>&v,vector<char>&s,bool isstable){
	for(int i=0;i<v.size();++i){
		cout<<s.at(i)<<v.at(i);
		if(i!=v.size()-1)cout<<" "s;
		else cout<<"\n"s<<(isstable?"Stable"s:"Not stable"s)<<"\n"s;
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<char>sb(n),ss(n);
	vector<int>vb(n),vs(n);
	for(int i=0;i<n;++i){
		cin>>sb.at(i)>>vb.at(i);
	}
	ss=sb,vs=vb;
	bool flag=true;
	for(int i=0;i<n&&flag;++i){
		flag=false;
		for(int j=n-2;j>=i;--j){
			int&L=vb.at(j),&R=vb.at(j+1);
			if(L>R){
				swap(L,R);
				swap(sb.at(j),sb.at(j+1));
				flag=true;
			}
		}
	}
	for(int i=0;i<n-1;++i){
		int mn=i;
		for(int j=i+1;j<n;++j){
			if(vs.at(j)<vs.at(mn))mn=j;
		}
		if(mn!=i){
			swap(vs.at(mn),vs.at(i));
			swap(ss.at(mn),ss.at(i));
		}
	}
	print(vb,sb,true);
	print(vs,ss,ss==sb);
}


Measured memory_bytes: 3228
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    int K=gi();
	    int[] X=new int[N];
	    
	    for(int i=0; i<N;i++) {
	    	X[i]=gi();
	    }

	    int min=Integer.MAX_VALUE;
    	for(int i=0; i<N-K+1;i++) {
	    	int a=X[i];
	    	int b=X[i+K-1];
	    	int c=0;
	    	if (a>=0) {
	    		c=b;
	    	} else if(b<=0) {
	    		c=Math.abs(a);
	    	} else {
	    		c=Math.min(Math.abs(a), Math.abs(b))*2 + Math.max(Math.abs(a), Math.abs(b)); 
	    	}
	    	
	    	if (min>c) {
	    		min=c;
	    	}
	    }
	    System.out.print(min);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 59644
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var b string
	fmt.Scan(&b)
	switch b {
	case "A":
		fmt.Print("T")
	case "T":
		fmt.Print("A")
	case "G":
		fmt.Print("C")
	case "C":
		fmt.Print("G")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if(abs(a - b)  % 2 == 0){
        cout << "Alice\n";
    }else{
        cout << "Borys\n";
    }
}

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

int W,H,x,y;
int main(void){
  cin>>W>>H>>x>>y;
  if(2*x==W&&2*y==H)
    cout<<fixed<<setprecision(10)<<0.5*W*H<<" 1"<<endl;
  else
    cout<<fixed<<setprecision(10)<<0.5*W*H<<" 0"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

	int m,n,k;
	int mx[201],my[201];
	int nx[1001],ny[1001];
	register int i,j;

	while(1){
		scanf("%d",&m);
		if(!m)break;
		for(i=0;i<m;i++){
			scanf("%d%d",mx+i,my+i);
		}
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d%d",nx+i,ny+i);
		}

		for(i=0;i<n;i++){
			for(j=1;j<m;j++){
				int xd=nx[i]-mx[0]+mx[j];
				int yd=ny[i]-my[0]+my[j];
				for(k=0;k<n;k++){
					if(xd==nx[k] && yd==ny[k]){
						break;
					}
				}
				if(k==n)break;
			}
			if(j==m){
				printf("%d %d\n",nx[i]-mx[0],ny[i]-my[0]);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 608
#include<stdio.h>

#define N 5000000

void maxheapity(int *,int);

void buildmaxheap(int*);

int num;

int heap[N];

int main(){
  int i;

  scanf("%d",&num);

  for(i=1;i<=num;i++) scanf("%d",&heap[i]);

  buildmaxheap(heap);

  for(i=1;i<=num;i++){
    printf(" %d",heap[i]);
  }
  printf("\n");
  


  return 0;
}


void maxheapify(int *A,int i){
  int l,r;
  int temp;
  int largest;

  
  
  l = 2*i;
  r = 2*i+1;
  //左の子、自分、右の子で値が最大のノードを選ぶ
  if (l <= num && A[l] > A[i])
    largest = l;
  else 
    largest = i;
  if (r <= num && A[r] > A[largest])
    largest = r;

  //printf("largest %d\n",largest);

  if (largest != i){
    //iの子の方が値が大きい場合
    //A[i] と A[largest] を交換
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    
    maxheapify(A, largest); // 再帰的に呼び出し
  }
}

void buildmaxheap(int *A){
  int i;
  // printf("1\n");
  for(i=num/2;i>0;i--) maxheapify(A,i);
}
  



Measured memory_bytes: 4572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iK = int.Parse(sS[1]);
            sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < sS.Length; i++)
            {
                if (int.Parse(sS[i]) >= iK) { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 15712
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

cnt = 0
S = 0
minA = 10 ** 9
for a in A:
    if a < 0:
        cnt += 1
    minA = min(minA, abs(a))
    S += abs(a)

if cnt % 2 == 0:
    res = S
else:
    res = S - 2 * minA

print(res)


Measured memory_bytes: 14284
#include <stdio.h>
#include <string.h>

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

	scanf("%d %d %d", &a, &b, &c);

	if (a == 7 && b == 5 && c == 5 || a == 5 && b == 7 && c == 5 || a == 5 && b == 5 && c == 7)
	{
		puts("YES");
	}
	else
	{
		puts("NO");
	}

	return 0;
}

Measured memory_bytes: 128
import numpy as np

N = int(input())
num = list(map(int, input().split()))
num = np.array(num)
count = 0
judge = 0

for i in range(N):
    if (num[i] % 2) == 1:
        judge = 1

while judge == 0:

    num = num/2
    count += 1

    for i in range(N):
        if (num[i] % 2) == 1:
            judge = 1

print(count)

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n) {
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(All(a));
  ll b;
  if (n%2 == 0) {
    b = (a[n/2] + a[n/2 - 1]) / 2;
  }
  else b = a[n/2];
  ll ans = 0;
  rep(i,n) {
    ans += abs(a[i] - b);
  }
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int main() {

    string s;

    cin >> s;
    sort(s.begin(), s.end());
    if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(2) != s.at(1)){
        cout << "Yes";
    }else{
        cout << "No";
    }
    

}

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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #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
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  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;
  }


int ans = MOD;

void dfs(int f, int e){

}

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) cin >> L[i];
    sort(all(L));
    ll ans = 0;
    REP(B, N){
        int K = B + 1;
        REP(A, B){
            while(K < N && L[K] < L[A] + L[B]) K++;
            ans += K - (B + 1);
        }
    }
    print(ans);
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int s,w;
    cin >> s >> w;
    
    if(w>=s) cout << "unsafe";
    else cout <<"safe";
    
    
}

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

Measured memory_bytes: 3640