akhauriyash/Code-Regression huggingface dataset:
// finish date: 2018/04/21

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    ll C;
    cin >> N >> C;
    vl x(N);
    vl v(N);
    rep(i, N) {
        cin >> x[i] >> v[i];
    }
    vl ruiseki1(N), ruiseki2(N);
    rep(i, N) {
        ruiseki1[i] = v[i];
        if (i != 0) ruiseki1[i] += ruiseki1[i - 1];
    }
    for (int i = N - 1; i >= 0; i--) {
        ruiseki2[i] = v[i];
        if (i != N - 1) ruiseki2[i] += ruiseki2[i + 1];
    }
    vl max1(N), max2(N);
    rep(i, N) {
        if (i == 0) max1[i] = ruiseki1[i] - x[i];
        else max1[i] = max(max1[i - 1], ruiseki1[i] - x[i]);
    }
    for (int i = N - 1; i >= 0; i--) {
        if (i == N - 1) max2[i] = ruiseki2[i] - (C - x[i]);
        else max2[i] = max(max2[i + 1], ruiseki2[i] - (C - x[i]));
    }

    ll ans = 0;
    rep(i, N) {
        //先に時計回り
        ll temp = ruiseki1[i] - x[i];
        if (i != N - 1) temp += max((ll) 0, max2[i + 1] - x[i]);
        ans = max(ans, temp);

        //先に反時計回り
        temp = ruiseki2[i] - (C - x[i]);
        if (i != 0) temp += max((ll) 0, max1[i - 1] - (C - x[i]));
        ans = max(ans, temp);
    }
    printf("%.0f\n", ans);



    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int binarySearch(int* p, int n, int target){
    int l = 0, r = n-1;
    int m = (l+r+1)/2;
    while(l < r){
        if(*(p + m) <= target){
            l = m;
        }else{
            r = m-1;
        }
        m = (l+r+1)/2;
    }
    /*if(*(p+m) != target){
        return -1;
    }*/
    return m;
}

int cmpAsc(const void* a, const void* b){
    int x = *(int*)a, y = *(int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, 0, n){
        scanf("%d", &a[i]);
    }
    qsort(a, n, sizeof(int), cmpAsc);
    int x = a[n-1], y, id, target = x/2;
    id = binarySearch(a, n-1, target);
    if(a[id] != target && id < n-2){
        if(abs(a[id] - target) >= abs(a[id+1] - target)){
            id++;
        }
    }
    y = a[id];
    printf("%d %d", x, y);

    return 0;
}


Measured memory_bytes: 892
#pragma warning(disable:4996)
#include<stdio.h>
#include<iostream>

void trace(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			printf(" ");
		}
		printf("%d", a[i]);
	}
	printf("\n");
}

int selectSort(int a[], int n) {
	int min ,num=0,tag;//num记录交换次数
	for (int i = 0; i < n; i++) {
		int k = -1;//记录最小值的位置
		tag = 0;//标记a[i]是否是最小值，决定是否发生交换
		min = a[i];//记录最小值，默认是当前的a[i]
		for (int j = i; j < n; j++) {
			if (min > a[j]) {
				min = a[j];
				k = j;
				tag = 1;
			}
		}
		if (tag) {//如果a[i]不是min，则交换之
		int temp = a[i];
		a[i] = a[k];
		a[k] = temp;
		//trace(a,n);
		num++;
	}
	}
	return num;
}

int main() {
	int n, i, j;
	int a[100];

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

		
		int m = selectSort(a, n);
		trace(a, n);
		printf("%d\n", m);
	

	return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> d;
  vector<vector<pair<int, LL>>> t;
  Solver(LL n) : n(n), d(n), t(n){};

  void solve() {
    for (int i = 0; i < n - 1; ++i) {
      int u, v, w;
      cin >> u >> v >> w;
      t[--u].emplace_back(--v, w);
      t[v].emplace_back(u, w);
    }
    dfs(0);
    for (int i = 0; i < n; ++i) {
      cout << d[i] % 2 << endl;
    }
  }
  void dfs(int c, int p = -1, LL depth = 0) {
    d[c] = depth;
    for (auto e : t[c]) {
      if (e.first != p) {
        dfs(e.first, c, depth + e.second);
      }
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 9216
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).expect("Failed to read line\n");
    let s = input.trim().to_string().chars().collect::<Vec<_>>();

    input = "".to_string();
    io::stdin().read_line(&mut input).expect("Failed to read line\n");
    let t = input.trim().to_string().chars().collect::<Vec<_>>();
    
    let mut cnt=0;
    for i in 0..3 {
        if s[i]==t[i] {
            cnt+=1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<functional>

using namespace std;

//typedef pair<int, int> P;
typedef long long int ll;

int N;


int main() {
	cin >> N;
	vector<string> S(N);
	vector<int> P(N, 0);
	vector<int> ans(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> S[i] >> P[i];
	}
	int next;
	for (int i = 0; i < N; i++) {
		next = 0;
		for (int j = 1; j < N; j++) {
			if (S[next] > S[j]) { next = j; }
			else if (S[next] == S[j]) {
				if (P[next] < P[j]) { next = j; }
			}
		}
		ans[i] = next+1;
		S[next] = "zzzzzzzzzzzz";
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>d(N);
	rep(i, N)cin >> d[i];
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d.size() << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n, m = map(int, input().split())
a = list(map(int, input().split()))

# マッチと数字の対応表を作る
match = [2, 5, 5, 4, 5, 6, 3, 7, 6]
mat = []
for i in range(m):
    mat.append((match[a[i]-1], a[i]))

d = defaultdict(int)
for ma, num in mat:
    d[ma] = max(d[ma], num)

# dp[i]: マッチをi本使ってできる整数のケタの最大値
INF = float('inf')
dp = [-INF] * (n+10)
dp[0] = 0

for i in range(n):
    if dp[i] == -INF:
        continue
    for ma, num in mat:
        if dp[i] + 1 > dp[i+ma]:
            dp[i+ma] = dp[i] + 1

mat.sort(key=lambda x: x[1], reverse=True)

# 経路復元
ans = ""
i = n
while i > 0:
    for ma, num in mat:
        if i - ma < 0:
            continue
        if dp[i] == dp[i-ma] + 1:
            ans += str(num)
            i -= ma
            break

print(ans)


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
long long h,w,ans;
int main(){
	scanf("%lld%lld",&h,&w);
	if(h==1||w==1){
		printf("1");
		return 0;
	}
	ans+=(h/2)*w;
	if(h&1){
		if(w&1)
			ans+=(w/2)+1;
		else
			ans+=(w/2);
	}
	printf("%lld",ans);
	return 0;
}

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

 const int INF = 1e9+7;

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	for(int i=0; i<m; i++){
		cin >> a.at(i);
	}
	long long dp[100100];
	for(int i=0; i<=n; i++){
		dp[i] = 0;
	}

	dp[0] = 1;
	for(int i=0; i<m; i++){
		dp[a.at(i)] = -1;
	}
	for(int i=0; i<n; i++){
		if(dp[i] < 0) continue;
		if(dp[i+1] >= 0){
			dp[i+1] += dp[i];
			dp[i+1] %= INF;
		}
		if(dp[i+2] >= 0){
			dp[i+2] += dp[i];
			dp[i+2] %= INF;
		}
	}
	cout << (dp[n]<0?0:dp[n]) << endl;
}

Measured memory_bytes: 1408
<?php


fscanf(STDIN, "%d", $n);

$math = explode(" ", trim(fgets(STDIN)));
$now = $math[$n-1];
for($i = $n -1; $i >= 0; $i--){
    if($math[$i]<= $now){
        $now = $math[$i];
    }elseif($math[$i] - 1 != $now){
        echo "No";
        exit;
    }
}
echo "Yes";

Measured memory_bytes: 14840
from bisect import bisect_right as bl
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

At=[0]
Bt=[0]

for i in range(N):
    At.append(At[-1]+A[i])
for j in range(M):
    Bt.append(Bt[-1]+B[j])
ans=0
for k in range(N+1):
    temp=k+bl(Bt,K-At[k])-1
    if K-At[k]>=0:
        ans=max(ans,temp)
print(ans)

Measured memory_bytes: 47696
import sys
n=int(input())
t=[]
for i in range(n):
    t.append(list(map(int,input().split())))
for i,d in enumerate(t):
    if i>0:
        b=d[0]-a
        c=abs(d[1]+d[2]-aa)
    a=d[0]
    aa=d[1]+d[2]
    if i==0:
        if not (a >= aa and a % 2 == aa % 2):
            print('No')
            sys.exit()
        else:
            continue
    if not (b>=c and b%2==c%2):
        print('No')
        sys.exit()
print('Yes')

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

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

  set<int> d;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    d.insert(tmp);
  }

  cout << d.size() << endl;
}

Measured memory_bytes: 3616
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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 mut x: u64 = read();
    let mut ans: u64 = 0;
    while x >= 500 {
        x -= 500;
        ans += 1000;
    }
    while x >= 5 {
        x -= 5;
        ans += 5;
    }
    println!("{}", ans);
}


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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector<int> a(4, 0);
  rep(i, N) {
    string s;
    cin >> s;
    if (s ==  "AC")
      a[0]++;
    else if (s == "WA")
      a[1]++;
    else if (s == "TLE")
      a[2]++;
    else
      a[3]++;
  }
  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
        string s;
        cin >> s;
        //sort(s.begin(),s.end());
        for(int i =0;i<4;i++){
                if(s[i]==s[i+1]){
                        cout << "Bad" << endl;
                        return 0;
                }
        }
        cout << "Good" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a[3];
	int b[3];
	int num[4] = { 0,0,0,0 };
	bool ans = false;
	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i < 3; i++) {
		num[a[i]-1]++;
		num[b[i]-1]++;
	}

	for (int i = 0; i < 4; i++) {
		if (num[i] == 3)ans = true;
	}
	if (ans)printf("NO");
	else printf("YES");
	return 0;
}

Measured memory_bytes: 888
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans_idx = min(j - i, abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1)
        ans[ans_idx] += 1
[print(x) for x in ans[1:]]


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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const ll inf=2e18;
ll a[3],b[3];

int main(){
	io;
	cin>>a[1]>>a[2]>>b[1]>>b[2];
	ll ans=-inf;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=2;j++){
			ans=max(ans,a[i]*b[j]);
			// dbg(ans);
		}
	cout<<ans<<endl;
}

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

int main() {
int N, T , c[1000], t[1000];
cin >> N >> T;
int ans=10000;
for (int i = 0; i < N; ++i) {
cin >> c[i] >> t[i];
if (t[i] <= T) {
ans = min(ans,c[i]);
} 
}
if (ans == 10000) {
cout << "TLE" << endl;
}
else {
cout << ans << endl ; 
}
}

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

signed main(){
  string S;
  cin>>S;
  int ans=700;
  rep(i,3)if(S[i]=='o')ans+=100;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;

const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main()
{
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";


    return 0;
}

Measured memory_bytes: 3616
from collections import Counter

s = input()
mod1 = 673
mod2 = 3

num1 = 0
num2 = 0
li1 = []
li2 = []
pw1 = 10
pw2 = 10
for i, e in enumerate(s, 1):
    num1 *= 10
    num1 += int(e)
    num1 %= mod1
    inv = pow(pw1, mod1 - 2, mod1)
    li1.append(num1 * inv % mod1)

    num2 *= 10
    num2 += int(e)
    num2 %= mod2
    inv = pow(pw2, mod2 - 2, mod2)
    li2.append(num2 * inv % mod2)

    pw1 *= 10
    pw1 %= mod1
    pw2 *= 10
    pw2 %= mod2

li = [0] + [10 * e1 + e2 for e1, e2 in zip(li1, li2)]
c = Counter(li)

ans = 0
for v in c.values():
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 26036
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define psi std::pair<string,int>
#define pli std::pair<ll,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%I64d",&x)
#define prll(x) printf("%I64d ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vli std::vector<std::list<int>>
#define vlpi vector<list<pii>>
#define li std::list<int>
#define Endl printf("\n")
#define ma 1000000
#define mod 786433
#define FOR(i,a) for(int i=0; i<a; i++)
#define FORL(i,a) for(ll i=0; i<a; i++)


using namespace std;


int main()
{
    ll n ; cin >> n ;
    vll t ;
    FORL(i,n){
        ll x ;
        cin >> x ;
        t.pb(x) ;
    }

    ll s=0 ;
    ll r =0 ;
    if (n==1)
        cout << 0 ;
    else {
    FOR(i,n-1) {
        if (t[i]>=t[i+1]){
            s++ ;
            r=max(s, r) ;
        }
        else
        s=0 ;
    }

    cout << r ;
    }
}









Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

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

  int n,m;
  cin >> n >> m;
  
  vector<long> a(n),b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }

  vector<long> c(m),d(m);
  for(int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }
  for(int i = 0; i < n; i++){
    long mins = 1000000000;
    int ans = 0;
    for(int j = 0; j < m; j++){
      if(mins > abs(a[i] - c[j]) + abs(b[i] - d[j])){
        mins = abs(a[i] - c[j]) + abs(b[i] - d[j]);
        ans = j + 1;
      }
    }
  cout << ans << endl;
  }
}

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

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

  string S, T;
  int A, B;

  cin >> S >> T >> A >> B;

  string U;
  cin >> U;

  if(U == S) --A;
  if(U == T) --B;

  cout << A << " " << B << '\n';

  return 0;
}

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

int main(){
	int n,m;
	string s;
	while(cin>>n,n){
		cin>>m>>s;
		int ans=0,c=0;
		for(int i=0;i<s.size();i++){
			if(c%2&&s[i]=='O' || c%2==0&&s[i]=='I')c++;
			else c=0;
			if(2*n+1<=c&&c%2)ans++;
			if(c==0&&s[i]=='I')c=1;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
  ll N,M;
  cin >> N >> M;
  ll K = ll(pow(2,N));
  vector<ll> dp(K, 1e9);
  dp[0] = 0;
  ll i,j,k,l;
  ll a,b;
  ll t;
  for(i=0;i<M;i++){
    cin >> a >> b;
    k = 0;
    for(j=0;j<b;j++){
      cin >> t;
      l = 1;
      l = l << (t-1);
      k = k|l;
    }
    for(j=0;j<K;j++){
      if(j|k < K){
        if(dp[j|k] > dp[j] + a) dp[j|k] = dp[j] + a;
      }
    }
  }
  if(dp[K-1] == 1e9) cout << -1;
  else cout << dp[K-1];
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k;
int a[200000];
int b[100];
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = 0; j <= 40; j++) {
			if ((1ll << j) & a[i]) {
				b[j]++;
			}
		}
	}
	int ans = 0;
	for (int i = 39; i >= 0; i--) {
		if (!((1ll << i) & k)) continue;
		int sum = 0;
		for (int j = i + 1; j < 40; j++) {
			if (k & (1ll << j)) {
				sum += (n - b[j]) * (1ll << j);
			}
			else {
				sum += b[j] * (1ll << j);
			}
		}
		sum += (1ll << i) * b[i];
		for (int j = 0; j < i; j++) {
			sum += (1ll << j) * max(b[j], n - b[j]);
		}
		ans = max(ans, sum);
	}
	int res = 0;
	for (int i = 0; i < 40; i++) {
		if ((1ll << i) & k) {
			res += (n - b[i]) * (1ll << i);
		}
		else {
			res += b[i] * (1ll << i);
		}
	}
	cout << max(ans, res) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    ll t;
    cin >> n >> t;
    ll tt[n], sum = 0;
    rep(i, n) cin >> tt[i];
    rep(i, n-1){
        sum += min(tt[i+1] - tt[i], t);
    }
    sum += t;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    string s, t;
    cin >> s;

    for (char c: s) {
        if (c=='0' || c=='1') {
            t.push_back(c);
        } else if (c=='B' && t.size()) {
            t.erase(t.end()-1);
        }
    }
    cout << t << endl;
    return 0;
}


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

using namespace std;

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

  long long ans = 0;
  for (int i = 1;i < N+1;i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }

  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin>>n;
    int dp[n] = {0};
    vector<int> h(n);
    for(int i=0; i<n; i++) cin>>h[i];
    for(int i=1; i<n; i++) {
        if(i == 1) {
            dp[i] = abs(h[i] - h[i-1]);
        }
        else {
            dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
        }
    }
    cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		int a=stdin.nextInt();
		int b=stdin.nextInt();
		int c=stdin.nextInt();
		if(c-b<=0) {
			System.out.println("delicious");
		} else if(c-b<=a) {
			System.out.println("safe");

		}else {
			System.out.println("dangerous");

		}
		

	}

}


Measured memory_bytes: 23764
N=input()
K=int(input())
S="0"*(100-len(N))+N
DP=[[[0]*2 for _ in range(K+2)] for _ in range(101)]

DP[0][0][0] = 1
for i in range(100):
  for j in range(K+1):
    #SがN以下かわからないまま、「0」の文字をなぞるとき、0でない数字jはそのまま
    if S[i]=='0':
      DP[i+1][j][0]+=DP[i][j][0]
      
    #SがN以下かわからないまま、「0」以外の文字をなぞるとき、0でない数字jも+1
    else:
      DP[i+1][j+1][0]+=DP[i][j][0]
    
    #SがN以下が確定している　
    DP[i+1][j][1]+=sum(DP[i][j])
    if int(S[i])==0:
      #あとは数字が同じとはいえ000…と埋めるしかないパターン
      DP[i+1][j][1]-=DP[i][j][0]
      
    #SがN以下が確定しているものは、1~9をくっつけたものと、同じ桁だけどより低い数字が来たとき
    DP[i+1][j+1][1] += DP[i][j][1]*9+DP[i][j][0]*(max(0, int(S[i])-1))
    
print(DP[-1][K][0]+DP[-1][K][1])

Measured memory_bytes: 3064
n, y = list(map(int, input().split()))

for i in range(0, n+1):     # 10000円の枚数 = i
  for j in range(0, n-i+1):
    if y == 10000 * i + 5000 * j + 1000 * (n - i - j):
     print(i, j, n-i-j)
     exit()

print(-1, -1, -1)

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
  cin >> A.at(i);
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
  if(A.at(i) >= K){
  ans +=1;
  }
  }
  cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int A, B, M, min_a=100001, min_b=100001, x, y, c;
    cin >> A >> B >> M;

    int a[A], b[B], min_v = 300000;
    REP(i, A){
        cin >> a[i];
        min_a = min(min_a, a[i]);
    }
    REP(i, B){
        cin >> b[i];
        min_b = min(min_b, b[i]);
    }

    min_v = min_a + min_b;

    REP(i, M){
        cin >> x >> y >> c;
        x--; y--;
        min_v = min(min_v, a[x]+b[y]-c);
    }

    cout << min_v << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    ans=[]
    for s in input():
        k=(ord(s)-ord('A')+n)%26+ord('A')
        ans.append(chr(k))

    print(''.join(ans))
resolve()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
using P = pair<int, int>;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> ng(N);
    // (x, j) -> jはx個のngをもつ
    set<P, greater<P>> ngs;
    set<int> cards;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        a--;
        A[i] = a;
        ng[a]++;
        cards.insert(i);
    }
    for(int i = 0; i < N; i++) {
        ngs.insert({ng[i], i});
    }
    vector<int> ans;
    // 最後のカード
    int l = -1;
    for(int n = N - 1; n >= 0; n--) {
        P p = *ngs.begin();
        int j;
        if(p.first == n) { // 先端にしないといけないやつ
            j = p.second;
        } else {
            bool cycle_flag = false;
            if(n == 2) {
                // 循環が起きそうなら排除
                for(int a : cards) {
                    for(int b : cards) {
                        if(A[a] == b && A[b] == a) {
                            for(int i : {min(a,b), max(a,b)}) {
                                if(l < 0 || A[l] != i) {
                                    j = i;
                                    break;
                                }
                            }
                            cycle_flag = true;
                        }
                    }
                }
            }
            if(!cycle_flag) { // 先端を辞書順最小で決める
                for(int i : cards) {
                    if(l < 0 || A[l] != i) {
                        j = i;
                        break;
                    }
                }
            }
        }
        // カードjを取り出す
        ans.push_back(j);
        cards.erase(j);
        ngs.erase({ng[j], j});
        int k = A[j];
        if(ngs.count({ng[k], k})) {
            ngs.erase({ng[k], k});
            ng[k]--;
            ngs.insert({ng[k], k});
        }
        l = j;
    }

    // validate
    for(int i = 0; i < N - 1; i++) {
        if(A[ans[i]] == ans[i + 1]) {
            cout << -1 << endl;
            return 0;
        }
    }

    string delim = "";
    for(int a : ans) {
        cout << delim << a + 1;
        delim = " ";
    }
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b;
    cin >> a >> b;
    cout << max<int32>(a - 2 * b, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	x := ((n-m)*100 + 1900*m) * (1 << uint(m))
	fmt.Fprintln(writer, x)

	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)
#define SORT(a) std::sort((a).begin(), (a).end())
typedef std::vector<long> VL;

int N, K;
VL a;

int main() {
    std::cin >> N >> K;
    a.resize(N);
    REP(i, N) std::cin >> a[i];

    SORT(a);

    int sum = 0;
    int ans = N;
    RREP(i, N-1) {
        if(sum + a[i] < K) {
            sum += a[i];
        } else {
            ans = i;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A=[]
B=[]
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

C=[0]*(N+1)

for i in range(M):
    C[A[i]]+=1
    C[B[i]]+=1

for i in range(1,N+1):
    print(C[i])

Measured memory_bytes: 9096
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] list = new int[n];

        int ans = 0;
        for (int i = 0 ; i < n; i ++) {
            int value = sc.nextInt();
            boolean canLookSea = true;
            for(int left : list) {
                if (left > value) {
                    canLookSea = false;
                    break;
                }
            }
            if (canLookSea) {
                ans++;
            }
            list[i] = value;
        }
        // 出力
        System.out.println(ans);
    }
}

Measured memory_bytes: 21840
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <queue>
#include <iostream>
#include <string>
using namespace std;



int main()
{
	string s;
	cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() - 1 - i])cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    loop {
        let (n, x) = {
            let i = read::<usize>();
            (i[0], i[1])
        };
        if n + x == 0 { return; }
        else { println!("{}", solve(n, x)); }
    }
}

fn solve(n: usize, x: usize) -> usize {
    let mut cnt = 0;
    for i in 1..n+1 { for j in i+1..n+1 { for k in j+1..n+1 {
        if i + j + k == x { cnt += 1; }
    }}}
    cnt
}

#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 5028
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int l[100006], r[100006];
vector<P>V;

int seg(int a1, int a2, int b1, int b2) {
	int s1 = a2 - a1 + 1;
	int s2 = b2 - b1 + 1;
	if (s1 < 0)s1 = 0; if (s2 < 0)s2 = 0;
	return s1 + s2;
}

signed main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> l[i] >> r[i];
		V.push_back(P(r[i], l[i]));
	}
	sort(V.begin(), V.end());
	rep(i, n) {
		l[i] = V[i].second;
		r[i] = V[i].first;
	}

	set<P>L1, L2, R1, R2;
	rep(i, n) {
		L1.insert(P(l[i], i));
		R1.insert(P(r[i], i));
	}
	int ans = 0;
	rep(i, n - 1) {
		L1.erase(P(l[i], i));
		R1.erase(P(r[i], i));
		L2.insert(P(l[i], i));
		R2.insert(P(r[i], i));
		int x1, y1, x2, y2;
		x1 = L1.rbegin()->first;
		y1 = R1.begin()->first;
		x2 = L2.rbegin()->first;
		y2 = R2.begin()->first;
		ans = max(ans, seg(x1, y1, x2, y2));
	}

	rep(i, n) {
		V[i] = P(l[i], r[i]);
	}

	sort(V.begin(), V.end());
	rep(i, n) {
		l[i] = V[i].first;
		r[i] = V[i].second;
	}

	set<P>L3, L4, R3, R4;
	rep(i, n) {
		L3.insert(P(l[i], i));
		R3.insert(P(r[i], i));
	}

	rep(i, n - 1) {
		L3.erase(P(l[i], i));
		R3.erase(P(r[i], i));
		int x1, y1, x2, y2;
		x1 = L3.rbegin()->first;
		y1 = R3.begin()->first;
		x2 = l[i];
		y2 = r[i];
		ans = max(ans, seg(x1, y1, x2, y2));
		L3.insert(P(l[i], i));
		R3.insert(P(r[i], i));
	}

	cout << ans << endl;

}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;

	int c =0 ; 
	vi a(3);
	for(int i = 0 ; i<3 ; i++){
		cin>>a[i];
	}

	sort(all(a));
	for(int i = 1 ; i<3 ; i++){
		c+=abs(a[i]-a[i-1]);
	}
	cout<<c;






	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int mx = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h >= mx) ans++;
    mx = max(mx, h);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define inf 100000000
#define _GLIBCXX_DEBUG
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int main(){
    int h,w;
    cin >>h>>w;
    vector<string> a(h);
    rep(i,h){
        cin >>a[i];
    }
    vector<bool> row(h,false);
    vector<bool> column(h,false);
    rep(i,h){
        rep(j,w){
            if (a[i][j]=='#'){
                row[i]=true;
                column[j]=true;
            }
                }
    }
    rep(i,h){
        if (row[i]){
            rep(j,w){
                if (column[j]){
                    cout <<a[i][j];
                }
            }
            cout<<endl;
        }
    }
    
}

Measured memory_bytes: 256
import math

def decompose(d, n):
    limit = (int)(math.sqrt(n)) + 1
    for i in range(2, limit):
        while n % i == 0:
            if i not in d:
                d[i] = 0
            d[i] += 1
            n //= i
    if n != 1:
        if n not in d:
            d[n] = 0
        d[n] += 1

def main():
    N = int(input())
    D = {}
    for i in range(2, N + 1):
        decompose(D, i)
    f2, f4, f14, f24, f74 = 0, 0, 0, 0, 0
    for d in D:
        n = D[d]
        if n >= 74:
            f74 += 1
        if n >= 24:
            f24 += 1
        if n >= 14:
            f14 += 1
        if n >= 4:
            f4 += 1
        if n >= 2:
            f2 += 1
    # print(D, f2, f4, f14, f24, f74)
    if f2 == 0 or f4 < 2:
        print(0)
        return
    # 75
    ans = f74
    # 25 * 3
    ans += f24 * (f2 - 1)
    # 15 * 5
    ans += f14 * (f4 - 1)
    # 5 * 5 * 3
    ans += f4 * (f4 - 1) // 2 * (f2 - 2)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if((i%2&&s[i]=='R')||((i%2==0)&&s[i]=='L'))
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define double long double
#define int long long
#define inf 1000000007 
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define rep(i,n) for(int i=0;i<n;i++)
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int h,w,cnt=0,ans=0;
int a[514][514],b[514][514];
signed main() {
  cin>>h>>w;
  rep(i,h) {
    rep(j,w) {
      scanf("%Ld",&a[i][j]);
      if(a[i][j]%2) cnt++;
      b[i][j]=a[i][j];
    }
  }
  if(cnt<2) cout<<0<<endl;
  else {
    cnt=0;
    rep(i,h) {
      rep(j,w) {
        int k=w-j-1;
        if(i%2) {
          if(a[i][k]%2) {
            if(k==0) {
              if(i==h-1) goto n;
              a[i+1][k]++;
              cnt++;
            }
            else {
              a[i][k-1]++;
              cnt++;
            }
          }
        }
        else {
          if(a[i][j]%2) {
            if(j==w-1) {
              if(i==h-1) goto n;
              a[i+1][j]++;
              cnt++;
            }
            else {
              a[i][j+1]++;
              cnt++;
            }
          }
        }
      }
    }
    n:;
    cout<<cnt<<endl;
    rep(i,h) {
      rep(j,w) {
        int k=w-j-1;
        if(i%2) {
          if(b[i][k]%2) {
            if(k==0) {
              if(i==h-1) return 0;
              printf("%lld %lld %lld %lld\n",i+1,k+1,i+2,k+1);
              b[i+1][k]++;
            }
            else {
              printf("%lld %lld %lld %lld\n",i+1,k+1,i+1,k);
              b[i][k-1]++;
            }
          }
        }
        else {
          if(b[i][j]%2) {
            if(j==w-1) {
              if(i==h-1) return 0;
              printf("%lld %lld %lld %lld\n",i+1,j+1,i+2,j+1);
              b[i+1][j]++;
            }
            else {
              printf("%lld %lld %lld %lld\n",i+1,j+1,i+1,j+2);
              b[i][j+1]++;
            }
          }
        }
      }
    }
  }
}


Measured memory_bytes: 6144
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    println!("{}", if N == M { "Yes" } else { "No" })
}


Measured memory_bytes: 4476
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> M(H);
  for(int i = 0; i < H; i++) cin >> M[i];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if (M[i][j] == '.') continue;
      bool flag = false;
      for(int k = 0; k < 4; k++) {
      	int tx = j + dx[k];
        int ty = i + dy[k];
        if (tx < 0 || tx >= W || ty < 0 || ty >= H) continue;
        if (M[ty][tx] == '#') {
          flag = true;
        }
      }
      if (!flag) {
      	cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import           Data.Char

solve :: [Int] -> Int -> String
solve [] _     = ""
solve [x] n    = [chr ((x+n)`mod`26 + ord 'a')]
solve (x:xs) n = if n < (26 - x) `mod` 26
  then chr (x + ord 'a') : solve xs n
  else 'a' : solve xs (n - ((26 - x) `mod` 26))

main :: IO ()
main = do
  s <- map (\c -> ord c - ord 'a') <$> getLine
  k <- readLn
  putStrLn $ solve s k


Measured memory_bytes: 5116
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: usize,
    }
    let odds = if k % 2 == 0 {
        k / 2
    } else {
        k / 2 + 1
    };
    let evens = k / 2;
    println!("{}", odds * evens);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;
const int mxN = 1e5 + 9;

ll ar[mxN];


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N;
	cin >> N;
	for(int i=1; i <= N; i++){
        cin >> ar[i];
        if( ar[i] == 0 ){
            cout << 0; return 0;
        }
	}
    ll ans = 1;
    const ll MX = 1e18;
    for(int i=1; i <= N; i++){
        if( ar[i] <= ( MX / ans ) ){
            ans *= ar[i];
        }
        else{
            cout << -1; return 0;
        }
    }
    cout << ans;




}



Measured memory_bytes: 4420