akhauriyash/Code-Regression huggingface dataset:
-- Generates the sequence of prime numbers.
-- Based on http://qiita.com/little_Haskeller/items/614a3ae20a517c19bb1f
primes :: Integral a => [a]
primes = map fromIntegral primes'
    where
        primes' = [2, 3, 5] ++ sieve2 5 7 (drop 2 primes')
        sieve2 m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ sieve2 (m * p) (p * p) ps
            where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]

--  Judges whether the given integer is a prime number or not.
--  Based on https://wiki.haskell.org/Testing_primality
isPrime :: Integral a => a -> Bool
isPrime n = n > 1 && foldr (\p r -> p * p > n || ((mod n p) /= 0 && r)) True primes

smallerPrime :: Integral a => a -> a
smallerPrime n = maximum $ takeWhile (< n) primes

largerPrime :: Integral a => a -> a
largerPrime n
    | odd n  = head [p | k <- [2, 4 ..], let p = n + k, isPrime p]
    | even n = head [p | k <- [1, 3 ..], let p = n + k, isPrime p]

main :: IO ()
main = putStr . unlines . map unwords . map (map show) .
    map (\n -> [smallerPrime n, largerPrime n]) . map read . lines =<< getContents

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D){
        cout << "Left" << endl;
    } else if (A + B < C + D){
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}

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

int main(){
    ll n,k;
    cin >> n >> k;
    n = min(n,n%k);
    n = min(n,abs(n-k));
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000


int main(){
	
	int K,N;
	cin>>K>>N;
	
	vector<int> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	int ans = 0;
	for(int i=0;i<N-1;i++){
		ans = max(ans,A[i+1]-A[i]);
	}
	
	ans = max(ans,A[0]+K-A.back());
	
	cout<<K-ans<<endl;
	
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> m;
  rep(i, n) m[a[i]]++;
  in(int, q);
  ll sum = accumulate(all(a), 0LL);
  while (q--) {
    in(ll, b, c);
    auto it = m.find(b);
    if (it == m.end()) {
      out(sum);
      continue;
    }
    ll diff = (c - it->first) * it->second;
    sum += diff;
    out(sum);
    m[c] += it->second;
    m.erase(it);
  }
  /*
  ll ans = 0;
  for (auto [k, v] : m) {
    ans += k * v;
  }
  out(ans);
  */
}


Measured memory_bytes: 7956
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll m, n, mod = 1e9 + 7, a = 1;
	cin >> n >> m;
	if (n == m) {
		for (int i = 1; i <= n; i++) {
			a *= i;
			a %= mod;
		}
		a *= a;
		a %= mod;
		a *= 2;
		a %= mod;
	}
	else if (abs(n - m) == 1) {
		for (int i = 1; i <= min(n, m); i++) {
			a *= i;
			a %= mod;
		}
		a *= a;
		a %= mod;
		a *= max(n, m);
		a %= mod;
	}
	else a = 0;
	cout << a << endl;
	return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

int main(){
    int n; cin >> n;
    ll mid, mid1, sum = 0, sum1 = 0;
    vector<ll> lis(n);
    REP(i, 0, n){
        ll c; cin >> c;
        lis[i] = c-(i+1);
    }
    sort(ALL(lis));
    if(n % 2 == 1){
        mid = lis[n/2];
        REP(i, 0, n){
            sum += abs(lis[i] - mid);
        }
    }else{
        mid = (lis[n/2] + lis[n/2-1]) / 2;
        mid1 = (lis[n/2] + lis[n/2-1] + 1) / 2;
        REP(i, 0, n){
            sum += abs(lis[i] - mid);
            sum1 += abs(lis[i] - mid1);
        }
        sum = max(sum, sum1);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = N*A;
    System.out.println(B > C ? C : B);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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 int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
    int n;
    cin >> n;
    vector<vector<ll>> dis(n, vector<ll>(n));
    for(int i = 0; i < n; i++)for(int j = 0; j < n; j++) {
        cin >> dis[i][j];
    }
    vector<vector<ll>> predis = dis;
    for(int k = 0; k < n; k++) {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                chmin(dis[i][j], dis[i][k]+dis[k][j]);
            }
        }
    }
    bool ok = true;
    for(int i = 0; i < n; i++)for(int j = 0; j < n; j++)if(predis[i][j] != dis[i][j]) ok = false;
    if(!ok) {
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            bool flag = true;
            for(int k = 0; k < n; k++) {
                if(i == k || k == j) continue;
                if(dis[i][k]+dis[k][j]==dis[i][j]) flag = false;
            }
            if(flag) ans += dis[i][j];
        }
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 1664
use std::cmp::Ordering;
use std::collections::BinaryHeap;
const INF: i64 = std::i64::MAX;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[derive(PartialEq, Debug)]
struct MinInt {
    value: i64,
}

impl Eq for MinInt {}

impl PartialOrd for MinInt {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        other.value.partial_cmp(&self.value)
    }
}

impl Ord for MinInt {
    fn cmp(&self, other: &MinInt) -> Ordering {
        other.value.cmp(&self.value)
    }
}

fn make_pair(x: i64, y: usize) -> (MinInt, usize) {
    (MinInt { value: x }, y)
}

#[derive(Debug, Clone)]
struct Edge {
    to: usize,
    cost: i64,
}

fn solve(edges: &Vec<Vec<Edge>>, start_idx: usize, num_apexes: usize) -> Vec<i64> {
    let mut d = vec![INF; num_apexes];
    d[start_idx] = 0;
    let mut que = BinaryHeap::new();
    que.push(make_pair(0, start_idx));

    while let Some((u, v)) = que.pop() {
        if d[v] < u.value {
            continue;
        }
        for e in &edges[v] {
            if d[e.to] > d[v] + e.cost {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
    // println!("{:?}", d);
    d
}

fn main() {
    let n = read::<usize>();
    let mut edges: Vec<Vec<Edge>> = vec![Vec::new(); n];
    for i in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b, c) = (v[0] - 1, v[1] - 1, v[2] as i64);
        edges[a].push(Edge { to: b, cost: c });
        edges[b].push(Edge { to: a, cost: c });
    }
    let v = read_vec::<usize>();
    let (q, k) = (v[0], v[1] - 1);

    let d = solve(&edges, k, n);
    for i in 0..q {
        let v = read_vec::<usize>();
        let (x, y) = (v[0] - 1, v[1] - 1);
        println!("{}", d[x] + d[y]);
    }
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << ((fabs(c-a))<=d?"Yes":(fabs(b-a)<=d && fabs(c-b)<=d)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
mylist=[]
for i in range(n):
    s=input()
    mylist.append(s)
#print(mylist)
c=Counter(mylist)

#max=sum(x==max(mylist) for x in mylist)
answer=[]
flag=0
#print(max)
for word,i in c.most_common():
    #print(word,i)
    if flag==0:
        max=i
        flag+=1
        answer.append(word)
    else:
        if i==max:
            answer.append(word)
        else:
            break

answer.sort()
for i in range(len(answer)):
    print(answer[i])

Measured memory_bytes: 121808
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfLong()
    val BC = mutableListOf<Pair<Long, Long>>()
    for (n in 0 until N) BC.add(A[n] to 1)
    for (m in 0 until M) {
        val (b, c) = listOfLong()
        BC.add(c to b)
    }
    BC.sortByDescending { it.first }
    var ans = 0L
    var cnt = 0L + N
    for (n in 0 until BC.size) {
        if (cnt <= 0) break
        val C = Math.min(cnt, BC[n].second)
        ans += C * BC[n].first
        cnt -= C
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)

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

int N, M;
char g[105][105];
int cnt[26], val1, val2, val4;

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++) scanf("%s", &g[i]);
	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) cnt[g[i][j] - 'a']++;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			int ans = 1;
			if (i != N - i - 1) ans *= 2;
			if (j != M - j - 1) ans *= 2;
			if (ans == 1) val1++;
			else if (ans == 2) val2++;
			else val4++;
		}
	}
	val4 /= 4;
	val2 /= 2;
	for (int i = 0; i < 26; i++) {
		while (cnt[i] >= 4 && val4 > 0) {
			cnt[i] -= 4;
			val4--;
		}
		while (cnt[i] >= 2 && val2 > 0) {
			cnt[i] -= 2;
			val2--;
		}
		while (cnt[i] >= 1 && val1 > 0) {
			cnt[i] -= 1;
			val1--;
		}
	}
	if (val1 == 0 && val2 == 0 && val4 == 0) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
uses crt;
var
        g,h: array [0..100000] of longint;
        i,j,m,s,n: longint;

begin
        clrscr;
        readln (n);
        for i:=1 to n do read (g[i]);
        readln;

        fillchar (h, sizeof (h), 0);
        h[1]:=0;
        h[2]:= abs ( g[1] - g[2]);
        for i:=3 to  n do
        begin
                if (abs(g[i] - g[i-1]) + h[i-1]) > (abs(g[i] - g[i-2]) + h[i-2]) then
                h[i]:= abs(g[i] - g[i-2]) + h[i-2] else h[i]:= abs(g[i] - g[i-1]) + h[i-1];
        end;

        write (h[n]);
        readln;
end.

Measured memory_bytes: 896
<?php
fscanf(STDIN, "%d", $n);

$sum = 0;
for ($i=1; $i <= 1000000; $i++) {
  if ($i % 5 === 0 && $i % 3 === 0) {
  } elseif ($i % 3 === 0) {
  } elseif ($i % 5 === 0) {
  } else {
    $sum += $i;
  }

  if ($i === $n) {
    echo $sum;
    exit;
  }
}


Measured memory_bytes: 16220
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n,m,x;
	cin >> n >> m >> x;

  	vector<int> a(n+1,0);
	int num;
  	for(int i=0; i<m; i++){
		cin >> num;
      	a.at(num)=1;
    }  
	
  	int to0=0, toN=0;
  	for(int i=0; i<x; i++){
		to0 += a.at(i);
    }
  	for(int i=x; i<=n; i++){
		toN += a.at(i);
    }
  	cout << min(to0, toN) << endl;
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0] * (N)
for n in range(N-1):
    add = 1 if S[n:n+2] == "AC" else 0
    t[n+1] = t[n] + add
for q in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])


Measured memory_bytes: 7748
#include <stdio.h>

int f(int a,int b){
  int r;
  while(b>0){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}

int main(){
  int G,N,A;
  scanf("%d\n",&N);
  int D[1000001];
  int PC[1000001];
  for(int i=1;i<=1000000;i++){
    D[i]=1;
    PC[i]=0;
  }
  int p=2,k=2;
  while(p<=1000000){
    if(D[p]==1){
      D[p]=2;
      k=1;
      while(p*k<=1000000){
        D[p*k]=p;
        k++;
      }
    }
    p++;
  }
  for(int i=1;i<=N;i++){
    scanf("%d",&A);
    if(i==1) G=A;
    else G=f(G,A);
    while(A>1){
      p=D[A];
      PC[p]++;
      while(A%p==0) A/=p;
    }
  }
  int c=1;
  for(int i=1;i<=1000000;i++){
    if(PC[i]>1) c=0;
  }
  if(c==1) printf("pairwise coprime\n");
  else if(G==1) printf("setwise coprime\n");
  else printf("not coprime\n");
  return 0;
}

Measured memory_bytes: 9468
import sys
input = sys.stdin.buffer.readline

mod = 10**9+7
N = int(input())
adj = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a].append(b)
    adj[b].append(a)

st = [1]
seen = [0] * (N+1)
seen[1] = 1
child = [[] for _ in range(N+1)]
seq = []
while st:
    v = st.pop()
    seq.append(v)
    for u in adj[v]:
        if not seen[u]:
            seen[u] = 1
            st.append(u)
            child[v].append(u)
seq.reverse()

ans = 0
half = pow(2, mod-2, mod)
half_n = pow(half, N-1, mod)
dp = [1] * (N+1)
for v in seq:
    tmp = (1 - half_n)%mod
    tmp2 = 0
    for u in child[v]:
        dp[v] += dp[u]
        tmp2 = (tmp2 + ((1 - pow(half, dp[u], mod))%mod * pow(half, N-dp[u]-1, mod)) % mod) % mod
    if dp[v] < N:
        tmp2 = (tmp2 + ((1 - pow(half, N-dp[v], mod)) % mod * pow(half, dp[v]-1, mod)) % mod) % mod
    if child[v]:
        tmp = (tmp - tmp2) % mod
        ans = (ans + tmp) % mod

print((ans * half)%mod)


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

int main() {
	
	string n;
	int k;
	cin >> n >> k;
	int m = n.size();
	vector<vector<vector<int>>> dp(m,vector<vector<int>>(2,vector<int>(k+1)));
	dp.at(0).at(1).at(1) = n.at(0)-1-'0';
	dp.at(0).at(1).at(0) = 1;
	dp.at(0).at(0).at(1) = 1;
	for(int i=1; i<m; i++){
		for(int j=0; j<k+1; j++){
			if(j)dp.at(i).at(1).at(j) += 9*dp.at(i-1).at(1).at(j-1);
			dp.at(i).at(1).at(j) += dp.at(i-1).at(1).at(j);
			if(n.at(i)>'0'){
				if(j)dp.at(i).at(1).at(j) += ((n.at(i))-1-'0') * dp.at(i-1).at(0).at(j-1);
				dp.at(i).at(1).at(j) += dp.at(i-1).at(0).at(j);
			}
			if(n.at(i)>'0'){
				if(j)dp.at(i).at(0).at(j) += dp.at(i-1).at(0).at(j-1);
			}
			else{
				dp.at(i).at(0).at(j) += dp.at(i-1).at(0).at(j);
			}
		}
	}
	cout << dp.at(m-1).at(1).at(k)+dp.at(m-1).at(0).at(k) << endl;
	
}

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

int main()
{
  int n;
  double ans,a;
  cin >> n;
  REP(i,n){
    cin >> a;
    ans += 1 / a;
  }
  ans = 1 / ans;
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    string S, T;
    cin >> S >> T;

    ll sn = S.size(), tn = T.size();
    ll cnt = INF;
    rep(i, sn - tn + 1){
        string tmps = S.substr(i, tn);
        ll tmp = 0;
        rep(j, tn) if (tmps[j] != T[j]) tmp++;
        chmin(cnt, tmp);
    }

    cout << cnt << endl;
}   

Measured memory_bytes: 3648
import copy
n = int(input())
nums = []
for i in range(n):
  nums.append(int(input()))  

nums_sorted = sorted(nums)  
biggest = nums_sorted[-1]
second_biggest = nums_sorted[-2]
max_ind = nums.index(biggest)

if nums.count(biggest) == 1:
  for i in range(n):
    if i == max_ind:
      print(second_biggest)
    else:
      print(biggest)
else:
  for i in range(n):
    print(biggest)

Measured memory_bytes: 14556
N = int(input())

S1 = input()
S2 = input()

dom_list = []
flag=False
for i in range(N):
    if S1[i]==S2[i]:
        dom_list.append(0)
    else:
        if flag:
            dom_list.append(1)
            flag=False
        else:
            flag=True

D = [0]*len(dom_list)
if dom_list[0]==0:
    D[0]=3
else:
    D[0]=6

mod = 10**9 + 7

for i in range(1,len(dom_list)):
    if dom_list[i]==0:
        if dom_list[i-1]==0:
            D[i]=D[i-1]*2
            D[i]%=mod
        else:
            D[i]=D[i-1]
    else:
        if dom_list[i-1]==0:
            D[i]=D[i-1]*2
            D[i]%=mod
        else:
            D[i]=3*D[i-1]
            D[i]%=mod

print(D[len(dom_list)-1])

Measured memory_bytes: 38568
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, long long K){
    if(K > 1)
        cout << N-K<<endl;
    else
        cout << 0 <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


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



int main(){
    string s;
    cin >> s;
    if(s[0]==s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;
 
int main(){
 
  int k, n;
  cin >> k >> n;

  int minA = 1000000000, maxA = -1, temp, maxdiff = -1, A[n];

  for (int i = 0; i < n; ++i){
	  cin >> temp;
	  A[i] = temp;
	  if (i > 0)
	  maxdiff = max(maxdiff, A[i] - A[i - 1]);
	  minA = min(minA, temp);
	  maxA = max(maxA, temp);
  }

  int mindist = min(maxA - minA, k - (maxdiff) );
  cout << mindist << '\n';

  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

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

struct OwnVector2
{
	double x, y;
	OwnVector2(double x,double y):x(x),y(y){}
	OwnVector2() :OwnVector2(0, 0) {}
	OwnVector2 operator+(const OwnVector2& v)const
	{
		return OwnVector2(x + v.x, y + v.y);
	}
	OwnVector2 operator-(const OwnVector2& v)const
	{
		return OwnVector2(x - v.x, y - v.y);
	}
};

bool SegmentIntersection(OwnVector2 p1, OwnVector2 p2, OwnVector2 p3, OwnVector2 p4)
{
	OwnVector2 p12, p13, p14, p34, p31, p32;
	p12 = p2 - p1; p13 = p3 - p1; p14 = p4 - p1; p34 = p4 - p3; p31 = p1 - p3; p32 = p2 - p3;

	if (p1.x < p2.x)
	{
		if ((p3.x < p1.x&&p4.x < p1.x) || (p2.x < p3.x&&p2.x < p4.x))
		{
			return false;
		}
	}
	else
	{
		if ((p3.x < p2.x&&p4.x < p2.x) || (p1.x < p3.x&&p1.x < p4.x))
		{
			return false;
		}
	}
	if (p1.y < p2.y)
	{
		if ((p3.y < p1.y&&p4.y < p1.y) || (p2.y < p3.y&&p2.y < p4.y))
		{
			return false;
		}
	}
	else
	{
		if ((p3.y < p2.y&&p4.y < p2.y) || (p1.y < p3.y&&p1.y < p4.y))
		{
			return false;
		}
	}

	if ((p12.x*p13.y - p12.y*p13.x)*(p12.x*p14.y - p12.y*p14.x)>0)
	{
		return false;
	}
	if ((p34.x*p31.y - p34.y*p31.x)*(p34.x*p32.y - p34.y*p32.x)>0)
	{
		return false;
	}

	return true;
}

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

	int q;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		double x0, x1, x2, x3, y0, y1, y2, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		OwnVector2 p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);

		printf(SegmentIntersection(p0, p1, p2, p3) ? "1\n" : "0\n");
	}

	return 0;
}


Measured memory_bytes: 3300
s = list(input())
if s[0] == "A" and s[2:-1].count("C") == 1:
    s.remove("A")
    s.remove("C")
    s = "".join(s)
    if s.islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        StringBuilder sb = new StringBuilder();
        StringBuilder re = new StringBuilder();
        int index = 0;
        while (index < line.length()) {
            char c = line.charAt(index);
            if (c == ' ' || c == '.' || c == ',') {
                if (3 <= sb.length() && sb.length() <= 6) {
                    re.append(sb.toString() + " ");
                }
                sb.setLength(0);
            } else {
                sb.append(c);
            }
            index++;
        }
        if (sb.length() != 0) {
            if (3 <= sb.length() && sb.length() <= 6) {
                re.append(sb.toString() + " ");
            }
        }
        System.out.println(re.toString().trim());
    }
}


Measured memory_bytes: 24324
A, B = map(int, input().split())
digits = len(format(B, 'b'))
A -= 1
ans = 0
for k in range(digits):
    na = (A // (2 << k)) * (1 << k) + max(0, A % (2 << k) - (1 << k) + 1)
    nb = (B // (2 << k)) * (1 << k) + max(0, B % (2 << k) - (1 << k) + 1)
    x = (nb - na) % 2
    ans += x << k

print(ans)

Measured memory_bytes: 3064
while True:
    a, op, b = input().split()   # 3変数ともに文字列として読み込む
    a = int(a)                   # a を整数に変換
    b = int(b)                   # b を整数に変換
    if op==("?"):
        break
    if op==("+"):
        print(a+b)
    elif op==("-"):
        print(a-b)
    elif op==("*"):
        print(a*b)
    elif op==("/"):
        print(a//b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  double a;
  int A, B, C, D, E; 
 
 
  cin >> A >> B >> C;
 
  for (int i = A; i <= B; i++) {
   a = C;
   E = C;
   a /= i;
   E /= i;

   
   if (a == E) {
    D++;
   }
   
  }
 
  cout << D << endl;

return 0;
 
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int32_t main()
{
	string s;
	cin>>s;
	int n=s.length();
	int l=0,r=n-1;
	int ans=0;
	while(l<=r)
	{
		if(s[l]==s[r]){l++;r--;continue;}
		if(s[l]!=s[r])
		{
			if(s[l]!='x' and s[r]!='x')
			{
				cout<<-1;return 0;
			}
			if(s[l]=='x')
			{
				l++;ans++;
			}
			else
			{
				r--;ans++;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int N;
int L[2000];

int first,second;

int f(int begin,int end){
    if(end-begin<=1){
        if(first-second<L[begin]){
            return begin;
        }
        return end;
    }

    int c=(begin+end)/2;
    if(first-second<L[c]){
        f(begin,c);
    }else{
        f(c,end);
    }
}

int main(){
    cin>>N;
    rep(i,N) cin>>L[i];

    sort(L,L+N);

    //rep(i,N) cout<<L[i]<<' ';
    //cout<<endl;

    int ans=0;
    for(int i=N-1;i>=2;i--){
        for(int j=i-1;j>=1;j--){
            first=L[i];
            second=L[j];
            int s=f(0,j);
            //cout<<"i="<<i<<",j="<<j<<",s="<<s<<endl;
            ans+=j-s;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
X = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]
X.sort(key=lambda x: x[0])
ans = 0
for k in range(N):
    if M == 0:
        break
    buy = min(X[k][1], M)
    M -= buy
    ans += buy * X[k][0]
print(ans)


Measured memory_bytes: 22756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int answer = 0;
  int i = 0;
  while (1000 * i - N < 1000) {
    answer = 1000 * i - N;
    i++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <algorithm>
using namespace std;
 
const int NR = 1e5 + 10;
 
int n, a[NR];
 
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
 
	sort(a + 1, a + n + 1);
 
	int pos = a[n]; bool lst = 1;
 
	for (int i = n; i >= 1;) {
		int cnt = 0;
		for (; a[i - cnt] == a[i]; ++cnt);
		int len = a[i] - a[i - cnt] + cnt;
		if (pos - len < 0) {
		//	printf("!%d\n", pos);
			if (pos == 0 && cnt % 2 == 0) printf("%s\n", lst ? "First" : "Second");
			else printf("%s\n", (pos + cnt) % 2 == 1 ? "First" : "Second");
			break;
		}
		pos -= len;
		lst = (len + cnt) % 2;
		i -= cnt;
	}
 
	/*for (int i = 1; i <= n; ++i)
		b[i] = a[i] - a[i - 1] + 1;
 
	int pos = 0;
	for (int i = 1; i <= n; ++i) {
		//[0,a[i]-1]
		if (pos <= a[i] - 1 || (a[i] - 1 - pos) % 2 == 0)
			pos = a[i];
		else
			pos = a[i] - 1;
	}*/
 
	
	return 0;
}

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

int main(){
    string s,p;
    cin>>s>>p;
    s=s+s;
    if(s.find(p)!=-1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int x;cin>>x;
	if (x){
		cout << 0 << endl;
	}
	else{
		cout << 1 << endl;
	}
	return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


const int D = 86400;
const int H = 10800;
int xs[D*2];
int main(){
  int N; cin >> N;
  int sum = 0;
  for(int i=0;i<N;++i){
	int a, b; cin >> a >> b;
	(sum += a) %= D;
	xs[sum]++;
	(sum += b) %= D;
  }

  for(int i=0;i<D;++i)
	xs[i+D] = xs[i];

  sum = 0;
  for(int t=0;t<=H;++t){
	sum += xs[t];
  }
  int ans = sum;
  for(int b=0;b<D;++b){
	sum -= xs[b];
	sum += xs[b+H+1];
	ans = max(ans, sum);
  }

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


Measured memory_bytes: 896
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define Temp template<typename T>
using namespace std;
typedef long long LL;
Temp inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
const int maxn=500+10;
int n;
int c[maxn],s[maxn],f[maxn];
inline int ask(int t,int pos){
	int tim=t-s[pos];
	int mo=tim%f[pos],cn=tim/f[pos];
	if(mo==0)return t;
	else return (cn+1)*f[pos]+s[pos];
}
int main(){
	read(n);
	for(Rint i=1;i<n;i++){
		read(c[i]);read(s[i]);read(f[i]);
	}
	for(Rint i=1;i<=n;i++){
		int t=s[i],pos=i;
		while(pos<n){
			if(t<=s[pos])t=s[pos];
			t=ask(t,pos);
			t+=c[pos];
			pos++;
		}
		printf("%d\n",i==n?0:t);
	}
}


Measured memory_bytes: 256
s = input()
n = len(s)

res1 = 0
res2 = 0

for i in range(n):
  if i % 2 == 0:
    if s[i] == "0":
      res1 += 1
    else:
      res2 += 1
  else:
    if s[i] == "1":
      res1 += 1
    else:
      res2 += 1

print(min(res1,res2))

Measured memory_bytes: 9172
d_num = int(input())

graph = [[] for _ in range(d_num+1)]
for _ in range(d_num):
    u, k, *neighbors = map(int, input().split())
    graph[u] = neighbors

visited = set()
timestamps = [None for _ in range(d_num+1)]

def dfs(u, stmp):
    visited.add(u)
    entry = stmp

    stmp += 1
    for v in graph[u]:
        if v not in visited:
            stmp = dfs(v, stmp)

    timestamps[u] = entry, stmp
    return stmp+1

stmp = 1
for v in range(1, d_num+1):
    if v not in visited:
        stmp = dfs(v, stmp)

for num, (entry, leave) in enumerate(timestamps[1:], 1):
    print(num, entry, leave)


Measured memory_bytes: 5716
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int MAXN = 2e5 + 10;
const int mod = 998244353;

int f[MAXN];

int powmod(int a, int p) {
    if (p == 0) return 1;
    if (p == 1) return a % mod;
    int k = powmod(a, p / 2);
    if (p & 1) return (k * k % mod) * a % mod;
    return k * k % mod;
}

int rev(int x) {
    return powmod(x, mod - 2);
}

int C(int n, int k) {
    int ans = f[n];
    ans = (ans * rev(f[n - k])) % mod;
    ans = (ans * rev(f[k])) % mod;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        f[i] = (f[i - 1] * i) % mod;
    }
    int n, m, k;
    cin >> n >> m >> k;
    int ans = (powmod(m - 1, n - 1) * m) % mod;
    for (int i = 1; i <= k; i++) {
        ans += (C(n - 1, i) * m % mod) * powmod(m - 1, n - i - 1) % mod;
        ans %= mod;
    }
    cout << ans;
}
/*

*/  

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

int main(){
  int n , x , sum;
  double k;
  cin >> n >> k;
  sum = 0;
  
  for(int i = 0; i < n; i++){
    cin >> x;
    if(k/2 > x)
      sum += 2*x;
    else
      sum += 2*(k-x);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)

for i in range(n-1):
    if a[i]+1==a[i+1]:
        ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w, n;
    int sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    string s,t;
    cin >> s >> t;

    sr--;
    sc--;
    int flag = 0;
    //右で終わる場合：
    int pos = sc;
    
    for(int i=0; i<n; i++){
        //cout << pos << endl;
        if(s[i] == 'R'){
            pos = pos + 1;
        }
        if(pos >= w){
            //cout << "RIGHT" << endl;
            flag = 1;
            break;
        }
        if(t[i] == 'L'){
            if(pos!=0){
                pos --;
            }
        }
    }

    //左で終わる場合
    pos = sc;
    for(int i=0; i<n; i++){
        if(s[i] == 'L'){
            pos --;
        }
        if(pos < 0){
            //cout << "LEFT" << endl;
            flag = 1;
            break;
        }
        if(t[i]=='R'){
            if(pos != w-1){
                pos ++;
            }
        }
    }

    //上で終わる場合
    pos = sr;
    for(int i=0; i<n; i++){
        if(s[i]=='U'){
            pos--;
        }
        if(pos < 0){
            //cout << "UP" << endl;
            flag=1;
            break;
        }
        if(t[i]=='D'){
            if(pos!=h-1){
                pos++;
            }
        }
    }

    //下
    pos = sr;
    for(int i=0; i<n; i++){
        if(s[i]=='D'){
            pos++;
        }
        if(pos>=h){
            //cout <<"DOWN"<<endl;
            flag=1;
            break;
        }
        if(t[i]=='U'){
            if(pos != 0){
                pos--;
            }
        }
    }

    if(flag==1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }


    return 0;
}

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

int main()
{
    int m, n, a;
    map<int, int> M;
    cin >> m >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a;
        M[a]=1;
    }
    if(n==0 or M[m]!=1) cout << m;
    else
    {

        int z=m-1, y=m+1;
        while(true)
        {
            if(M[z]!=1) break;
            else z--;
        }
        while(true)
        {
            if(M[y]!=1) break;
            else y++;
        }
        int s = abs(z-m);
        int t = abs(y-m);
        if(s>t) cout << y;
        else    cout << z;
    }
}


Measured memory_bytes: 3636
n,*move=[int(input()) for i in range(6)]

#多分ボトルネックを超える時間数を使う
min_index=0
min_move=move[0]
for i in range(1,5):
    if min_move > move[i]:
        min_move=move[i]
        min_index=i

move_time=min_index

if n%min_move==0:
    move_time+=int(n/min_move)
else:
    move_time+=int(n/min_move)+1


move_time+=5-min_index-1
print(move_time)

Measured memory_bytes: 3064
import bisect
N, K = [int(_) for _ in input().split()]
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)])
b = [int(_) for _ in bin(K)[-1:1:-1]]
cand = [0]

ans = 0
for ab in AB:
    if ab[0] & ~K:
        continue
    ans += ab[1]

for p in range(K.bit_length()):
    q = K >> p
    if q & 1:
        r = (q << p) - 1
        now = 0
        for ab in AB:
            if ab[0] & ~r:
                continue
            now += ab[1]
        ans = max(ans, now)
print(ans)


Measured memory_bytes: 23320
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<ctime>
//#include<Windows.h>
using namespace std;
#define ll long long int
#define LL ll
#define INF 0x3f3f3f3f
const int maxn = 1e5 + 10;
const int maxm = 1e2 + 10;
const double eps = 1e-8;
int sz = 0;
int n, m, p, q, T;
int a[maxn];
int fa[maxn];
int vis[maxn];
int head[maxn];
struct edge {
	int to, nx;
	int w;
}e[maxn];
void add(int u, int v) {
	e[++sz].to = v;
	e[sz].nx = head[u];
	head[u] = sz;
}
void addw(int u, int v, int w) {
	e[++sz].to = v;
	e[sz].w = w;
	e[sz].nx = head[u];
	head[u] = sz;
}
void init();
int _find(int x) {
	if (fa[x] == x) return x;
	else return _find(fa[x]);
}
int get_fri(int x, int y) {
	int xx = _find(x);
	int yy = _find(y);
	if (xx == yy) return 0;
	else fa[xx] = yy;
	return 1;
}

int main()
{
	string str;
	cin >> str;
	int len = str.length();
	int res = 0;
	for (int i = 0; i < len; i++) {
		if (str[i] == 'o') res++;
	}
	if (15 - len + res >= 8) puts("YES");
	else puts("NO");
	//system("pause");
	return 0;
}


//_CRT_SECURE_NO_WARNINGS
void init() {
	for (int i = 1; i < maxn; i++) {
		fa[i] = i;
	}
	memset(vis, 0, sizeof vis);
	memset(head, -1, sizeof head); sz = 0;
}

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

int     main() {
        vector<char> C(4);
        string S="Yes";
        for (int i=0; i<4; i++) {
                cin >> C.at(i);
        }
        sort(C.begin(), C.end());
        if (C.at(0) != C.at(1)) S="No";
        if (C.at(2) != C.at(3)) S="No";
        if (C.at(1) == C.at(3)) S="No";
        cout << S << endl;
        return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc127_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int total = 0;

            if(A > 12)
            {
                total = B;
            }
            else if (A > 5)
            {
                total = B / 2;
            }

            Console.WriteLine(total);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define MODNUM (INT(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	VI h(n);
	REP(i, n) { scanf("%d", &h[i]); }
	sort(ALL(h), greater<int>());
	ll result = 0;
	RANGE(i, k, n) { result += h[i]; }
	printf("%lld\n", result);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int H, W ,K;
    cin >> H >> W >> K;
    vector<string> c(H);
    REP(i, H) cin >> c[i];
    int ans = 0;
    REP(bith, 1<<H) {
        REP(bitw, 1<<W) {
            int cnt = 0; 
            REP(i, H) {
                REP(j, W) {
                    if((bith>>i&1) & (bitw>>j&1)) {
                        if(c[i][j] == '#')cnt++;
                    }  
                }
            }
            if(cnt == K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
while True:
    n = int(input())
    if n == 0:
        break
    p = 1000-n
    
    c = 0
    for k in [500, 100, 50, 10, 5, 1]:
        if p == 0:
            break
        c += p // k
        p %= k
        
    print(c)
        
    


Measured memory_bytes: 5588
#include <complex>
#include <cstdio>
#include <cmath>
using namespace std;

// ?????§?¨?????????¨??????
typedef complex<double> P;
// ???????????
#define PI 3.1415926535898

// ?¨±?????????????????
#define EPS (1e-10)
//XY??§?¨?
#define X real()
#define Y imag()
	
// ????§???¢?????????
class Triangle{

private:
	//????§???¢??????????????§?¨?
	P a, b, c;
	//????§???¢??????????????????
	double edgeA,edgeB,edgeC;
	//????§???¢???????§??????§??????(????????¢???)
	double angleA,angleB,angleC;
	//????????????????????????????§????????±?????????¢??°
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	//?????????double????????°???????????????????????????
	bool equal(double a, double b){
		return (abs( a-b ) < EPS)? true : false ;
	}

public:
	//?????????????????????(??????????????¨?????¨?§????????????????)
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	
	double circumscribedCircleRadius(){//?????\?????????????????????
		return ( edgeA / sin(angleA) / 2.0 );
	}
	double circumscribedCircleX(){//??????(?????\????????????)???X??§?¨??????????
		double A = sin(2.0*angleA);
		double B = sin(2.0*angleB);
		double C = sin(2.0*angleC);
		return ( (a.X * A + b.X * B + c.X * C) / (A+B+C) );
	}
	double circumscribedCircleY(){//??????(?????\????????????)???Y??§?¨??????????
		double A = sin(2.0*angleA);
		double B = sin(2.0*angleB);
		double C = sin(2.0*angleC);
		return ( (a.Y * A + b.Y * B + c.Y * C) / (A+B+C) );
	}
};

int main(){
	int n;
	double x1, x2, x3, y1, y2, y3;
	double r, xp, yp;

	scanf("%d", &n);
	for (int i=0 ; i<n ; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		Triangle Tr(a,b,c);
		r  = Tr.circumscribedCircleRadius();
		xp = Tr.circumscribedCircleX();
		yp = Tr.circumscribedCircleY();
		printf("%.3f %.3f %.3f\n", xp,yp,r);
	}
}

Measured memory_bytes: 2880
S = input()
# 接尾辞の降順が崩れるタイミングが狙い目
if len(S) == 26:
    # 降順が崩れるタイミングを狙う
    pointa = -1
    for i in reversed(range(1, 26)):
        if ord(S[i]) > ord(S[i-1]):  # 後ろから見て降順が崩れたタイミング
            pointa = i-1
            break
    # 後ろからi-1文字目を書き換えればok
    if pointa != -1:
        happend = list(S[:pointa])  # ここに出ていないかつ, S[pointa]より大きい最小のもの
        for i in range(26):
            if chr(ord("a") + i) not in happend and ord("a")+i > ord(S[pointa]):
                target = chr(ord("a") + i)
                break
        print(S[:pointa]+target)
    else:
        print(-1)

else:
    # 1文字付け足すだけ
    happend = list(S)
    for i in range(26):
        if chr(ord("a") + i) not in happend:
            target = chr(ord("a") + i)
            break
    print(S+target)


Measured memory_bytes: 3064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool sente = true;
    while(a>0 && c>0) {
        if(sente) {
            c -= b;
        }else {
            a -= d;
        }
        sente = !sente;
    }
    if(a>0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624