akhauriyash/Code-Regression huggingface dataset:
object Main extends App {

  import scala.io.StdIn._

  var n = readLine.toInt
  while (n != 0) {
    val scores = readLine.trim.split(' ').map(_.toInt).sorted
    println(
      (1 until n).map { i ⇒ scores(i) - scores(i - 1) }.min
    )
    n = readLine.toInt
  }
}



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

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

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

using namespace std;

int a,b;
int main(){
    cin >> a >> b;
    if(a==2 || b==2){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc145b()
}

fun abc145b() {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    if (n % 2 != 0) return println("No")

    val answer = if (s.slice(0..s.lastIndex / 2) == s.slice(s.lastIndex / 2 + 1..s.lastIndex)) "Yes" else "No"

    println(answer)
}




Measured memory_bytes: 31928
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	auto edge = vector<vector<int>>(10,vector<int>(10,0));
	for (int i = 0; i < m;++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a][b] = edge[b][a] = 1;
	}
	vector<int> order;
	for (int i = 0; i < n; ++i) {
		order.push_back(i);
	}
	int sum = 0;
	do {
		bool flag = true;
		if (order[0] != 0) continue;
		for (int i = 0; i + 1 < n; ++i) {
			if (edge[order[i]][order[i + 1]] == 0) {
				flag = false;
			}
		}
		if (flag) sum++;
	} while (next_permutation(order.begin(), order.end()));
	cout << sum << endl;
	return 0;
}

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

typedef long long ll;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void solve(){
    ll n,m;
    cin>>n>>m;
    ll total=0;
    vector<ll> v(n);
    for(auto &x:v){
        cin>>x;
        total+=x;
    }
    int ok=0;
    for(auto x:v){
        if(x>=(float)total/(4*m))ok++;
    }
    if(ok>=m)cout<<"Yes\n";
    else cout<<"No\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

 int dp[50];
 
int fibonacci( int n){
  if ( n == 0 || n == 1)return dp[n] =1;
  if ( dp[n] != -1 )return dp[n];
  return dp[n] = fibonacci( n - 1 ) + fibonacci( n - 2 );
}
 
int main(){
  int n,i;
  for( i = 0 ; i <=44 ; i++) dp[i] = -1;
 
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
 
  return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

bool find_cand(char c0, char c1, int N, const char *ans, char *cand);

int main()
{
    int N;
    string s;

    cin >> N;
    cin >> s;

    const char *ans = s.c_str();

    char cand[100'001];

    if (find_cand('S', 'S', N, ans, cand) ||
        find_cand('S', 'W', N, ans, cand) ||
        find_cand('W', 'S', N, ans, cand) ||
        find_cand('W', 'W', N, ans, cand))
    {
        cout << cand << endl;
    }
    else
    {
        cout << "-1" << endl;
    }

    return 0;
}

bool find_cand(char c0, char c1, int N, const char *ans, char *cand)
{
    cand[N] = '\0';

    cand[0] = c0;
    cand[1] = c1;

    for (int i = 0; i < N; i++)
    {
        int curr = i + 2;
        bool same = ans[(curr - 1) % N] == 'o';
        bool honest = cand[(curr - 1) % N] == 'S';
        bool sheep = cand[(curr - 2) % N] == 'S';

        cand[curr % N] = !(honest ^ same) ? sheep ? 'S' : 'W'
                                          : sheep ? 'W' : 'S';
    }

    return cand[0] == c0 && cand[1] == c1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	
	for(int i=0;i<t.size();i++){
		cout<<t[i];
	}
	for(int i=0;i<s.size();i++){
		cout<<s[i];	
	}
	
	return 0;
} 

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

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define fr(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define gf(i,n) for (int i=0 ; i<n ; i+=1)
#define rfor(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define prarr(a,n) gf(i,n){printf("%d ", a[i]);}printf("\n");
#define sumarr(a,n) int zserkd=0;gf(i,n){zserkd+=a[i];}cout<<zserkd<<endl;
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

/****** Template of some basic operations *****/
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

void prmap(map<int,int>m)
{
	cout << "printig map"<<endl;
	for(auto it=m.begin();it!=m.end();it++)
	{
		cout << it->first << " "<< it->second<< " | ";
	}
	cout << endl;
}
int main(){
	
	int n;
	cin >> n;
	int a[n];
	gf(i,n)
	{
		cin >> a[i];
	}
	map<long long ,long long>m1,m2,m3,m4;
	gf(i,n)
	{	
		long long n1,n2,n3,n4;
		n1=a[i]-i;
		n2=-a[i]-i;
		n3=a[i]+i;
		n4=-a[i]+i;
		auto it = m1.find(n1);
		if(it!=m1.end())
			it->second++;
		else
			m1.insert(mp(n1,1));
		 it = m2.find(n2);
		if(it!=m2.end())
			it->second++;
		else
			m2.insert(mp(n2,1));
		 it = m3.find(n3);
		if(it!=m3.end())
			it->second++;
		else
			m3.insert(mp(n3,1));
		 it = m4.find(n4);
		if(it!=m4.end())
			it->second++;
		else
			m4.insert(mp(n4,1));
	}
	// prmap(m1);
	// prmap(m2);
	// prmap(m3);
	// prmap(m4);
	long long ans =0;
	for(auto it=m1.begin();it!=m1.end();it++)
	{
		auto it2=m2.find(it->first);
		if(it2!=m2.end())
		{
			ans+=it->second * it2->second;
		}
	}
	for(auto it=m3.begin();it!=m3.end();it++)
	{
		auto it2=m4.find(it->first);
		if(it2!=m4.end())
		{
			ans+=it->second * it2->second;
		}
	}
	cout << ans/2;
	return 0;
}


Measured memory_bytes: 50572
#include<iostream>
using namespace std;
int mod(int a, int b) {
    if(a>b) return a-b;
    else return b-a;
}
int main( ){
    int n;
    cin>>n;
    int arr[n],dp[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=mod(arr[1],arr[0]);
    for(int i=2;i<n;i++) {
        dp[i]=min((mod(arr[i],arr[i-1])+dp[i-1]),(mod(arr[i],arr[i-2])+dp[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

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

	string divide[4] ={"dream", "dreamer", "erase", "eraser"};

	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++) {
		reverse(divide[i].begin(), divide[i].end());
	}

	bool can = true;
	for (int i = 0; i < s.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; j++) {
			string d = divide[j];
			if (s.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}

	if (can) {
		cout << "YES" << endl;
	} else {
		cout << "NO"  << endl;
	}

    return 0;
}


Measured memory_bytes: 512
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {

	var N int;
    N = nextInt();
    var A int;
    A = nextInt();
    var B int;
    B = nextInt();
	solve(N, A, B);

}

func solve(N int, A int, B int){
	if A*N >= B {
		Println(B)
	}else{
		Println(A*N)
	}
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



Measured memory_bytes: 2816
#include <iostream>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
const ll INF = 1e18;

ll dp[200005][4];

// cp temp.cpp abc160_e.cpp

int main() {
  int n;
  cin >> n;
  n = n%10;
  if(n==3){
    cout << "bon" << endl;
  }else if(n==0 || n==1 || n==6 || n==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
  return 0;
}


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

int main () {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  rep(i,m) cin >> x[i];

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

  vector<int> diff(m-1);
  rep(i,m-1) {
    diff[i] = x[i+1] - x[i];
  }
  sort(diff.begin(), diff.end(), greater<int>());

  int ans = x[m-1] - x[0];
  rep(i,n-1) {
    if(i < m - 1) ans -= diff[i];
  }
  cout << ans << endl;

  return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

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

    string str;
    cin >> str;

    int wins = 15 - str.length();
    for (char c : str)
        wins += c == 'o';

    cout << (wins >= 8 ? "YES" : "NO") << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int kaisu = scan.nextInt();
		long[] num= new long[kaisu];
		long max = -1000001;
		long min = 1000001;
		long sum = 0; 

		for(int i = 0; i < kaisu ; i++){
			num[i] = scan.nextLong();
			if(max < num[i]) max = num[i];
			if(min > num[i]) min = num[i];
			sum = sum + num[i];
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

Measured memory_bytes: 31828
a,b=map(int, input().split())

n=b-a

k=0

for i in range(n+1):
  A=str(a)
  if A[0]==A[-1] and A[1]==A[-2]:
    k+=1
  else:
    k+=0
  a+=1
  
print(k)  
  
  
  

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,q; cin>>n>>q;
	set<int> st;
	int t;
	q*=2;
	while(q--){
		cin>>t;
		if(st.count(t)) st.erase(t);
		else st.insert(t);
	}
	if(st.empty()) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}





























Measured memory_bytes: 2560
<?php
fscanf(STDIN, "%d", $N);
$fmt = '%d';
for ($i = 0; $i < $N; $i++) $fmt .= ' %d';
$a = fscanf(STDIN, $fmt);

$sum = intval(gmp_xor($a[0], $a[1]));
for ($i = 2; $i < $N; $i++) {
  $sum = intval(gmp_xor($sum, $a[$i]));
}

echo intval(gmp_xor($sum, $a[0]));
for ($i = 1; $i < $N; $i++) {
	echo ' ' . intval(gmp_xor($sum, $a[$i]));
}


Measured memory_bytes: 27560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const tuple<ll, ll, string, ll, string>& x, const tuple<ll, ll, string, ll, string>& y) const {
        if(get<0>(x)==get<0>(y)){
            if(get<1>(x)==get<1>(y)){
                if(get<2>(x)==get<2>(y)){
                    if(get<3>(x)==get<3>(y)){
                        return get<4>(x) < get<4>(y);
                    }else return get<3>(x) < get<3>(y);
                }else return get<2>(x) < get<2>(y);
            }else return get<1>(x) < get<1>(y);
        }else return get<0>(x) < get<0>(y);
            
	}
};
void print_vector(vector<tuple<ll, ll, string, ll, string> >& v)
{
    for(auto& element : v){
        cout << get<0>(element) << " " << get<1>(element) << " " << get<2>(element) << " " << get<3>(element) << " " << get<4>(element)  << endl;
    }
    
}


vector<tuple<ll, ll, string, ll, string> > v;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    REP(i, n) {
        ll vv, w, d; string t, s;
        cin >> vv >> w >> t >> d >> s;
        tuple<ll, ll, string, ll, string> tu = make_tuple(vv, w, t,d,s);
        v.push_back(tu);
    }
    sort(v.begin(), v.end(), Less());
    
    
    print_vector(v);
	return 0;
}


Measured memory_bytes: 16600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define MOD 1000000007
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	priority_queue<int> que;
	string s;
	while (cin >> s)
	{
		if (s == "end") break;
		if (s == "insert")
		{
			int t; cin >> t;
			que.push(t);
		}
		if (s == "extract")
		{
			cout << que.top() << endl;
			que.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 7040
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
    
		// 出力
		System.out.println(c >= a && c <= b ? "Yes" : "No");
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N,M;cin>>N>>M;
    vector<int> S(M,0);
    for(int i=0;i<M;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int s;cin>>s;
            S[i]+=(1<<(s-1));
        }
    }
    vector<int> P(M,0);
    for(int i=0;i<M;i++){
        int p;cin>>p;
        P[i]=p;
    }
    
    int count=0;
    for(int bit=0;bit<(1<<N);bit++){
        bool ok=true;
        for(int i=0;i<M;i++){
            int sum=S[i]&bit;
            if(__builtin_popcount(sum)%2!=P[i]){
                ok=false;break;
            }
        }
        if(ok) count++;
    }
    cout<<count<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vector<bool> F(N);
  bool flag=0;
  int count=0;
  rep(i,0,N){
    int K=N-1-i;
    int sum=0;
    REP(j,2,N/(K+1)){
      if(F[(K+1)*j-1]){
        sum++;
      }
    }
    if(sum%2==A[K])
      continue;
    else{
      F[K]=1;
      count++;
    }
  }
  if(flag)
    cout<<-1<<endl;
  else{
    cout<<count<<endl;
    rep(i,0,N){
      if(F[i])
        cout<<i+1<<" ";
    }
    cout<<endl;
  }
  }



Measured memory_bytes: 2560
import java.util.Scanner;

class Main{
public static void main(String[] args){

	Scanner s = new Scanner(System.in);
	
	int a= s.nextInt();
    int b= s.nextInt();
    int c= s.nextInt();
    int cnt=0;
    for(int i=a;i<=b;i++){
        
        if(c%i==0){
            
            cnt++;
        }else{continue;}
        }
    
		System.out.println(cnt);
		
		
	}
	
}



Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, M, C;
    cin >> N >> M >> C;
    vector<ll> B(M);
    vector<vector<ll>> A(N, vector<ll>(M));
    repi(i, M, 0)
    {
        cin >> B[i];
    }
    repi(i, N, 0)
    {
        repi(j, M, 0)
        {
            cin >> A[i][j];
        }
    }
    ll cnt = 0;
    repi(i, N, 0)
    {
        ll s = 0;
        repi(j, M, 0)
        {
            s += A.at(i).at(j) * B.at(j);
        }
        cnt = s + C > 0 ? ++cnt : cnt;
    }
    cout << cnt << endl;
    return 0;
}

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

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int main()
{
    const double pi = acos(-1);
    //fastio();
    int a,b,h,m;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    double p = 1.0*(h+1.0*m/60)*360/12;
    double q = 1.0*m*360/60;
    double k = fabs(p-q);
    double ans = 1.0*a*a+1.0*b*b-2.0*a*b*cos(k*pi/180.0);

    printf("%.12f\n",sqrt(ans));
    return 0;
}


Measured memory_bytes: 4256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtcoderTemplateForCSharp
{
    public class AtcoderTemplateForCSharp
    {
        public static void Main(string[] args)
        {
            var inputString = Console.ReadLine();

            if(inputString.Substring(0, 7) == "keyence")
            {
                Console.WriteLine("YES");
                return;
            }

            if (inputString.Substring(inputString.Length - 7, 7) == "keyence")
            {
                Console.WriteLine("YES");
                return;
            }

            var keyenceString = "keyence";
            int pointer = 0;
            int cutStart = 0;

            while (true)
            {
                if (inputString[cutStart] == keyenceString[cutStart])
                {
                    cutStart++;
                }
                else
                {
                    pointer = cutStart;
                    break;
                }
            }

            while (true)
            {
                pointer++;

                if (pointer == inputString.Length)
                {
                    Console.WriteLine("NO");
                    return;
                }

                if (inputString[pointer] == keyenceString[cutStart])
                {
                    if(inputString.Substring(pointer) == keyenceString.Substring(cutStart))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main(void) {
	int A, B, ans;
	char op;
	cin >> A >> op >> B;
	if (op == '+') {
		ans = A + B;
	}
	else {
		ans = A - B;
	}
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 256
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
    
n,k=map(int,input().split())
a=sorted(list(map(int, input().split())))
MOD=10**9+7

fac, ifac=make_tables(MOD,n)

s=0
for i in range(k-1,n):
	s+=(a[i]-a[n-i-1])*cmb(i,k-1,MOD,fac,ifac)
	s%=10**9+7
print(s)

Measured memory_bytes: 77480
N,A,B=map(int,input().split())
A += B
cnt = [0,0]
S=list(input())
for i in range(N):
    if S[i] == 'c':
        print("No")
    elif S[i] == 'a':
        if cnt[0] < A:
            print("Yes")
            cnt[0] += 1
        else:
            print("No")
    else:
        if cnt[0] < A and cnt[1] < B:
            print("Yes")
            cnt[0] += 1
        else:
            print("No")
        cnt[1] += 1

Measured memory_bytes: 9644
import sys

Even = True
for s in sys.stdin:
    if Even:
        Even = False
        a = list(map(int, s.split()))
    else:
        Even = True
        b = list(map(int, s.split()))
        hit = sum(a[i] == b[i] for i in range(4))
        blow = sum(b[i] in a for i in range(4)) - hit
        print(hit, blow)

Measured memory_bytes: 7716
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 1000000

int32_t main()
{   
    io
    int a,b;
    cin>>a>>b;

    int gcd = __gcd(a,b);

    int gcd1 = gcd;
    int count=1;

    for(int i=2;i<=MAX_SIZE;i++)
    {
        if(gcd%i==0)
        {
            while(gcd%i==0)
                gcd /= i;
            count++;
        }

    }

    (gcd>1)? cout<<count+1:cout<<count;



return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
from math import *
input = sys.stdin.readline

def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10**9 + 7

    prime_factors = defaultdict(int)
    
    #各素因数の最大値を保持
    for i in range(n):
        pf = factorization(As[i])
        for j in pf:
            prime_factors[j] = max(pf[j], prime_factors[j])
    
    lcm = 1
    for key in prime_factors:
        lcm *= pow(key, prime_factors[key])    
    
    ans = 0
    ans = sum([lcm // As[i] for i in range(n)]) % mod

    print(ans)
    return

#参考: https://qiita.com/ophhdn/items/e6451ec5983939ecbc5b
def pow(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

def factorization(n):
    dic = defaultdict(int)
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            dic[i] = cnt
            
    if temp!=1:
        dic[temp] = 1
    if not dic:
        dic[n] = 1

    return dic

if __name__ == '__main__':
    main()

Measured memory_bytes: 294760
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
const int mod=924844033;
int n,k,ans,fac[2001],g[2001],f[4001][2001][2];
int main()
{
	re(n),re(k);
	f[0][0][0]=1;
	for(int i=1,be=2,now=1;i<=n+n;++i)
	{
		for(int j=0;j<=n;++j)	
		{
			f[i][j][0]=(f[i-1][j][1]+f[i-1][j][0])%mod;
			if(now!=be/2)f[i][j][1]=f[i-1][j-1][0];
		}
		now+=k;
		if(now>n)
			++be,now=be/2;
	}
	for(int i=0;i<=n;++i)g[i]=(f[n+n][i][0]+f[n+n][i][1])%mod;
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=0,f=1;i<=n;++i,f*=-1)	
		ans=(ans+1ll*f*fac[n-i]*g[i])%mod;
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 62848
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    sx, sy, tx, ty = il()

    ret = ''
    for n in range(ty - sy): ret += 'U'
    for n in range(tx - sx): ret += 'R'
    for n in range(ty - sy): ret += 'D'
    for n in range(tx - sx): ret += 'L'

    ret += 'L'
    for n in range(ty - sy + 1): ret += 'U'
    for n in range(tx - sx + 1): ret += 'R'
    ret += 'D'
    ret += 'R'
    for n in range(ty - sy + 1): ret += 'D'
    for n in range(tx - sx + 1): ret += 'L'
    ret += 'U'

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

//typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    rep(i, n) repr(j, i+1, n){
        int k = lower_bound(l.begin(), l.end(), l[i]+l[j]) - l.begin();
        ans += k - j - 1;
    }
    cout << ans << endl;

    return 0;
} 

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int[] num = new int[1000];
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        for(int i = 0;i < 1000;i++)
            num[i] = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++)
            num[i] = scanner.nextInt();
        Arrays.sort(num);
        int sum = 0;
        for(int i = 0;i < k ;i++)
            sum += num[i];
        System.out.println(sum);


    }
}


Measured memory_bytes: 38592
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(auto &i:a) cin>>i;
  int sum=0;
  for(auto i:a)
    sum+=i-1;
  cout<<sum<<endl;
  
  return 0;
}


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

int main(){
  int m,n,t[100],i;
  int u[10],l[10];

  for(;;){
    cin >> m >> n;
    if(!m && !n)break;

    for(i=0;i<n;i++)cin >> t[i];
    for(i=0;i<m;i++){
      u[i] = 0;
      l[i] = 0;
    }

    int time = 0;
    queue<int> q,ans;

    do{
      /*
      cout << time << " " << ans.size() << endl;
      for(i=0;i<m;i++)cout << u[i] << " ";
      cout << endl;
      for(i=0;i<m;i++)cout << l[i] << " ";
      cout << endl;
      */
      //time pending
      for(i=0;i<m;i++){
	if(u[i] && t[u[i]-1])t[u[i]-1]--;
	if(l[i] && t[l[i]-1])t[l[i]-1]--;
      }
      //out
      for(i=0;i<m;i++){
	if(l[i] && !t[l[i]-1]){
	  ans.push(l[i]);
	  l[i] = 0;
	}
	if(!l[i] && u[i])swap(l[i],u[i]);
	if(l[i] && !t[l[i]-1]){
	  ans.push(l[i]);
	  l[i] = 0;
	}
      }
      //in
      if(!(time%10) && time<n*10)q.push(time/10+1);
      while(q.size()){
	int tmp = q.front();
	//cout << tmp << endl;
	for(i=0;i<m;i++)
	  if(!l[i])break;
	if(i<m){
	  l[i] = tmp;
	  q.pop();
	  continue;
	}
	int pos = -1;
	for(i=0;i<m;i++)
	  if(!u[i] && t[l[i]-1]>=t[tmp-1]){
	    if(pos<0)pos = i;
	    else if(t[l[pos]-1]>t[l[i]-1])pos = i;
	  }
	if(pos>=0){
	  u[pos] = l[pos];
	  l[pos] = tmp;
	  q.pop();
	  continue;
	}
	//cout << pos << endl;
	for(i=0;i<m;i++)
	  if(!u[i]){
	    if(pos<0)pos = i;
	    else if(t[l[pos]-1]<t[l[i]-1])pos = i;
	  }
	//cout << pos << endl;
	if(pos>=0){
	  u[pos] = l[pos];
	  l[pos] = tmp;
	  q.pop();
	  continue;
	}
	break;
      }
      time++;
    }while((int)ans.size()<n);

    while(ans.size()){
      cout << ans.front();
      ans.pop();
      if(ans.size())cout << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(),a.end());

  int ans = 1e9;
  for (int i = 0; i + k - 1 < n; i++) {
    ans = min(ans, a[i + k - 1] - a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#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; 
#define ll long long
#define MOD 1000000007
#define ull unsigned long long int
#define db double
#define fi first
#define se second
#define pb push_back
#define vec vector<ll>
#define pr pair<ll,ll>
#define pq priority_queue<ll,vector<ll>, compare_queue >
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define GS(s)   string s; getline(cin,s);
#define lll __int128_t
#define endl "\n"
#define Next cout.flush()

struct compare_queue
{
    bool operator()(const ll& a, const ll& b)
    {
        return a>b;
    }
};

ll gcd(ll u,ll v)
{
	if(v==0)
	return u;
	
	else
	return gcd(v,u%v);
}

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2)%MOD; 
    p = ((p%MOD) * (p%MOD))%MOD; 

    return (y%2 == 0)? p%MOD : ((x%MOD) * (p%MOD))%MOD; 
} 

    // ll power(ll x,ll y){
    //     ll i;
    //     ll ans=1;
    //     for(i=0;i<y;i++){
    //         ans=ans*x;
    //     }
    //     return ans;
    // }


// ll modInverse(int a, int m) 
// { 
//     if(a==1){return 1;}
//     return power(a, m-2, m); 
// } 
  



// // // #define MAX 1000000
// int primes[100009],cnt=0;
// // vector<int> factors[1000009];
// char str[1000009];
// void pre()
// {
//     // calcualting primes
//     int n=100000;
//     for(int i=2; i*i<=n; i++)
//         if(str[i]==0)
//             for(int j=i; j*i<=n; j++)
//                 str[i*j]=1;
//     for(int i=2; i<=n; i++)
//         if(str[i]==0)primes[cnt]=i,cnt++;
// }


// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
// vector<ll> getFactorization(ll x) 
// { 
//     vector<ll> ret; 
//     while (x != 1) 
//     { 
//         ret.push_back(spf[x]); 
//         x = x / spf[x]; 
//     } 
//     return ret; 
// } 

// C:\Users\A\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\lambda


// ll getPow(ll n,ll k){
//     double f=log((double)n);
//     double g=log((double)k);
//     f=f/g;
//     return (ll)f;
// }

vec f;

void fro(){
    vec g(2001,1);
    for(ll i=1;i<=2000;i++){
        g[i]=((g[i-1]%MOD)*(i%MOD))%MOD;
    }    
    f=g;
}

ll po(ll n,ll i){
    if(i==1){return 1;}
    ll hi=f[n-2*i-1]%MOD;
    ll lo=f[i-1]%MOD;
    lo = ((lo%MOD)*(f[n-3*i]%MOD))%MOD;
    lo = power(lo,MOD-2)%MOD;

    hi=((hi%MOD)*(lo%MOD))%MOD;
    return hi;

}




void Function(){
ll n;
cin >> n;
ll ans=0,i;
fro();
for(i=1;3*i<=n;i++){
    ans=((ans%MOD) + (po(n,i)%MOD))%MOD;
}

cout << ans << endl;

}


int main(){ 
fast;
ll t=1,i=0,j=0,k,h;
 //pre();
// cin >> t;
for(h=1;h<=t;h++){

Function();

}


return 0;

}

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

N,Q = [int(x) for x in input().split()]
S = list(input())
lrlist =[]
for _ in range(Q):
    l,r = [int(x) for x in input().split()]
    lrlist.append((l,r))

sumls =[0]*(N+1)
for i in range (N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        sumls[i+1] = sumls[i] + 1
    else:
        sumls[i+1] = sumls[i]

for _ in range (Q):
    l = lrlist[_][0]
    r = lrlist[_][1]
    ans = sumls[r-1]-sumls[l-1]
    print(ans)






Measured memory_bytes: 20488
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int n,m;
    cin>>n>>m;
    priority_queue <int> pq;
    vector<pair<int,int>> p(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        p[i] = mp(a,b);
    }
    all(p);
    int j=0;
    int64_t sum=0;
    for(int i=1;i<=m;i++){
        while(j<n && p[j].first<=i){
            pq.push(p[j].second);
            j++;
        }
        if(!pq.empty()){
            int64_t mo = pq.top();
            pq.pop();
            sum += mo;
        }
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n);
  Cins(int, n, a);

  for (auto& e : a) e--;

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[a[i]] == i) ans++;
  }

  cout << ans / 2 << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

int n,s[100005],tp;

int main(){
    scanf("%d",&n);
    if(!n)s[tp++]=0;
    while(n){
        s[tp++]=n&1;
        n-=(n&1);
        n/=-2;
    }
    while(tp--)printf("%d",s[tp]);
    return 0;
}

Measured memory_bytes: 256
//file_name:ABC62_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int h,w;
    scanf("%d%d",&h,&w);

   

    rep(i,w+2){
        cout << '#';
    }
    cout << endl;
    rep(i,h){
        string s;
        cin >> s;

        cout << '#' << s << '#' << endl;
    }

    rep(i,w+2){
        cout << '#';
    }
    cout << endl;
    




    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {
	string s;
	int i;
	cin >> s;
	if (s[0] == s[1]  || s[1] == s[2] || s[2] == s[3])   cout << "Bad" << endl;
	else cout << "Good" << endl;
	
	return 0;
	
	
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static long MOD = (long)Math.pow(10, 9) + 7;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    String s = sc.next();
    long n = s.length();
    long[] rui26 = new long[1000001];
    long[] rui25 = new long[1000001];
    rui26[0] = 1;
    rui25[0] = 1;
    long[] kai = new long[2000001];
    kai[0] = 1;
    for(long i = 1; i < 2000001; i++) {
      kai[(int)i] = (kai[(int)(i - 1)] * i) % MOD;
    }
    for(int i = 1; i < 1000001; i++) {
      rui26[i] = (rui26[(int)(i - 1)] * (long)26) % MOD;
    }
    for(int i = 1; i < 1000001; i++) {
      rui25[i] = (rui25[(int)(i - 1)] * (long)25) % MOD;
    }
    long ans = 0;
    for(long t = 0; t <= k; t++) {
      long c = (rui26[(int)t] * rui25[(int)(k - t)]) % MOD;
      c = (c * kai[(int)(n + k - t - 1)]) % MOD;
      long d = kai[(int)(n - 1)];
      long e = kai[(int)(k - t)];
      c = (c * func(d, MOD - 2)) % MOD;
      c = (c * func(e, MOD - 2)) % MOD;
      ans = (ans + c) % MOD;
    }
    System.out.println(ans);
  }

  public static long func(long a, long x) {
    if(x == 0) return 1;
    if((x % 2) == 0) {
      long t = func(a, x / 2);
      return (t * t) % MOD;
    } else {
      return (a * func(a, x - 1)) % MOD;
    }
  }
}

Measured memory_bytes: 75032
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;
#define F(i,n) for(int i=0; i<(int)(n); i++)
#define BW(x,a,b) ( a <= x && x < b )
#define SV(v,w) { F(i,v.size()) cout << setw(w) << v[i]; cout << endl;}
int dx[] = {1,-1,0,0}, dy[] = {0,0,-1,1};
int debug_counter = 0;
#define debug_print printf("debug_print: %d\n", ++debug_counter)
 
main(){
  string line;
  char dir, now;
  while( cin >> line && line != "#" ){
    now = 'A';
    F( i, line.size() ){
      dir = line.at(i);
      if( now == 'A' ){
	if( dir == '0' ){ now = 'X'; }
	if( dir == '1' ){ now = 'Y'; }
      } else if( now == 'X' ){
	if( dir == '0' ){ now = 'O'; }
	if( dir == '1' ){ now = 'Z'; }
      } else if( now == 'Y' ){
	if( dir == '0' ){ now = 'X'; }
	if( dir == '1' ){ now = 'O'; }
      } else if( now == 'Z' ){
	if( dir == '0' ){ now = 'W'; }
	if( dir == '1' ){ now = 'B'; }
      } else if( now == 'W' ){
	if( dir == '0' ){ now = 'B'; }
	if( dir == '1' ){ now = 'Y'; }
      } else if( now == 'B' ){
	if( dir == '0' ){ now = 'Y'; }
	if( dir == '1' ){ now = 'X'; }
      } else if( now == 'O' ){
	if( dir == '0' ){ now = 'O'; }
	if( dir == '1' ){ now = 'O'; }
      }
    }
    if( now == 'B' ){ cout << "Yes" << endl; }
    else{ cout << "No" << endl; }
  }
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int ans;
  int x,n;
  cin>>x>>n;
  vector<int> a(110);
  REP(j,n){
    cin>>a.at(j);
  }
  REP(i,120){
    bool flag_s=true;
    bool flag_l=true;
    REP(j,n){
      if(x-i==a.at(j)){
        flag_s=false;
      }
      if(x+i==a.at(j)){
        flag_l=false;
      }
    }
    if (flag_s==true){
      cout<<x-i;
      return 0;
    }
    if (flag_l==true){
      cout<<x+i;
      return 0;
    }
  }
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int MAX = 1000005;
const long long mod = 1e9 + 7;
vector<long long> fact(MAX);
vector<long long> inv(MAX);
vector<long long> finv(MAX);

void init() {
	fact[0] = fact[1] = 1;
	inv[1] = 1;
	finv[0] = finv[1] = 1;

	for (int i = 2; i < MAX; ++i) {
		fact[i] = (fact[i - 1] * i) % mod;
		inv[i] = (mod - (mod / i)*inv[mod%i] % mod) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long nCr(int n, int r) {
	if (r > n) return 0LL;
	else if (n < 0 || r < 0) return 0LL;
	else return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int h, w, a, b; cin >> h >> w >> a >> b;

	long long ans = 0;
	init();
	for (int i = b; i <= (w - 1); ++i) {
		ans = (ans + (nCr(h-a-1+i,i) * nCr(a+w-i-2,a-1) % mod))%mod;
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> B(N-1);
	for(int i(0);i<N-1;++i){
		cin >> B[i];
	}
	ll ans(0);
	for(int i(0);i<N;++i){
		if(i == 0){
			ans += B[0];
		}else if(i == N-1){
			ans += B[N-2];
		}else{
			ans += min(B[i-1],B[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

string s;
int main() {
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3636