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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct E {
  int to, w;
};
const int MAX_N = 2505;
vector<E> g[MAX_N];

const ll INF = 1LL << 40;
ll dist[MAX_N];

int main2() {
  REP(i, MAX_N) g[i].clear();
  int N = nextInt();
  int M = nextInt();
  int P = nextInt();
  REP(i, M) {
    int A = nextInt() - 1;
    int B = nextInt() - 1;
    int C = -nextInt() + P;
    g[A].push_back({B, C});
  }

  ll ans = INF;
  REP(i, MAX_N) dist[i] = INF;
  dist[0] = 0;
  REP(step, 4 * N + 1) {
    REP(i, N) if (dist[i] < INF) {
      for(E e : g[i]) {
        if (dist[e.to] > dist[i] + e.w) {
          dist[e.to] = dist[i] + e.w;
          if (step >= 2 * N) {
            dist[e.to] = -INF;
            if (e.to == N-1) ans = -1;
          }
        }
      }
    }
  }
  if (ans != -1) ans = max(0LL, -dist[N-1]);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,x,g;
		while(true){
			n = sc.nextInt();
			x = sc.nextInt();
			if( n==0 && x==0 ) break;
			g = 0;
			for( int i=1; i<=n-2; i++ ){
				for( int j=2; j<=n-1; j++ ){
					for( int k=3; k<=n; k++ ){
						if( i>=j || i>=k || j>=k ) continue;
						if( i+j+k==x ) g++;
					}
				}
			}
			System.out.println( g );
		}
	}
}

Measured memory_bytes: 19608
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;
int main(){
//  int i = 1;

  double a = 0;
  double b = 0;

  cin >> a >> b;

  cout << (int)(a/b) <<endl;
  cout << fmod(a,b) <<endl;
  cout << fixed << a/b <<endl;


}



Measured memory_bytes: 3364
#include<bits/stdc++.h>
#include<stdio.h>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn=2e5+500;
const int inf=0x3f3f3f3f;
const int p=1e9+7;
int n;
//int a[maxn],b[maxn];
ll a,b;
int ar[maxn];
int main()
{
//    ios_base::sync_with_stdio(false);cin.tie(0);
    while(cin>>a){
        if(a&1){
            cout<<0<<endl;
        }else{
            ll ans=0;
            ll x=1,y=1;
            ll base=10;
            ll ha=5;
            while(1){
                if(a/ha){
                }else{
                    break;
                }
                ans+=(a/ha)/2;
                ha*=5;
            }
            cout<<ans<<endl;
        }
    }
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	int n,k;
	cin >> n >> k;
	vl a(k);
	rep1(i,n+1){
		if(i >= k - i){
			a[i%k]++;
		}
	}
	//for(auto it : a)cout << it << endl;
	ll tot = 0;
	if(k%2==0){tot = a[0]*a[0]*a[0] + a[k/2]*a[k/2]*a[k/2];}
	else tot = a[0]*a[0]*a[0];
	cout << tot << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        const int ID = 4;
        var n = new List<int>();
        var cal = new Calq();
        string line;
        while (!string.IsNullOrEmpty(line = Console.ReadLine()))
        {
            IEnumerable<double> t = line.Split(',').Where(x=>x.Contains(".")).Select(double.Parse);
            if (cal.BMIIsOver25(t))
            {
                n.Add(int.Parse(line.Substring(0,ID)));
            }
        }
        Console.WriteLine(string.Join("\n", n));
    }
}
class Calq
{
    const int MIN= 25;
    internal bool BMIIsOver25(IEnumerable<double> t)
    {
        return (GetBMI(t.ToList())>=MIN);
    }
    private double GetBMI(List<double> t)
    {
        var ans = t[0] / Math.Pow(t[1], 2);
        return ans;
    }
}



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

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if (A==1 && B == 2) ans = 3;
    if (A==2 && B == 3) ans = 1;
    if (A==3 && B == 1) ans = 2;
    if (A==3 && B == 2) ans = 1;
    if (A==2 && B == 1) ans = 3;
    if (A==1 && B == 3) ans = 2;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  vvi task = vv(N, 2, 0, int);
  for(int i=0;i<N;i++) std::cin >> task[i][1] >> task[i][0];
  sort(task.begin(), task.end());
  ll yoka = 0, now=0;
  for(int i=0;i<N;i++){
    yoka += task[i][0] - now - task[i][1];
    if(yoka<0){
      std::cout << "No" << '\n';
      return 0;
    }
    now = task[i][0];
  }
  std::cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int w, h; cin >> w >> h;
	using P = pair<Int, bool>;
	priority_queue<P, vector<P>, greater<>> pq;
	for(Int i=0; i<w; ++i){
		Int p; cin >> p;
		pq.push(P(p, 0));
	}
	for(Int i=0; i<h; ++i){
		Int q; cin >> q;
		pq.push(P(q, 1));
	}
	Int a = h+1, b = w+1, c = 0, ans = 0;
	while(c < w*h+w+h){
		P p = pq.top(); pq.pop();
		if(!p.second){
			Int t = min(a, w*h+w+h-c);
			ans += p.first * t;
			c += t;
			--b;
		}else{
			Int t = min(b, w*h+w+h-c);
			ans += p.first * t;
			c += t;
			--a;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6512
s = input()

while True:
    if len(s) == 0:
        print('YES')
        break
    elif s[-5:] == 'dream':
        s = s[:-5]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    elif s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    else:
        print('NO')
        break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vii a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 0, cnt = 0, s = 0;
    rep(i, 0, n) {
        s += a[i];
        if (i % 2 && s <= 0) {
            ans += abs(s) + 1;
            s = 1;
        } else if (i % 2 == 0 && s >= 0) {
            ans += s + 1;
            s = -1;
        } 
    }

    ll t = 0;
    rep(i, 0, n) {
        t += a[i];
        if (i % 2 && t >= 0) {
            cnt += t + 1;
            t = -1;
        } else if (i % 2 == 0 && t <= 0) {
            cnt += abs(t) + 1;
            t = 1;
        }
    }
    if (ans < cnt) {
        if (s == 0) ans++;
    } else {
        ans = cnt;
        if (t == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int n, k; cin >> n >> k;
  string s; cin >> s;
  if('a' <= s[k - 1] && s[k - 1] <= 'z') {
    s[k - 1] -= 32;
  } else {
    s[k - 1] += 32;
  }
  cout << s << "\n";
}

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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int main(){
    int N, R;
    cin >> N >> R;
    int P[300000];
    UnionFind uf(N);
    for(int i=0; i<N; i++){
        cin >> P[i];
        uf.unite(i, P[i]-1);
    }

    vector<int> cmp;
    for(int i=0; i<N; i++) if(uf.find(i) == i) cmp.push_back(uf.size(i));

    R = min(R, N-R);
    bitset<150001> dp;
    dp[0] = 1;
    for(int a : cmp) dp |= (dp << a);
    cout << (dp[R] ? "Yes" : "No") << endl;
    return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

vector<int> mm(100010,-1); 

bool rec(int x){
  if(x==0)return true;
  if(x<0)return false;
  if(mm[x] != -1) return mm[x] == 1;
  bool res = false;
  for(int i = 100; i <= 105; ++i){
    res |= rec(x-i);
  }
  mm[x] = (res==true?1:0);
  return res;
}

int main(){
  int x; cin >> x;
  cout << (rec(x)?1:0) << endl;
  return 0;
}


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

int main() {
    int H[255];
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> H[i];
    for (int i = 1; i <= n; i++) {
        cout <<"node " << i << ": key = " << H[i] << ", ";
        if (i != 1) cout << "parent key = " << H[int(i / 2)] << ", ";
        if (2 * i <= n) cout << "left key = " << H[2 * i] << ", ";
        if (2 * i + 1 <= n) cout << "right key = " << H[2 * i + 1] << ", "; 
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3040
class Generator
	def initialize
		@ops = []
	end

	def lt(i, j, k)
		@ops << [:<, i, j, k]
	end

	def add(i, j, k)
		@ops << [:+, i, j, k]
	end

	def to_s
		str = ""
		str << size.to_s + "\n"
		@ops.each do |(op, i, j, k)|
			str << "#{op} #{i} #{j} #{k}\n"
		end
		str
	end

	def size
		@ops.size
	end
end

gen = Generator.new

=begin
予約領域：
0..2 : 入出力
4 : 予約
5..9: 汎用レジスタ
10..39 : 2^n-1 (定数)
40..69 : 2^n-1 (入力Aを分解するため)
70..99 : 2^n-1 (入力Bを分解するため)
100..129 : 入力Aの分解
130..159 : 入力Bの分解
200..258 : 分解の積
=end

# 1をつくる
gen.add 0, 1, 3
gen.lt 4, 3, 11

# 2**2-1から2**29-1までつくる
(2..29).each do |i|
	gen.add 10+i-1, 10+i-1, 10+i
	gen.add 10+i, 11, 10+i
end

# コピー
(0..29).each do |i|
	gen.add 10+i, 10, 40+i
end

# コピー
(0..29).each do |i|
	gen.add 10+i, 10, 70+i
end

# Aを分解
29.downto(0) do |i|
	29.downto(i+1) do |j|
		gen.lt 10, 100+j, 5
		j.times do
			gen.add 5, 5, 5
		end
		gen.add 5, 40+i, 40+i
	end
	gen.lt 40+i, 0, 100+i
end

# Bを分解
29.downto(0) do |i|
	29.downto(i+1) do |j|
		gen.lt 10, 130+j, 5
		j.times do
			gen.add 5, 5, 5
		end
		gen.add 5, 70+i, 70+i
	end
	gen.lt 70+i, 1, 130+i
end

# 掛け算
(0..29*2).each do |ij|
	([0, ij-29].max..[ij, 29].min).each do |i|
		j = ij - i
		gen.add 100+i, 130+j, 5
		gen.lt 11, 5, 5
		gen.add 5, 200+ij, 200+ij
	end
end

# 復元
(0..29*2).each do |i|
	i.times do
		gen.add 200+i, 200+i, 200+i
	end
	gen.add 200+i, 2, 2
end

STDERR.puts "%d lines" % gen.size
puts gen.to_s

Measured memory_bytes: 17504
#include <vector>
#include <cstring>
#include <iostream>
using namespace std;
int n, a[10000]; bool p[10000];
int main() {
	while(scanf("%d", &n), n) {
		vector<int> v;
		memset(a, 0, sizeof(a));
		memset(p, 0, sizeof(p));
		for(int i = 1; i < n; i++) p[i * i % n] = true;
		for(int i = 0; i < n; i++) {
			if(p[i]) v.push_back(i);
		}
		for(int i = 0; i < v.size(); i++) {
			for(int j = i + 1; j < v.size(); j++) {
				int r = v[j] - v[i];
				if(r < 0) r += n;
				if(r > n / 2) r = n - r;
				a[r - 1]++;
			}
		}
		for(int i = 0; i < n / 2; i++) printf("%d\n", a[i] * 2);
	}
}

Measured memory_bytes: 3180
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($args: tt)*) => { eprintln!($fmt, $($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($args: tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let (a, b, c) = {
        let v = parse_vec::<i32>();
        (v[0], v[1], v[2])
    };

    let k = parse_line::<i32>();

    let max = vmax!(a, b, c);
    let ans = a + b + c + ((1 << k) - 1) * max;

    println!("{}", ans);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[22][22][200];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,s;
  while(cin>>n>>k>>s,n+k+s){
    for(int i=0;i<22;i++)
      for(int j=0;j<22;j++)
	for(int k=0;k<200;k++)
	  dp[i][j][k] = 0;
    dp[0][0][0] = 1;

    for(int i=0;i<n;i++){
      for(int j=0;j<20;j++){
	for(int k=0;k<160;k++){
	  if(dp[i][j][k]){
	    dp[i+1][j+1][k+(i+1)] += dp[i][j][k];
	  }
	  dp[i+1][j][k]+=dp[i][j][k];
	}
      }
    }
    cout<<dp[n][k][s]<<endl;
  }
  return 0;
}



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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int MAXN = 1e5+200;
const int INF = 1e9;
int dp[MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin>>n>> k;
    int h[n];
    forn(i,n) cin>> h[i];
    dp[0]=0;

    for1(i,n-1){
        dp[i]=INF;
        for1(j,k){
            if(i-j>=0){
                dp[i]= min(dp[i], dp[i-j] + abs(h[i]- h[i-j]));
            }
        }
    }
    cout<< dp[n-1]<<el;


}



Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int n; cin >> n;
    bool ok = true;
    map<int,int> mp;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (mp[a]) {
            ok = false; 
            break;
        } else mp[a]++;
    }
    if (ok) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1e9+7;
const ll mod2=998244353;

int main(){
    ll N;
    cin >> N;
    ll D[N];
    for(int i = 0; i < N; i++) cin >> D[i];
    if(D[0] != 0){
        cout << 0 << "\n";
        return 0;
    }
    ll ans[N];
    for(int i = 0; i < N; i++) ans[i] = 0;
    for(int i = 0; i < N; i++) ans[D[i]]++;
    if(ans[0] >= 2){
      cout << 0 << "\n";
      return 0;
    }
  
    ll pattern = 1;

    for(int i = 1; i < N; i++){
        for(int j = 0; j < ans[i]; j++){
            pattern *= ans[i - 1];
            pattern %= mod2;
        }
    }   
    cout << pattern << "\n";
    return 0;
}


Measured memory_bytes: 1792
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a, b := nextInt(), nextInt()
	fmt.Printf("%d %d %f\n", a/b, a%b, float64(a)/float64(b))
}



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

int main(){
  long N,M;cin>>N>>M;
  vector<int>AC(N,0),WA(N,0);
  for(int i=0;i<M;i++){
    long p;string s;cin>>p>>s;
    if(AC[p-1]==0 && s=="WA")WA[p-1]++;
    if(s=="AC")AC[p-1]=1;
  }
  long a=0,b=0;
  for(int i=0;i<N;i++){
    a+=AC[i];
    if(AC[i])b+=WA[i];
  }
  cout<<a<<" "<<b<<endl;
  
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
	cin>>n;
	while(n){
		int cnt=n%10;
		if(cnt==7){
			cout<<"Yes";
			return 0;
		}
		n/=10;
	} 
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    if (s.find('7')!=-1)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
# 数字を取得
N = int(input())

# 数値分ループ
calc = []
for cnt in range(1, N + 1):
    # 3もしくは5の倍数であれば、加算しない
    if cnt % 3 != 0 and cnt % 5 != 0:
        calc.append(cnt)

# 合計を出力
print(sum(calc))

Measured memory_bytes: 30140
#include <stdio.h>

int main(){
    char s[3];
    for(int i=0; i<3; i++){
        scanf("%c", &s[i]);
    }
    
    if(s[0] == s[1] && s[1] == s[2]){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 128
// template.cpp {{{
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
#define reps(i, a, n) for (lint i = (a); i < (lint)(n); ++i)
#define rep(i, n) reps(i, 0, n)
struct pre_{pre_(){cin.tie(0);ios::sync_with_stdio(0);}} pre__;
// }}}

signed main() {
  int a, b;
  char c;
  cin >> a >> c >> b;
  if (c == '+') {
    cout << a + b << endl;
  } else {
    cout << a - b << endl;
  }
}



Measured memory_bytes: 256
import bisect
primes = [0, 0] + [1] * 49999
for i in range(2, 224):
    if primes[i]:
        for j in range(i*i, 50001, i):
            primes[j] = 0
values = [i for i, k in enumerate(primes) if k]
while True:
    n = int(input())
    if n == 0:
        break
    I = bisect.bisect(values, n//2)
    print(len([1 for v in values[:I] if primes[n-v]]))


Measured memory_bytes: 6308
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100012
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

int v1, f1, v2, f2;
int q1, q2;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> v1 >> f1 >> v2 >> f2;
    q1 = (v2+f1-1)/f1;
    q2 = (v1+f2-1)/f2;
    if(q1 <= q2) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 1005;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#endif

int dp[1<<12];

int unlocks[N];
int cost[N];

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

  int n, m;
  cin >> n >> m;

  rep(i, 1, m+1) {
    int a, b; cin >> a >> b;
    cost[i] = a;
    fo1(j, b) {
      int c; cin >> c;
      --c;
      unlocks[i] |= 1<<c;
    }
  }

  int k = 1<<n;

  memset(dp, oo, sizeof dp);
  dp[0] = 0;

  rep(i, 1, m+1) {
    repb(j, k-1, -1) {
      dp[j | unlocks[i]] = min(dp[j | unlocks[i]], dp[j] + cost[i]);
    }
  }

  cout << (dp[k-1] >= oo ? -1 : dp[k-1]) << endl;
  return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n;
  cin >> n;
  int count = 0;
  int max = 0;
  for (int i = 0; i < n; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) {
      count++;
      UpdateMax(max, count);
    } else {
      count = 0;
    }
  }
  if (max >= 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main()
{
	string s;
	int cnt = 0;
	cin >> s;
	int r = 0, l = s.size() - 1;
	while (r<l)
	{
		if (s[r] != s[l])
			cnt++;
		r++; l--;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
int n, d, x;
vector<int> data(110);
int ans;
void cnt(int i, int d){
    ans += (d - 1) / data.at(i) + 1;
}
void solve(){
    cin >> n, cin >> d >> x;
    for(int i = 0; i < n; i++)
        cin >> data.at(i);
    ans = 0;
    for(int i = 0; i < n; i++)
    cnt(i, d);
    ans += x;
    cout << ans << endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class ABC162C {
	private static void Main(string[] args) {
		var k = ReadInt();
		var answer = 0;

		for (int a = 1; a <= k; a++) {
			for (int b = 1; b <= k; b++) {
				for (int c = 1; c <= k; c++) {
					answer += CalcGCD(a, b, c);
				}
			}
		}

		Console.WriteLine(answer);
	}

	private static int ReadInt() => int.Parse(Console.ReadLine().Trim());
	private static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
	private static int CalcGCD(int a, int b) => a > b ? GCD(a, b) : GCD(b, a);
	private static int CalcGCD(int a, int b, int c) => CalcGCD(CalcGCD(a, b), c);
}

Measured memory_bytes: 27480
def main():
    N, M = (int(i) for i in input().split())
    dic = {}
    for i in range(M):
        s, c = (i for i in input().split())
        if s in dic.keys() and dic[s] != c:
            return print(-1)
        dic[s] = c
    # print(dic)
    for i in range(1000):
        s = str(i)
        if len(s) != N:
            continue
        for k, v in dic.items():
            if s[int(k)-1] != v:
                break
        else:
            return print(i)
    print(-1)


if __name__ == '__main__':
    main()


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

int main(){
    int i,j,n,m;
    int templ,tempr;

    cin >> n >> m;
    int lmax = -1;
    int rmin = 100000;

    for(i = 0; i < n; i++){
        cin >> templ >> tempr;
        lmax = max(templ,lmax);
        rmin = min(tempr,rmin);
    }
    int ans;

    if(rmin >= lmax){
        ans = rmin - lmax + 1;
    }
    else{
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(20);
    string s,t; cin >> s >> t;
    int x = SIZE(s), y = SIZE(t);
    string ans = ""; bool good = false;
    rep(i,SIZE(s)) ans += 'z';
    per(i,x-y+1){
        bool check = true;
        rep(j,y){
            if(s[i+j] == '?') continue;
            if(s[i+j] != t[j]){
                check = false;
                break;
            }
        }
        if(check){
            string cur = "";
            rep(k,x){
                if(k == i){
                    cur += t;
                    k += y-1;
                }
                else if(s[k] == '?') cur += 'a';
                else cur += s[k];
            }
            chmin(ans, cur);
            good = true;
        }
    }
    if(!good) cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
lint choose(lint n)
{
	return n*(n-1)/2;
}
int main()
{
	//atcoder159D
	lint n=0;
	lint total=0;
	cin>>n;
	vector<lint> a(n);
	vector<lint> b(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		a[i]--;
	}
	for(int i=0;i<n;i++)
	{
		b[a[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		total+=choose(b[i]);
	}
	for(int i=0;i<n;i++)
	{
		lint ans=total;
		ans-=choose(b[a[i]]);
		b[a[i]]--;
		ans+=choose(b[a[i]]);
		b[a[i]]++;
		cout<<ans<<endl;
	}	
	return 0;
}

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

using namespace std;

int X[110], Y[110];

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

	cout << setprecision(6) << fixed;

	int n;
	cin >> n;
	for(int i=0;i<n;++i)
		cin >> X[i];
	for(int i=0;i<n;++i)
		cin >> Y[i];
	double d1 = 0, d2 = 0, d3 = 0, dinf = 0;
	for(int i=0;i<n;++i){
		d1+=abs(X[i]-Y[i]);
		d2+=pow(X[i]-Y[i],2);
		d3+=pow((double)(abs(X[i]-Y[i])),3);
		dinf=max(dinf,(double)abs(X[i]-Y[i]));
	}
	cout << d1 << '\n' << sqrt(d2) << '\n' << cbrt(d3) << '\n' << dinf << '\n';	
	
	return 0;

} // br1



Measured memory_bytes: 3532
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  
  int H=a.at(0),ans=0,count=0;
  for(int i=1;i<N;i++){
    if(a.at(i)<=H){
      H=a.at(i);
      count++;
      ans=max(ans,count);
    }
    else{
      H=a.at(i);
      ans=max(ans,count);
      count=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 1000000007
#define PI 3.1415926535897932384
#define F first
#define S second
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair


void solve(){ 

ll n;
cin>>n;
ll a[n];
fr(n) cin>>a[i];
ll ans=0;
sort(a,a+n,greater <ll>());
ans+=a[0];
ll k=n-2,i=1;
while(k){
    ll mn=min(k,(ll)2);
    ans+=mn*a[i];
    i++;
    k-=mn;
}
cout<<ans;

}
int main()
{   FAST;
   
   
    ll test;
    test=1;
   
    //cin>>test;
    while(test--)
    {
        solve();
    }
     //cerr<<endl<<"maut : "<<elasped_time<<endl;
    return 0;
}
 
    



Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2)
  {
    cout<<"No\n";
    return 0;
  }
  int k=n/2;int f=0;
  for(int i=0;i<n/2;i++)
  {
    if(s[i]==s[k])
    {
      k++;
    }
    else
    {
      f=1;
      break;
    }
  }
  if(f)
    cout<<"No\n";
  else
    cout<<"Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
template<int H,int W>int wa(int x1,int y1,int x2,int y2,int(&p)[H][W]){
	return p[y2][x2]-p[y2][x1]-p[y1][x2]+p[y1][x1];
}
struct Node{
	vector<pair<int,int>> e;
} node[1];
int A,B,C,D,N,M,K,S,T,H,W;
int p[114514],q[114514],r[114514];
signed main(){
	int i,j,k;
	cin>>A>>B;
	if(A%B==0)
		cout<<-1<<endl;
	else
		cout<<A<<endl;
	return 0;
}

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


ll dp[MAXN];
int n, k;
vector<ll> v;

ll solve(int i)
{
	if(i < 0)
		return 0;
	if(dp[i] >= 0)
	{
		return dp[i];
	}

	ll res1 = -1;
	for (int j = 1; j <= min(k, i); ++j)
		if(res1 != -1)
			res1 = min(res1, abs(v[i] - v[i-j]) + solve(i - j));
		else
			res1 = abs(v[i] - v[i-j]) + solve(i - j);

	dp[i] = res1;

	return dp[i];

}





int main()
{
    
	ll num;
	cin >> n >> k;
	
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		v.push_back(num);
	}

	dp[0] = 0LL;
	dp[1] = abs(v[0] - v[1]); 

	cout << solve(n - 1) << endl;



    return 0;
}

Measured memory_bytes: 12724
import math

x = int(input())
for i in range(1,x+1):
    if i%3==0:
        print(f" {i}",end="")
        continue
    r=i
    while True:
        if r<=0:
            break
        if r%10==3:
            print(f" {i}",end="")
            break
        r//=10
print("")



Measured memory_bytes: 5936
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int a[300][300], cnt[300];
bool chk[300];
int n, m, ans;
Vi b;
void go()
{
	MEM0(cnt);
	fup(i, 0, n - 1, 1)
	{
		fup(j, 0, m - 1, 1)
		{
			if (!chk[a[i][j]])
			{
				cnt[a[i][j]]++;
				break;
			}
		}
	}
	b.clear();
	fup(i, 0, m - 1, 1)if (!chk[i])b.pb(i);
	sort(ALL(b), [&](int x, int y) {
		return cnt[x] > cnt[y];
	});
	ans = min(ans,cnt[b[0]]);
	chk[b[0]] = 1;
}
int main() {
	scanf("%d%d", &n, &m);
	fup(i, 0, n - 1, 1)fup(j, 0, m - 1, 1)scanf("%d", &a[i][j]),a[i][j]--;
	ans = INF;
	fup(i, 0, m - 1, 1)go();
	printf("%d", ans);
}

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

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

  if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
  {
    cout << "hon" << endl;
  }
  else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "bon" << endl;
  }

  return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
const int MAX=3003;

long long ncr[MAX][MAX];
long long dp[MAX][MAX];
int po[MAX*MAX];
int ppo[MAX*MAX];
int pod[MAX*MAX];
typedef long long LL; 
typedef long double LD;
 
int add(int a, int b, int c) {
	int res = a + b;
	return (res >= c ? res - c : res);
}
 
int mod_neg(int a, int b, int c) {
	int res; if(abs(a-b) < c) res = a - b;
	else res = (a-b) % c;
	return (res < 0 ? res + c : res);
}
 
int mul(int a, int b, int c) {
	LL res = (LL)a * b;
	return (res >= c ? res % c : res);
}
 
template <typename T>T power(T e, T n, T m) {
	T x = 1, p = e;
	while(n) {
		if(n & 1) x = mul(x, p, m);
		p = mul(p, p, m);
		n >>= 1;
	}
	return x;
}
 
template<typename T> T extended_euclid(T a, T b, T &x, T &y) {
	T xx = 0, yy = 1; y = 0; x = 1;
	while(b) {
		T q = a / b, t = b;
		b = a % b; a = t;
		t = xx; xx = x - q * xx;
		x = t; t = yy;
		yy = y - q * yy; y = t;
	}
	return a;
}
 
template<typename T> T mod_inverse(T a, T n) {
	T x, y, z = 0; 
	T d = extended_euclid(a, n, x, y);
	return (d > 1 ? -1 : mod_neg(x, z, n));
}

int main()
{
	int n,MOD;
	scanf("%d %d",&n,&MOD);//scanning n,mod
	ncr[0][0]=1;

	for(int i=1;i<=n;i++)
	{
		ncr[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			ncr[i][j]=(ncr[i-1][j-1]+ncr[i-1][j])%MOD;
		}
	}

	po[0]=1;
	ppo[0]=2;
	pod[0]=1;
	for(int i=1;i<=n;i++)
	{
		po[i]=(po[i-1]*2)%(MOD-1);
		ppo[i]=power(2,po[i],MOD);
	}
	for(int i=1;i<=n*n;i++)
	{
		pod[i]=(pod[i-1]*2)%MOD;
	}
	dp[0][0]=1;
	for(int i=1;i<=(n+1);i++)
	{
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j-1];
			dp[i][j]+=((dp[i-1][j]*j)%MOD);
			dp[i][j]%=MOD;
		}
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
	{
		long long val=0;
		for(int j=0;j<=i;j++)
		{
			val+=((pod[((n-i)*1ll*j)%(MOD-1)]*1ll*dp[i+1][j+1])%MOD);
			val%=MOD;
		}
		val*=ppo[n-i];
		val%=MOD;
		val*=ncr[n][i];
		val%=MOD;
		int sign=((i%2)==0)?1:-1;
		ans+=(sign*val);
		ans+=MOD;
		ans%=MOD;
	//	printf("%lld\n",val);
		
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 181248
#include <stdio.h>

int main(void) {
	int n, k, x, y, sum;
	scanf("%d %d %d %d", &n, &k, &x, &y);
	if (n <= k) sum = x*n;
	else sum = x*k + y*(n - k);
	printf("%d", sum);
	return 0;
}


Measured memory_bytes: 128
n, k, s = map(int, input().split())
if k == 0:
    ans = [s + 1 for _ in range(n)] if s != 10**9 else [1 for _ in range(n)]
    print(*ans)
else:
    ans = [s + 1 for _ in range(n)] if s != 10**9 else [1 for _ in range(n)]
    for i in range(k):
        ans[i] = s
    print(*ans)


Measured memory_bytes: 13784
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n;
      cin >>n; 
      lint ans;
      rep(i,n){
          lint a;
          cin>>a;
          if(i==0)ans=a;
          else ans=gcd(ans,a);
      }
      cout<<ans<<endl;
    }
      
    
  

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,N) {
        cin >> V[i];
    }
    sort(V.begin(),V.end());
    cout << V[N - 1] - V[0] << endl;
}



Measured memory_bytes: 3568
n,k=map(int,input().split())
m=10**9+7
t=pow(k,n,m)
p=[0,0]
for i in range(2,k+1):
    p.append(pow(k//i,n,m))
for i in range(k,1,-1):
    if 2*i<=k:
        for j in range(2*i,k+1,i):
            p[i]-=p[j]
    t+=(i-1)*p[i]
    t%=m
print(t)

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

int main() {
  long long x;
  cin >>x;
  long long kotae=x/11*2;
  int amari=x%11;
  if(amari>6)kotae+=2;
  else if(amari>0)kotae++;
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
  int n; cin >> n;
  vector<int> a(n + 1);
  vector<int> b(n);
  for(int i = 0; i < n + 1; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  int sum = 0;
  
  for(int i = 0; i < n; i++){
    int val = min(a[i], b[i]);
    sum += val;
    b[i] -= val;
    int val2 = min(a[i + 1], b[i]);
    sum += val2;
    a[i + 1] -= val2;
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 200500;
const int mod = 1e9 + 7;
char s[N];
int suf[N][26], dp[N];
int n;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < 26; ++i) {
		suf[n][i] = n;
	}
	for (int i = n - 1; i >= 0; --i) {
		dp[i] = n + 5;
		for (int j = 0; j < 26; ++j) {
			suf[i][j] = suf[i + 1][j];
			dp[i] = min(dp[i], dp[suf[i][j]] + 1);
		}
		suf[i][s[i] - 'a'] = i;
	}
	int now = 0;
	while (*max_element(suf[now], suf[now] + 26) != n) {
		int nxt = suf[now][0];
		for (int i = 1; i < 26; ++i) {
			if (dp[suf[now][i]] < dp[nxt]) {
				nxt = suf[now][i];
			}
		}
		printf("%c", s[nxt]);
		now = nxt + 1;
	}
	printf("%c", max_element(suf[now], suf[now] + 26) - suf[now] + 'a');
	return 0;
}


Measured memory_bytes: 21504
def resolve():
  X = int(input())

  rank = 0
  if X<=599:
    print(8)
    return True

  if X<=799:
    print(7)
    return True  

  if X<=999:
    print(6)
    return True  

  if X<=1199:
    print(5)
    return True  

  if X<=1399:
    print(4)
    return True  

  if X<=1599:
    print(3)
    return True  

  if X<=1799:
    print(2)
    return True  

  if X<=1999:
    print(1)
    return True  

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 9196
#include <stdio.h>
#define N 100
main(){
  int n,A[N],a,count=0,i,j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(A[j] < A[j-1]){
        a = A[j];
        A[j] = A[j-1];
        A[j-1] = a;
        count++;
      }
    }
  }
  for(i = 0; i < n; i++){
    if (i > 0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
int main() {
  string w; cin >> w;
  bool f[256] = {};
  for (char c : w) {
    f[c] ^= 1;
  }
  bool ans = 0;
  for (int i = 0; i < 256; i++) ans |= f[i];
  cout << (ans ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
n = gets.strip.to_s
until n.empty? do
  breakmarker=1
  ['eraser','dreamer','dream','erase'].map do |word|
    if n[0-word.length,word.length]==word
      n=n[0,(n.length-word.length)]
      breakmarker=0
    end
  end
  if breakmarker==1
    break  
  end
end
if n.length == 0
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 59520
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

l = factorization(n)

ttl = 0
if l == [[1, 1]]:
    ttl = 0
else:
    for m in l:
        x = m[1]
        for i in range(1, x + 1):
            x -= i
            if x >=0:
                ttl += 1
            else:
                break

print(ttl)

Measured memory_bytes: 9496
import itertools

N = int(input())
P = int("".join(input().split()))
S = int("".join(input().split()))

conb = list(itertools.permutations([str(i+1) for i in range(N)], N))
conb = sorted([int("".join(list(string))) for string in conb])

print(abs(conb.index(P) - conb.index(S)))

Measured memory_bytes: 9972
S = input()
ans = [0] * len(S)
temp_R, temp_L = 0, 0
temp_i = -1
for i, (s1, s2) in enumerate(zip(S, S[1:])):
    st = s1 + s2
    if temp_i == -1: temp_R += 1
    else: temp_L += 1
    if st == 'RL':
        temp_i = i
    elif st == 'LR':
        q_R, q_L = temp_R // 2, temp_L // 2
        ans[temp_i], ans[temp_i + 1] = q_L - q_R + temp_R, q_R - q_L + temp_L
        temp_R, temp_L = 0, 0
        temp_i = -1
temp_L += 1
q_R, q_L = temp_R // 2, temp_L // 2
ans[temp_i], ans[temp_i + 1] = q_L - q_R + temp_R, q_R - q_L + temp_L
print(*ans)

Measured memory_bytes: 6400