akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str>>str2;
	if(str[0]==str2[2]&&str[1]==str2[1]&&str[2]==str2[0]){
		cout<<"YES";
	}else{
		cout<<"NO";
	}







	cout<<endl;
} 


Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let mut a:Vec<i32> = Vec::new();
	let mut maxi = 1;
	a.push(1);
	a.push(1);
	for i in 2..x {
		for j in 2.. {
			if i.pow(j) > x {
				break;
			}
			if i.pow(j) > maxi {
				maxi = i.pow(j);
				a.pop();
				a.pop();
				a.push(j as i32);
				a.push(i);
			}
		}
	}
	let b = a.pop().unwrap();
	let p = a.pop().unwrap();
	println!("{}", b.pow(p as u32));
}

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

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

            // 解析
            int iOut = 0;
            decimal iZ = iX;
            while (true)
            {
                iOut += 1;
                iZ = iZ * 2;
                if (iZ > iY) { break; }
            }

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

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


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("substrcmp.in", "r", stdin);
       // freopen("substrcmp.out", "w", stdout);
#endif
}

void solve(){
    int n, a, b;
    cin >> n >> a >> b;
    int kek = a+b;
    int ans = n/(kek) * a;
    n %= kek;
    ans += min(n, a);
    cout << ans;
}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

void Print(vector<ll> nums)
{
	for (int i = 0; i < nums.size(); i++)
	{
		cout << nums[i] << " ";
	}
	cout << endl;
}
int main()
{
	int n, t;
	cin >> n >> t;
	vector<ll> prices(n);
	for (int i = 0; i < n; i++)
	{
		cin >> prices[i];
	}

	ll min = -1;
	ll max_profit_cnt = 0;
	ll max_profit = 0;

	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			min = prices[i];
			continue;
		}

		if (min > prices[i])
		{
			min = prices[i];
		}

		ll profit = prices[i] - min;
		if (profit == max_profit)
		{
			max_profit_cnt++;
		}
		else if (profit > max_profit)
		{
			max_profit_cnt = 1;
			max_profit = profit;
		}
	}

	cout << max_profit_cnt << endl;
}

Measured memory_bytes: 1024
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List                      ( unfoldr )
import           Control.Monad
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.IntSet                    ( IntSet )
import qualified Data.IntSet                   as IntSet
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import qualified Data.Vector.Generic           as VG
import qualified Data.Vector.Generic.Mutable   as VGM

main :: IO ()
main = do
  x <- readLn :: IO Int
  xs <- V.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let t = sieveLD 1000000
  let pfs = V.map (primeFactorS t) xs
  let pa = V.sum (V.map IntSet.size pfs) == IntSet.size (V.foldl1 IntSet.union pfs)
  let se = V.foldl1 gcd xs == 1
  putStrLn $ if pa then "pairwise coprime" else if se then "setwise coprime" else "not coprime"

-- Prime factor

type LDTable = VU.Vector Int

primeFactorS :: LDTable -> Int -> IntSet
primeFactorS t x = IntSet.fromAscList $ primeFactorRaw t x 

primeFactorRaw :: LDTable -> Int -> [Int]
primeFactorRaw _ 1 = []
primeFactorRaw t x = let f = t VU.! x in f : primeFactorRaw t (x `div` f)

-- Least Divisor
-- LD(4) = 2
-- LD(6) = 2
-- LD(35) = 5

sieveLD :: Int -> LDTable
sieveLD n = VU.create $ do
  vec <- VU.thaw $ VU.enumFromN 0 (n + 1)
  VUM.write vec 0 1
  forM_ [2 .. n] $ \i -> do
    d <- VUM.read vec i
    when (i == d) $ forM_ [2 * i, 3 * i .. n] $ \j -> VUM.modify vec (min i) j
  return vec


Measured memory_bytes: 246552
#include <iostream>

using namespace std;

int V[101][101];
int n;

int d[101];
int f[101];

int t = 1;
void dfs(int src){
  t++;
  for(int i=1;i<=n;i++){
    if(V[src][i] != 0 && !d[i]){
      d[i] = t;
      dfs(i);
      t++;
    }
  }
  f[src] = t;
}
int main(){
  int  src, dst, num, non_visited;
  cin >> n;
  for(int i=1;i<=n;i++){
    d[i] = 0; f[i] = 0;
  }
  for(int i=1;i<=n;i++){
    cin >> src >> num;
    for(int j=0;j<num;j++){
      cin >> dst;
      V[src][dst] = 1;
    }
  }
  non_visited = 1;
  do{
    d[non_visited] = t;
    dfs(non_visited);
    non_visited = 0;
    for(int i=1;i<=n;i++){
      if(!d[i]){
        non_visited = i;
        break;
      }
    }
    t++;
  }while(non_visited);

  for(int i=1;i<=n;i++){
    cout << i <<" "<< d[i] <<" "<< f[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
// 金子先生へ
// ITC-LMSの「第9回提出物」の提出期間が6/23までで、期間後の提出が不可になっています。
// しかし月曜までに今回の課題全部は解き終わらないので、いつもの様に7月末までにしてくださると幸いです。
// 多分、今回の課題は全部解けそうです。

// Sampleは全部正解を出しましたが、ジャッジは通りませんでした。
// 反例も作成できなかったです。

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp
#include <iostream>
#include <algorithm>
#include <queue>
#include <utility> // pair<int,int> xxxx;  make_pair(first,second);
// 今から考えればstructで十分だった……
using namespace std;

int W,H;
int X,Y; // 自分の位置
char s[20+10];
char c;
bool tile[20+10][20+10]; // タイルの状態。trueは黒、falseは赤(または壁)。
bool visited[20+10][20+10];
int answer;

// 下方向がx軸(第1成分)、右方向がy軸(第2成分)。

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

bool valid (int x, int y) {
  return 0 <= x && x < H && 0 <= y && y < W && tile[x][y] ;
}

void init() { // 初期化
  fill(&tile[0][0], &tile[0][0]+30*30, 0);
  fill(&visited[0][0], &visited[0][0]+30*30, 0);
  answer = 0;
}

void make_tile() { // タイル読み込み
  for (int i=0; i<H; i++) {
    scanf("%s", s);
    for (int j=0; j<W; j++) {
      c = s[j];
      if (c == '.') {
	tile[i][j] = true;
      } else if (c == '@') {
	tile[i][j] = true;
	X = i;
	Y = j;
      }
    }
  }
}

void count_tile() {
  queue<pair<int,int>> Q; // 幅優先探索を使う。周辺から徐々に探査する感じになるのでイメージしやすい。
  pair<int,int> cur = make_pair(X,Y);
  Q.push(cur);
  while (!Q.empty()) {
    cur = Q.front();
    Q.pop();
    if (visited[cur.first][cur.second]) {
      continue;
    }
    visited[cur.first][cur.second] = true;
    answer++;
    for (int i=0; i<4; i++) {
      int a = cur.first+dx[i];
      int b = cur.second+dy[i];
      if (valid(a, b) && !visited[a][b]) {
	Q.push(make_pair(a, b));
      }
    }
  }
  printf("%d\n", answer);
}

int main() {
  while (scanf("%d%d", &W, &H) && W && H) {
    init();
    make_tile();
    count_tile();
  }
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int n;
  while (n = in()){
    n = 1000 - n;
    int v = 0;
    for (int i = 0; i < 6; i++){
      static const int c[] = {500, 100, 50, 10, 5, 1};
      v += n / c[i];
      n %= c[i];
    }
    printf("%d\n", v);
  }

  return (0);
}

Measured memory_bytes: 1188
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long ll;

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

  vector<ll> xs(N);
  for (int i = 0; i < N; ++i) {
    cin >> xs[i];
  }

  long long ans = -1;
  for (int i = 0; i <= N - K; ++i) {
    long long tmp = 0;
    tmp = abs(xs[i]) + abs(xs[i + K - 1] - xs[i]);
    tmp = min(tmp, abs(xs[i + K - 1]) + abs(xs[i] - xs[i + K - 1]));
    if (ans == -1) {
      ans = tmp;
    } else {
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    long long n, a, b;
    long long l,r,ans;
    cin >> n >> a >> b;

    if (n == 1) {
        if (a==b){ans = 1;}
        else {ans = 0;}
    }
    else {
        if (a>b){ans = 0;}
        else {
            l = a * (n-1) + b;
            r = b * (n-1) + a;
            ans = r-l+1;
            //ans = (b-a) * (n-2) + 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int absv(int a) {
	if(a<0) return -a;
	return a;
}

int main()
{
	int N;
	scanf("%d",&N);
	int h[N];
	int cost[N];
	int i=0,c1=0,c2=0;
	
	for(i=0; i<N; i++){
		scanf("%d",&h[i]);
	}
	
	cost[0] = 0;
	cost[1] = absv(h[1]-h[0]);
	
	for(i=2;i<N;i++){
		c1 = absv(h[i]-h[i-1])+cost[i-1];
		c2 = absv(h[i]-h[i-2])+cost[i-2];
		if(c1>c2){
			cost[i]=c2;
		}
		else {
			cost[i]=c1;
		}
	}
	printf("%d",cost[N-1]);
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, l, t;
	cin >> n >> l >> t;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	int idx;
	if (p[0].second == 1) {
		int goal = p[0].first + 2 * t;
		int per = 0; int cnt = 0;
		rep(i, n) {
			if (p[i].second == 2) {
				per++;
				if (goal%l >= p[i].first) cnt++;
			}
		}
		cnt += goal / l * per;
		idx = cnt % n;
	}
	else {
		vector<P> q(n);
		for (int i = n - 1; i >= 0; i--) q[n - 1 - i] = P(l - p[i].first, 3 - p[i].second);
		int goal = q[n - 1].first + 2 * t;
		int per = 0; int cnt = 0;
		rep(i, n) {
			if (q[i].second == 2) {
				per++;
				if (goal%l >= q[i].first) cnt++;
			}
		}
		cnt += (goal / l - 1) * per;
		idx = ((n - cnt) % n + n) % n;

	}
	//cerr << idx << '\n';
	assert(0 <= idx && idx < n);
	vector<P> to(n);
	rep(i, n) {
		if (p[i].second == 1) to[i] = P((p[i].first + t) % l, -1);
		else to[i] = P(((p[i].first - t) % l + l) % l, -2);
	}
	sort(all(to));
	rep(i, n) to.pb(to[i]);
	P g;
	if (p[0].second == 1) g = P((p[0].first + t) % l, -1);
	else g = P(((p[0].first - t) % l + l) % l, -2);
	vector<P> rto;
	bool flag = false;
	rep(i, 2 * n) {
		if (to[i] == g) flag = true;
		if (flag) rto.pb(to[i]);
	}
	assert(flag);
	vector<int> ans(n);
	rep(i, n) ans[(i + idx) % n] = rto[i].first;
	rep(i, n) cout << ans[i] << '\n';
}

Measured memory_bytes: 13028
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n ;
    ll k ;
    cin >> n >> k;
    vector<int> a (n) ;
    rep(i, n){
        cin >> a[i] ;
        a[i]-- ;
    }
    vector<int> loop ;
    vector<int> used (n) ;
    ll t = 0 ;
    while(1){
        if(used[t]){
            break ;
        }
        loop.push_back(t) ;
        used[t] = 1 ;
        t = a[t] ;
    }
    ll f = loop.size() ;
    ll num = 0 ; 
    rep(i, f){
        if(loop[i] == t){
            break ;
        }
        num++ ;
    }
    if(k < num){
        cout << loop[k] + 1 << endl ;
        return 0 ;
    }
    ll div = f - num ;
    k = (k - num) % div ;
    cout << loop[num + k] + 1 << endl ;
    return 0 ;
}  

Measured memory_bytes: 5884
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

a = 0
b = 0
c = 0
for p in P:
	if p <= A: a += 1
	if A + 1 <= p <= B: b += 1
	if B + 1 <= p : c += 1

print(min(a, b, c))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=int(l);i<int(r);i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10;

int n,k;
num ans;
int32_t main(){
    cin>>n>>k;
    if(k==0){
	cout<<1ll*n*n<<endl;
	return 0;
    }
    rep(b,k+1,n+1){
	int cnt=b-k;
	ans+=cnt*(n/b);
	int n0=n%b;
	if(n0==0) continue;
	ans+=max(0,n0-k+1);
    }
    cout<<ans<<endl;
}


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

int main(){ 
    int n,y; cin>>n>>y;
    int huku=-1,higu=-1,nogu=-1;

    for(int i=0;i<=n;i++){
        for(int j=0;j+i<=n;j++){
            for(int k=0;i+j+k<=n;k++){
            if(y==i*10000+j*5000+k*1000&&i+j+k==n){
                huku=i;
                higu=j;
                nogu=k;
                
                }
            }
        }
    }
    cout<<huku<<" "<<higu<<" "<<nogu<<endl;
    }


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,a[N],b[N];
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i],b[a[i]]++;
	int ans=0;
	for(int i=0;i<1e5;i++){
		int tmp=b[i];
		if(i-1>=0) tmp+=b[i-1];
		if(i+1<1e5) tmp+=b[i+1];
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4356
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    string s;
    while(cin >> s)
	{
        string str;
        for(int i = 0; i < s.length() ;i++)
		{
            if(s[i] == '@')
			{
                for(int j=0;j<(s[i+1]-'0');j++)
				{
                    str += s[i+2];
                }
                i+=2;
            }
			else
			{
                str += s[i];
            }
        }
        cout << str <<endl;
    }
     
    return 0;
}

Measured memory_bytes: 1184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Integer a[] = new Integer[n];
		String str[] = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		Arrays.sort(a);

		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int k = ~Arrays.binarySearch(a, a[i] + a[j], (x, y) -> x.compareTo(y) >= 0 ? 1 : -1);

				ans += Math.max(k - (j + 1), 0);
			}
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 46676
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



struct Mint {
  int x;

  Mint() : x(0) {}

  Mint(int y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}

  Mint &operator+=(const Mint &p) {
    if((x += p.x) >= M) x -= M;
    return *this;
  }

  Mint &operator-=(const Mint &p) {
    if((x += M - p.x) >= M) x -= M;
    return *this;
  }

  Mint &operator*=(const Mint &p) {
    x = (int) (1LL * x * p.x % M);
    return *this;
  }

  Mint &operator/=(const Mint &p) {
    *this *= p.inverse();
    return *this;
  }

  Mint operator-() const { return Mint(-x); }

  Mint operator+(const Mint &p) const { return Mint(*this) += p; }

  Mint operator-(const Mint &p) const { return Mint(*this) -= p; }

  Mint operator*(const Mint &p) const { return Mint(*this) *= p; }

  Mint operator/(const Mint &p) const { return Mint(*this) /= p; }

  bool operator==(const Mint &p) const { return x == p.x; }

  bool operator!=(const Mint &p) const { return x != p.x; }

  Mint inverse() const {
    int a = x, b = M, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return Mint(u);
  }

  Mint power(int n) const {
    Mint ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const Mint &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, Mint &a) {
    int t;
    is >> t;
    a = Mint(t);
    return (is);
  }


};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  int i=0;
  Mint ans=0;
  while(i<=60){
    Mint cnt[2]={};
    Mint s=(1LL<<i);
    rep(j,n){
      cnt[((a[j]>>i)&1)]+=1;
    }
    //cout<<cnt[0]<<' '<<cnt[1]<<endl;

    ans+=s*cnt[0]*cnt[1];
    
    i++; 
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
const int N = 1000+5;
const int inf = 1e7+7;
char s[N];
int f[N][26+5];


int min(int a,int b){ return a>b?b:a; }

int judge(int n){
	for(int i = 2; i <= n; i++){
		if(s[i]!=s[1]) return 0;
	}
	return 1;
}

int solve(int n,int k){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < k; j++){
			s[j*n+i] = s[i];
		}
	}
	n = n*k;
	for(int i = 0; i < 26; i++) f[0][i] = 0;
	int res = inf;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 26; j++){
			f[i][j] = inf;
			for(int k = 0; k < 26; k++){
				if(j!=k && f[i-1][k]<inf){ 
					int add = (j+'a')!=s[i];
					f[i][j] = min(f[i][j],f[i-1][k]+add);
				}
			}
			if(i==n) res = min(res,f[i][j]);
		}
	}
	return res;
}

int main(){
	int k;
	scanf("%s%d",s+1,&k);
	int n = strlen(s+1);
	if(k<=8) printf("%d\n",solve(n,k));
	else{
		if(s[1]!=s[n]) printf("%lld\n",(long long)solve(n,1)*(long long)k);
		else if(judge(n)){
			printf("%lld\n",(long long)n*(long long)k/2ll);
		}
		else{
			long long ans3 = solve(n,8);
			long long ans4 = solve(n,9);
			long long cnt = k-8;
			long long ans = (ans4-ans3)*(cnt)+ans3;
			printf("%lld\n",ans);
		}
	}
	return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    if(S.size() + 1 != T.size()) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, S.size()){
      if(S.at(i) != T.at(i)){
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    int a_;
    cin >> a_;
    a[i] = a_;
  }
  priority_queue<int, vector<int>, greater<int>> pq;
  vector<long long> maxv(n + 1, 0);
  for (int i = 0; i < n; i++) {
    pq.push(a[i]);
    maxv[0] += (long long)a[i];
  }
  for (int i = 0; i < n; i++) {
    int crr = a[n + i];
    if (crr > pq.top()) {
      maxv[i + 1] = maxv[i] + (long long)crr - (long long)pq.top();
      pq.pop();
      pq.push(crr);
    } else {
      maxv[i + 1] = maxv[i];
    }
  }
  priority_queue<int> qq;
  vector<long long> minv(n + 1, 0);
  for (int i = 0; i < n; i++) {
    qq.push(a[2 * n + i]);
    minv[0] += (long long)a[2 * n + i];
  }
  for (int i = 0; i < n; i++) {
    int crr = a[2 * n - 1 - i];
    if (crr < qq.top()) {
      minv[i + 1] = minv[i] + (long long)crr - (long long)qq.top();
      qq.pop();
      qq.push(crr);
    } else {
      minv[i + 1] = minv[i];
    }
  }
  long long ans = -1e18;
  for (int i = 0; i <= n; i++) {
    ans = max(ans, maxv[i] - minv[n - i]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4216
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
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) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 18;
char C[CM + CL], * ci = C + CL, * owa = C + CM, c;

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


	fread(ci, 1, CM, stdin);
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';

	int D[10];
	int d = 1;
	for (int i = 9; i >= 0; i--) {
		D[i] = d;
		d *= 10;
	}
	ll p[20][20] = {};
	rep(i, N) {
		if (ci - owa > 0) {
			memcpy(C, owa, CL);
			ci -= CM;
			fread(C + CL, 1, CM, stdin);
		}

		ll kari = 0;
		while ((c = *ci++) >= '0') kari = kari * 10 + c - '0';
		d = 0;
		if (*(ci - 1) == '.') {
			while ((c = *ci++) >= '0') {
				kari = kari * 10 + c - '0';
				d++;
			}
		}
		kari *= D[d];

		int a = __builtin_ctzll(kari);
		if (a > 18) a = 18;
		int b = 0;
		while (kari % 5 == 0) {
			b++;
			kari /= 5;
		}
		p[a][b]++;
	}
	ll kotae = 0;
	rep(a, 19) rep(b, 19) if (p[a][b]) {
		ll P = p[a][b];
		for (int x = 18 - a; x <= 18; x++) {
			for (int y = 18 - b; y <= 18; y++) {
				kotae += P * p[x][y];
			}
		}
	}
	for (int a = 9; a <= 18; a++) {
		for (int b = 9; b <= 18; b++) {
			kotae -= p[a][b];
		}
	}

	printf("%lld\n", kotae / 2);

	Would you please return 0;
}

Measured memory_bytes: 1668
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int d[90][90],h,w;
int dfs(int x, int y) {
	int res = 0;
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < h && 0 <= ny&&ny < w&&d[nx][ny]) {
			d[nx][ny] = 0;
			res = max(res, dfs(nx, ny) + 1);
			d[nx][ny] = 1;
		}
	}
	return res;
}

int main() {

	while (cin >> w >> h&&w&&h) {
		for (int i = 0; i < 90; i++)for (int j = 0; j < 90; j++)d[i][j] = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> d[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (d[i][j] == 1) {
					d[i][j] = 0;
					ans = max(ans, dfs(i, j) + 1);
					d[i][j] = 1;
				}
			}
		}
		cout << ans << endl;
	}
}

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

#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

int gcd(int a, int b){
    if(!b) return a;
    return  gcd(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

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

    ll h, n;
    cin>>h>>n;
    ll a[n];
    fr(i, n) cin>>a[i];
    ll s = accumulate(a, a+n, 0ll);
    if(s >= h){
        cout<<"Yes";
    } else {
        cout<<"No";
    }

    return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, a, b;
    cin >> n >> a >> b;
    int ans1 = min(a, b);
    int ans2 = max(0, a + b - n);
    cout << ans1 << " " << ans2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

int main(){

    int N;
    cin >> N;
    vector<int> s(N);
    for(int i = 0; i < N; i++) cin >> s[i];

    int sum = 0, mul10 = 1000;
    for(int i = 0; i < N; i++){
        sum += s[i];
        if(s[i] % 10 != 0 && mul10 > s[i]) mul10 = s[i];
    }

    if(sum % 10 == 0){
        if(mul10 == 1000) cout << 0 << endl;
        else cout << sum - mul10 << endl;
    }else{
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <string>
#include <set>
#include <cmath>
#include <stack>
#include <cctype>
#define MOD 1000000007
#define ll  long long int
using namespace std;



int main()
{
   ios::sync_with_stdio(false) ;cin.tie(0) ;
   cout.tie(0) ;
   ll n   ;cin>>n ;
   ll arr[n] ;
   for(ll i = 0  ; i< n ; ++i)
    cin>>arr[i] ;

   ll maxi  = 10000000000000;
   ll sum[n] ;
   sum[0] = arr[0] ;
   for(ll i = 1 ; i < n ; ++i)
   {
       sum[i] =  sum[i-1] + arr[i] ;
   }


   for(ll i =  0 ; i <  n-1 ;++i)
   {
       ll k   = sum[n-1] - sum[i] ;
       maxi   =  min(maxi  , abs((sum[i] - k )) ) ;
   }



   cout<<maxi ;

return 0
;}

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

int main(void){
    // Your code here!
    while(true){
        string g;
        int y,m,d;
        cin>>g;
        if(g=="#")break;
        cin>>y>>m>>d;
        if(y*10000+m*100+d<=31*10000+4*100+30){
            cout<<"HEISEI"<<" "<<y<<" "<<m<<" "<<d<<endl;
        }
        else{
            cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
        }
    }    
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
//1 to enable Debugging, 0 to disable
#define DEBUG 0
#define LL long long
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define SET(x) memset(x, 0, sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define SQR(x) ((x)*(x))
#if DEBUG
	#define DBG(x) cout << "> " << #x << ": " << x << endl;
#else
	#define DBG(x)
#endif
#define REP(i,N) for(int i=0; i<N; i++)
#define REPx(i,x,N) for(int i=x; i<N; i++)
#define REPit(it, x) for(__typeof(x.begin()) it = x.begin(); it != x.end(); it++)
#define NOSYNC std::ios_base::sync_with_stdio(false)
inline int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
using namespace std;
    
int main(){
	NOSYNC;
	cin.tie(NULL);
    cout.tie(NULL);
    int N;
    cin>>N;
    int h[N];
    REP(i,N)
        cin>>h[i];
    int dp[N+1];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;++i)
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    cout<<dp[N-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ld = long double;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "[";
    for (const auto& e : v) {
        os << e << ",";
    }
    os << "] ";
    os << "size = " << v.size() << endl;
    return os;
}

int main()
{
    ll n, m, a, b, p, q;
    cin >> n >> m >> a >> b >> p >> q;

    if (p + q > m) {
        cout << min(m, p + q - m) << endl;
    } else if (a == 1 and b == 1) {
        ll nearest = m / (p + q);
        if (m - (p + q) * nearest > (p + q) * (nearest + 1) - m) {
            nearest++;
        }
        if (nearest > n) {
            cout << m - (p + q) * n << endl;
        } else {
            cout << (p + q) * nearest - m << endl;
        }


    } else {
        ll k = 0;
        ll A = 1;
        ll B = 1;
        vector<ll> value;
        for (; p * A + q * B <= m and k < n; k++) {
            value.push_back(p * A + q * B);
            A *= a;
            B *= b;
        }
        n = k;
        const ll former = n / 2;
        const ll latter = n - former;
        const ll fmax = 1 << former;
        const ll lmax = 1 << latter;

        vector<ll> fsum(fmax, 0LL);
        for (ll i = 0; i < fmax; i++) {
            for (ll j = 0; j < former; j++) {
                if (i & (1LL << j)) {
                    fsum[i] = fsum[i - (1LL << j)] + value[j];
                    break;
                }
            }
        }
        vector<ll> lsum(lmax, 0LL);
        for (ll i = 0; i < lmax; i++) {
            for (ll j = 0; j < latter; j++) {
                if (i & (1LL << j)) {
                    lsum[i] = lsum[i - (1LL << j)] + value[former + j];
                    break;
                }
            }
        }
        sort(lsum.begin(), lsum.end());
        constexpr ll INF = 1LL << 60;
        ll error = INF;
        for (ll f : fsum) {
            const ll res = m - f;
            if (res <= 0) {
                error = min(error, -res);
            } else {
                auto it = lower_bound(lsum.begin(), lsum.end(), res);
                if (it != lsum.end()) {
                    error = min(error, abs(res - (*it)));
                }
                it--;
                error = min(error, abs(res - (*it)));
            }
        }
        cout << error << endl;
    }
    return 0;
}

Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dp(100100,vector<int>(13,-1));
vector<int> mods = {1,10,9,12,3,4};
string s;
int n;

int ans(int curr , int mod){
	if(curr == -1){
		if(mod == 5){
			return 1;
		}
		return 0;
	}
	if(dp[curr][mod] != -1){
		return dp[curr][mod];
	}
	int v = n-curr-1;
	v %= 6;
	int ret = 0;
	if(s[curr] == '?'){
		for(int i = 0 ; i <= 9 ; i += 1){
			ret += ans(curr-1,(mod + mods[v]*i) % 13);
			ret %= 1000000007;
		}
	}else{
		ret += ans(curr-1,(mod + mods[v]*(s[curr]-'0')) % 13);
		ret %= 1000000007;
	}
	dp[curr][mod] = ret;
	return ret;
}

int main(){
	cin >> s;
	n = s.size();
	cout << ans(n-1,0);
}

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

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

    if(n[0] == '7' 
    || n[1] == '7'
    || n[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>

using namespace std;

int main ( void )
{
	const int m[] = { 1, 5, 10, 50, 100, 500 };
	int n;
	
	while ( cin >> n, n )
	{
		n = 1000 - n;
		int count = 0;
		for (int i = 5; i >= 0; --i)
		{
			count += n / m[i];
			n %= m[i];
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let a: i64 = sc.cin();
    let b: i64 = sc.cin();
    let c: i64 = sc.cin();
    let k: i64 = sc.cin();
    put!((a-b) * if k % 2 == 0 { 1 } else { -1 });

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

int main(){
	int x=0,y=0;
	double dx=0.0,dy=0.0;
	int ho,ka=0;
	int pka=90;
	int i,j,k,l,m;
	char c;

	while (1){
		scanf("%d",&ho);
		dx+=ho*sin(pka*M_PI/180);
		dy-=ho*cos(pka*M_PI/180);
		scanf("%c%d",&c,&ka);
		pka+=ka;
		if(ho==0&&ka==0)break;
	}
	x=dx;
	y=dy;
	printf("%d\n%d\n",y,x);
	return 0;
}

Measured memory_bytes: 604
first_line = STDIN.gets.strip
second_line = STDIN.gets.strip

inn_heights = second_line.split(' ').map(&:to_i)
count = 0

inn_heights.each_with_index do |height, idx|
  if idx == 0
    count = count + 1
    next
  end

  is_ocean_view = true
  (0...idx).each do |i|
    if height < inn_heights[i]
      is_ocean_view = false
      break
    end
  end

  count = count + 1 if is_ocean_view
end

puts count

Measured memory_bytes: 1788
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    v = sorted(c.values())
    ans = 0
    if len(c.keys()) <= K:
        pass
    else:
        ans += sum(v[:len(v) - K])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 98896
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

map<long long, int> factorize(long long n)
{
	map<long long, int> m;
	for (long long x = 2; x * x <= n; ++x) {
		while (n % x == 0) {
			++m[x];
			n /= x;
		}
	}
	if (n != 1) {
		++m[n];
	}
	return m;
}

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

int main()
{
	long long A, B;
	cin >> A >> B;
	auto d = gcd(A, B);
	auto ans = factorize(d).size() + 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int N, A[6666], D[2222][2222], R[2222], M;

int main()
{
	scanf ("%d", &N);
	for (int i = 0; i < N * 3; i++) scanf ("%d", &A[i]);
	for (int i = 1; i <= N; i++){
		for (int j = 1; j <= N; j++) D[i][j] = -1e9;
		R[i] = -1e9;
	}
	M = -1e9;

	D[A[0]][A[1]] = D[A[1]][A[0]] = 0;
	R[A[0]] = R[A[1]] = M = 0;

	int base = 0;
	for (int i = 2; i + 3 < N * 3; i += 3){
		sort(A + i, A + i + 3);

		if (A[i] == A[i + 2]){ base++; continue; }
		
		struct inst{ int x, y, c; };
		vector<inst> upd;

		int w = -1, v = -1, u = -1;
		if (A[i] == A[i + 1]) w = A[i], v = A[i + 2];
		if (A[i + 1] == A[i + 2]) w = A[i + 2], v = A[i];

		if (w != -1){
			for (int p = 1; p <= N; p++){
				upd.push_back({ p, v, D[w][p] + 1 });
				upd.push_back({ p, v, R[p] });
			}
			upd.push_back({ w, w, D[v][v] + 1 });
			upd.push_back({ w, w, M });
			upd.push_back({ w, v, D[w][w] + 1 });
			upd.push_back({ w, v, M });
		}
		else{
			for (int k = 0; k < 3; k++){
				if (k == 0) w = A[i + 1], v = A[i + 2];
				if (k == 1) w = A[i], v = A[i + 2];
				if (k == 2) w = A[i], v = A[i + 1];
				u = A[i + k];

				for (int p = 1; p <= N; p++) upd.push_back({p, u, R[p]});
				upd.push_back({ w, v, D[u][u] + 1 });
				upd.push_back({ w, v, M });
			}
		}

		for (auto& t : upd){
			int x = t.x, y = t.y;
			D[x][y] = max(D[x][y], t.c);
			R[x] = max(R[x], t.c);
			M = max(M, t.c);
			swap(x, y);
			D[x][y] = max(D[x][y], t.c);
			R[x] = max(R[x], t.c);
		}
	}

	int ans = max(M, D[A[3 * N - 1]][A[3 * N - 1]] + 1) + base;
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 20712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	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;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

string s, t;

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

  int N = s.size(), M = t.size();

  vector<vector<int>> dp(N + 1, vector<int>(M + 1, 0));

  rep(i, N) rep(j, M) {
    dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
    if (s[i] == t[j]) {
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
    }
  }

  string ans;
  for (int l = dp[N][M], i = N, j = M; l > 0; --l) {
    while (dp[i][j] >= l) --i;
    while (t[j - 1] != s[i]) --j;
    --j;
    ans = s[i] + ans;
  }
  cout << ans;
  if (ans != "") cout << endl;

  return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll a,b;
  cin>>a>>b;
  for(ll i=1;i<=10000;i++)
    if(ll(i*0.08)==a&&ll(i*0.1)==b){
      cout<<i;
      exit(0);
    }
  cout<<"-1";
}

Measured memory_bytes: 256
N = int(input())
L = sorted([list(map(int,input().split())) for i in range(N)])

D = {}

for i in range(N-1) :
    ax,ay = L[i]
    for j in range(i+1,N) :
        bx,by = L[j]
        
        p = bx-ax
        q = by-ay
        tag = str(p)+str(q)
        if tag not in D :
            D[tag] = 1
        else :
            D[tag] += 1
if N == 1 :
    ans = 1
else :
    ans = N-max(D.values())

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 26;
const int N = (int)1e5 + 5;
const int M = 123;

vector<int> g[N];
int deg[N];
int n, m;
int dp[N];
bool used[N];
vector <int> start;

void dfs(int v) {
    if (used[v])
        return;
    used[v] = 1;
    for(auto &to : g[v])
        dfs(to);

    start.pb(v);
}

void solve() {
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
    }

    for(int i = 1; i <= n; i++) {
        dp[i] = -inf;
    }

    for(int i = 1; i <= n; i++) {
        if (!used[i]) {
            dfs(i);
        }
    }

    rev(start);

    int ans = -1;
    for(int i = 0; i < (int)start.size(); i++) {
        int v = start[i];
        if (dp[v] == -inf)
            dp[v] = 1;
        for(auto to : g[v]) {
            dp[to] = max(dp[to], dp[v] + 1);
        }
        ans = max(ans, dp[v]);
    }

    cout << ans - 1 << endl;
}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


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

using namespace std;

int main()
{
	int x;
	cin >> x;
	string out[] = {"thu", "fri", "sat", "sun", "mon", "tue", "wed"};
	cout << out[x % 7] << endl;

	return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>

void swap(int *,int *);
int main()
{
  int i,j,N,count=0;
  int a[100];
  
  scanf("%d",&N);
  for (i=0;i<N;i++)
    {
      scanf("%d",&a[i]);
    }

  for(i=0;i<N;i++)
    {
      for(j=N-1;j>i;j--)
	{
	  if(a[j]<a[j-1])
	    {
	      swap(&a[j],&a[j-1]);
	      count++;
	    }
	}
    }
  for(i=0;i<N;i++)
    {
      printf("%d",a[i]);
      if(i!=N-1) printf(" ");
    }
  printf("\n");
  
  printf("%d\n",count);
  
  return 0;
}

void swap(int *x ,int *y)
{
  int z;
  
  z=*x;
  *x=*y;
  *y=z;
}

Measured memory_bytes: 604
//In The Name of Allah
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template < class T > using Tree = tree < T , null_type , less < T > , rb_tree_tag , tree_order_statistics_node_update >;

typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define all(x)          (x).begin(), (x).end()
#define SZ(x)           (ll)(x.size())
#define sep             ' '
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);

const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

int main(){
    fast_io
    //dbl_io(10);
    ll n, a, b;
    cin >> n >> a >> b;
    ll x, y;
    if (n == 1){
        cin >> x;
        return cout << abs(x - b), 0;
    }
    for (ll i = 0; i < n - 2; i ++)
        cin >> x;
    cin >> x >> y;
    cout << max(abs(y - b), abs(x - y));
    return 0;
}


Measured memory_bytes: 256