akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	long[] first = new long[N];
	long[] second = new long[N];
	long[] third = new long[N];

	for (int i = 0; i < N; i++) {
	    first[i] = -Long.parseLong(scan.next());
	    upHeap(first, i);
	}
	for (int i = 0; i < N; i++) {
	    second[i] = Long.parseLong(scan.next());
	}
	for (int i = 0; i < N; i++) {
	    third[i] = Long.parseLong(scan.next());
	    upHeap(third, i);
	}

	long[] firstScore = new long[N+1];
	for (int i = 0; i < N; i++) firstScore[0] += (-first[i]);
	for (int i = 1; i <= N; i++) {
	    firstScore[i] = firstScore[i-1];
	    long dif = second[i-1] + first[0];
	    if(dif > 0) {
		firstScore[i] += dif;
		first[0] = -second[i-1];
		downHeap(first, 0);
	    }		    
	}

	long[] thirdScore = new long[N+1];
	for (int i = 0; i < N; i++) thirdScore[0] += third[i];
	for (int i = 1; i <= N; i++) {
	    thirdScore[i] = thirdScore[i-1];
	    long dif = third[0] - second[N-i];
	    if(dif > 0) {
		thirdScore[i] -= dif;
		third[0] = second[N-i];
		downHeap(third, 0);
	    }
	}

	long ans = firstScore[0] - thirdScore[N];
	for (int i = 1; i <= N; i++) {
	    long tmp = firstScore[i] - thirdScore[N-i];
	    ans = tmp > ans ? tmp : ans;
	}

	System.out.println(ans);
	scan.close();
    }

    private static void downHeap(long[] heap, int index) {
	int left = 2*index+1;
	int right = left+1;

	if(left < heap.length) {
	    if(right < heap.length) {
		int biggerIndex = (heap[left] > heap[right] ? left : right);
		if(heap[index] < heap[biggerIndex]) {
		    swap(heap, index, biggerIndex);
		    downHeap(heap, biggerIndex);
		}
	    } else {
		if(heap[index] < heap[left]) {
		    swap(heap, index, left);
		    downHeap(heap, left);
		}
	    }
	}
    }

    private static void upHeap(long[] heap, int index) {
	if(index == 0) return;
	
	int parent = (index-1) / 2;
	if(heap[index] > heap[parent]) {
	    swap(heap, index, parent);
	    upHeap(heap, parent);
	}
    }

    private static void swap(long[] heap, int index1, int index2) {
	long tmp = heap[index1];
	heap[index1] = heap[index2];
	heap[index2] = tmp;
    }
}



Measured memory_bytes: 66088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int a, b, c;
  cin >> a >> b >> c;
  Yes_No(a<=c&&c<=b);

}
int main(void) { solve(); }

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  
  int ans = 0;
  rep(i,n) {
    if (h.at(i)>=k) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string s; cin >> s;
    // 常にあいこにすることはできるので，得点０は保証される
    // わざと負けることに意味はない
    // -> パーを出せるならパーを出す。出せないならグー
    int score = 0;
    int pNum = 0, gNum = 0;
    for (int i = 0; i < s.length(); ++i)
    {
        char ch = s[i];
        // グーしか出せないとき
        if (pNum + 1 > gNum)
        {
            score = ch == 'g' ? score : score - 1;
            ++gNum;
        }
        else {
            score = ch == 'g' ? score + 1 : score;
            ++pNum;
        }
    }
    cout << score << endl;
}


Measured memory_bytes: 512
/*===============================================================
*  Filename: E.cpp
*  Author: zhuyutian
*  Date: 2018.04.16
================================================================*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100005;

int n,K;

int main()
{
    //freopen("E.in","r",stdin);
    //freopen("E.out","w",stdout);
    scanf("%d%d",&n,&K);
	ll ans = 0;
	if(K == 0) ans = 1ll * n * n;
	for(int i = K; i <= n && K; i++){
		ans += n - i;
		for(int j = i; j <= n; j += i){
			if(j + i <= n) ans += i - K;
			else if(j + K <= n) ans += n - j - K + 1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N, on, te, ha, th;
  
  scanf("%d", &N);
  th = N / 1000;
  ha = N % 1000 / 100;
  te = N % 100 / 10;
  on = N % 10;
  
  if((th == ha && ha == te) || (ha == te && te == on)){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 100
#define INF 2e+11
int V,E;
long long M[MAX][MAX];
void search(){
    for(int k=0;k<V;k++){
        for(int i=0;i<V;i++){
            if(M[i][k]==INF) continue;
            for(int j=0;j<V;j++){
                if(M[k][j]==INF) continue;
                M[i][j]=min(M[i][j],M[i][k]+M[k][j]);
            }
        }
    }
}
int negative(int x){
    if(M[x][x]<0) return 1;
    else return 0;
}
int main(){
   int s,t,d,count=0;;
   cin>>V>>E;
   for(int i=0;i<V;i++){
       for(int j=0;j<V;j++){
           if(i==j) M[i][j]==0;
           else M[i][j]=INF;
       }
   }
   for(int i=0;i<E;i++){
       cin>>s>>t>>d;
       M[s][t]=d;
   }
   search();
   for(int i=0;i<V;i++){
       negative(i);
       if(negative(i)!=0) count+=1;
   }
   if(count==0){
       for(int i=0;i<V;i++){
           for(int j=0;j<V;j++){
               if(j>0) cout<<" ";
               if(M[i][j]==INF) cout<<"INF";
               else cout<<M[i][j];
           }
           cout<<endl;
       }
   }
   else cout<<"NEGATIVE CYCLE"<<endl;
}


Measured memory_bytes: 3172
import itertools,math,bisect,pprint,sys
#n, m = map(int, raw_input().split())
n = input()
res = 10**5
for i in range(1,int(math.sqrt(n)+1)):
    a = i
    if n%i==0:
        b = n/a
        res = min(res,max(len(str(a)),len(str(b))))
print res

Measured memory_bytes: 5884
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
inline ll read(){
	ll k=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		k=k*10+c-'0';
		c=getchar();
	}
	return k*f;
}
int main(){
	int x=read(),y=read(),a=read(),b=read(),c=read();
	vector<ll>p(a),q(b),r(c);
	forn(i,a)p[i]=read();
	forn(i,b)q[i]=read();
	forn(i,c)r[i]=read();
	
	sort(p.begin(),p.end(),greater<ll>());
	sort(q.begin(),q.end(),greater<ll>());
	sort(r.begin(),r.end(),greater<ll>());
	
	vector<ll>v;
	forn(i,x)v.push_back(p[i]);
	forn(i,y)v.push_back(q[i]);
	forn(i,c)v.push_back(r[i]);
	
	sort(v.begin(),v.end(),greater<ll>());
	ll ans=0;
	forn(i,x+y){
		ans+=v[i];
		} 
	printf("%lld\n",ans);
}

Measured memory_bytes: 8688
#include<iostream>
#include<cmath>
int prime(int a){
	int flag=1;
	int r=std::sqrt(a);
	
	int n=2;
	while(n<=r){
		if(a%n==0){
			flag=0;
			break;
		}
	n++;	
	}
	
	return flag;
	
}

int main(void){
	int n,x;
	int cnt=0;
	
	std::cin>>n;
	
	for(int i=0;i<n;i++){
		std::cin>>x;
		if(prime(x)){
			cnt++;
		}
	}
	
	std::cout<<cnt<<'\n';
	
}


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


int main()
{
  ll n,k;
  cin>>n>>k;
  if(n>=10)
    cout<<k;
  else
  {
      ll ans = k + 100 *(10-n);
      cout<<ans<<endl;
  }

}


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

long long A[2][3];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    for(int i=0; i<3; i++)
        cin >> A[0][i];
    
    for(int ans = 0; ans <= 1000000; ans++)
    {
        for(int i=0; i<3; i++)
            if(A[0][i] % 2)
            {
                cout << ans << "\n";
                return 0;
            }
        
        for(int i=0; i<3; i++)
            A[1][i] = (A[0][(i+1)%3] + A[0][(i+2)%3]) / 2;

        for(int i=0; i<3; i++)
            A[0][i] = A[1][i];
    }

    cout << -1 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;
const int MOD = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  int A[1010], B[1010];
  set<int> AS, BS;
  for (int i = 0; i < N; i++) {
    cin >> A[i]; AS.insert(A[i]);
  }
  if (AS.size() < N) {
    cout << 0 << endl; return 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i]; BS.insert(B[i]);
  }
  if (BS.size() < M) {
    cout << 0 << endl; return 0;
  }
  sort(A,A+N);
  sort(B,B+M);
  ll ans = 1;
  for (int i = N*M; i >= 1; i--) {
    int r = 0;
    while (r < N && A[N-1-r] >= i)
      r++;
    int c = 0;
    while (c < M && B[M-1-c] >= i)
      c++;
    if (A[N-r] == i && B[M-c] == i) {
      ans *= 1;
    }
    else if (A[N-r] == i && B[M-c] != i) {
      ans *= c;
    }
    else if (A[N-r] != i && B[M-c] == i) {
      ans *= r;
    }
    else {
      if (r*c - (N*M-i) <= 0) {
        cout << 0 << endl; return 0;
      }
      ans *= (r*c - (N*M-i));
    }
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
t = [[i for i in range(w)] for j in range(h)]
visited = [[0 for i in range(w)] for j in range(h)] # いったところ
ans = 0
for i in range(h):
  temp = input()
  for j in range(w):
    t[i][j] = temp[j]

d = deque([(Ch, Cw)])
ans = 0
a = [(1,0),(-1,0),(0,1),(0,-1)]

while True:
  # 移動A
  stemp = set()
  while len(d) != 0:
    Th, Tw = d.popleft()
    # s.add((Th, Tw))
    stemp.add((Th, Tw))
    if (Th,Tw) == (Dh, Dw):
      print(ans)
      exit()
    for i, j in a:
      _h,_w = Th + i, Tw + j
      _p = (_h, _w)
      if 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
        d.append(_p)
        visited[_h][_w] = 1
  # 移動B
  ans += 1
  for Th,Tw in stemp:
    for i in range(-2, 3) :
      for j in range(-2, 3) :
        _h,_w = Th + i, Tw + j
        _p = (_h, _w)
        if 0 <= _h < h and 0 <=  _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
          d.append(_p)
          visited[_h][_w] = 1
  if len(d) == 0:
    print('-1')
    exit()


Measured memory_bytes: 171628
N, X = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

s = x.reduce([0]){|s,a|
  s << s[-1] + a
}

s.reverse!

res = (1..N).map{|k|
  cost = (N + k) * X
  cost += 5 * s[0]
  (2 * k).step(N, k){|i|
    cost += 2 * s[i]
  }
  cost
}

p res.min


Measured memory_bytes: 24380
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++) cin >> A[i];
	
	
	vector<int> Idx(N + 1);
	for(int i=0;i<N;i++){
		Idx[A[i]] = i;
	}
	
	ll tot = 0;
	set<int> st;
	
	for(int i=1;i<=N;i++){
		int me = Idx[i];
		auto ri = st.lower_bound(me);
		int r = (ri == st.end() ? N : *ri);
		int l = (ri == st.begin() ? -1 : *(prev(ri)));
		tot += (ll)(r - me) * (ll)(me - l) * i;
//cerr << "r: " << r << " l:" << l << endl;
//cerr << "tot: " << tot << endl;
		st.insert(me);
	}
	
	cout << tot << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	ll a,b;
	cin>>a>>b;

	for(int i=1; i<b+1; i++){
		if((a*i)%b==0){
			cout<<a*i<<endl;
			return 0;
		}
	}
	return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int a,b,c,d;
    cin >> a>> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d&&abs(b-c)<=d)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}
   

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

int main() {
    int n, y;
    vector<tuple<int, int, int>> combination_candidate;
    cin >> n >> y;
    for (int yen10000 = 0; yen10000 < n+1; yen10000++) {
        for (int yen5000 = 0; yen5000 < n - yen10000 + 1; yen5000++) {
            if ((y - yen10000*10000 - yen5000*5000) == (n - yen10000 - yen5000)*1000){
                combination_candidate.push_back(make_tuple(yen10000, yen5000, n-yen10000-yen5000));
            }
        }
    }
    if (combination_candidate.size() > 0) {
        printf("%d %d %d\n", get<0>(combination_candidate.at(0)), get<1>(combination_candidate.at(0)), get<2>(combination_candidate.at(0)));
    }
    else cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let mut s = buf.trim().chars();
    
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("");
    let mut t = buf.trim().chars();
    let mut cnt:u32 = 0;
    
    for i in 0..s.clone().count() {
        if s.next() != t.next() {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 2612
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const S = readToken();
      const L = cast(int)(S.length);
      
      bool ans = (L % 2 == 0);
      foreach (i; 0 .. L) {
        ans = ans && (S[i] == "hi"[i % 2]);
      }
      writeln(ans ? "Yes" : "No");
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	defer stdout.Flush()
	n := readInt()
	X := readInt()
	x := make([]int, n)
	for i := range x {
		x[i] = abs(readInt() - X)
	}

	ans := x[0]
	for i := 1; i < n; i++ {
		ans = gcd(ans, x[i])
	}
	println(ans)
}

// -----------------------------------------------------------------------------


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i, M) cin >> A[i];

    int sum = 0;
    rep(i, M) sum += A[i];
    int ans = max(N - sum, -1);
    cout << ans << endl;
}


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

int main(){
	int n;
	cin >> n;
	int counts = 0;
	for(int i = 1; i<10; i++){
	for(int j = 1; j<10; j++){
		if(n%i == 0 && n/i ==j) counts++;
	}
	}
	if(counts == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
} 

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

int main() {
  int N;
  cin >> N;
  
  int64_t ans = 0;
  for (int j = 0; j < N; j++) {
    if ((j + 1) % 3 == 0) {
      continue;
    }
    
    if ((j + 1) % 5 == 0) {
      continue;
    }
    
    ans += j + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		int x;
		cin>>x;
		if(x>=30)cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3688
#include <stdio.h>

int main(void){
    int n,i;
    scanf("%d",&n);
    int c[200001]={0};
    int A[n+2];
    for(i=2;i<n+1;i++){
        scanf("%d",&A[i]);
        c[A[i]]++;
    }
    for(i=0;i<n;i++)
    printf("%d\n",c[i+1]);
    return 0;
}

Measured memory_bytes: 3268
def solve_L():
    X = input()
    Y = input()
   
    a = len(X)
    b = len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
   
n = int(input())
ans = [[] for i in range(n)]
for i in range(n):
    ans[i] = solve_L()
for i in range(n):
  print(ans[i])


Measured memory_bytes: 5628
#include<stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	
	int n;
	double x[1000], y[1000], z[1000];
	double a = 0, b = 0, c = 0, d = 0;
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		cin >> x[i];
	}
		for(int i = 0; i < n; ++i){
		cin >> y[i];
	}
	
	for(int i = 0; i < n; ++i){
		
		a += fabs(x[i] - y[i]);
		b += (x[i] - y[i]) * (x[i] - y[i]);
		c += fabs( (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]) );
		z[i] = fabs(x[i] - y[i]);
	}
	
	for(int i = 0; i < n-1; ++i){
		if(z[i] > z[i+1]){
			z[i+1] = z[i];
		}
	}
	
	b = sqrt(b);
	c = cbrt(c);
	d = z[n-1];
	
	
	printf("%f\n%f\n%f\n%f\n",a,b,c,d);
	
	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
//#define int long long
using namespace std;

const int MOD = 1e9+7;
int pw(int a,int n){
	if (!a) return 0;
	int y = 1;
	for (;n;n/=2){
		if (n & 1)
		y = 1ll*y*a%MOD;
		a = 1ll*a*a%MOD;
	}
	return y;
}
int r,c,a,b,G[200005],F[200005],D[200005];
int C(int a,int b){
	if (a < b) return 0;
	return (1ll*F[a]*pw(F[b],MOD-2)%MOD)*pw(F[a-b],MOD-2)%MOD;
}
main(){
	F[0] = 1;
	for (int i = 1; i <= 200001; i++)
		F[i] = 1ll*F[i-1]*i%MOD;
	int ans = 0;
	cin >> r >> c >> a >> b;
	a = r - a + 1;
	for (int i = a ; i <= r; i++){
		D[i] = C(b+i-2,i-1);
	//	G[i] = (D[i] - D[i-1])%MOD;
	//G[i] = (1ll*C(b+i-2,i-1) - G[i-1]+ MOD)%MOD;
}
	for (int i = a; i <= r; i++)
	ans = (1ll*ans + 1ll*C(r-i+c-b - 1,r-i)*D[i]%MOD)%MOD;
	cout << (1ll*C(r+c-2,c-1) - ans%MOD + MOD)%MOD;	
}

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

#define ll long long

/*
5
000000
00001
1000
011
11
*/

/*
7
0000000000
000000001
10000000
0000011
110000
00111
1110
101
*/



signed main(){
   int n;
   vector<string > ans;
   cin >> n;
   if (n == 1){
      cout << 1 << endl;
      cout << "0" << endl;
      return 0;
   }
   if (n == 2) { 
      cout << 2 << endl;
      cout << "1" << endl;
      cout << "00" << endl;
      return 0;
   }
   int num0 = n - 2;
   while(num0 >= 0){
      ans.push_back("1" + string(num0, '0') + "1");
      num0 -= 1;
   }

   /*if (n % 3 == 0){
      cout << ans.size() - 1 << endl;
      for(int i = 0; i < ans.size() - 1; i += 1){
         cout << ans[i] << endl;
      }
   }*/
   //else {
   cout << ans.size() << endl;
   for(int i = 0; i < ans.size(); i += 1){
      cout << ans[i] << endl;
   }
   //}
}


Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

const char cup_list[3] = {'A', 'B', 'C'};

int calcIndex(string s);

int main()
{
    int cup[3] = {1, 0 , 0};
    string in_str;
    while(getline(cin, in_str))
    {
        istringstream stream(in_str);
        string field;
        vector<string> in_data;
        while (std::getline(stream, field, ',')) 
        {
            in_data.push_back(field);
        }
        int x = calcIndex(in_data[0]);
        int y = calcIndex(in_data[1]); 
        swap(cup[x], cup[y]);       
    }
    for(int i=0; i<3; i++)
    {
        if(cup[i] > 0)
        {
            cout << cup_list[i] << endl;
        }
    }
    return 0;
}

int calcIndex(string s)
{
    int index; 
    if(s == "A")
    {
        index = 0;
    }
    else if(s == "B")
    {
        index = 1;
    }
    else
    {
        index = 2;
    }
    return index;
}

Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
using namespace std;
 int main(){
   int a[3];for(int i=0;i<3;i++)cin>>a[i];int k;cin>>k;
   for(int i=0;i<k;i++){sort(a,a+3);a[2]*=2;}
   int sum=0;
   for(int i=0;i<3;i++)sum+=a[i];
   cout<<sum<<endl;
 }

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define pb(a) push_back(a);
#define all(a) begin(a),end(a)
#define sz(a) a.size()
#define len(a) a.length()
using namespace std;
vector<vector<int>>dp;
int solve(int i,int j,vector<int>arr1,vector<int>arr2)
{
    if(i<0 || j<0) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    if( abs(arr1[i]-arr2[j]) <= 1 )
    dp[i][j]= 1+solve(i-1,j-1,arr1,arr2);
    else dp[i][j]= max(solve(i,j-1,arr1,arr2),solve(i-1,j,arr1,arr2));
    return dp[i][j];
}
void solveA()
{
    ll a,b,k;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;i++)
    if(i%k==0)
    {
        cout<<"OK";
        return;
    }
    cout<<"NG";
}
int main() {
    solveA();
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,sum = 0,m;
  cin >> n;
  vector<int> a(n),b(n),c(n-1);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  for (int i = 0; i < n-1; i++){
    cin >> c[i];
  }
  for (int i = 0; i < n; i++){
    sum += b[a[i]-1];
    if (i + 1 != 1 && a[i] - 1 == m){
      sum += c[a[i-1]-1];
    }
    m = a[i];
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

double W,H,X,Y;

signed main(){
	cin>>W>>H>>X>>Y;
	double S=(W*H)/2.00000000;
	int flag=0;
	int w=W,h=H,x=X,y=Y;
	if(w%2==0&&h%2==0&&x==w/2&&y==h/2){
		flag=1;
	}
	cout<<fixed<<setprecision(12)<<S;
	cout<<" "<<flag<<endl;
	return 0;
}


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

class Team{
public:
	int x,y,z;
	Team(){ x=y=z=0;}
	Team(int win, int loose, int ID){ x=win, y=loose, z=ID;}
	bool operator>(Team tmp){
		if( this->x > tmp.x ) return true; else if( this->x < tmp.x ) return false;
		// winが等しい
		if( this->y < tmp.y ) return true; else if( this->y > tmp.y ) return false;
		//勝ちも負けも等しい
		return this->z < tmp.z;
	}
};
bool cmp(Team a, Team b){
	return a > b;
}
int main() {
	while(1){
		int n; cin >> n ; if(!n) break;
		char ch[10]; Team a[10];
		for(int j=0;j<n;j++){
			cin >> ch[j] ;
			int win=0,loose=0;
			for(int i=0;i<n-1;i++){
				int tmp; cin >> tmp ;
				if(tmp==0) win++;
				else if(tmp==1) loose++;
			}
			a[j].x=win,a[j].y=loose,a[j].z=j;
		}
		sort(a,a+n,cmp);
		for(int i=0;i<n;i++){
			cout << ch[a[i].z] << '\n' ;
		}
	}
}

Measured memory_bytes: 1124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

void show(int e, int m){
    string s = "";
    rep(i,12){
        s = char('0'+e%2) + s;
        e /= 2;
    }
    cout << s;
    for(int i = 51; i >= 0; i--)cout << ((m >> i)&1);
    cout << endl;
}
signed main(void) {
    int n;
    while(cin >> n,n){
        string s;
        cin >> s;
        int e = 0;
        int m = 1;
        rep(i,52){
            m *= 2;
            m += s[i] == '1';
        }
        int a = m;
        while(n && a){
            int left = (1LL<<53) - m;
            int num = left/a + !(left % a == 0);
            if(n < num){
                num = n;
                m += a*num;
            }else{
                e++;
                m += a*num;
                m = m >> 1;
                a = a >> 1;
            }
            n -= num;
        }
        show(e,m);
    }
}



Measured memory_bytes: 3212
#include<stdio.h>
int main(void){
  long int a,b;
  scanf("%ld %ld",&a,&b);
  long int x = a*b;
  if(a < b) {
    long int tmp = a;
    a = b;
    b = tmp;
  }
  long int r = a%b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  printf("%ld\n",x/b);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
 
int main(){
  int n = 0;
  double *s;
  double ave=0,b= 0;
  cin >> n;
  while(n != 0){
    s = new double[n];
    for(int i = 0; i < n; i++){
      cin >> s[i];
    }
    for(int i = 0; i < n; i++){
      ave += s[i];
    }
     //cout << ave << endl;
    ave /= (double)n;
    //cout << ave << endl;
    for(int i = 0; i < n; i++){
      b += (s[i] - ave)*(s[i] - ave);
    }
    b /= (double)n;
    printf("%.8lf\n",sqrt(b));
    s = NULL;
    ave = 0;
    b = 0;
    cin >> n;
  }
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int M=1e6;
int n,pw[15],lzy[M],ch[M][3],ans[M],to[M];
inline void cao(int x){
	lzy[x]^=1; swap(ch[x][1],ch[x][2]);
}
void dfs(int p,int de,int su,int a){
	if(p>=pw[n-1]){
		//cout<<p-pw[n-1]<<" "<<su<<endl;
		ans[p-pw[n-1]]=su; to[a]=su; return;
	}
	if(lzy[p]){
		For(i,0,2)cao(ch[p][i]);
	}
	For(i,0,2)dfs(ch[p][i],de*3,su+de*i,a*3+i);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,pw[0]=1,n)pw[i]=pw[i-1]*3; 
	For(i,1,n)pw[i]+=pw[i-1];
	For(i,0,pw[n]-1){
		For(j,0,2)ch[i][j]=i*3+j+1;
	}
	string s;
	cin>>s;
	for(auto i:s)if(i=='S'){
		cao(0);
		//cout<<ch[0][0]<<" "<<ch[0][1]<<" "<<ch[0][2]<<endl;
	}else{
		int dq=0;
		For(j,0,n-1){
			if(lzy[dq]){
				lzy[dq]=0;
				For(k,0,2)cao(ch[dq][k]);
			}
			int t=ch[dq][2]; ch[dq][2]=ch[dq][1]; ch[dq][1]=ch[dq][0]; ch[dq][0]=t;
			dq=ch[dq][0]; 
		}
		//cout<<ch[0][0]<<" "<<ch[0][1]<<" "<<ch[0][2]<<endl;
	}
	dfs(0,1,0,0);
	For(i,0,pw[n]-pw[n-1]-1)wri(ans[to[i]]);
}


Measured memory_bytes: 20964
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1e9+7;

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

int main(void){
    int n, len;
    string s;
    vector< vector<long long> > dp;
    cin >> n >> s;
    len = s.length();
    dp.assign(2, vector<long long>());
    for(int i=0;i<2;i++){
        dp[i].assign(n+2, 0);
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        int a = i%2, b = (i+1)%2;
        dp[a][0] = dp[b][0] + dp[b][1];
        for(int j=1;j<=i;j++){
            dp[a][j] = dp[b][j-1] * 2 + dp[b][j+1];
            dp[a][j] %= mod;
        }
    }
    cout << (dp[n%2][len] * mod_pow(mod_pow(2, len), mod-2)) % mod << endl;

}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		String ans[] = { "Yes", "No"};
		int a = 0;
		char s2[] = s.toCharArray();
		Arrays.sort(s2);
		String tmp = "abc";
		for(int i = 0; i < s.length(); ++i) {
			if(tmp.charAt(i) != s2[i])a = 1;
		}
		System.out.println(ans[a]);
	}

}


Measured memory_bytes: 22612
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int n, k, s; cin >> n >> k >> s;
    rep(i, k) {
        cout << s << " ";
    }
    if(s != 1e9 && s != 1) {
        int cnt = n - k;
        while(cnt > 0) {
            cout << s - 1 << " ";
            cnt --;
            if(cnt == 0) break;
            cout << (1000000000 - s + 1) << " ";
            cnt --;
        }
        cout << endl;
    } else if(s == 1) {
        rep(i, n - k) {
            cout << 100 << " ";
        }
        cout << endl;
    } else {
        rep(i, n - k) {
            cout << 1 << " ";
        }
        cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int x[3];
	x[0] = a; x[1] = b; x[2] = c;
	sort(x, x + 3);
	int sum = 0;
	sum += x[2]-x[1];
	x[0] += x[2] - x[1];
	if ((x[2] - x[0]) % 2 == 1) {
		x[2]++; sum++;
	}
	sum += (x[2] - x[0]) / 2;
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <queue>
#include <cmath>
#include <set>



using namespace std;
typedef long long ll;

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

pair<ll, ll> minuss(pair<ll, ll> a,pair<ll, ll> b)
{
    ll up=a.first*b.second-a.second*b.first;
    if(up<0)
        return {-1,-1};
    ll dwon=a.second*b.second;
    ll gc=gcd(up,dwon);
    up/=gc;
    dwon/=gc;
    return {up,dwon};
}

int main () {
    ios_base::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<pair<int, int>> a(n);
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    
    auto m=max_element(a.begin(), a.end());
    ll ans=(*m).first+(*m).second;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=1e4+5;
string s[N];
int n,ans,a,b,ba,last;
void tj(string t)
{
	int l=0,r=t.size()-1;
	if(t[l]=='B'&&t[r]=='A')ba++;
	if(t[r]=='A')a++;
	if(t[l]=='B')b++;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		for(int j=0;j<s[i].size()-1;j++)
			if(s[i][j]=='A'&&s[i][j+1]=='B')
				ans++;
		tj(s[i]);
	}
	ans+=min(a,b);
	if(a==ba&&b==ba&&ba)ans--;
	cout<<ans<<endl;
	return 0;
}

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

using i64 = int64_t;

int main(){
    string o, e;
    cin >> o >> e;
    for(int i=0;i<o.size();++i){
        cout << o[i];
        if(i<e.size())cout << e[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;

int main(){
  ll N; cin >> N;
  vector<ll> alp(26, 0LL);
  for(int i = 0; i < N; i++){
    char c; cin >> c;
    ll ind = (ll)(c - 'a');
    alp[ind]++;
  }
  
  ll ans = 1LL;
  for(int i = 0; i < 26; i++){
    ans *= alp[i] + 1;
    ans %= MOD;
  }
  cout << ans - 1LL;
}

Measured memory_bytes: 256
#line 1 "0423.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0423"

#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Mon Apr 27 01:47:13 JST 2020
 **/

#define CALL_FROM_TEST
#line 1 "/Users/knshnb/competitive_programming/competitive_library/src/Graph/Dijkstra.hpp"
template <class T, bool directed = true> struct Dijkstra {
    struct Edge {
        int to;
        T cost;
    };
    std::vector<std::vector<Edge>> g;
    Dijkstra(int n) : g(n) {}
    void add_edge(int u, int v, T cost) {
        g[u].push_back({v, cost});
        if (!directed) g[v].push_back({u, cost});
    }
    std::vector<T> run(int s) {
        std::vector<T> dist(g.size(), std::numeric_limits<T>::max() / 2);
        // {d, v}
        std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>, std::greater<std::pair<T, int>>> q;
        q.push({0, s});
        while (!q.empty()) {
            std::pair<T, int> p = q.top();
            q.pop();
            int v = p.second;
            if (dist[v] <= p.first) continue;
            dist[v] = p.first;
            for (const Edge& e : g[v]) {
                if (dist[e.to] <= p.first + e.cost) continue;  // 定数倍枝刈り
                q.emplace(p.first + e.cost, e.to);
            }
        }
        return dist;
    }
};
#line 19 "0423.test.cpp"
#undef CALL_FROM_TEST

signed main() {
    Int n, R;
    std::cin >> n >> R;
    Dijkstra<Int> dj(n + 1);
    std::vector<Int> e(n);
    REP(i, n) {
        Int t;
        std::cin >> t >> e[i];
        dj.add_edge(n, i, t);
    }
    REP(_, R) {
        Int a, b, c;
        std::cin >> a >> b >> c;
        a--, b--;
        dj.add_edge(b, a, c - 1);
    }
    auto dist = dj.run(n);
    Int ans = 0;
    REP(i, n) ans += dist[i] * e[i];
    std::cout << ans << std::endl;
}



Measured memory_bytes: 14628
package main

import (
	"fmt"
	"math"
)

func main() {
	var n,l int
	var nums []int
	var mini =-1
	var minv = 1000.0
	fmt.Scan(&n,&l)
	for i:=	0;i<n;i++{
		nums = append(nums,l+i)
		abs := math.Abs(float64(l+i))
		if minv > abs{
			mini = i
			minv = abs
		}
	}
	sum := 0
	for i:=	0;i<n;i++{
		if mini == i{
			continue
		}
		sum += nums[i]
	}
	fmt.Print(sum)
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

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

        char s[n];
        for(i=0; i<n; i++)
                cin >> s[i];

        int p=0,w=0,g=0,y=0;
        for(i=0; i<n; i++){
                if(s[i] == 'P')
                        p=1;
                if(s[i] == 'W')
                        w=1;
                if(s[i] == 'G')
                        g=1;
                if(s[i] == 'Y')
                        y=1;
        }

        if(p+w+g+y == 4)
                cout << "Four" << endl;
        else if(p+w+g+y == 3)
                cout << "Three" << endl;

        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    Int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    int t = 0;
    for (int i = 0; i < N - 1; i++) {
        if (A[i + 1] <= A[i]) {
            t++;
        }
    }
    cout << 1 + t << '\n' << N << endl;
    return 0;
}



Measured memory_bytes: 3124
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int N;
 cin>>N;

 for(int i=0; i<=N/4; i++)
  for(int j=0; j<=N/7; j++){
   if(4*i+7*j==N){
    std::cout<<"Yes"<<std::endl;
	return 0;
   }
  }
 std::cout<<"No"<<std::endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define INF 1e+9
#define MAX_N 101

using namespace std;
int main(void){
	int n;cin>>n;
	int g[MAX_N][MAX_N];
	for(int i=0;i<MAX_N;++i)for(int j=0;j<MAX_N;++j) g[i][j]=INF;
	for(int i=0,r,k;i<n;++i){
		cin>>r>>k;
		for(int j=0,t;j<k;++j){
			cin>>t;
			g[r][t]=1;
		}
	}
	int d[MAX_N][MAX_N];
	for(int i=0;i<MAX_N;++i)for(int j=0;j<MAX_N;++j)d[i][j]=(i==j)?1:INF;
	for(int i=1;i<=n;++i){
		bool f=false;
		for(;;){
			for(int j=1;j<=n;++j){//from
				for(int k=1;k<=n;++k){//to
					if(d[i][j]!=INF && d[i][j] + g[j][k] < d[i][k]){
						d[i][k] = d[i][j] + g[j][k];
						f=true;
					}
				}
			}
			if(f==false) break;
			f=false;
		}
	}
	int p;cin>>p;
	for(int i=0,from,to,v;i<p;++i){
		cin>>from>>to>>v;
		if(d[from][to]>v) cout<<"NA"<<endl;
		else cout<<d[from][to]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1240
n,m = [int(x) for x in input().split(' ')]

items = [int(a) for a in input().split(' ')]

selected = 0

for i in range(n):
    if items[i] >= ((1/(4*m)) * sum(items)):
        selected += 1

if selected >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int K; cin>>K;
    string S; cin>> S;
    if(S.size() <= K){
        cout << S << endl;
    }
    else{
        string sub = S.substr(0,K);
        REP(i,3){
            sub.push_back('.');
        }
        cout << sub << endl;
    }
    //endl;
}

Measured memory_bytes: 3640
def count_patties(L, x):
    if L == 0:
        return 0 if x <= 0 else 1
    if x <= total_layers[L - 1] + 1:
        return count_patties(L - 1, x - 1)
    else:
        return (
            count_patties(L - 1, x - total_layers[L - 1] - 2) + 1 + total_patties[L - 1]
        )


N, X = map(int, input().split())
total_layers = [2 ** (i + 2) - 3 for i in range(51)]
total_patties = [2 ** (i + 1) - 1 for i in range(51)]
print(count_patties(N, X))


Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 20000001;
bool pr[N+10];
set<int>prs;

int main(){
    int x;
    scanf("%d", &x);
    int an = x; 
    for(int i = x; i <= N; ++i){
        if(i & 1 ^ 1)continue;
        bool f = false;
        for(auto j = 3; j <= sqrt(i); ++j){
           if(i % j == 0){f = true;break;}
        }
        if(!f){an = i;break;}
    }
    printf("%d\n", x == 2? 2: an);
} 

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

using namespace std;

int main() {
    string in;
    cin >> in;
    int pa = 0;
    int score = 0;
    for (int i=0; i<in.length(); i++) {
        if (!pa) {
            if (in[i] == 'p') score--;
            pa++;
        } else {
            if (in[i] == 'g') score++;
            pa--;
        }
    }
    cout << score << endl;
    return 0;
}


Measured memory_bytes: 512