akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
ll n;
ll ans[2];
ll ans2[2];
bool v = false;
ll mx3 = -4e18, mi = -1;
ll now = 1;
vector<ll> ve, a;
 
int main()
{
    cin>>n;
    for(ll i = 0; i < n; i++)
    {
        ll t;
        cin>>t;
        a.push_back(t);
        if(mx3 < a[i]) mx3 = a[i], mi = i;
        ans[i % 2] += max(0LL, a[i]);
        if(a[i] >= 0) v = true;
    }
    if(!v)
    {
        cout<<mx3<<endl;
        cout<<n - 1<<endl;
        for(ll i = 0; i < mi; i++) cout<<1<<endl;
        for(ll i = n - mi; i >= 2; i--) cout<<i<<endl;
        return 0;
    }
    cout<<max(ans[0], ans[1])<<endl;
    if(ans[0] < ans[1])
    {
        ve.push_back(1);
        a.erase(a.begin(), a.begin() + 1);
    }
    while(a.size() > 1)
    {
        if(a[0] < 0)
        {
            ve.push_back(1);
            a.erase(a.begin(), a.begin() + 1);
            if(a.size() > 1)
            {
                ve.push_back(1);
                a.erase(a.begin(), a.begin() + 1);
            }
            continue;
        }
        if(a.size() <= 2)
        {
            ve.push_back(2);
            break;
        }
        if(a.size() > 2)
        {
            if(a[2] < 0)
            {
                if(a.size() > 3)
                {
                    ve.push_back(3);
                    a.erase(a.begin() + 2, a.begin() + 4);
                }
                else
                {
                    ve.push_back(3);
                    a.erase(a.begin() + 2, a.begin() + 3);
                }
            }
            else
            {
                ve.push_back(2);
                a.erase(a.begin() + 1, a.begin() + 3);
            }
        }
    }
    cout<<ve.size()<<endl;
    for(ll i = 0; i < ve.size(); i++)
    {
        cout<<ve[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

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

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int l,r,d;
    cin>>l>>r>>d;
    cout << r / d -  (l - 1) / d << '\n';

    return 0;
}


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

int main(){
	int a[101];
	int i,n;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];	
	}
	
	for(i=0;i<n;i++){
		int k=n-i;
		cout<<a[k];
		if(i!=n-1){
			cout<<" ";
		}
	}
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();

	int d;
	int[] dCount = new int[101];
	for ( int i=0; i<n; i++ ) {
	    d = sc.nextInt();
	    dCount[d]++;
	}

	int cnt = 0;
	for ( int i=1; i<101; i++ ) {
	    if ( dCount[i] > 0 ) {
		cnt++;
	    }
	}

	System.out.println(cnt);
    }
    
}

Measured memory_bytes: 21844
H,W,K = map(int, input().split())

id_count = 0
d = {}

for i in range(H):
  
  l = input()
  for j in range(W):
#    print(i,j,j+H)
    if l[j] == '#':
      if i in d:
        d[i].append(id_count)
      else:
        d[i]=[id_count]
        
      if j+H in d:
        d[j+H].append(id_count)
      else:
        d[j+H]=[id_count]
      id_count +=1

#print(d)
      
ans = 0
#print(id_count)

#if id_count == K:
#  print(1)
#else:
  
for i in range(2 ** (H+W)):
  wrk_list=[]
  for j in range(H+W):  # このループが一番のポイント
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      wrk_list.extend(d.get(j,[]))  
    if wrk_list==[]:
      set1 = []
    else:
      set1 = set(wrk_list)
  
#    print('set',set1,i)
  if id_count - len(set1) == K:
    ans +=1
print(ans)

Measured memory_bytes: 9124
// C - Colorful Leaderboard
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);++i)

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

	vi C(9);//[color_no]<count>
	int n = 0;//number of colors
	rp(i, N){
		int a; cin>>a;
		int b = min(8, a/400);
		if(C[b] == 0) n++;
		C[b]++;
	}

	if(C[8] > 0){
		if(n > 1) printf("%d %d\n", n-1, n-1+C[8]);
		else printf("%d %d\n", 1, C[8]);
	}
	else printf("%d %d\n", n, n);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
#define INF INT_MAX
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();
int n;


int f(ll x,ll y){
    int ma=-1;
    rep(i,32){
        if((x%3)==1 and (y%3)==1)chmax(ma,(int)i);
        x/=3;y/=3;
    }
    if(ma==-1)return 0;
    ll res=1;
    rep(i,ma)res*=3;
    return res;
}
vec to_3(ll x){
    vec res;
    rep(i,32){
        res.pb(x%3);x/=3;
    }
    // reverse(all(res));
    return res;
}

main(){
    ios
    int k=in();
    vec a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[k-1]<<endl;
}




Measured memory_bytes: 256
package main

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

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    N, _ := strconv.Atoi(readLine(reader))
    line := readLine(reader)
    arr := strings.Split(line, " ")
    var nums []int = make([]int, N)

    for k, v := range arr {
        nums[k], _ = strconv.Atoi(v)
    }

    sort.Sort(sort.IntSlice(nums))
    half := N / 2

    if nums[half-1] == nums[half] {
        fmt.Println(0)
    } else {
        fmt.Println(nums[half] - nums[half-1])
    }
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 6656
def v():
 import sys
 from collections import deque
 H,W,N=map(int,input().split())
 e='X'*(W+2)
 M=e+''.join('X'+e[:-1]+'X'for e in sys.stdin)+e
 m=(1,-1,W+2,-W-2)
 def f(s,g):
  p,t=s,0
  q=deque()
  b=[1]*len(M);b[s]=0
  while 1:
   for d in m:
    n=p+d
    if'X'!=M[n]and b[n]:
     if M[n]==g:return(n,t+1)
     b[n]=0;q.append([n,t+1])
   p,t=q.popleft()
 s=M.find('S')
 a=0
 for i in range(1,N+1):
  s,t=f(s,str(i))
  a+=t
 print(a)
if'__main__'==__name__:v()


Measured memory_bytes: 14812
using System;
using System.Collections.Generic;


class A
{
	public static void Main ()
	{

		int[] output = new int[26];


		while (true) {
			string s = Console.ReadLine ();

			if ( string.IsNullOrEmpty(s))
				break;
			string s2 = s.ToUpper ();


			for (int i=0; i	<s2.Length; i++) {
				if (s2 [i] >= 'A' && s2 [i] <= 'Z') {
					output [(int)s2 [i] - 'A']++;
				}
			}

		}

		for (int i =0; i<output.Length; i++) {
			Console.WriteLine ("{0} : {1}", Convert.ToChar (i + 'a'), output [i]);
		}
	}
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) { cin >> A[i]; }
  int cash = 1000;
  int stock = 0;
  int lastVal = 0;
  rep(i, N - 1) {
    if (A[i] < A[i + 1] && cash > A[i]) {
      stock = cash / A[i];
      cash = cash % A[i];
      lastVal = A[i];
    } else if (A[i] > A[i + 1]) {
      cash += stock * A[i];
      stock = 0;
    }
  }
  cash += stock * max(lastVal, A[N - 1]);

  cout << cash << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c==17)
    {
        if(a==7 || a==5)
        {
            if(b==5 || b==7)
            {
                if(c==5 || c==7){
                cout<<"YES";}
                else{cout<<"NO";}
            }
            else{cout<<"NO";}

        }
        else{cout<<"NO";}


    }
    else
    {
        cout<<"NO";
    }
}







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

using namespace std;




int main(){
   // std::ifstream cin("A.in");
  //  std::ofstream cout("A.out");
    long long cnt;
    long long n, x, la, l;
    long long ans = 0;
    cin >> n >> x;
    if(2 * x < n) {
        ans = n;
        l = x;
        la = n - x;
        cnt = 1;
    }
    else {
        ans = x;
        l = n - x;
        la = x;
        cnt = 0;
    }
    while(la % l != 0) {
        if(cnt % 2 == 1) {
            ans += ((la / l) * 2) * l;
            cnt += (la / l) * 2;
        }
        else {
            ans += ((la / l) * 2 + 1) * l;
            cnt += (la / l) * 2 + 1;
        }
        long long aux = l;
        l = la % l;
        la = aux;
    }
    if(cnt % 2 == 1)
        ans += ((la / l) * 2 - 1) * l;
    else
        ans += ((la / l) * 2) * l;
    cout << ans << std::endl;
   // cin.close();
   // cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int h1,h2,k1,k2,hp,kp,a,b,c,d;
	scanf("%d%d%d%d%d%d%d%d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	hp = h1*a+(h1/10)*c+h2*b+(h2/20)*d;
	kp = k1*a+(k1/10)*c+k2*b+(k2/20)*d;
	if(hp>kp){printf("hiroshi\n");}
	else if(hp<kp){printf("kenjiro\n");}
	else{printf("even\n");}
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

int N,A[2][1010];
int revsum[1010];

void compute() {
  revsum[N-1] = A[1][N-1];
  for(int x=N-2;x>=0;--x) revsum[x] = revsum[x+1] + A[1][x];
  int maxi = 0;
  int sum = 0;
  rep(x,N) {
    sum += A[0][x];
    maxi = max(maxi,sum+revsum[x]);
  }
  cout << maxi << endl;
}

int main() {
  cin >> N;
  rep(i,2) rep(j,N) cin >> A[i][j];
  compute();
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    N, _ := strconv.Atoi(readLine(reader))
    line := readLine(reader)
    arr := strings.Split(line, " ")

    var rate [8]int
    cnt_min := 0
    cnt_max := 0
    cnt_over := 0

    for k, v := range arr {
        num, _ := strconv.Atoi(v)

        if num >= 1 && num <= 399 {
            rate[0]++
        } else if num >= 400 && num <= 799 {
            rate[1]++
        } else if num >= 800 && num <= 1199 {
            rate[2]++
        } else if num >= 1200 && num <= 1599 {
            rate[3]++
        } else if num >= 1600 && num <= 1999 {
            rate[4]++
        } else if num >= 2000 && num <= 2399 {
            rate[5]++
        } else if num >= 2400 && num <= 2799 {
            rate[6]++
        } else if num >= 2800 && num <= 3199 {
            rate[7]++
        } else {
            cnt_over++
        }

        if k + 1 == N {
            for _, vv := range rate {
                if vv > 0 {
                    cnt_min++
                }
            }

            cnt_max = cnt_min + cnt_over

            if cnt_min == 0 {
                cnt_min = 1
            }

            //if cnt_max > 8 {
                //cnt_max = 8
            //}

            fmt.Printf("%d", cnt_min)
            fmt.Printf("%s", " ")
            fmt.Printf("%d", cnt_max)
            fmt.Println()
        }
    }
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}


Measured memory_bytes: 640
package main

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

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	N := Int(s)
	M := Int(s)
	div := M / N
	res := 1

	for i := div; i > 1; i-- {
		if M%i == 0 {
			res = i
			break
		}
	}
	fmt.Println(res)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


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

using namespace std;

const long long MOD = 1000000007;

int main() {
   int N,M;
   cin>>N>>M;
   string S;
   cin>>S;
   int now=S.size()-1;
   vector<int>ans;
   bool muri=false;
   while(1){
       bool flag=false;
       for(int i=M;i>0;i--){
           if(now-i<0){
               continue;
           }
           if(S[now-i]=='0'){
               now-=i;
               ans.push_back(i);
               break;
           }
           if(i==1){
               flag=true;
           }
       }
       if(flag){
           muri=true;
           break;
       }
       if(now==0){
           break;
       }
   }
   if(muri){
       cout<<-1<<endl;
   }else{
       reverse(ans.begin(),ans.end());
       for(int i=0;i<ans.size();i++){
           cout<<ans[i];
           if(i==ans.size()-1){
               cout<<""<<endl;
           }else{
               cout<<" ";
           }

       }
   }


}





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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y){
  x+=y;
  if (x>=mod) return x-mod;
  return x;
}
inline int sub(int x,int y){
  x-=y;
  if (x<0) return x+mod;
  return x;
}
inline int mul(int x,int y){
  return (x*1ll*y)%mod;
}
inline int power(int x,int y){
  int ans=1;
  while(y){
    if (y&1) ans=mul(ans,x);
    x=mul(x,x);
    y>>=1;
  }
  return ans;
}
inline int inv(int x){
  return power(x,mod-2);
}

int main()
{
  IOS;
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;

  return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll K; cin >> K;
  int N = 50;
  cout << N << endl;
  rep(i, N) {
    if (i != 0) cout << " ";
    if ((K%N) > i) cout << N + K/N - (K%N) + N;
    else cout << N + K/N - (K%N) - 1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int c = 0;
	for (int i = 1; i < 10; i++)
	{
		if (a % i == 0)
		{
			c = a/i;
		}
		if (c < 10)
		{
			cout << "Yes" << endl;
				return 0;
		}
	}
	cout << "No" << endl;
}


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

int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  if(A<=K){
    cout << 0;
    K = K-A;
  } else {
    cout << A-K;
    K = 0;
  }
  cout << " ";
  if(B<=K){
    cout << 0;
  } else {
    cout << B-K;
  }
}


Measured memory_bytes: 256
N = int(input())
result = 0
for i in range(1, N + 1, 2):
    counter = 0
    for j in range(1, int(i ** 0.5) + 1):
        if i % j == 0:
            counter += 1
            if j != i // j:
                counter += 1
    if counter == 8:
        result += 1
print(result)


Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define dbg(x) cout<<#x<<" = "<<x<<endl
typedef long long ll;
const int Mod = 1e9+7;
const int maxn = 2e5+10;
ll Fac[maxn],Inv[maxn],inv[maxn];
void init()
{
    Fac[0]=Inv[0]=Fac[1]=Inv[1]=inv[1]=1;
    for(int i=2;i<maxn;i++)
    {
        Fac[i]=Fac[i-1]*i%Mod;
        inv[i]=inv[Mod%i]*(Mod-Mod/i)%Mod;
        Inv[i]=Inv[i-1]*inv[i]%Mod;
    }
}
ll C(int n,int m)
{
  if(n<m||m<0) return 0;
  return Fac[n]*Inv[m]%Mod*Inv[n-m]%Mod;
}
ll tt[maxn];
int main()
{
    int h,w,a,b;
    init();
    scanf("%d%d%d%d",&h,&w,&a,&b);
    ll ans=0;
    ll pre=0;
    for(int i=b+1;i<=w;i++)
    {
        tt[i]=(C(h-a+i-2,i-1)-pre+Mod)%Mod;
        pre=C(h-a+i-2,i-1);
       // dbg(i);
    }
    for(int i=w;i>=b+1;i--)
    {
        ll tmp=C(a+w-i,a);
        ans=(ans+tmp*tt[i]%Mod)%Mod;
    }
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  int A, B, C, D;

  cin >> A >> B >> C >> D;

  int i = 0;

  while (i >= 0) {
    int judge = i % 2;
		if (judge == 0 ) {
			C = C - B;
      if (C <= 0){
        cout << "Yes" << endl;
        break;
      }
		}
    else {
      A = A - D;
      if (A <= 0){
        cout << "No" << endl;
        break;
      }
    }
    i++;
	}

  return 0;
}


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

int main() {
	// your code goes here
	int N;
	scanf("%d\n",&N);
	
	int A;
	scanf("%d\n",&A);
	
	int total=N*N;
	int rem=total-A;
	printf("%d",rem);
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

lint gcd(lint a, lint b)
{
    return a == 0 ? b : gcd(b % a, a);
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint A, B;
    cin >> A >> B;
    lint g = gcd(A, B);

    int ret = 1;
    FOR(i, 2, 1000001)
        if (g % i == 0) {
            ret++;
            while (g % i == 0)
                g /= i;
        }

    if (g > 1)
        ret++;

    cout << ret << endl;
    return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
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> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;

signed main()
{
   string s; cin >> s;
   map<char,int> cnt;
   for (int i = 0; i < s.size(); ++i) {
      ++cnt[s[i]];
   }

   auto list = {cnt['a'], cnt['b'], cnt['c']};
   if (max(list) - min(list) <= 1) {
      cout << "YES" << endl;
   } else {
      cout << "NO" << endl;
   }

   return 0;
}


Measured memory_bytes: 512
n,p=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]%2==1:c+=1
if c==0:
  if p==0:print(2**n)
  else:print(0)
elif c==n:
  if n!=1:print(2**(n-1))
  else:print(0)
else:print(2**(n-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	int a,b;
	cin>>a>>b;
	if(a*500>=b)puts("Yes");
	else puts("No");
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool win = false;
    while(true){
        c -= b;
        if(c <= 0){
            win = true;
            break;
        } 

        a -= d;
        if(a <= 0){
            win = false;
            break;
        }
    }

    if(win) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, C;
    cin >> N >> C;
    vector<ll> s(N),t(N),c(N);
    map<ll,ll> mps[31],mpt[31];
    rep(i,N){
        cin >> s[i] >> t[i] >> c[i];
        mps[c[i]][s[i]]++;
        mpt[c[i]][t[i]]++;
        if(mpt[c[i]][s[i]] > 0){
            mpt[c[i]][s[i]]--;
            mps[c[i]][s[i]]--;
        }
        if(mps[c[i]][t[i]] > 0){
            mpt[c[i]][t[i]]--;
            mps[c[i]][t[i]]--;
        }
    }
    vector<ll> S(100010);
    REP(i,1,C+1){
        for(auto& p:mps[i]){
            if(p.second > 0){
                S[p.first] += p.second;
            }
        }
    }
    REP(i,1,C+1){
        for(auto& p:mpt[i]){
            if(p.second > 0){
                S[p.first+1] -= p.second;
            }
        }
    }
    /*rep(i,N){
        S[s[i]-1]++;
        S[t[i]+1]--;
    }*/
    //PR(S,100);
    rep(i,100009){
        S[i+1] += S[i];
    }
    ll ans = 0;
    rep(i,100010){
        cmax(ans, S[i]);
    }
    //PR(S,100);
    cout << ans << endl;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d)cout<<"Left"<<endl;
  else if(a+b<c+d)cout<<"Right"<<endl;
  else cout<<"Balanced"<<endl;



return 0;}


Measured memory_bytes: 256
a,b,c, = map(int,input().split())
if a < b:
	if a < c:
		if b < c:
			print(a, b, c)
		else:
				print(a, c, b)
	else:
				print(c, a, b)
else:
	if b < c:
		if a < c:
			print(b, a, c)
		else:
				print(b, c, a)
	else:
				print(c, b, a)

Measured memory_bytes: 7568
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int k[5];
	for (int i = 0; i < 4; ++i) {
		cin >> k[i];
	}
	sort(k, k + 4);
	if (k[0] == 1 && k[1] == 4 && k[2] == 7 && k[3] == 9) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
}

Measured memory_bytes: 764
from collections import defaultdict
import string
import sys
sys.setrecursionlimit(10 ** 7)
from functools import lru_cache

N = int(input())
alph = string.ascii_lowercase

def search(S, mx):
    if len(S) == N:
        print(S)
    else:
        for s in alph[: mx + 1]:
            search(S + s, mx)
        search(S + alph[mx + 1], mx + 1)

search('a', 0)


Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int a, b; cin >> a >> b;
	cout << ((b % a == 0) ? a + b : b - a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>

using namespace std;

#define INFTY 1e8

typedef long long ll;


//int dp[1005][1005];

int N, M;
vector<int> edge[200005];


int dfs(int depth, int n, int pre) {
	if (depth > 2)
		return 0;
	
	for (int i = 0; i < edge[n].size(); ++i) {
		if (edge[n][i] == N)
			return 1;
		if (edge[n][i] == pre)
			continue;
		else {
			if (dfs(depth + 1, edge[n][i], n))
				return 1;
		}
	}
	return 0;
}


int main() {

	cin >> N >> M;
	
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		edge[a].push_back(b);
	}

	if (!dfs(1, 1, 0))
		printf("IM");
	printf("POSSIBLE\n");



	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 1e9;

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  set<int> st1, st2;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'c' || st1.size() == a + b) {
      cout << "No" << endl;
    } else {
      if (s[i] == 'a') {
        st1.insert(i);
        cout << "Yes" << endl;
      } else {
        if (st2.size() < b) {
          st1.insert(i);
          st2.insert(i);
          cout << "Yes" << endl;
        } else cout << "No" << endl;
      }
    }
  }
  
  return 0;
} 

Measured memory_bytes: 7808
#include<stdio.h> 
#include<iostream>
#include<vector> 
using namespace std;
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
long long int knapsack(long long int W, vector<long long int> wt, vector<long long int> val, long long int n) 
{ 
   long long int i, w; 
   long long int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
int main()
{
	long long int n,w;
	cin>>n>>w;
	vector<long long int> val;
	vector<long long int> wt;
	for(int i=0;i<n;i++)
	{
	int a,b;
	cin>>a>>b;
	val.push_back(b);
	wt.push_back(a);
	}
	cout<<knapsack(w,wt,val,n)<<endl;


	return 0;
}

Measured memory_bytes: 79104
import sys
readline = sys.stdin.readline

S = readline().rstrip()
S = S.replace("BC","X")
S = S.replace("B",".").replace("C",".")
arr = S.split(".")
ans = 0
for a in arr:
  cnt = 0
  for i in range(len(a)):
    if a[i] == "X":
      ans += (i - cnt)
      cnt += 1
  
print(ans)

Measured memory_bytes: 5412
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
struct e{
  ll a,b,c;  
};
ll l,x=0;
vector<e>ans;
int main(void){
    cin>>l;
    ll a=1;
    while(a*2<=l){
        a*=2;
        x++;
    }
    x++;
    cout<<x;
    ll b=1;
    for(int i=x-1;i>=1;i--){
        ans.PB(e{i,i+1,b});
        ans.PB(e{i,i+1,0});
        b*=2;
    }
    ll y=0;
    b=1;
    while(a+b<=l){
        while(a+b*2<=l){
            b*=2;
            y++;
        }
        ans.PB(e{1,x-y,a});
        a+=b;
        b=1;
        y=0;
    }
    cout<<' '<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i].a<<' '<<ans[i].b<<' '<<ans[i].c<<endl;
    }
}


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

const ll MAX = 200200, MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
// 前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数の計算
ll COM(int n, int k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll n, m, k; cin >> n >> m >> k;
    COMinit();
    ll ans = 0;
    rep(i,n) ans += i*((n-i)*m*m % MOD) * COM(n*m-2, k-2) % MOD, ans %= MOD;
    rep(i,m) ans += i*((m-i)*n*n % MOD) * COM(n*m-2, k-2) % MOD, ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8324
s=input()
kuro=""
for i in range(len(s)):
    if i%2==0:
        kuro+="1"
    else:
        kuro+="0"
ans=0
for i in range(len(s)):
    if s[i]==kuro[i]:
        ans+=1
print(min(ans,len(s)-ans))

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main() {
    
    int A, B;
    cin >> A >> B;
    if (A > 0 && B > 0)
    {
        if (A + B > A * B)
        {
            cout << (A + B) << endl;
        } else {
            cout << (A * B) << endl;
        }
    } else if (A > 0 && B == 0) {
        cout << A << endl;
    } else if (A > 0 && B < 0) {
        cout << (A - B) << endl;
    } else if (A == 0 && B > 0) {
        cout << B << endl;
    } else if (A == 0 && B == 0) {
        cout << 0 << endl;
    } else if (A == 0 && B < 0) {
        cout << (A - B) << endl;
    } else if (A < 0 && B > 0) {
        cout << (A + B) << endl;
    } else if (A < 0 && B == 0) {
        cout << A << endl;
    } else if (A < 0 && B < 0) {
        if (A - B > A * B)
        {
            cout << (A - B) << endl;
        } else {
            cout << (A * B) << endl;
        }
    }


    return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k,r=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<n;i++)
    {
    	for(int j=i+1;j<n;j++)
    	{
    		if(a[j]>a[i])
    		{
    			int s=a[i];
    			a[i]=a[j];
    			a[j]=s;
			}
		}
	}
	for(int i=0;i<k;i++)
		r+=a[i];
	cout<<r;	
}

Measured memory_bytes: 256
import collections
 
n = int(input())
v = list(map(int, input().split()))
a = v[::2]
b = v[1::2]
ac = collections.Counter(a).most_common(2)
bc = collections.Counter(b).most_common(2)
if ac[0][0] != bc[0][0]:
    print(n - ac[0][1] - bc[0][1])
else:
    if len(ac) == 1:
        print(n // 2)
    else:
        print(n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1]))

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

const int maxn = 50;

int n;
int a[maxn];

int main(){
	a[0] = 1;
	a[1] = 1;
	scanf("%d",&n);
	for(int i = 2;i <= n; i++)a[i] = a[i-1] + a[i-2];
	printf("%d\n",a[n]);
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)(x).size())
#define BOOST ios_base::sync_with_stdio(false); cin.tie(0)

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
                                    

/*************************** END OF TEMPLATE ***************************/




PLL operator-(const PLL &a, const PLL &b)
{
        return {a.ST - b.ST, a.ND - b.ND};
}

// det(a, b, c) :
// a -> b -> c
// - jesli skret jest w lewo to jest na plusie
LL det(const PLL &a, const PLL &b, const PLL &c)
{
        return (a.ST * b.ND + b.ST * c.ND + c.ST * a.ND
                 - a.ND * b.ST - b.ND * c.ST - c.ND * a.ST);
}

vector<PLL> hull(vector<PLL> v)
{
        sort(v.begin(), v.end());
        vector<PLL> r;
        int minsize = 1;
        for(auto i : v)
        {
                while(SIZE(r) > minsize && det(r[SIZE(r) - 2], r.back(), i) > 0)
                        r.pop_back();
                r.push_back(i);
        }
        reverse(v.begin(), v.end());
        r.pop_back();
        minsize = SIZE(r) + 1;
        for(auto i : v)
        {
                while(SIZE(r) > minsize && det(r[SIZE(r) - 2], r.back(), i) > 0)
                        r.pop_back();
                r.push_back(i);
        }
        r.pop_back();
        return r;
}


LL dist(const PLL &a, const PLL &b)
{
        return (a.ST - b.ST) * (a.ST - b.ST) + (a.ND - b.ND) * (a.ND - b.ND);
}



int main()
{
        BOOST;
        
        int n;
        cin >> n;
        vector<PLL> v;
        while(n > 0)
        {
                int a, b;
                cin >> a >> b;
                v.PB({a, b});
                n--;
        }

        vector<PLL> h = hull(v);

        reverse(h.begin(), h.end());

        int m = 0;
        FOR(i, 0, SIZE(h) - 1)
                if(h[i].ND < h[m].ND || (h[i].ND == h[m].ND && h[i].ST < h[m].ST))
                        m = i;

        rotate(h.begin(), h.begin() + m, h.end());

        cout << SIZE(h) << endl;
        for(auto i : h)
                cout << i.ST << ' ' << i.ND << endl;



}





Measured memory_bytes: 8208
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	var n int
	var s string

	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}

	if sc.Scan() {
		s = sc.Text()
	}

	var rgb, r, g, b int
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
	}
	rgb = r * g * b

	for j := 0; j < n; j++ {
		for i := 0; i < j; i++ {
			k := j + (j - i)
			if k < n {
				if s[i] == s[j] {
					continue
				}
				if s[i] == s[k] {
					continue
				}
				if s[j] == s[k] {
					continue
				}
				rgb--
			}
		}
	}

	fmt.Print(rgb)
}


Measured memory_bytes: 1780
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder=new StringBuilder();
        while(true){
            String data[]=reader.readLine().split(" ");
            int x=Integer.parseInt(data[0]);
            int y=Integer.parseInt(data[1]);
            if(x==0 && y==0) break;
            builder.append(Integer.toString(x<y?x:y)).append(" ").append(Integer.toString(x<y?y:x)).append("\n");
        }
        System.out.print(builder);
    }
}

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

int main(){
  int c; cin>>c;
  int r; cin>>r;
  
  if(c>=10){
    cout<<r;
  }
  else{
    int inr = 100*(10 - c);
    inr += r;
    cout<<inr;
  }
  
}




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

int main(){
  int a, min, max, n, i;
  long long sum;
  cin >> n;
  cin >> a;
  min = max = sum = a;
  for(i = 1; i < n; i++){
    cin >> a;
    sum += a;
    if (a < min) {
      min = a;
      continue;
    }
    if (a > max) max = a;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
  double  n;
  cin>>n;
  double x=n/3.0;
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  setprecision(12);
  cout<<x*x*x<<endl;
}


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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int count =0;
    for(int k=0;k<n;k++){
        if(a[a[k]-1]==k+1){
            count++;
        }
    }
cout<<count/2<<endl;
}

Measured memory_bytes: 640
#!/usr/bin python3
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
p = [int(i)-1 for i in input().split()]
c = list(map(int, input().split()))

ret = - 10 ** 18
for s in range(n):
    nxt = p[s]
    S = [c[nxt]]
    while nxt != s:
        nxt = p[nxt]
        S.append(S[-1]+c[nxt])

    if k<=len(S):
        pt = max(S[:k])
    else:
        if S[-1] <= 0:
            pt = max(S)
        else:
            pt = max(S)
            if k%len(S)!=0:
                pt = max(pt, S[-1]+max(S[:k%len(S)]))
            pt += S[-1]*(k//len(S)-1)
    ret = max(ret, pt)
print(ret)


Measured memory_bytes: 81472
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
  long long ans = 0;
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }
  int sum = 0;
  for(i = 0; i < n; i++)
  {
    sum += a.at(i);
  }
  for(i = 1; i <= (int)sqrt(sum); i++)
  {
    if(sum%i==0)
    {
      int cc;
      for(cc = 0; cc < n; cc++)
      {
        b.at(cc) = a.at(cc)%i;
      }
      sort(b.begin(),b.end());
      int count = 0;
      int indexl = 0;
      int indexr = n-1;
      while(indexl < indexr)
      {
        int nn = min(b.at(indexl),i-b.at(indexr));
        b.at(indexl) -= nn;
        b.at(indexr) += nn;
        count += nn;
        if(b.at(indexl) == 0)indexl++;
        if(b.at(indexr) == i)indexr--;
      }
      if(count <= k && i > ans)ans = i;

      for(cc = 0; cc < n; cc++)
      {
        b.at(cc) = a.at(cc)%(sum/i);
      }
      sort(b.begin(),b.end());
      count = 0;
      indexl = 0;
      indexr = n-1;
      while(indexl < indexr)
      {
        int nn = min(b.at(indexl),(sum/i)-b.at(indexr));
        b.at(indexl) -= nn;
        b.at(indexr) += nn;
        count += nn;
        if(b.at(indexl) == 0)indexl++;
        if(b.at(indexr) == sum/i)indexr--;
      }
      if(count <= k && sum/i > ans)ans = sum/i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define int long long
#define F(a,b,c) for(int a=b;a<=c;++a)
const int p=1e9+7;
int f[55][55][55],c[55][55];
signed main(){
	int n;	
	std::cin>>n;
	f[1][1][1]=1;
	F(i,0,n){
		c[i][0]=c[i][i]=1;
		F(j,1,i-1)c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;
	}
	F(i,1,n-1)F(j,1,i)F(k,0,j)F(l,0,j)F(w,(k-l>0?k-l:0),(n-i+k-l)>>1)
	if(w+l-k+w>0)(f[w+l-k+w+i][w+l-k+w][w]+=f[i][j][k]*c[j][l]%p*c[w+l-k+w+i][i])%=p;
	int ans=0;
	F(i,1,n)F(j,0,i)ans=(ans+f[n][i][j]*c[i][j])%p;
	std::cout<<ans;
	return 0;
}



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

using namespace std;

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

int main (){
    cin.tie(0);
    int N,sqN;
    cin >> N;
    sqN = (int)sqrt(N);
    REP(i,sqN+2){
        if(i*i>N){
            cout << (i-1)*(i-1) <<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mkp make_pair
#define pi pair<int,int>//struct pi {int fi,se;};
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define ln length()
#define sz size()
const int N=100005;
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    // int t;cin>>t;while(t--)
    {
        int i,k,n,j,cnt=1,pre;
        cin>>n>>k;
        int a[n];
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        j = 0;
        
        pre = a[j];
        rep(i,k,n){
            if(a[i] > pre){
                cout << "Yes"<<endl;
            }else{
                cout << "No"<<endl;
            }
            j++;
            pre = a[j];
        }
        
    }
}


Measured memory_bytes: 5172
// B - Foods Loved by Everyone
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);i++)

int in(){int x;cin>>x;return x;}

int main(){
	int N,M; cin>>N>>M;

	vector<int> A(M);
	rp(i, N){
		int k = in();
		rp(j,k) A[in()-1]++;
	}

	int count = 0;
	for(int c:A) if(c==N) count++;
	cout<< count <<endl;
}

Measured memory_bytes: 256
/**
  @file b.cpp
  @title B - 0 or 1 Swap
  @url https://atcoder.jp/contests/abc135/tasks/abc135_b
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N;
  cin >> N;
  vector<int> p(N, 0);
  vector<int> p_sorted(N, 0);
  REP(i, N) {
    cin >> p[i];
    p_sorted[i] = p[i];
  }
  sort(ALL(p_sorted));

  int count = 0;
  REP(i, N) {
    if (p_sorted[i] != p[i]) {
      count++;
    }
  }

  if (count == 2 || count == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string t = s;
    reverse(t.begin(), t.end());
    if (s == t) {
        reverse(t.begin(), t.begin() + (s.size() - 1) / 2);
        reverse(t.begin() + (s.size() + 1) / 2, t.end());
        if (s == t) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define eol '\n'
using namespace std;

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

  int N,L;
  cin >> N >> L;
  
  vector<string> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }
  
  sort(list.begin(), list.end());

  for (int i = 0; i < N; i++) {
    cout << list[i];
  }
  cout << eol;
  
  return 0;
}


Measured memory_bytes: 256
X,Y = list(map(int, input().split()))

if Y % 2 == 1 :
  print("No")
else :
  if Y//2 -X < 0 :
    print("No")
  else :
    if X - (Y//2 -X) < 0 :
      print("No")
    else :
      print("Yes")

Measured memory_bytes: 9180