akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

// res に文字列 text の中にある検索文字列 pattern のすべての一致箇所の開始位置が入る(0_indexed).
class KMP
{
public:
    string pattern;
    int plen;
    vector<int> table;
    KMP(const string& s) : pattern(s), plen((int)pattern.size()), table(plen+1){
        table[0] = -1;
        int j = -1;
        for(int i = 0; i < plen; i++){
            while(j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if(pattern[i+1] == pattern[++j]) table[i+1] = table[j];
            else table[i+1] = j;
        }
    }
    void search(const string& text, vector<int>& res){
        int head = 0, j = 0, tlen = (int)text.size();
        while(head + j < tlen){
            if(pattern[j] == text[head + j]){
                if(++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    string s2 = "";
    while (s2.size() < t.size()) s2 += s;
    string s3 = s2 + s2 + s2 + s2;
    KMP kmp(t);
    vector<int> ids;
    kmp.search(s3, ids);
    
    if (ids.empty()) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> memo(s3.size(), -1);
    for (int i = 0; i < ids.size(); i++) memo[ids[i]] = i;

    int n = s.size();
    int m = t.size();
    vector<int> used(ids.size(), false);
    int ans = 0;
    for (int i = 0; i < ids.size(); i++) {
        if (used[i]) continue;
        used[i] = true;
        int src = ids[i];
        int dst = src;
        for (int j = src + m; j < s3.size(); j += m) {
            if (memo[j] == -1) break;
            dst = j;
            used[memo[j]] = true;
        }

        int hoge = n - src % n;
        int foo = dst % n + 1;
        int dis = dst - src + m;
        int rest = dis - hoge - foo;
        if (rest >= n) {
            cout << -1 << endl;
            return 0;
        } else {
            ans = max(ans, dis / m);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

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

int N, K;
vec<int> A;
int bin[111];

signed main() {
  cin >> N >> K; A.resize(N);
  rep (i, N) { cin >> A[i]; }

  // bitに印をつける
  rep (i, N) {
    int num = A[i];
    for (int mask = 0; ; mask++) {
      if (num < (1LL<<mask)) break;
      if (num & (1LL<<mask)) {
        bin[mask]++;
      }
    }
  }

  int Mask = 0;
  using p = pair<int, int>;
  vec<p> add;
  for (int mask = 0; ; mask++) {
    if ((1LL << mask) > K) break;

    int num1 = (1LL << mask) * bin[mask];
    int num2 = (1LL << mask) * (N - bin[mask]);
    if (num1 < num2) {
      add.push_back({num2, mask});
      // Mask |= (1LL << mask);
    }
  }

  sort(all(add));
  reverse(all(add));
  rep (i, add.size()) {
    // if (Mask > K) continue;
    // dbg(add[i].second)
    if ((Mask | (1LL << add[i].second)) > K) continue;
    Mask |= (1LL << add[i].second);
  }
  // dbg(Mask)

  // 答えを求めるだけ
  int ans = 0;
  rep (i, N) {
    ans += (Mask ^ A[i]);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)



priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(){
    int n;
    cin >> n;
    if(n>=30)cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main(){
    solve();
    return 0;
}





Measured memory_bytes: 3608
package main

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

type cluster struct {
	status byte // 0 or 1
	q      int
}

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)

	n := getInt()
	k := getInt()
	s := getString()

	clusters := make([]cluster, 0, n)
	clusters = append(clusters, cluster{status: s[0]})

	for i, j, sum := 0, 0, 0; ; i++ {
		if clusters[j].status != s[i] {
			clusters = append(clusters, cluster{status: s[i]})
			clusters[j].q = sum
			sum = 0
			j++
		}
		sum++

		if i == n-1 {
			clusters[j].q = sum
			break
		}
	}

	ans := 0
	i := 0
	m := len(clusters)
	for cnt := 0; i < m; i++ {
		ans += clusters[i].q
		if clusters[i].status == '0' {
			cnt++
		}

		if cnt == k {
			if i < m-1 {
				ans += clusters[i+1].q
				i++
			}
			break
		}
	}

	before := ans
	for ; i < m-1; i += 2 {
		tmp := before

      	if i-k*2+1 == 0 {
			tmp -= clusters[i-k*2+1].q
		} else {
			tmp -= clusters[i-k*2].q + clusters[i-k*2+1].q
		}

		if i+1 == m-1 {
			tmp += clusters[i+1].q
		} else {
			tmp += clusters[i+1].q + clusters[i+2].q
		}

		ans = max(ans, tmp)
		before = tmp
	}

	fmt.Println(ans)
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli n;

bool solve(){
  return ((n%1000)%111) == 0 || ((n/10)%111) == 0;
}

int main(){
  cin >> n;
  cout << (solve() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

const M: usize = 1000000;
fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, x: i64);
    for b in 0..M {
        let b = b as i64;
        let b5 = b.pow(5);
        if b.pow(5) > x {
            break;
        }
        let a5 = x - b.pow(5);
        let a = (a5 as f64).powf(1. / 5.) as i64;
        if a.pow(5) + b5 as i64 == x {
            println!("{} {}", a, -b);
            return;
        }
    }
    for b in 0..M {
        let b = b as i64;
        let b5 = b.pow(5);
        let a5 = x + b5;
        let a = (a5 as f64).powf(1. / 5.) as i64;
        if a.pow(5) - b5 as i64 == x {
            println!("{} {}", a, b);
            return;
        }
    }
    unreachable!();
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, K; cin >> N >> K; 
	int L[12], R[12]; 
	for(int i = 0; i < K; i++) cin >> L[i] >> R[i]; 
	long long dp[200010] = {}; 
	long long DP[200010] = {}; 
	dp[1] = 1; DP[1] = 1; 
	long long mod = 998244353; 
	for(int i = 2; i <= N; i++){
		for(int j = 0; j < K; j++){
			int l = i - R[j]; int r = i - L[j]; 
			if(r < 0) continue; 
			else if(l <= 0) dp[i] += DP[r]; 
			else dp[i] += DP[r] - DP[l-1]; 
		}
		dp[i] += mod * 10; 
		dp[i] %= mod; 
		DP[i] = (DP[i-1] + dp[i]) % mod; 
	}
	cout << dp[N] << "\n"; 
}

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

int main(){
	string s; cin >> s;
  	int count = 0;
    int maxx = 0;
  for(auto d : s){
  	if(d == 'R'){
    	count++;
        maxx = max(maxx,count);
    } else{
    	count = 0;
    }
    
    
  }
  cout << maxx;
}



Measured memory_bytes: 3600
int main()
{
    char tab[3];
    int i;
    int cpt;
    for(i = 0; i < 3; i++)
    {
        scanf("%c", &tab[i]);
        if(tab[i] == 'o')
        {
            cpt++;
        }
    }
    int result = 700 + 100 * cpt;
    printf("%d\n", result);
	return 0;	
}

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

using namespace std;
int main() {
  int N,tmp;
  cin>>N;
  vector <int>A(N);
  for(int i=0;i<N;i++){
      cin>>tmp;
      A[tmp-1]=i+1;
  }
  for(int i=0;i<N;i++){
      cout<<A[i]<<" ";
  }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
 int a,b,k;
  cin >> a >> b>>k ;
  if(b-a+1>=2*k){
  rep(i,k){
    cout << a+i << endl;
  }
  rep(i,k){
    cout << b-k+1+i << endl;
  }
  }
  else{
    for(int i=a;i<=b;i++){
      cout << i << endl;
    }
  }     
}

Measured memory_bytes: 256
import array

K = int(input())
s = 0

cache = [1] * K


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


for i in range(1, K+1):
    cache[i-1] = [1] * K
    for j in range(i, K+1):
        cache[i-1][j-1] = array.array('i', [1] * K)
        for k in range(j, K+1):
            cache[i-1][j-1][k-1] = gcd(k, gcd(j, i))

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            a, b, c = sorted([i, j, k])
            s += cache[a-1][b-1][c-1]

print(s)


Measured memory_bytes: 89444
import sys

input = sys.stdin.readline


def main():
    S = input().strip()

    g = 0
    p = 0
    ans = 0
    for s in S:
        if p + 1 > g:
            g += 1
            if s == 'p':
                ans -= 1
        else:
            p += 1
            if s == 'g':
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#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")
//#pragma GCC optimize("branch-target-load-optimize")
//#pragma GCC optimize("branch-target-load-optimize2")
//#pragma GCC optimize("btr-bb-exclusive")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double

#define data sdadsd

#define int lll

using namespace std;
using namespace __gnu_pbds;

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

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

const int N = 1e6 + 31;
const int M = 1e9 + 7;
const int mod = 998244353;
const int rx[4] = {0, 0, -1, 1};
const int ry[4] = {-1, 1, 0, 0};
const lld eps = 1e-7;
const double pi = acos(-1.0);
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

lll ans[N];

vector < int > g[N];

int c[N];

int sz[N];

vector < int > all[N];

bool u[N];

lll f(lll x) {
    return (x * (x + 1) / 2);
}

void solve(int v, int p = -1) {
    u[c[v]] = 1;
    sz[v] = 1;
    all[c[v]].pb(v);
    lll cur;
    for (auto to : g[v]) {
        if (to == p) {
            continue;
        }
        solve(to, v);
        sz[v] += sz[to];
        cur = sz[to];
        while (all[c[v]].back() != v) {
            cur -= sz[all[c[v]].back()];
            all[c[v]].pop_back();
        }
        ans[c[v]] += f(cur);
    }
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("anagrams2.in", "r", stdin);
//    freopen("anagrams2.out", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    int x, y;
    for (int i = 1; i < n; ++i) {
        cin >> x >> y;
        --x;
        --y;
        g[x].pb(y);
        g[y].pb(x);
    }
    solve(0);
    lll cur;
    for (int i = 1; i <= n; ++i) {
        if (!all[i].empty()) {
            cur = n;
            for (auto j : all[i]) {
                cur -= sz[j];
            }
            ans[i] += f(cur);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (!u[i]) {
            cout << "0\n";
        } else {
            cout << f(n) - ans[i] << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 81448
#include<iostream>
using namespace std;
int main(){
  int N=0;
  int a=0;
  cin>>N;
  for(int i=0;i<9;i++){
    if(N%(i+1)==0&&N/(i+1)<10){
      a++;
      break;
    }
  }
  if(a==0){
    cout<<"No";
  }else{
    cout<<"Yes";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
typedef long long int ll;
typedef unsigned long long ull;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}


ll n, k;
vector<ll> p;
vector<int> flg_r, flg_l, flg_s;


int main(void){
	cin >> n >> k;
	p = vector<ll>(n);
	for(int i=0;i<n;i++) cin >> p[i];
	flg_r = vector<int>(n); // 右側 K-1 個に自分より小さなものがいるか
	flg_l = vector<int>(n); // 左側 K-1 個に自分より大きなものがいるか
	flg_s = vector<int>(n); // そこから K 個が昇順になっているか

	set<ll> se;
	for(int i=0;i+1<k;i++) se.insert(p[i]);
	for(int i=0;i<n;i++){
		se.erase(p[i]);
		if (i+k-1<n) se.insert(p[i+k-1]);
		if (i+1<n && p[i] > *se.begin()) flg_r[i] = 1;
	}
	se = set<ll>();
	for(int i=n-1;i>n-1-(k-1);i--) se.insert(p[i]);
	for(int i=n-1;i>=0;i--){
		se.erase(p[i]);
		if (i-k+1>=0) se.insert(p[i-k+1]);
		if (i>0 && p[i] < *se.rbegin()) flg_l[i] = 1;
	}
	// for(int i=0;i<n;i++) cerr << flg_r[i] << " "; cerr << endl;
	// for(int i=0;i<n;i++) cerr << flg_l[i] << " "; cerr << endl;
	int ans = 0;
	int cnt = 1;
	for(int i=1;i<n;i++){
		if (p[i-1] < p[i]) cnt++; else cnt = 1;
		if (cnt >= k){
			flg_s[i-k+1] = 1;
			ans = 1; // 変わらない場合についてはもう数えたことにする．
		}
	}
	
	for(int i=0;i+k<=n;i++){
		if (i==0){
			if (!flg_s[i]){
				ans++;
			}
		}
		else{
			if (flg_r[i-1] || flg_l[i+k-1]){
				if (!flg_s[i]){
					// cerr << "[" << i << "]" << endl;
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
    return 0;
}










Measured memory_bytes: 13568
#include <bits/stdc++.h>
 
using namespace std ;
 
string s ;
 
int a ;
 
int main ()
{
    cin >> s ;
    a = s . size () ;
    string t = "AC" ;
    int b = 0 ;
    if ( s [ 0 ] != 'A' ){
        t = "WA" ;
    }
    for ( int i = 1 ; i < a ; ++ i ){
        if ( isupper ( s [ i ] ) ){
            if ( i == 1 || i == a - 1 || s [ i ] != 'C' ){
                t = "WA" ;
            }
            b ++ ;
        }
    }
    if ( b != 1 ){
        t = "WA" ;
    }
    cout << t ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int main()
{
  long X,A,B;
  cin >> X >> A >> B;

  // X + 1 日以上
  string res;
  // if (B - A >= X + 1)
  if (B <= A) res = "delicious";
  else if (B - A <= X) res = "safe";
  else res = "dangerous";

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int solve(long x, long y) {
  int c = 0;
  while(x <= y) {
    c++;
    x *= 2;
  }
  return c;
}

int main() {
  long long x, y;
  cin >> x >> y;
  cout << solve(x, y);
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = [int(x) for x in input().split()]

a = []
for i in range(n):
    a.append([int(x) for x in input().split()])

ans = 0
for i in range(n):
    solve = c
    for j in range(m):
        solve += a[i][j] * b[j]
    if solve > 0:
        ans += 1

print(ans)


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

int main() {
  string S, ans;
  cin >> S;
  for (int i = 0; i <S.length(); i++) {
    if(S.at(i) !='B') {
      ans += S.at(i);
    }
    
    if(S.at(i) == 'B') {
      if(ans.length() != 0) {
        ans.pop_back();
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
// Aizu Vol-5 0547: Commute routes
// 2017.9.2 bal4u@uu

#include <stdio.h>
#include <string.h>

#define S 0
#define W 1

int p[102][102][2][2];

int main()
{
	int w, h, x, y;

	while (scanf("%d%d", &w, &h) && w) {
		memset(p, 0, sizeof(p));
		for (x = 1; x <= w; x++) p[x][1][W][S] = p[x][1][W][W] = 1;
		for (y = 1; y <= h; y++) p[1][y][S][W] = p[1][y][S][S] = 1;
		p[w][1][W][W] = p[1][h][S][S] = 0;
		for (y = 2; y <= h; y++) for (x = 2; x <= w; x++) {
			p[x][y][S][S] += p[x][y-1][S][S] + p[x][y-1][W][S];
			p[x][y][W][W] += p[x-1][y][W][W] + p[x-1][y][S][W];
			p[x][y][S][W] += p[x][y-1][S][S];
			p[x][y][W][S] += p[x-1][y][W][W];
			p[x][y][S][S] %= 100000, p[x][y][W][W] %= 100000;
			p[x][y][S][W] %= 100000, p[x][y][W][S] %= 100000;
		}
		printf("%d\n", (p[w][h][S][S]+p[w][h][W][W]) % 100000);
	}
	return 0;
}

Measured memory_bytes: 1952
#include <stdio.h>
int p=0;
int q[2000001];

void swap(int,int);
void insert(int);
int extract();
int max_index(int,int);

int main()
{
  char cmd[10];
  int i,j;
  int k;
  while(1)
  {
    scanf("%s",cmd);
    if(cmd[0]=='i')
    {
      scanf("%d",&k);
      insert(k);
    }
    if(cmd[0]=='e')
    {
      if(cmd[1]=='x')
	printf("%d\n",extract());
      if(cmd[1]=='n') break;
    }
  }
  return 0;
}

void swap(int a,int b)
{
  int tmp;
  tmp=q[a];
  q[a]=q[b];
  q[b]=tmp;
}

void insert(int k)
{
  int tmp;
  int i,j;
  p++;
  q[p]=k;
  i=p;
  while(q[i]>q[i/2] && i>1)
  {
    swap(i,i/2);
    i=i/2;
  }
}

int extract()
{
  int ret=q[1];
  int i;
  int tmp;
  int M;
  q[1]=q[p];
  p--;
  i=1;
  while(i*2 <= p )
  {
    if(i*2+1 <= p)
      M=max_index(i*2,i*2+1);
    else M=i*2;
    if(max_index(M,i)==M){swap(M,i);i=M;}
    else break;
    
  }
  return ret;
}

int max_index(int a,int b)
{
  if(q[a]>q[b])return a;
  else return b;
}


Measured memory_bytes: 5648
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    bc = [list(map(int, input().split())) for _ in range(m)]
    bc.sort(key=lambda a: a[1])
    a.sort()
    res = 0
    cnt = 0
    while cnt<n:
        if not bc:
            res += sum(a[cnt-n:])
            break
        if a[-1] >= bc[-1][1]:
            res += a.pop()
            cnt += 1
        else:
            d, e = bc.pop()
            if n-cnt >= d:
                res += d*e
                cnt += d
            else:
                res += (n-cnt)*e
                break

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33168
#include<stdio.h>
long a[4];  //a0=n,a1=k,a2=x,a3=y;
int main()
{
	long i,fee;
	for(i=0 ; i<4 ; i++)
	{
		scanf("%ld",&a[i]);
	}
	if(a[0] > a[1])
		fee = a[2]*a[1]+a[3]*(a[0]-a[1]);
	else
		fee = a[0]*a[2];
	printf("%ld",fee);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	int a[n];
	int ans=0;
	for(int i=0;i<n;++i)
		cin>>a[i];
	for(int i=0;i<=k;++i)
	{
		for(int j=0;j<=i;++j)
		{
			if(i>n)
				continue;
			if(i+j>k)
				continue;
			// cout<<i<<" "<<j<<endl;
			for(int x=0;x<=i;++x)
			{
				vector<int> v;
				for(int y=0;y<x;++y)
				{
					v.push_back(a[y]);
				}
				for(int y=n-1;y>=n-(i-x);--y)
				{
					v.push_back(a[y]);
				}
				// cout<<v.size()<<endl;
				// for(auto r:v)
				// {
				// 	cout<<r<<" ";
				// }cout<<endl;
				sort(v.begin(), v.end());
				int va=0;
				for(int y=0;y<v.size();++y)
				{
					if(y>=j)
						va+=v[y];
				}
				ans=max(ans,va);
			}
			// cout<<endl;
			// cout<<ans<<endl;
		}
	}
	cout<<ans;
}

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

ll mod = 1e9+7;
const double error = 1e-7;
const double PI = acos(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise\n"
#define tham getchar()
mt19937_64 rng((unsigned int) chrono::system_clock::now().time_since_epoch().count());

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e8+5;
const ll infl = 1e15;
const int nmax = 2e6+5;
///====================== template =========================

vector<ll> primes;
vector<ll> freq;

int main(){
    ll n, p;
    cin>>n>>p;
    for(ll i = 2; i*i<=p; i++){
        if(p % i != 0) continue;
        primes.push_back(i);
        freq.push_back(0);
        while(p % i == 0)
            freq.back()++, p /= i;
    }

    if(p > 1){
        primes.push_back(p);
        freq.push_back(1);
    }

    ll ans = 1;
    for(int i= 0; i<primes.size(); i++){
        int k = (freq[i]/n);
        for(int j = 0; j<k; j++){
            ans *= primes[i];
        }
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
def mapt(fn, *args):
    return tuple(map(fn, *args))
    
    
def calc_grades(m, f, r):
    if m == -1 or f == -1: return "F"
    elif m + f >= 80: return "A"
    elif m + f >= 65: return "B"
    elif m + f >= 50: return "C"
    elif m + f >= 30 and r >= 50: return "C"
    elif m + f >= 30: return "D"
    elif m + f < 30: return "F"


def Input():
    while True:
        m, f, r= mapt(int, input().split(" "))
        if m == f == r == -1: break
        print(calc_grades(m, f, r))


Input()


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)

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

    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2005
using namespace std;
typedef pair<int,int> P;

int n, k, s;

int x[N], y[N], z[N];
vector<int> G[N];
vector<int> order;
int edge[N][N];

int find(int node){
  
  set<int> used;
  
  queue<int> q;

  int res=node;

  q.push(node);
  
  while(!q.empty()){
    
    int A=q.front(); q.pop();

    if(used.count(A)) continue;

    used.insert(A);

    res=A;
    
    for(int i=0;i<G[A].size();i++){

      int nA=G[A][i];

      q.push(nA);
      
    }
    
  }
  
  return res;
}

int check(int A, int B){
  
  int X=min(x[A]+s,x[B]+s)-max(x[A],x[B]);
  int Y=min(y[A]+s,y[B]+s)-max(y[A],y[B]);
  int Z=min(z[A]+s,z[B]+s)-max(z[A],z[B]);
  
  if(X<=0||Y<=0||Z<=0) return 0;
  
  return X*Y*2+Y*Z*2+Z*X*2;
}

bool used[N];

void dfs(int  node, int prev){

  if(used[node]) return;
  
  used[node]=true;
  
  order.push_back(node);
  
  for(int i=0;i<G[node].size();i++){

    int nnode=G[node][i];
    
    if(nnode==prev) continue;
    
    dfs(nnode, prev);
    
  }
  
}

int main(){

  while(1){
  
    cin>>n>>k>>s;
    
    if(!n&&!k&&!s) break;
    
    for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i];
    
    memset(edge,0,sizeof(edge));
        
    for(int i=0;i<n;i++)

      for(int j=0;j<n;j++){
      
	if(i==j) continue;

	int r=check(i,j);
	
	if(r>0){
	
	  G[i].push_back(j);
	  G[j].push_back(i);

	  edge[i][j]=edge[j][i]=r;
	  
	}
      
      }
    
    memset(used,0,sizeof(used));
    
    int ans=2e9;
    
    for(int i=0;i<n;i++){
      
      if(used[i]) continue;
      
      order.clear();
      
      dfs(find(i),find(i));
      
      int S=order.size();
      
      for(int j=0;j<S;j++){
	
	int sum=s*s*6*k;
	
	if(S<k) continue;

	int f=0;
	
	for(int l=0;l<k-1;l++)
	  if(edge[order[(j+l)%S]][order[(j+l+1)%S]])
	    sum-=edge[order[(j+l)%S]][order[(j+l+1)%S]];
	  else f=1;

	if(f) continue;
	
	if(S>=3 && S==k && edge[order[j]][order[(j+k-1)%S]])
	  sum-=edge[order[j]][order[(j+k-1)%S]];
	
	ans=min(ans, sum);
	
      }
    
    }
    
    if(ans==2e9) ans=-1;

    cout<<ans<<endl;

    for(int i=0;i<n;i++) G[i].clear();
    
  }
  return 0;
}

Measured memory_bytes: 18864
import sys
sys.setrecursionlimit(1000000)

n = int(input())
t = [[] for _ in range(n)]
color = [None for _ in range(n)]
visited = [False for _ in range(n)]


def dfs(n_num):
    visited[n_num] = True
    for i in t[n_num]:
        if visited[i[0]]:
            continue
        if i[1] % 2 == 0:
            color[i[0]] = color[n_num]
        else:
            color[i[0]] = abs(color[n_num] - 1)
        dfs(i[0])


for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    t[u] += [(v, w)]
    t[v] += [(u, w)]

color[0] = 0
dfs(0)
for i in color:
    print(i)


Measured memory_bytes: 80176
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F         first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cerr << #x << " is " << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
 
void solve(){
    
    int n,k;
    cin>>n>>k;

    ll dp[n+1][k+1];
    ll pre[n+1][k+1];
    ll a[n+1];
    rep(i,1,n+1)cin>>a[i];

    memset(dp,0,sizeof dp);
    memset(pre,0,sizeof pre);
    dp[0][0]=1;

    pre[0][0]=1;
    for(int i=1;i<=a[1];i++){
        pre[0][i]=1;
    }
    for(int i=1;i<=n;i++){
        dp[i][0]=1;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            dp[i][j]=pre[i-1][j];
        }
        if(i!=n){
            pre[i][0]=1;
            for(int j=1;j<=a[i+1];j++){
                pre[i][j]=(pre[i][j-1]+dp[i][j])%hell;
            }
            for(int j=a[i+1]+1;j<=k;j++){
                pre[i][j]=(pre[i][j-1]+dp[i][j]-dp[i][j-a[i+1]-1]+hell)%hell;
            }
        }
    }



    cout<<dp[n][k];

}
 
 
 
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   
 
    int t=1,i=1;
   // cin>>t;
    
 
    while(t--){
       // cout<<"Case #"<<i++<<": ";
        solve();
    
    }
 
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int H[105] = {0};
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  int result = 1;
  int maxH = H[0];
  for (int i = 1; i < N; i++)
  {
    if (maxH <= H[i]) {
      result++;
      maxH = H[i];
    }
  }

  cout << result << "\n";
}

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

const int maxv = 1e6;
int n;
int p[maxv + 10], check[maxv + 10];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    for (int i = 2; i <= maxv; ++i)
        if (!p[i])
            for (int j = i; j <= maxv; j += i) p[j] = i;
    cin >> n;
    int hold, pairwise = 1;
    for (int i = 1; i <= n; ++i)
    {
        int val;    cin >> val;
        if (i == 1) hold = val;
        else hold = __gcd(hold, val);
        while (val != 1)
        {
            int u = p[val];
            if (check[u]) pairwise = 0;
            else check[u] = 1;
            while (val % u == 0) val /= u;
        }
    }
    if (pairwise) cout << "pairwise coprime";
    else if (hold == 1) cout << "setwise coprime";
    else cout << "not coprime";
}


Measured memory_bytes: 19196
def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    local_a = list(a)
    a.sort(reverse=True)
    return sum(a[::2]) - sum(a[1::2])


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 1000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);

int n;
double a[N];
double dp[3333][3333];

double calc(int idx , int h){
	if(idx==n)
		return dp[idx][h]=(h<<1)>n;
	double&ret = dp[idx][h];
	if(ret>-9)return ret;
	ret = (calc(idx+1,h)*(1-a[idx]))+(calc(idx+1,h+1)*(a[idx]));
	
	return ret;

}

int main() {
	for(int i = 0 ; i < 3333 ; i++)
		for(int j = 0 ; j < 3333; j++)
			dp[i][j]=-10.0;
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	printf("%.10lf\n",calc(0,0));


    return 0;
}

Measured memory_bytes: 88448
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n;
int a[nax];

int main () {
    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i)
        scanf("%d", a + i);

    sort(a + 1, a + 1 + n);

    int pt = n - 1;
    long long ans = a[n];

    for (int i = n - 2 ; i >= 1 ; i -= 2) {
        ans += a[pt];
        if (i - 1 > 0)
        ans += a[pt];
        -- pt;
    }

    printf("%lld\n", ans);
}
/*
    Good Luck
        -Lucina
*/


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  int t = 1;
  rep(i, n-1) {
    t *= (k-1);
  }
  int ans = 0;
  ans = k * t;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=21,M=(1<<19)+1,mod=1e9+7;
int f[1<<N],R[1<<N],p[N][1<<N],zero[N],one[N];
int n,m,K,a,b,c,k,tt;

void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}

#define doit(s) \
	if(f[s]&&(k=p[j][s])&&!(s>>(k-1)&1)) \
	add(f[s^(k<n?(1<<k):0)^(1<<(k-1))],f[s])

int main(){
	read(n),read(m),read(K),n--;
	rep(i,1,K){
		read(a),read(b),read(c);
		if(c) one[a]|=1<<(b-1);
		else zero[a]|=1<<(b-1);
	}
	REP(s,1<<n){
		int c=0;
		REP(i,n) if(s>>i&1) p[++c][s]=i;
		p[c+1][s]=n;
		R[s]=(s&1?R[s^1]|(1<<(n-1)):R[s>>1]>>1);
	}
	f[0]=1;
	int A=1<<(n-1),B=1<<n;
	rep(i,1,m){
		rep(j,1,n) REP(s,1<<n) doit(R[s]);
		REP(s,1<<n) if(f[s]){
			if((s&one[i])!=one[i]) f[s]=0;
			if((~s&zero[i])!=zero[i]) f[s]=0;
		}
	}
	int ans=0;
	REP(s,1<<n) add(ans,f[s]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 88448
import java.util.*;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double x1, x2, y1, y2;
        x1 = sc.nextDouble();
        y1 = sc.nextDouble();
        x2 = sc.nextDouble();
        y2 = sc.nextDouble();
        double d = Math.sqrt(Math.pow((x2-x1),2)+Math.pow((y2-y1),2));
        BigDecimal bd = new BigDecimal(d);
        BigDecimal ans = bd.setScale(5,BigDecimal.ROUND_DOWN);
        System.out.println(ans);
    }
}


Measured memory_bytes: 28236
from collections import Counter
N = int(input())
c = Counter()
for n in range(2, N + 1):
    i = 2
    while i**2 <= n:
        count = 0
        while n % i == 0:
            n //= i
            count += 1
        if count != 0:
            c[i] += count
        i += 1
    if n > 1:
        c[n] += 1


def num(m):  # 指数がm-1以上の素因数の個数を求める
    return len(list(filter(lambda x: x >= m - 1, c.values())))


ans = 0
ans += num(75)
ans += (num(5) - 1) * num(15)
ans += (num(3) - 1) * num(25)
ans += (num(3) - 2) * num(5) * (num(5) - 1) // 2
print(ans)


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

int main() {
  int a,b;
  cin>> a >> b;
  if(a!=1 && b!=1) {
    cout << 1 << endl;
  }
  if(a!=2 && b!=2) {
    cout << 2 << endl;
  }
  if(a!=3 && b!=3) {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	
    	 Scanner stdIn = new Scanner(System.in);
         int n = stdIn.nextInt();
         int[] x = new int[n];
  
         for (i = 0; i < n; i++) {
             x[i] = stdIn.nextInt();
         }
  
         int p1 = 0;
         double p2 = 0;
         double p3 = 0;
         int pInf = -1;
  
         for (i = 0; i < n; i++) {
             x[i] = Math.abs(x[i] - stdIn.nextInt());
             p1 += x[i];
             p2 += Math.pow(x[i],2);
             p3 += Math.pow(x[i],3);
             pInf = Math.max(pInf,x[i]);
         }
         System.out.println(p1);
         System.out.printf("%.5f\n",Math.pow(p2,0.5));
         System.out.printf("%.5f\n",Math.pow(p3,(double)1/3));
         System.out.println(pInf);
    }
}


Measured memory_bytes: 26596
from itertools import permutations
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

P="".join(map(str,P))
Q="".join(map(str,Q))
for i,v in enumerate(permutations(range(1,N+1))):
  v="".join(map(str,v))
  if P==v:
    a=i
  if Q==v:
    b=i
print(abs(a-b))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    string S;
    cin>>S;
    {
       if(S=="Sunny")
       {
           cout<<"Cloudy";
       }
       else if(S=="Cloudy")
       {
           cout<<"Rainy";
       }
       else if(S=="Rainy")
       {
           cout<<"Sunny";
       }


   }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, m;
int a,b,c;
int gcd(int x, int y) {
	if (y == 0) return x;
  return gcd(y, x%y);
}
int main() {
  cin>>a>>b>>c;
  if (c%gcd(a,b)==0) {
  	cout<<"YES"<<endl;
  } else {
  	cout<<"NO"<<endl;
  }
	return 0;
}

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


using std::cin;
using std::cout;


int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int res = 0;

    if (2 * c < a + b) {
        res += 2 * c * std::min(x, y);
        int minin = std::min(x, y);
        x -= minin;
        y -= minin;
        if (x == 0 && y > 0) {
            if (2 * c > b) {
                res += y * b;
            } else {
                res += y * 2 * c;
            }
        } else {
            if (2 * c > a) {
                res += x * a;
            } else {
                res += x * 2 * c;
            }
        }
        cout << res << "\n";
        return 0;
    }

    int minim = std::min(x, y);
    res = (a + b) * minim;
    x -= minim;
    y -= minim;

    if (x == 0 && y > 0) {
        if (2 * y * c < y * b) {
            res += 2 * y * c;
        } else {
            res += y * b;
        }
    } else if (x > 0 && y == 0) {
        if (2 * x * c < x * a) {
            res += 2 * x * c;
        } else {
            res += x * a;
        }
    }


    cout << res << "\n";
}


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

int main() {
  while (1) {
    int h, w;
    cin >> h >> w;

    if (h == 0 && w == 0) { break; }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (i == 0 || i == (h - 1) || j == 0 || j == (w - 1)) {
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3008
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto S = RD!string;
	
	long ans;
	long cnt;
	foreach (i; 0..N)
	{
		if (S[i] == 'I')
			++cnt;
		else
			--cnt;
		ans = max(ans, cnt);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test(t) int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
 
const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p,ll mod)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,mod);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{		
	ll a,b,k;
	cin>>a>>b>>k;
	ll x=max(0ll,a-k);
	k-=(a-x);
	ll y=max(0ll,b-k);
	cout<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  ll s;
  std::cin >> s;
  const int x = 753;

  int ans = 0;
  while(s > 100){
    int run = s%1000;
    if(abs(x-ans) > abs(x-run))
      ans = run;

    s/=10;
  }

  std::cout << abs(x-ans) << '\n';
  return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 K, X;
    cin >> K >> X;
    i32 left = max(X + 1 - K, -1000000);
    i32 right = min(X - 1 + K, 1000000);
    for (; left <= right; left++) {
        cout << left;
        if (left != right) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define pb push_back
#define pf push_front
#define mod 1000000007
#define ull unsigned long long int
#define what_is(qq) cerr << #qq << " is " << qq << "\n"

int frogJump(vector<int> h, int n)
{
  vector<int> dp(n+1);
  dp[1] = 0;

  for(int i=2;i<=n;i++)
  {
    int a = abs(h[i]-h[i-1]) + dp[i-1];
    int b = (i==2) ? inf : abs(h[i]-h[i-2]) + dp[i-2];

    dp[i] = min(a,b);
  }
  return dp[n];
}

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

  vector<int> h(n+1);

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

  cout<<frogJump(h,n)<<"\n";

}


Measured memory_bytes: 4568
#include <stdio.h>
#define MOD (1000000007)
int main(){
  long w,h,path[1001][1001]={0};
  char grid[1001][1001],c;
  scanf("%ld%ld",&h,&w);
  for (long i=1;i<h+1;i++){
      scanf("%s",&grid[i][1]);
  }
  for (long i=0;i<h+1;i++) grid[i][0]='#';
  for (long i=0;i<w+1;i++) grid[0][i]='#';
  path[1][1]=1;
  for (long i=0;i<h+1;i++){
    for (long j=0;j<w+1;j++){
      if (grid[i][j]=='.'){
        if (grid[i][j-1]=='.') path[i][j]+=path[i][j-1];
        if (grid[i-1][j]=='.') path[i][j]+=path[i-1][j];
      }
      path[i][j]%=MOD;
    }
  }
  printf("%ld\n",path[h][w]);
  return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n;
    cin >> n;
    vi x(n);
    rep(i, n)
    {
        cin >> x[i];
    }
    vi y = x;
    sort(all(x));
    int c1 = x[n / 2 - 1];
    int c2 = x[n / 2];
    rep(i, n)
    {
        if (y[i] <= c1)
        {
            cout << c2 << endl;
        }
        else
        {
            cout << c1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4804