akhauriyash/Code-Regression huggingface dataset:
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let mut n = read_as_vec::<usize>()[0];
    let mut ans: Vec<char> = vec![];

    if n == 0 {
        println!("a");
        return;
    }

    while n > 0 {
        ans.push((((n - 1) % 26) as u8 + 'a' as u8) as char);
        n = (n - 1) / 26;
    }

    println!("{}", ans.iter().rev().collect::<String>());
}


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

int main(){
    string S;
    cin>>S;
    vector<int> a(S.size()+1,0);
    for(int i=0;i<S.size();i++){
        if(S[i]=='<'){
            a[i+1]=a[i]+1;
        }
    }
    for(int i=S.size()-1;i>=0;i--){
        if(S[i]=='>'){
            a[i]=max(a[i],a[i+1]+1);
        }
    }
    long long ans=0;
    for(int i=0;i<S.size()+1;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2820
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
    int n = int.Parse(input[0]);
    int k = int.Parse(input[1]);
    long[] dp = new long[n+1];
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

    dp[1] = 0;
    for(int i = 2; i <= n; i++) dp[i] = long.MaxValue;

    for(int i = 2; i <= n; i++)
    {
      for(int j = 0; j < k; j++)
      {
        if(i-j-1 >= 1)
        {
          dp[i] = Math.Min(dp[i], dp[i-j-1]+Math.Abs(nums[i-1]-nums[i-j-2]));
        }
      }
    }
		
		Console.WriteLine(dp[n]);
	}
}

Measured memory_bytes: 18016
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

const long long INF =  1LL << 60;
long long dp[110000];
long long hight[110000];

int main(){
    int N, K;
    cin >> N >> K;
    //init
    for(int i=0; i<N; ++i) cin >> hight[i];
    for(int i=0; i<110000; ++i) dp[i] = INF;

    dp[0] = 0;

    for(int i=0; i<N; ++i){
        for(int j=1; j<=K; ++j){
            chmin(dp[i + j], dp[i] + abs(hight[i] - hight[i + j]));

            //dp[i+j] = min( dp[i+j], dp[i] + abs(hight[i] - hight[i+j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,x; cin >> n >> x;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	b=a;
	ll ans=1e18;
	for(int i=0;i<n;i++){
		// 色変する回数の最大値
		ll res=x*i;
		for(int j=0;j<n;j++){
			res+=b[j];
		}
		ans=min(ans,res);
		for(int j=0;j<n;j++){
			b[j]=min(b[j],a[(j-i-1+n)%n]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
ll fac[2000005];
void init()
{
    fac[0]=fac[1]=1;
    for(int i=2;i<=2000000;i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    return ;
}
ll pow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n=n>>1;
    }
    return ans;
}
ll work(ll m,ll n)
{
    ll ans=fac[m+n-2];
    ans=ans*pow(fac[n-1],mod-2)%mod;
    ans=ans*pow(fac[m-1],mod-2)%mod;
    return ans;
}
int main()
{
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    init();
    ll pre=0,ans=0,k=w-b;
    for(int i=b+1;i<=w;i++,k++)
    {
        ll cnt=work(h-a,i);
        ll tmp=cnt*work(a,w-i+1)%mod;
        ans=(ans+tmp)%mod;
    }
    printf("%lld\n",ans);
}


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

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

int n,x,y;
int a[102],b[102],c[102],d[102];

// idx, umaka, fugashi
int dp[102][302][700];
const int offset = 301;

#define at(i,j,k) dp[i][j][k+offset]

int dfs(int i,int j,int k) {
    if(i==n) return 0;
    int ret=dfs(i+1,j,k);
    if(j>=a[i]) ret=max(ret,dfs(i+1,j-a[i],k+b[i]));
    ret=max(ret,dfs(i+1,j,k-c[i])+d[i]);
    return ret;
}

int main() {
    cin>>n>>x>>y;
    rep(i,n) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    rep(i,102) rep(j,302) rep(k,302*2) dp[i][j][k]=-1e8;
    at(0,x,y)=0;

    rep(i,n) rep(j,302) for(int k=-301;k<=301;k++) {
        //cout<<i<<", "<<j<<", "<<k<<endl;
        chmax(at(i+1,j,k),at(i,j,k));
        if(j-a[i]>=0&&k+b[i]<303*2) chmax(at(i+1,j-a[i],k+b[i]),at(i,j,k));
        if(k-c[i]+offset>=0) chmax(at(i+1,j,k-c[i]), at(i,j,k)+d[i]);
    }
    int ans=-1e8;
    rep(i,n+1) rep(j,302) rep(k,302) chmax(ans,at(i,j,k));
    cout<<ans<<endl;

    return 0;
}

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

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

    int64_t ans = 0;
    for (int64_t A = 1; A <= N; A++) {
        ans += (N - 1) / A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
int32_t main()
{

	    #ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	    #endif

    IOS


    int n;
    cin >> n;

    string ans;

    while(n)
    {
    	int k = (n)%26;
    	if(k == 0)
    	{
    		ans +='z';
    		n/=26;
    		n--;
    	}
    	else
    	{
    		ans += char((k-1) + 'a');
    		n/=26;
    	}

    }

    reverse(all(ans));
    cout << ans;


    return 0;
}


Measured memory_bytes: 3652
//2017-9-30
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define M (300000+5)
#define N (100000+5)

struct node{
	int l, r, len;
	bool operator <(const node &rhs)const{return len < rhs.len;}
}a[M];

int m, c[N];

int lowbit(int x){
	return x & (-x);
}

void Add(int x, int ad){
	while(x <= m){
		c[x] += ad; x += lowbit(x);
	}
}

int Sum(int x){
	int ret = 0;
	while(x > 0){
		ret += c[x]; x -= lowbit(x);
	}
	return ret;
}

int main(){
	int n;

	scanf("%d%d", &n, &m);
	For(i, 1, n){
		scanf("%d%d", &a[i].l, &a[i].r);
		a[i].len = a[i].r - a[i].l + 1;
	}
	sort(a+1, a+n+1);
	
	int ans, ap = 1;
	For(d, 1, m){
		while(ap <= n && a[ap].len < d){
			Add(a[ap].l, 1); Add(a[ap].r+1, -1);
			++ap;
		}
		
		ans = n - ap + 1;
		for(int now = d; now <= m; now += d) ans += Sum(now);
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 4864
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    int n;
    in n;
    vector<int> v;
    rep(i,n)
    {
        int a;
        in a;
        a--;
        v.push_back(a);
    }
    int now=0,c=0;
    while(true)
    {
        if(now==1)
        {
            cout<<c<<endl;
            break;
        }
        if(c>=n)
        {
            cout<<-1<<endl;
            break;
        }
        c++;
        now=v[now];
    }
}


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

const ll mod = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    rep(i, m) {
        int a;
        cin >> a;
        dp[a] = -1;
    }
    for (int i = 1; i <= n; i++) {
        if (dp[i] == -1) continue;
        dp[i] = (dp[i - 1] == -1 ? 0 : dp[i - 1]);
        dp[i] %= mod;
        if (i - 2 >= 0) {
            dp[i] += (dp[i - 2] == -1 ? 0 : dp[i - 2]);
            dp[i] %= mod;
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	var n int
	fmt.Scanln(&n)

	var official_house [4][3][10]int

	for i := 0; i < n; i++ {
		scanner.Scan()
		string := scanner.Text()
		words := strings.Split(string, " ")

		b, _ := strconv.Atoi(words[0])
		f, _ := strconv.Atoi(words[1])
		r, _ := strconv.Atoi(words[2])
		v, _ := strconv.Atoi(words[3])

		official_house[b-1][f-1][r-1] += v
	}


	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 10; k++ {
				fmt.Printf(" %d", official_house[i][j][k])
			}
			fmt.Printf("\n")
		}
		if i < 3 {
			fmt.Println("####################")
		}
	}
}



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

template<class T, class U> struct SegmentTree {
    using F = function<T(T, T)>;
    using G = function<T(T, U)>;
    int n;
    T id;
    vector<T> data;
    F f;
    G g;
    
    SegmentTree(int sz, F f, G g, T def) : f(f), g(g) {
        n = 1; id = def;
        while (n < sz) n *= 2;
        data = vector<T>(2*n-1, id);
    }
    void update (int i, T x) {
        i += n - 1;
        data[i] = g(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return data[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    
    auto f = [](int a, int b) { return min(a, b); };
    auto g = [](int a, int b) { return b; };
    SegmentTree<int, int> sg(N, f, g, INT_MAX);
    for (int q = 0; q < Q; q++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c&1) {
            if (x > y) swap(x, y);
            int res = sg.query(x, y+1);
            printf("%d\n", res);
        } else {
            sg.update(x, y);
        }
    }
    return 0;
}


Measured memory_bytes: 3816
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    n,r=INTM()
    print(r+(10-min(10,n))*100)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3316
def bigger(a, b):
    return a[0] > b[0] and a[1] > b[1]


N = int(input())
ab = []
cd = []
for i in range(N):
    ab.append(list(map(int, input().split())))
for i in range(N):
    cd.append(list(map(int, input().split())))

ab = sorted(ab, key=lambda x: (-x[1], -x[0]))
cd = sorted(cd, key=lambda x: (x[0], x[1]))

ret = 0
ab_used, cd_used = [], []
for c in cd:
    for a in ab:
        if a in ab_used:
            continue
        if c in cd_used:
            break
        if bigger(c, a):
            ab_used.append(a)
            cd_used.append(c)
            ret += 1
            break

print(ret)


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

using namespace std;

#define ll long long
#define ld long double

ll n , m , t;

int main(){
	cin >> n;
	m = 1000 - ( n % 1000 );
	if(m == 1000){
		m = 0;
	}
	cout << m << endl;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    ll n, a, b;

    cin >> n >> a >> b;

    if(a > b){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1){
        if(a != b){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (b - a) * (n - 2) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n){
    int num;
    cin >> num;
    mp[num]++;
  }
  if(n % 2 == 0){
    for(int i=1; i<n; i+=2){
      if(mp[i] != 2){
        cout << 0 << endl;
        return 0;
      }
    }
  }else{
    for(int i=0; i<n; i+=2){
      if(i == 0){
        if(mp[i] != 1){
          cout << 0 << endl;
          return 0;
        }
      }else{
        if(mp[i] != 2){
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  ll sum = 1;
  for(int i=0; i<n/2; i++){
    sum *= 2;
    sum %= mod;
  }
  cout << sum << endl;
  return 0;
}
  
  
  
  
  

Measured memory_bytes: 3200
#!/usr/bin/env python3
import sys


YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int):
    print(YES if A * B % 2 == 1 else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


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

int main() {
	int n, a, b[100010], ans = 0;
	cin >> n;
	for (int i = 1; i <= 100000; i++) b[i] = 0;
	for (int i = 1; i <= n; i++) {
	    cin >> a;
	    if (a <= 100000) b[a]++;
	    else b[100001]++;
	}
	for (int i = 1; i <= 100000; i++) {
	    if (b[i] < i) ans += b[i];
	    else if (b[i] > i) ans += (b[i] - i);
	}
	ans += b[100001];
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
h = []

for a in A: heapq.heappush(h, -a)
for _ in range(M):
	a = heapq.heappop(h) * -1
	a //= 2
	heapq.heappush(h, -a)

sum = 0
for _ in range(N): 
	sum -= heapq.heappop(h)
print(sum)

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	if ((A + B + C) >= 22) {
		cout << "bust" << endl;
    }
	else {
		cout << "win" << endl;
	}
	return 0;
}

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

int main(){
  int n , m;
  cin >> n >> m;
  vector <string> a(n);
  
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  
  for(int i = 0; i < m + 2; i++)
    cout << "#";
  cout << endl;
  
  for(int i = 0; i < n; i++)
    cout << "#" << a.at(i) << "#" << endl;
  
  for(int i = 0; i < m + 2; i++)
    cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=200005;
const int mod=924844033;
struct edge{int x,y,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int pre[MAXN],inv[MAXN];
int pow_mod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1LL*ret*a%mod;
		a=1LL*a*a%mod;b>>=1;
	}
	return ret;
}
int A[MAXN*4],B[MAXN*4],R[MAXN*4],L;
void NTT(int *y,int len,int on)
{
	for(int i=0;i<len;i++)if(i<R[i])swap(y[i],y[R[i]]);
	for(int i=1;i<len;i<<=1)
	{
		int wn=pow_mod(5,(mod-1)/(i<<1));if(on==-1)wn=pow_mod(wn,mod-2);
		for(int j=0;j<len;j+=(i<<1))
		{
			int w=1;
			for(int k=0;k<i;k++)
			{
				int u=y[j+k],v=1LL*y[j+k+i]*w%mod;
				y[j+k]=(u+v)%mod;
				y[j+k+i]=(u-v+mod)%mod;
				w=1LL*w*wn%mod;
			}
		}
	}
	if(on==-1)
	{
		int temp=pow_mod(len,mod-2);
		for(int i=0;i<len;i++)y[i]=1LL*y[i]*temp%mod;
	}
}
int n,siz[MAXN];
void init(int x,int fa)
{
	siz[x]=1;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y!=fa)init(y,x),siz[x]+=siz[y];
	}
}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int ans[MAXN];
int main()
{
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
	}
	init(1,0);
	int ln;
	for(ln=1;ln<=2*n;ln<<=1)L++;
	for(int i=1;i<ln;i++)R[i]=(R[i>>1]>>1)|(i&1)<<(L-1);
	for(int i=1;i<=n;i++)ad(A[siz[i]],pre[siz[i]]);
	for(int i=0;i<=n;i++)B[i]=inv[i];
	reverse(B,B+n+1);
//	for(int i=1;i<=n;i++)A[i]=B[i]=1;
	NTT(A,ln,1);NTT(B,ln,1);
	for(int i=0;i<ln;i++)A[i]=1LL*A[i]*B[i]%mod;
	NTT(A,ln,-1);
	for(int i=1;i<=n;i++)ad(ans[i],1LL*A[i+n]*inv[i]%mod);
//	for(int i=1;i<=n;i++)pr2(ans[i]);
//	return 0;
	memset(A,0,sizeof(A));
	for(int i=1;i<=n;i++)ad(A[n-siz[i]],pre[n-siz[i]]);
	NTT(A,ln,1);
	for(int i=0;i<ln;i++)A[i]=1LL*A[i]*B[i]%mod;
	NTT(A,ln,-1);
	for(int i=1;i<=n;i++)ad(ans[i],1LL*A[i+n]*inv[i]%mod);
	for(int i=1;i<=n;i++)dl(ans[i],C(siz[1],i));
	for(int i=1;i<=n;i++)ans[i]=(1LL*C(n,i)*n%mod-ans[i]+mod)%mod;
	for(int i=1;i<=n;i++)pr2(ans[i]);
	return 0;
}


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var nm = Input3();
            var n = nm[0];
            var m = nm[1];
            var ab = new Dictionary<long,long>();
            var a = new long[n];

            for(int i = 0; i < n; i++)
            {
                var data = Input3();
                if (!ab.ContainsKey(data[0])) ab.Add(data[0], data[1]);
                else ab[data[0]] += data[1];
                a[i] = data[0];
            }
            a = a.Distinct().ToArray();
            Array.Sort(a);
            

            long bought = 0;
            long ans = 0;

           for(long j = 0; j < n; j++)
            {
                ans += a[j]* Math.Min(m - bought, ab[a[j]]);
                bought += Math.Min(m - bought, ab[a[j]]);
                //Console.WriteLine(bought + " " + ans + " " + a[j]);
                if (m-bought==0) break;
               
            }
            
            Console.WriteLine(ans);
            
        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }
    }
}


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

int X;

int main() {
    cin >> X;
    long long int A, B;
    for (long long int i = 0; i * i * i * i <= X; i++) {
        for(long long int j = 0; j <= i; j++) {
            long long int i5 = i * i * i * i * i;
            long long int j5 = j * j * j * j * j;
            if (i5 - j5 == X) {
                cout << i << " " << j << endl;
                return 0;
            }
            else if (i5 + j5 == X) {
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 1; i <= k; i++)cout << s << " ";
    for (int i = k + 1; i <= n; i++)cout << (s == 1e9 ? s - 1 : s + 1) << " \n"[i == n];
    return 0;
}

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

using namespace std;

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

	int result = 1;
	char c = S[0];

	for (int i = 0; i < N; i++) {
		if (S[i] != c) {
			result++;
			c = S[i];
		}
	}

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		List<String> list = new ArrayList<>(); 
		for(int i = 0; i < a; i++) {
			list.add(sc.next());
		}
		Collections.sort(list);
		String out = "";
		for(int j = 0; j < list.size(); j++) {
			out += list.get(j);
		}
		System.out.println(out);
	}
}

Measured memory_bytes: 25044
x = int(input())

for i in range(-1000,1000) :
    flag = 0
    for j in range(-1000,i) :
        if x%(i-j) != 0 :
            continue
        v = x//(i-j)
        c = i**4+j**4+i*j*(i**2+i*j+j**2)
        if v == c :
            print(i,j)
            flag = 1
            break
    if flag == 1 :
        break

Measured memory_bytes: 67448
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void)
{
    int i, j, sa, a=100, c, judge=0;
    int X, N;
    scanf("%d",&X);
    scanf("%d",&N);
    int data[N];

    for(i=0; i<N; i++) {
        scanf("%d",&data[i]);
    }

    for(i=0; i<=120; i++){
        for(j=0;j<N;j++){
            if(i == data[j]){
                judge = 1;
                break;
            }
        }
        if(judge != 1) {
            sa = abs(X - i);
            if(sa < a) {        
                a = sa;
                c = i;
            }
        } else {
            judge = 0;
        }
    }

    printf("%d\n", c);

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    double left, right, top, bottom;
    ll n;
    left = 0;
    bottom = 0;
    cin >> right >> top >> n;
    REP(i, n) {
        double x, y;
        ll op;
        cin >> x >> y >> op;
        if (op == 1) {
            if (left < x) left = x;
        } else if (op == 2) {
            if (x < right) right = x;
        } else if (op == 3) {
            if (bottom < y) bottom = y;
        } else {
            if (y < top) top = y;
        }
    }
    if (top >= bottom && right >= left) {
        cout << (top - bottom) * (right - left) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  string s;
  cin >> s;
  ll N=s.size();
  ll i;
  ll l[MAX], r[MAX];
  
  //←(L)
  for(i=0; i<N; i++) {
    ll t=0;
    while(s[i]=='L') {
      l[i]=t;
      t++;
      i++;
    }
  }
  
  //→(R)
  for(i=N-1; i>=0; i--) {
    ll t=0;
    while(s[i]=='R') {
      r[i]=t;
      t++;
      i--;
    }
  }
  
  ll cnt[MAX]={};
  for(i=0; i<N; i++) {
    if(s[i]=='L') {
      if(l[i]&1) cnt[i-l[i]-1]++;
      else cnt[i-l[i]]++;
    }else if(s[i]=='R') {
      if(r[i]&1) cnt[i+r[i]+1]++;
      else cnt[i+r[i]]++;
    }
    
  }
  
  for(i=0; i<N; i++) {
    pt(cnt[i]);
  }
}












Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

int main()
{
    ios::sync_with_stdio(false);
    int sum = 0;
    vector<int> v;
    int n;
    cin >> n;
    REP(i,n)
    {
        int tmp;
        cin >> tmp;
        sum += tmp;
        v.push_back(tmp);
    }
    double f = sum / (double) n;
    int ave = f > 0 ? f+0.5 : f - 0.5;
    int ans = 0;
    REP(i, n)
    {
        int tmp = v[i] - ave;
        tmp *= tmp;
        ans += tmp;
    }
    cout << ans << '\n';
}



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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int check4 = (g*10+b) % 4;
    if(check4 == 0)
        {
             cout << "YES" << endl; 
        }
    else
        { 
            cout << "NO" << endl;
          }

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

char s[200000+10];
char t[200000+10];
int n;

char conv[30];

bool isOK(void) {
  REP(i, 26) {
    conv[i] = 'a' + i;
  }
  REP(i, n) {
    if(conv[s[i]-'a'] != t[i]) {
      REP(j, 26) {
        if(conv[j] == t[i]) {
          conv[j] = conv[s[i]-'a'];
        }
      }
      conv[s[i]-'a'] = t[i];
    }
  }
  REP(i, n) {
    if(conv[s[i]-'a'] != t[i]) {
      return false;
    }
  }
  return true;
}

int main(void) {
  scanf("%s%s", s, t);
  n = strlen(s);
  bool res = isOK();
  puts(res ? "Yes" : "No");
  return 0;
}



Measured memory_bytes: 640
#include <stdio.h>

int main(){

  int N,M,i,j,a[200000],b[200000],c[200000],x=1,y=0,z=0,max;
  scanf("%d %d",&N,&M);
  for(i=0;i<M;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
      z=N/2;
  for(i=0;i<M;i++){
    if(a[i]==1){
      c[b[i]]=1;
    }
  }
    for(j=0;j<M;j++){
      if(c[a[j]]==1 && b[j]==N){
        y++;
        break;
      }
    }
  if(y==1){
    printf("POSSIBLE");
  }else{
    printf("IMPOSSIBLE");
  }

  return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
	int x;
	int y;
	int i;
	for (i=0;i<3000;i++){
		scanf("%d%d", &x, &y);
		if (x==0&&y==0)
		break;
		if (x>y)
		printf("%d %d\n", y, x);
		else printf("%d %d\n", x, y);
	}
	return 0;
}


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

int n, f[1009][19], c[1009][19], minx = -1000000000;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) cin >> f[i][j];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 10; j++) cin >> c[i][j];
	}
	for (int i = 1; i < (1 << 10); i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			int s = 0;
			for (int k = 0; k < 10; k++) {
				if ((i / (1 << k)) % 2 == 1 && f[j][k] == 1) s++;
			}
			sum += c[j][s];
		}
		minx = max(minx, sum);
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

class B {
	int a, b, c, x;
public:
	void solve()
	{
		int ans{ 0 };
		for (int i{ 0 }; i <= a; i++)
		{
			for (int j{ 0 }; j <= b; j++)
			{
				for (int k{ 0 }; k <= c; k++)
				{
					if (500 * i + 100 * j + 50 * k == x) ans++;
				}
			}
		}
		cout << ans << endl;
	}

	B() { cin >> a >> b >> c >> x; }
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
//Name: My friends are small
//Level:
//Category:
//Note:

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define FOREACH(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define TIMES(i,n) for(int (i) = 0; (i) < (n); ++(i))

typedef long long LL;
const LL MOD = 1000000007;

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

    int N, K;
    while(cin >> N >> K) {
        //dp[i][w] = v[i...N]でwを作るパターン数
        vector<vector<LL> > dp(N+1, vector<LL>(10001, 0));
        vector<int> v(N);
        TIMES(i, N) {
            cin >> v[i];
        }
        sort(v.begin(), v.end());

        dp[N][0] = 1;
        for(int i = N-1; i >= 0; --i) {
            dp[i] = dp[i+1];
            TIMES(w, K+1) {
                if(w < v[i]) continue;
                dp[i][w] += dp[i+1][w-v[i]];
                dp[i][w] %= MOD;
            }
        }

        /*
        TIMES(i, N) {
            TIMES(w, K) {
                cout << dp[i][w] << ' ';
            }
            cout << endl;
        }
        */

        LL ans = 0;
        int sum = 0;
        TIMES(i, N) {
            // skip v[i]
            const int remain = K - sum;
            for(int w = max(0, K-sum-v[i]+1); w <= remain; ++w) {
                ans += dp[i+1][w];
                ans %= MOD;
            }
            sum += v[i];
            if(sum > K) break;
        }
        // use all
        if(sum <= K) {
            ans += 1;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 16844
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,k;
    cin >> n >> k;
    ll r,s,p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    vector<int> a(t.size()),b(t.size(),4);
    rep(i,t.size()){
        if (t[i]=='s') a[i]=0;
        if (t[i]=='p') a[i]=1;
        if (t[i]=='r') a[i]=2;
    }
    int u=0;
    ll ans=0;
    rep(i,t.size()){
        if (i>=k){
            if (b[i-k]==a[i]) continue;
        }
        if (a[i]==0) ans+=r;
        if (a[i]==1) ans+=s;
        if (a[i]==2) ans+=p;
        b[i]=a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
while True:
    H, W = map(int, input().split())
    if not(H or W):
        break
    print('#' * W)
    for i in range(H-2):
        print('#', end='')
        for j in range(W-2):
            print('.', end='')
        print('#')
    print('#' * W, end='\n\n')

Measured memory_bytes: 8956
solve a b = [sum $ map (\(y,z) -> y*z) (zip x b) | x <- a]
main = do
    [n, m] <- fmap (map read . words) getLine
    a <- fmap (map (map read) . map words) $ mapM (\_ -> getLine) [1..n]
    b <- fmap (concat. map (map read) . map words) $ mapM (\_ -> getLine) [1..m]
    putStr $ unlines $ map show $ solve a b




Measured memory_bytes: 7524
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    string s, t;
    sf(s, t);
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int R = sc.nextInt();
			
			if(N >= 10) {
				System.out.println(R);
			}else {
				System.out.println(R + 100 * (10 - N));
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int64_t rec(int64_t h) {
    if (h == 1) {
        return 1;
    }
    return 1 + 2 * rec(h / 2);
}

void solve() {
    int64_t h;
    cin >> h;
    cout << rec(h) << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

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

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  int ans8, ans1;
  for(int i = 0; i <= 10000; i ++){
    ans8 = i * (double)0.08;
    ans1 = i * (double)0.1;
    if(ans8 == a && ans1== b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;
int main(){
    int s, w;
    cin >> s>> w;
    if(s > w)cout << "safe";
    else cout << "unsafe";
}

Measured memory_bytes: 3604
N = int(input())
a = N // 1000
b = (N // 100) - a*10
c = (N // 10) - a*100 - b*10
d = N % 10
if a+b+c+d == 7:
    print("%d+%d+%d+%d=7" % (a,b,c,d))
elif a+b+c-d == 7:
    print("%d+%d+%d-%d=7" % (a,b,c,d))
elif a+b-c+d == 7:
    print("%d+%d-%d+%d=7" % (a,b,c,d))
elif a+b-c-d == 7:
    print("%d+%d-%d-%d=7" % (a,b,c,d))
elif a-b+c+d == 7:
    print("%d-%d+%d+%d=7" % (a,b,c,d))
elif a-b+c-d == 7:
    print("%d-%d+%d-%d=7" % (a,b,c,d))
elif a-b-c+d == 7:
    print("%d-%d-%d+%d=7" % (a,b,c,d))
elif a-b-c-d == 7:
    print("%d-%d-%d-%d=7" % (a,b,c,d))


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

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;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans=0;
    rep(i,n){
        ans+=min(a[i],abs(a[i]-k));
    }
    cout<<ans*2<<endl;
    
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>

using namespace std;

void Solution()
{
    string s;
    string rule;
    string origin = " ";
    
    while(cin>>s)
    {
        for(int i = 0; i < (int)s.size();)
        {
            if(s[i] == '@')
            {
                rule = s.substr(i, 3);
               
                i += 3;

                for(int i = 0; i < rule[1] - '0'; i++) //need change char to int
                {
                    cout<<rule[2];
                }
            }
            else
            {
                cout<<s[i];
                i++;
            }
    
        }
        
        cout<<endl;
    }
}

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

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

int main() {
  int A[9];
  for (int i = 0; i < 9; i++) cin >> A[i];
  int N; cin >> N;
  int b[N];
  for (int i = 0; i < N; i++) cin >> b[i];
  
  bool flag[9];
  for (int i = 0; i < 9; i++) flag[i] = false;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 9; j++){
      if (b[i] == A[j]) flag[j] = true;
    }
  }
  bool ans = false;
  if (flag[0] + flag[1] + flag[2] == 3) ans = true;
  if (flag[3] + flag[4] + flag[5] == 3) ans = true;
  if (flag[6] + flag[7] + flag[8] == 3) ans = true;
  if (flag[0] + flag[3] + flag[6] == 3) ans = true;
  if (flag[1] + flag[4] + flag[7] == 3) ans = true;
  if (flag[2] + flag[5] + flag[8] == 3) ans = true;
  if (flag[0] + flag[4] + flag[8] == 3) ans = true;
  if (flag[2] + flag[4] + flag[6] == 3) ans = true;
  if (ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
s = gets.chop
k = gets.to_i


i=0
while (k > 0) && (i < s.size)
  if s[i] != "a"
    d = "z".ord - s[i].ord + 1
    if k >= d
      k -= d
      s[i] = "a"
    end
  end
  i += 1
end


s[-1] = (((s[-1].ord + k - "a".ord) % 26) + "a".ord).chr
puts s


Measured memory_bytes: 2044
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

/*

struct mint {
	int x;
	mint(int x = 0) :x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= MOD)x -= MOD;
		return *this;
	}
	mint & operator-=(const mint a) {
		if ((x += MOD - a.x) >= MOD)x -= MOD;
		return *this;
	}
	mint & operator*=(const mint a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint a)const {
		return mint(*this) += a;
	}
	mint operator-(const mint a)const {
		return mint(*this) -= a;
	}
	mint operator*(const mint a)const {
		return mint(*this) *= a;
	}
	mint pow(int t)const {
		if (!t)return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1)a *= *this;
		return a;
	}
	
	//for prime mod
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a)const {
		mint res(*this);
		return res /= a;
	}
};
*/
int main() {
	ll R;
	cin >> R;
	cout << 2*R * 3.14159;


}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;

int main(void){
	cin >> s;
	ll ans=0;
	ll cnta=0;
	int flag=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'){
			if(flag==1){
				cnta=0;
				flag=0;
			}
			cnta++;
		}else if(s[i]=='B'){
			if(flag!=0){
				flag=0;
				cnta=0;
			}else{
				flag=1;
			}
		}else{
			if(flag!=1){
				cnta=0;
				flag=0;
			}else{
				ans+=cnta;
				flag=0;
			}
		}
		//printf("%c %d %lld %lld\n",s[i],flag,cnta,ans);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    char a;
    cin >> a;
    if (a >= 'a') cout << 'a';
    else cout << 'A';
    
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if(A + B > C + D)
        cout << "Left" << endl;
    else if(A + B == C + D)
        cout << "Balanced" << endl;
    else
        cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 888
F=Int[1]
mod=10^9+7
for i=1:2*10^5
	push!(F,F[i]*i%mod)
end
function f(H,W)
	F[H+W-1]*invmod(F[H]*F[W]%mod,mod)%mod
end
H,W,A,B=map(x->parse(Int,x),split(readline()))
ans=0
for i=B+1:W
	ans=(ans+f(H-A,i)*f(W-i+1,A)%mod)%mod
end
println(ans)


Measured memory_bytes: 152216