akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int n,l,i=0;
  scanf("%d %d",&n,&l);
  char s[n][l+1];
  for(i=0;i<n;i++) scanf("%s",s[i]);
  qsort(s,n,sizeof(s[0]),strcmp); 
  for(i=0;i<n;i++) printf("%s",s[i]);
}

Measured memory_bytes: 252
N=int(input())
T,A = list(map(int,input().split()))
H = list(map(int,input().split()))

min_dis = 10**9
ans = -1
for i in range(N):
    d = abs(A-(T-H[i]*0.006))
    if min_dis>d:
        ans=i+1
        min_dis = d

print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

tmp = True

N = int(input())
w = [input() for i in range(N)]
if len(set(w)) != N:
    tmp = False
for i in range(N-1):
    if w[i][-1] != w[i+1][0]:
        tmp = False
print('Yes'if tmp else 'No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    ll n,k;cin>>n>>k;
    ll sum = 0;
    for(ll i=k;i<=n+1;i++){
        ll dif = i*(2*n-i+1)/2-i*(i-1)/2+1;
        sum += dif%(ll)(1e9+7);
    }
    co(sum%(ll)(1e9+7));
}


Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    class P
    {
        public int index;
        public List<int> adj;
        public Dictionary<int, long> weights;
        public P(int index)
        {
            this.index = index;
            adj = new List<int>();
            weights = new Dictionary<int, long>();
        }
    }
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var ps = Enumerable.Range(0, nm[0]).Select(v => new P(v)).ToArray();
        var dist = new long[nm[0], nm[0]];
        for (var i = 0; i < nm[1]; i++)
        {
            var inp = Input.ar;
            for (var j = 0; j < 2; j++)
            {
                dist[inp[j] - 1, inp[1 - j] - 1] = inp[2];
                ps[inp[j] - 1].adj.Add(inp[1 - j] - 1);
                ps[inp[j] - 1].weights[inp[1 - j] - 1] = inp[2];
            }
        }
        for (var i = 0; i < nm[0]; i++)
            for (var j = 0; j < nm[0]; j++)
                if (i != j && dist[i, j] == 0)
                    dist[i,j] = int.MaxValue;
        for (var k = 0; k < nm[0]; k++)
            for (var i = 0; i < nm[0]; i++)
                for (var j = 0; j < nm[0]; j++)
                    dist[i, j] = Min(dist[i, j], dist[i, k] + dist[k, j]);
        var eg = Enumerable.Repeat(0, nm[0]).Select(v => new bool[nm[0]]).ToArray();
        dfs(ps, dist, new bool[nm[0]], eg, 0);
        WriteLine(eg.Sum(ar => ar.Count(b => b)));
       
    }
    private static void dfs(P[] ps,long[,] dist,bool[] bo,bool[][] edge,int index)
    {
        bo[index] = true;
        foreach (var ad in ps[index].adj)
        {
            if (!bo[ad])
                dfs(ps, dist, bo,edge,ad);
            var min = Min(ad, index);
            var max = Max(ad, index);
            if (!edge[min][max] && dist[index, ad] != ps[index].weights[ad])
                edge[min][max] = true;
        }
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13580
import java.util.*;

public class Main{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int P;
        int cnt1 = 0;
        int cnt2 = 0;
        int cnt3 = 0;

        for(int i=0;i<N;i++){
            P = sc.nextInt();
            if(P <= A) cnt1++;
            else if(A+1 <= P && P <= B) cnt2++;
            else if(B+1 <= P) cnt3++;
        }

        System.out.println(Math.min(cnt1, Math.min(cnt2,cnt3)));
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> a(100001,0);
vector<int> dp(100001,-1);
int mod = 1e9 + 7;
int topDown(int n, int i){
    if(dp[i]!=-1)
        return dp[i];
    if(a[i])
        return 0;
    if(i==n)
        return 1;
    
    int ways = 0;
    if(i<n)
        ways += topDown(n,i+1)%mod;
    if(i < n-1)
        ways += topDown(n,i+2)%mod;

    return dp[i]=ways%mod;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n>>m;
    for(i=0;i<m;i++){
        int x;
        cin>>x;
        a[x]=1;
    }
    cout<<topDown(n,0)<<'\n';

    
    
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAXN = 3000100;

int r1, r2, c1, c2;
ll fac[MAXN], ifac[MAXN];

ll cpow (ll b, int e)
{
    if (e == 0) return 1;
    if (e == 1) return b % MOD;
    ll v = cpow (b, e / 2);
    v = (v * v) % MOD;
    if (e & 1) v = (v * b) % MOD;
    return v;
}

ll inv (ll x)
{
    return cpow (x, MOD - 2);
}

ll gogo (int x, int y)
{
    ll v = (fac[x+y] * ifac[x] % MOD) * ifac[y] % MOD;
    return v - 1;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> r1 >> c1 >> r2 >> c2;

    fac[0] = 1;
    for (int i = 1; i < MAXN; i++)
        fac[i] = (fac[i-1] * i) % MOD;
    ifac[MAXN-1] = inv (fac[MAXN-1]);
    for (int i = MAXN - 1; i > 0; i--)
        ifac[i-1] = (ifac[i] * i) % MOD;

    r2++;
    c2++;
    ll res = gogo (r2, c2) + gogo (r1, c1) - gogo (r1, c2) - gogo (r2, c1);
    res = (res % MOD + MOD) % MOD;
    cout << res << "\n";
}

Measured memory_bytes: 47104
A,B,K = (int(T) for T in input().split())
for TK in range(0,K):
    if TK%2==0:
        A -= [0,1][A%2]
        Give = A//2
        A,B  = A-Give,B+Give
    else:
        B -= [0,1][B%2]
        Give = B//2
        A,B  = A+Give,B-Give 
print('{} {}'.format(A,B))

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

int main() {
    ll N;
    cin >> N;
    vll a(N);
    rep(i, N) cin >> a[i];
    reverse(a.begin(), a.end());
    vll dp(N+1);
    rep(i, N+1) dp[i] = INF;

    rep(i, N) *upper_bound(dp.begin(), dp.end(), a[i]) = a[i];

    rep(i, N+1) debug(dp[i]);

    ll ans = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int d = sc.nextInt();
        int t = sc.nextInt();
        int s = sc.nextInt();

        System.out.println(d - t * s <= 0 ? "Yes" : "No");

        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 35776
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n;

	static boolean ok(boolean[][] dp,int d) {
		boolean[] p = new boolean[n+1];
		for(int i=1;i<=n;i++) {
			if(dp[d][i]) p[i] = true;
		}
		for(int i=d-1;i>=1;i--) {
			boolean ok = false;
			for(int j=1;j<=n;j++) {
				if(dp[i][j] && p[j]) ok = true;
			}
			if(ok) {
				for(int j=1;j<=n;j++) {
					if(dp[i][j]) p[j] = true;
				}
			}
		}
//		for(int i=1;i<=n;i++) {
//			System.out.print(p[i] + " ");
//		}
		for(int i=1;i<=n;i++) {
			if(!p[i]) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		while(true) {
			n = sc.nextInt();
			if(n==0) break;
			boolean[][] dp = new boolean[31][n+1];
			for(int i=1;i<=n;i++) {
				int a = sc.nextInt();
				for(int j=0;j<a;j++) {
					int d = sc.nextInt();
					dp[d][i] = true;
				}
			}
			int ans = -1;
			for(int i=1;i<=30;i++) {
				if(ok(dp,i)) {
					ans = i;
					break;
				}
			}
			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 99212
fun main(args: Array<String>) {
    val nNum = readLine()!!.toInt()
    val numLine = readLine()!!
    val numbers = numLine.split(" ").map { s -> s.toInt() }.toIntArray()

    printNumbers(numbers)
    for (i in 1..nNum-1) {
        val value = numbers[i]
        var j = i-1
        while (j >= 0 && numbers[j] > value) {
            numbers[j+1] = numbers[j]
            j--
        }
        numbers[j+1] = value

        printNumbers(numbers)
    }
}

private fun printNumbers(numbers: IntArray) {
    for (i in 0..numbers.size-1) {
        print(numbers[i])
        if (i != numbers.size-1) {
            print(" ")
        }
    }
    println()
}


Measured memory_bytes: 37256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  string s,t;
  cin >> s >> t;
  
  int ans=0;
  
  rep(i,3){
    if(s.at(i)==t.at(i))ans+=1;
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string S;
  cin >> S;

  ll l = 0;
  rep(i, S.size()) {
    if (S[i] == 'A') {
      l = i;
      break;
    }
  }
  ll r = 0;
  repr(i, S.size() - 1) {
    if (S[i] == 'Z') {
      r = i;
      break;
    }
  }

  ll ans = r - l + 1;
  ANS;

  return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

const string YES = "YES";
const string NO = "NO";
#define judge(f) cout<<(f?YES:NO)<<"\n";

void solve(long long N, std::vector<long long> A){
    set<int> s(A.begin(),A.end());
    judge(s.size()==N);
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
import  fractions
N = int(input())
A = list(map(int,input().split()))
mod =10**9+7
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
inv_t = [0]+[1]
for i in range(2,10**6+5):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
  
k=1
ans=0
for a in A:
  k=lcm(k,a)
  ans+=inv_t[a]%mod
k%=mod

print(ans*k%mod)

Measured memory_bytes: 98120
n , c , k = map(int,input().split()) # n人数、cバスに乗れる数、k怒り出す時間
t = [int(input()) for _ in range(n)]

#n,c,k = 6,3,3
#t = [7,6,2,8,10,6]

t = sorted(t)

jyokyaku = 0
bus = 0
for i in t:

  if jyokyaku == 0: #バス最初の乗客
    bus += 1
    angrytime = i + k
    jyokyaku += 1
    if jyokyaku == c: #定員になりバス出発
      jyokyaku = 0

  else: 
    if i <= angrytime: #最初の乗客がキレる前だったら乗れる
      jyokyaku += 1
      if jyokyaku == c: #定員になりバス出発
        jyokyaku = 0

    else: #もうバス出発してたので最初の乗客になった
      bus += 1
      jyokyaku = 1
      angrytime = i + k

print(bus)




Measured memory_bytes: 8276
n, m = map(int, input().split())
a = list(map(int, input().split()))
sum = 0
for x in a:
    sum += x
cnt = 0
for x in a:
    if(x * 4 * m >= sum):
        cnt += 1
        
if cnt >= m:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
fn main() {
    let n: usize = readln();
    let s: Vec<char> = readln();
    let mut cur = 0;
    for &c in &s[0..] {
        if c == 'E' {
            cur += 1;
        }
    }
    let mut answer = cur;
    for i in 0..n {
        if s[i] == 'E' {
            cur -= 1;
        } else {
            cur += 1;
        }
        answer = min(answer, cur);
    }
    println!("{}", answer);
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    	
    ll n{0};
    cin>>n;

    ll cnt{0};
	for(ll i=1;i<n;i++){
		cnt=cnt+(n-1)/i;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

in ketasum(in n) {
    in res = 0;
    while(n > 0) {
        res += 1;//res ++にすると桁数
        n /= 2;//10を変えるとn進数(上のも)
    }
    return res;
}

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

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,k;
    cin>>n>>k;
    vector<bitset<48>> a(n);
    bitset<48> kk(k);
    in x;
        rep(i,n){
            cin>>x;
            a[i]=bitset<48>(x);
        }
    vector<in> cnt(48,0);
    rep(i,48)rep(j,n){
        if(a[j].test(i)) cnt[i] ++;
    }
    reverse(all(cnt));

    vector<vector<vector<in>>> dp(48,vector<vector<in>>(2,vector<in>(2,-1)));
    dp[0][0][0]=0;
    rep(i,47)rep(j,2)rep(h,2){
        if(dp[i][j][h]==-1) continue;
        chmax(dp[i+1][0][h||(kk.test(48-i-2))],dp[i][j][h]*2+cnt[i+1]);
        if(h==1) chmax(dp[i+1][1][1],dp[i][j][h]*2+n-cnt[i+1]);
        else if(kk.test(46-i)) chmax(dp[i+1][1][0],dp[i][j][h]*2+n-cnt[i+1]);
    }
    in ans=0;
    rep(i,2)rep(j,2){
        chmax(ans,dp[47][i][j]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }

vector<int> buf;
vector<int> res[1000000];
int re=0;

void dfs(int i, const int size, const int range_start, const int range_end)
{
    if (i == size) {
        for(int i = 0; i < buf.size(); ++i){
            res[re].push_back(buf[i]);
        }
        re++;
    }
    else{
        if(i==0){
        for(int j = range_start; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end);
        }
        }
        else{
            for(int j = buf[i-1]; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end);
        }
        }
    }
}

int main(void)
{
    int N,M,Q; cin>>N>>M>>Q;
    int a[Q],b[Q],c[Q],d[Q];
    rep(i,0,Q) cin>>a[i]>>b[i]>>c[i]>>d[i];

    int size = N;
    int range_start = 1;
    int range_end = M;
    buf.resize(size);
    dfs(0, size, range_start, range_end);


    ll ans=0;
    int re2=0;
  do{
      ll sum=0;
      rep(i,0,Q){
          if(res[re2][b[i]-1]-res[re2][a[i]-1]==c[i]) sum+=d[i];
      }
      ans=max(ans,sum);
      re2++;
  }
  while(re2<re);

  cout<<ans<<endl;

    
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
double distance(int a,int b,int c,int d){ return sqrt((a-c)*(a-c)+(b-d)*(b-d)); }
int main() {
  string a,b;
  cin >> a >> b;
  a += b;
  int c;
  c = stoi(a);
  rep(i, 1000000) {
    if (i * i == c) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int t[] = new int[10];
        t[0] = scan.nextInt();
        t[1] = scan.nextInt();
        t[2] = scan.nextInt();
        t[3] = scan.nextInt();
        t[4] = scan.nextInt();
        t[5] = scan.nextInt();
        t[6] = scan.nextInt();
        t[7] = scan.nextInt();
        t[8] = scan.nextInt();
        t[9] = scan.nextInt();

        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9 - i; j++) {
                if (t[j] < t[j + 1]) {
                    int temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;
                }

            }

        }
        for (int i = 0; i < 3; i++) {
            System.out.println(t[i]);

        }

    }
}



Measured memory_bytes: 26056
n = int(input())
s_list = []
for i in range(n):
	s_list.append(int(input()))
r = 0
total = sum(s_list)
if total % 10 != 0:
	r = total
else:
	s_list.sort()
	for s in s_list:
		if s % 10 != 0:
			r = total - s
			break
print(r)

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

#define fi first
#define se second

const int N = 100100;
const long long mod = 1e9 + 9;

using namespace std;

int n;
int a[N];
int d[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        int k;
        cin >> k;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                if(i == 1){
                        continue;
                }
                d[i] = 1e9;
                for(int j = 1; j <= k; j++){
                        if(i == j){
                                break;
                        }
                        d[i] = min(d[i], d[i - j] + abs(a[i] - a[i - j]));
                }
        }
        cout << d[n] << "\n";
}



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

int main() {
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int> (3));
  for (int i = 0; i < n; i ++) {
    for (int j = 0; j < 3; j ++) {
      cin >> a[i][j];
    }
  }

  vector<vector<int>> dp(n, vector<int> (3));
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][1];
  dp[0][2] = a[0][2];
  for (int i = 1; i < n; i ++) {
    for (int j = 0; j < 3; j ++) {
      for (int k = 0; k < 3; k ++) {
        if (j == k) continue;
        dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i][k]);
      }
    }
  }

  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
typedef long long ll;


int main()
{
	ll n,sum=0;
	cin >> n;
	vector<ll>a(n), b(n);
	vector<pair<ll, ll>>p(n);
	rep(i, n)cin >> a[i] >> b[i];
	rep(i, n) p[i] = make_pair(b[i],a[i]);
	sort(p.begin(), p.end());
	for (ll i = 0; i < n; i++) {
		sum += p[i].second;
		if (sum > p[i].first)return cout << "No" << endl, 0;
	}
	cout << "Yes" << endl;
}



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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

//const int INF = 1e9 + 10;
const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

ll n;

vector<ll> divisor(ll n) {
	vector<ll> res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

void solve() {
	vector<ll> a = divisor(n);
	sort(a.begin(), a.end());

	ll ans = INF;
	int sz = a.size();

	for (int i = 0; i <= sz / 2; i++) {
		ans = min(ans, (a[i] - 1) + (a[(sz - 1) - i] - 1));
	}

	printf("%lld\n", ans);
}

int main(void){
	cin>>n;

	solve();
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int bit(int a,int b,int c){
    if(!a & !b){
        return 0;
    }
    if(c & 1){
        return (bit(a>>1,b>>1,c>>1));
    }
    if(b & 1){
        return (bit(c>>1,b>>1,a>>1)+bit((a|b|c)>>1,0,0)+1);
    }
    if(a & 1){
        return (bit(a>>1,b>>1,c>>1)+2*bit((a|b|c)>>1,0,0)+2);
    }
}
int main(void){
    int n,m,data[3];
    while(1){
        cin>>n>>m;
        if(n==0 && m==0){
            return 0;
        }
        for(int i=0;i<3;i++){
            int k;
            cin>>k;
            data[i]^=data[i];
            for(int j=0;j<k;j++){
                int num;
                cin>>num;
                data[i]|=1 << --num;
            }
        }
        int ans=min(bit(data[0],data[1],data[2]),bit(data[2],data[1],data[0]));
        if(ans<=m){
            cout<<ans<<endl;
        }else{
            cout<<-1<<endl;
        }
    }
}


Measured memory_bytes: 3060
n, *ary = $stdin.read.split.map(&:to_i)
M = 10**9 + 7

lcm = 1
sum = 0
ary.each do |a|
  gcd = lcm.gcd(a)
  x, y = a / gcd, lcm / gcd
  sum = (sum * x + y) % M
  lcm *= x
end

puts sum


Measured memory_bytes: 54936
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n; cin>>n; 
   int a[n]; for(int i=0;i<n;i++) cin>>a[i]; 
   int l=0; 
   int b[n]; 
   int tot=0; 
   for(int i=0;i<n;i++){
           if(i<n-1) { b[i]=abs(l-a[i+1])-abs(l-a[i])-abs(a[i]-a[i+1]); }
           else { b[i]=abs(l)-abs(l-a[i])-abs(a[i]); }
           tot+=abs(l-a[i]); 
           l=a[i]; 
   }
   tot+=abs(a[n-1]); 
   for(int i=0;i<n;i++) cout<<tot+b[i]<<endl; 

           
   return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
	int N;
	cin>>N;
	map<int,int>m;
	rep(i,N){
		int a;cin>>a;m[a]++;
	}	
	
	if(N%3){
		if(m[0]==N){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	else{
		bool ok=true;
		int x=0;
		N/=3;
		for(auto p:m){
			if(p.se%N)ok=false;
			rep(i,p.se/N)x^=p.fi;
		}
		if(x)ok=false;

		if(ok)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 5120
// 2015/07/21 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int h[101];
		for(int i=0; i<n+1; i++){
			cin >> h[i];
		}

		for(int i=0; i<n+1; i++){
			int tmp[100];
			for(int j=0; j<i; j++){		// h[i]を除いてコピー
				tmp[j] = h[j];
			}
			for(int j=i+1; j<n+1; j++){
				tmp[j-1] = h[j];
			}

			bool flg = true;

			int d = tmp[1]-tmp[0];		// 差
			for(int j=1; j<n-1; j++){
				if(tmp[j+1]-tmp[j]!=d){
					flg = false;
					break;
				}
			}

			if(flg){
				cout << h[i] << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<set>
#include<stdio.h>
#include<stdlib.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; }

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=1e9+7;
#define ll long long

int main(){
  cin.tie(0); ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  int ans=0,temp=1;
  while(temp<b){
    temp+=(a-1);
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
c = 1
loop do
  w = gets.to_i
  break if w == 0
  n = gets.to_i
  table = Array.new
  n.times do
    table << gets.split(',').map(&:to_i)
  end

  mw, mv = w, 0
  dp = Array.new(n+1).map{Array.new}
  dp[0][0] = 0
  table.each.with_index(1) do |p, i|
    (0..w).each do |wi|
      unless dp[i-1][wi].nil?
        [wi, wi + p[1]].each_with_index do |tw, z|
          if tw <= w
            t = dp[i][tw] = [dp[i][tw]||0, dp[i-1][wi] + (z == 1 ? p[0] : 0)].max
            mw, mv = tw, t if ( t > mv || ( t == mv && tw < mw ) )
          end
        end
      end
    end
  end

  puts "Case #{c}:"
  puts mv
  puts mw

  c += 1
end

Measured memory_bytes: 15632
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 10000000000
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

long long int n;
long long int a,b;
long long int m=INF,k;
int main(){
  scanf("%lld",&n);
  REP(i,n){
    scanf("%lld %lld",&a,&b);
    if(m>b){
      m=b;
      k=a;
    }
  }
  printf("%lld\n", m+k);
  return 0;
}


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

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

  int cnt4 = 0;
  int cnt2 = 0;
  int cnt1 = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;

    if (a % 4 == 0) {
      cnt4++;
    } else if (a % 2 == 0) {
      cnt2++;
    } else {
      cnt1++;
    }
  }

  cout << (cnt4 >= cnt1 - (cnt2 == 0) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
int sosu(int i) {
    int k;
 
    if(i==1)
        return 0;
    if(i==2||i==3)
        return 1; 
    for(k=2;k<=sqrt(i);k++)
        if(i%k==0) return 0;
    return 1;
}
 
int main() {
 
    int a,d,n;
    int i,j;
 
    while(1){
        scanf("%d %d %d",&a,&d,&n);
        if(!a&&!d&&!n) break;
        j=0,i=a;
        while(j<n) {
            if(sosu(i)) {
                j++;
            }
            i+=d;
        }
        printf("%d\n",i-d);
    }
 
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



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

    ll num[41][2]={};
    ll x=1;
    for(ll i=0; i<=40; i++){
        for(int k=0; k<N; k++){
            
            if(A[k]%2==0){
                num[i][1] += x;
            }else{
                num[i][0] += x;
            }
            A[k]/=2;
        }
        
        x*=2;
    }
    
    ll keta_K[41]={};
    ll saijoi=-1;
    for(int i=0; i<41; i++){
        keta_K[i]+=K%2;
        if(keta_K[i]==1){
            saijoi=i;
        }
        K/=2;
    }


    int flag=1;
    for(int i=saijoi; i>=0; i--){
        if(flag==1){
            if(keta_K[i]==0){
                ans+=num[i][0];
            }else{
                if(num[i][1]>num[i][0]){
                    ans+=num[i][1];
                }else{
                    ans+=num[i][0];
                    flag=0;
                }

            }
        }else{
            ans+=max(num[i][0],num[i][1]);
        }
    }

    for(int i=saijoi+1; i<41; i++){
        ans+=num[i][0];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int m = 1;
  int arr[n] = {0};
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int q=1;q<=d;q++){
      int x;
      cin>>x;
      arr[x-1] = 1;
    }
  }
  int count = 0;
    for(int i = 0;i<n;i++){
      if(arr[i]==0)
        count++;
    }
  cout<<count<<endl;
  
  return 0;
}


Measured memory_bytes: 3620
N = int(input())
A = list(map(int,input().split()))

from collections import deque
B = deque([])

rev = False

for i in range(N):
  if not rev:
    B.append(A[i])
  else:
    B.appendleft(A[i])
  rev ^= True
  
if rev:
  B = list(B)[::-1]
    
print(*B)


Measured memory_bytes: 30824
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let c: u32 = read();
    let d: u32 = read();
    println!("{}", min(a, b)+min(c, d));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[100];
  int ai=0;
  long long sum=0;
  
  for(;ai<n;ai++){
    int atmp;
    cin >>atmp;
    a[ai]=atmp;
    sum+=atmp;
  }
  int avg;
  if(sum>=0)
    avg=(int)(((double)sum/ai)+0.5);
  else
    avg=(int)(((double)sum/ai)-0.5);
  sum=0;
  for(int i=0;i<ai;i++){
    sum += (avg-a[i])*(avg-a[i]);
  }
  cout<<sum<<endl;
	     
}


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

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
//i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> a;
//vector <i64> b;
//vector <i64> dp;


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


    //cin >> T;
    T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        i64 sum = 0;

        char c = ' ';
        bool fl = true;
        while (fl) {
            cin.get(c);
            if (c == '\n') {
                break;
            }
            sum += int(c) - 48;
            if (sum % 9 == 0) {
                sum = 0;
            }
        }

        if (sum % 9) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3004
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[100005];
double l;
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>l;
	cout<<fixed<<setprecision(9)<<pow(l/3,3);
	
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,ans=0,m;
  string s,ss,sss;
  cin>>s;
  if(s[2] == s[3] && s[4] == s[5])
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}
template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;



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

    ll N; cin >> N;    
    vector<ll> A(N); cin >> A;
    vector<ll> cnt(N + 10);
    rep(i, N) cnt[A[i]]++;

    ll res = 0;
    rep(i, cnt.size()) res += cnt[i] * (cnt[i] - 1) / 2;

    rep(i, N) {
      ll ans = res - cnt[A[i]] * (cnt[A[i]] - 1) / 2;
      ans += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
      cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 5760
public class Main {

    public static void main(String[] args) {
        final String line = readLine();
        System.out.println(calc(line));
    }

    protected static Answer calc0(String input) {
        double r = Double.parseDouble(input);

        Answer answer = new Answer();

        answer.area = r * r * Math.PI;
        answer.circumference =  (r + r) * Math.PI;

        return answer;
    }

    protected static String calc(String input) {
        return String.valueOf(calc0(input));
    }

    private static String readLine() {
        java.util.Scanner s = null;
        try {
            s = new java.util.Scanner(System.in);
            return s.nextLine();
        } finally {
            if (s != null) {
                s.close();
            }
        }
    }

    static class Answer {
        double area;
        double circumference;
        java.text.Format df = new java.text.DecimalFormat("0.000000");

        @Override
        public String toString() {
            return df.format(area) + " " + df.format(circumference);
        }
    }
}

Measured memory_bytes: 17356
#coding:UTF=-8
import math
N, H = map(int, input().split())

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

mx = max(a)
b = sorted(b, reverse=True)
count = 0
attack = 0
for i in range(N):
    if mx >= b[i] or attack >= H:
        break
    count += 1
    attack += b[i]

if attack < H:
    count += math.ceil((H - attack) / mx)

print(count)

Measured memory_bytes: 12100
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = 0;
        long b = 0;
        long ab = 0;
        String tmp;
        long ba = 0;
        long n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            tmp = sc.next();
            if (tmp.charAt(0) == 'B' && tmp.charAt(tmp.length() - 1) == 'A') {
                ba++;
            } else if (tmp.charAt(0) == 'B') {
                b++;
            } else if (tmp.charAt(tmp.length() - 1) == 'A') {
                a++;
            }
            ab += (tmp.length() - tmp.replaceAll("AB", "").length()) / 2;
        }
        if (ba == 0) {
            System.out.println(Math.min(a, b) + ab);
        } else if(a==0&&b==0){
            System.out.println(ba-1+ab);
        }else{
            System.out.println(ba+Math.min(a,b)+ab);
        }

    }
}

Measured memory_bytes: 38656
#include<iostream>
using namespace std;
int main(){
  int H,W,i,j;
  
  while(1){
 cin >> H >> W;
 if (H == 0 && W == 0) break;
  for(i=0;i<H;i++){
     for(j=0;j<W;j++){
       if(i == 0 && j ==0) cout << "#";
      else  if((i + j) % 2 == 0){
	cout << "#";
      }
	else cout << ".";
    }
    cout << endl;
  }
  cout << endl;


  }
}

Measured memory_bytes: 1152
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int D = sc.nextInt();
        final int N = sc.nextInt();
        int[] T = new int[D];
        for(int i = 0; i < D; ++i)
        {
            T[i] =  sc.nextInt();
        }
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N];
        for(int i = 0; i < N; ++i)
        {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
        }
        int[][] absum = new int[D][];
        absum[0] = new int[N];
        absum[1] = new int[N];
        for(int j = 0; j < N; ++j)
        {
            if(A[j] <= T[1] && T[1] <= B[j])
            {
                int max_dif = 0;
                for(int prev_j = 0; prev_j < N; ++prev_j)
                {
                    if(A[prev_j] <= T[0] && T[0] <= B[prev_j])
                    {
                        max_dif = Math.max(max_dif, Math.abs(C[j] - C[prev_j]));
                    }
                }
                absum[1][j] = max_dif;
            }
        }
        for(int day = 2; day < D; ++day)
        {
            absum[day] = new int[N];
            for(int j = 0; j < N; ++j)
            {
                if(A[j] <= T[day] && T[day] <= B[j])
                {
                    int max_dif = absum[day - 1][0] + (Math.abs(C[j] - C[0]));
                    for(int prev_j = 1; prev_j < N; ++prev_j)
                    {
                        max_dif = Math.max(max_dif, absum[day - 1][prev_j] + (Math.abs(C[j] - C[prev_j])));
                    }
                    absum[day][j] = max_dif;
                }
            }
        }
        int max_sum = absum[D - 1][0];
        for(int j = 1; j < N; ++j)
        {
            max_sum = Math.max(max_sum, absum[D - 1][j]);
        }
        System.out.println(max_sum);
    }
}

Measured memory_bytes: 23376
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
using namespace std;

typedef long long ll;

int main() {
    ll INF = 1e15;
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A+2), t(B+2), x(Q);
    s[0] = -INF;
    t[0] = -INF;
    s[A+1] = INF;
    t[B+1] = INF; 
    for(int i = 1; i <= A; i++) cin >> s[i];
    for(int i = 1; i <= B; i++) cin >> t[i];
    for(int i = 0; i < Q; i++) cin >> x[i];

    for(int i = 0; i < Q; i++){

        auto rs = lower_bound(s.begin(), s.end(), x[i]);
        auto rt = lower_bound(t.begin(), t.end(), x[i]);
        
        ll ans = INF;
        ans = min(ans, max(*rs, *rt) -x[i]);
        ans = min(ans, x[i] - min(*(rs-1), *(rt-1)));
        ans = min(ans, *rs-*(rt-1) + min(*rs-x[i], x[i]-*(rt-1)));
        ans = min(ans, *rt-*(rs-1) + min(x[i]-*(rs-1), *rt-x[i]));

        cout << ans << endl;   
    }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n,k; cin >> n >> k;
        vll v(n);
        rep(i,n){
            cin >> v[i];
        }
        sort(all(v));
        ll tot=0;
        rep(i,n-k){
            tot+=v[i];
        }
        cout << tot << endl;
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <climits>
using namespace std;
#define mod (1000000007)
#define ll long long int


int main(void){
  vector<int> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v[i];
  }

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

  if(v[0] == 5 and v[1] == 5 and v[2] == 7){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }


}


Measured memory_bytes: 256