akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))


typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

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


inline lint gcd(lint m, lint n) {
	if (n == 0)return abs(m);
	return gcd(n, m%n);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	lint n, k, in; cin >> n >> k;
	vector<lint> a;
	if (n == 1) {
		cin >> in;
		POSSIBLE(in == k);
		return 0;
	}

	rep(i, n) {
		cin >> in;
		a.push_back(in);
		if (in == k) {
			co("POSSIBLE");
			gc();
			return 0;
		}
	}
	lint g = a[0];
	repi(i, 1, n) {
		g = gcd(g, a[i]);
	}
	bool ans = 0;
	lint i = 0;
	lint m = vmax(a);
	while (m - i * g > 0) {
		if (k == m - i * g) {
			ans = 1;
			break;
		}
		i++;
	}
	POSSIBLE(ans);
	gc();
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    Graph G(n);
    rep(i, n-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[x].push_back(y);
    G[y].push_back(x);

    vector<LL> ans(n, 0);
    rep(i, n){
        vector<int> cost(n, -1);
        queue<int> que;
        que.push(i);
        cost[i] = 0;
    
        while(!que.empty()) {
            int p = que.front();
            que.pop();
            repe(j, G[p]){
                if(cost[j] >= 0) continue;
                cost[j] = cost[p]+1;
                ans[cost[j]]++;
                que.push(j);
            }
        }
    }
    rep1(i, n){
        cout << ans[i]/2 << endl;
    }
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define endl "\n"
int dp[100005];
int getAns(int a[],int i,int n,int k){
    if(i == n-1)return 0;
    if(dp[i] != -1)return dp[i];
    int ans = INT_MAX;
    forn(j,1,k){
        int x = INT_MAX;
        if(i < n-j)x = abs(a[i+j] - a[i]) + getAns(a,i+j,n,k);
        ans = min(ans,x);
    }
    return dp[i] = ans;
}
int main(){
    FASTIO
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<getAns(a,0,n,k)<<endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
typedef long long ll;
typedef long double ld;
int A[200005], B[200005];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
	for (int i = 0; i < n; ++i) scanf("%d", &B[i]);
	int ans = 0;
	for (int b = 0; b < 29; ++b) {
		int mask = (1 << b) - 1;
		vector<pair<int, int>> events;
		for (int i = 0; i < n; ++i)
			events.push_back({mask + 1 - (A[i] & mask), i});
		int totnum[2] = {0, 0}, num[2] = {0, 0};
		for (int i = 0; i < n; ++i) {
			bool bit = B[i] & (1 << b);
			++totnum[bit];
			events.push_back({B[i] & mask, i + n});
		}
		sort(events.begin(), events.end());
		ll tot = 0;
		for (auto e : events) {
			int i = e.second;
			if (i >= n) {
				i -= n;
				bool bit = B[i] & (1 << b);
				++num[bit];
			} else {
				bool bit = A[i] & (1 << b);
				if (bit) {
					tot += num[0] + totnum[1] - num[1];
				} else {
					tot += num[1] + totnum[0] - num[0];
				}
			}
		}
		if (tot & 1) ans += 1 << b;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 10044
module priority_queue
    implicit none
    private
    integer:: last
    integer(8), allocatable:: pq(:)
    public:: pq_init, pq_push, pq_pop
contains
subroutine pq_init(n)
    integer:: n
    allocate(pq(n))
    last = 0
end subroutine

subroutine pq_push(x)
    integer(8)::x
    integer:: ins, p
    last = last + 1
    
    ins = last
    p = last / 2
    do while(p >= 1)
        if(pq(p) >= x) exit
        pq(ins) = pq(p)
        ins = p
        p = ins / 2
    end do

    pq(ins) = x
    ! print*, pq(1:last)
end subroutine

function pq_pop() result(ret)
    integer(8):: ret, last_value
    integer:: ins, c1, c2
    ret = pq(1)
    last_value = pq(last)
    last = last - 1
    ins = 1
    c1 = ins*2
    c2 = c1 + 1

    do while(c1 <= last)
        if(max(pq(c1),pq(c2)) <= last_value) exit
        if(pq(c2) > pq(c1))c1 = c2
        pq(ins) = pq(c1)
        ins = c1
        c1 = ins*2
        c2 = c1 + 1 
    end do
    pq(ins) = last_value

    ! print*, c1, last_value
    ! print*, pq(1:last)
end function
    
end module

program main
    use priority_queue
    implicit none
    integer:: n,m, i,j,k
    integer(8):: max_, ans
    integer(8), allocatable:: a(:)

    read*, n, m
    allocate(a(n))
    read*, a(1:n)
    call pq_init(n)

    do i = 1, n
        call pq_push(a(i))
    end do

    do while(m > 0)
        max_ = pq_pop()
        max_ = max_ / 2
        call pq_push(max_)
        m = m - 1
    end do
    ans = 0
    do i = 1, n
        ans = ans + pq_pop()
    end do

    print*, ans    
end program

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

int main(){
    int n;
    cin >> n;
    deque<long> a;
    for (int i=0; i<n; i++){
        long input;
        cin >> input;
        if (i & 1) a.push_front(input);
        else a.push_back(input);
    }
    for (int i=0; i<n; i++){
        if (n & 1){
            cout << a[n-1-i] << " ";
        }
        else{
            cout << a[i] << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 5236
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	long long n,cou=0,cp;
	cin>>n;
	cp=n;
	vector<long long>p;
	long long rt=pow(n,0.5);
	for(int i=2;i<=rt;i++)
	{
		long long cc=0;
		while(n%i==0)
		{
			n=n/i;
			cc++;
		}
		if(cc>0)p.push_back(i);
	}
	if(n>1)p.push_back(n);
	n=cp;
	long long ans=0;
	for(int i=0;i<p.size();i++)
	{
		long long tem=0;
		while(n%p[i]==0&&n>1)
		{
			tem++;
			n=n/p[i];
		}
		long long min=0,max=1000,guess=(min+max)/2;
		while(min+1!=max)
		{
			if((guess*(guess+1))/2<=tem)
			{
				min=guess;
			}
			else max=guess;
			guess=(min+max)/2;
		}
		long long add=0;
		if(min-2>0)
		{
			if(((min-2)*(min-1))/2<=tem)add=min-2;
		}
		if(min-1>0)
		{
			if(((min-1)*(min))/2<=tem)add=min-1;
		}

		if(min>0)
		{
			if(((min+0)*(min+1))/2<=tem)add=min;
		}
		if(min+1>0)
		{
			if(((min+1)*(min+2))/2<=tem)add=min+1;
		}
		if(min+2>0)
		{
			if(((min+2)*(min+3))/2<=tem)add=min+2;
		}
		ans=ans+add;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
void dumpVector(const vector<ll>& vec) {
#ifdef SOURCE_TEST
    for (ll i = 0; i < vec.size(); ++i) {
        cout << vec[i] << ",";
    }
    cout << endl;
#endif
}

class UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
public:
    vector<ll> datas;
    UnionFind(ll N) : datas(N, -1) {
    }
    bool isRoot(ll x) const {
        return datas[x] < 0;
    }
    ll root(ll x) {
        if (isRoot(x)) return x;
        // Rootの情報を更新する
        datas[x] = root(datas[x]);
        return datas[x];
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (datas[x] > datas[y]) swap(x, y);
        datas[x] += datas[y];
        datas[y] = x;
        return true;
    }

    ll size(ll x) {
        return -datas[root(x)];
    }

    void Dump() {
#ifdef SOURCE_TEST
        REP(i, datas.size()) {
            if (isRoot(i)) {
                PS("Root:");
                PS(size(i));
            } else {
                cout << datas[i] << ":";
            }

            PR(i);
        }
#endif
    }
};

int main() {
    ll N, M;
    cin >> N >> M;

    UnionFind UF(N);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A -= 1;
        B -= 1;
        UF.unite(A, B);
    }

    UF.Dump();

    //最大の友達集合を求める
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans = max(ans, UF.size(i));
    }

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

Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll a[10010];
ll b[10010];
ll suma,sumb,cnta,cntb;
int main(){
  cin >> N;
  rep(i,N){
    cin >> a[i];
    suma += a[i];
  }
  rep(i,N){
    cin >> b[i];
    sumb += b[i];
    if(a[i] - b[i] < 0){
      cnta += (b[i]-a[i])/2;
      if((b[i] - a[i])%2 == 1){
        cnta += 1;
        cntb += 1;
      }
    }
    else{
      cntb += a[i] - b[i];
    }
  }
  ll action_num = sumb-suma;
  if(action_num < 0) cout << "No" << endl;
  else if(cnta > action_num || cntb > action_num) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 384
while True:
    count = 0
    n, x = map(int, input().split(' '))
    if n == x == 0:
        break
    max_a = x // 3
    for a in range(1, n-1):
        for b in range(a + 1, n):
            c = x - a - b
            if c > 0 and c <= n and c > b:
                count += 1
    print(count)


Measured memory_bytes: 5592
n, k = map(int,input().split())

numl = []
numl2 = []

for i in range(1,n+1):
  if (i%k == 0):
    numl.append(i)

if k%2 == 0:
  for i in range(1,n+1):
    if (i%k == k//2):
      numl2.append(i)

num = len(numl)
num2 = len(numl2)
ans = num**3 + num2**3

print(ans)

Measured memory_bytes: 11016
#include <stdio.h>
#include <math.h>

#define PI (3.14159265358979323846)

int main(void)
{
	int walk = 1, dir = 1;
	int dir_old = 90;
	double x = 0.0, y = 0.0;
	
	while ((walk != 0) && (dir != 0)){
		scanf("%d,%d", &walk, &dir);
		x += cos(((dir_old * PI) / 180)) * walk;
		y += sin(((dir_old * PI) / 180)) * walk;
		dir *= -1;
		dir_old = (dir_old + dir) % 360;
	}
	
	printf("%d\n%d\n", (int)x, (int)y);
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[40];
	for(int i=1;i<=32;i++){
		if(i==4 || i==6 || i==9 || i==10 || i==14 || i==21 || i==22 || i==25 ||i==26){
			a[i]=2;
		}
		else if(i==8 || i==12 || i==18 || i== 20 || i==27){
			a[i]=5;
		
		}
	else if(i==16){
		a[i]=14;
		}
	else if(i==24){
		a[i]=15;
	}
	else if(i==30 || i==28){
		a[i]=4;
	}
	else if(i==32){
		a[i]=51;
	}
	else 
		a[i]=1;
	}
	int k;
	cin>>k;
	cout<<a[k]<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define modulo 998244353
#define endl '\n'
#define pb push_back
using namespace std;
vector <int> adj[100001];
ll fxp(ll a, ll b)
{
    if(b == 0)return 1;
	if(b%2 == 0){
		ll c = fxp(a,b/2);
		return (c*c)%1000000007;
	}
	return (a*fxp(a,b-1))%1000000007;
}
int lcm(int c,int d)
{
    int a=c;
    int b=d;
    int ans;
    if(a>=b)
    {
        while(b!=0)
        { 
            int x=b;
            b=a%b;
            a=x;
        }
        ans = ( c*d)/a;
    }
    else
    {
        while(a!=0)
        {
            int x=a;
            a=b%a;
            b=x;
        }
        ans = ( c*d)/b;  
    }
    return ans;
}
int root_find()
{
    ll x;
    for(int i=1;i<100001;i++)
    {
        if(adj[i].size()==1)
        {
            x = i;
            break;
        }
    }
    return x;
}
void dfs(int s,int y)
{
    for(int i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]==y)
        continue;
        dfs(adj[s][i],s);
    }
}
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return n/2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return n/i; 
    } 
  
    return n; 
}  
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    ll n =s.length();
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6124
using System;
using System.IO;

class Solve {
    static void Main(string[] args) {
        var max = int.Parse(Console.ReadLine()) + 1;
        var dp = new int[max];
        for (int i = 0; i < max; i++) {
            dp[i] = max;
        }
        dp[0] = 0;
        for (int i = 0; i < max; i++) {
            for (int m_nine = 9; m_nine <= i; m_nine *= 9) {
                dp[i] = Math.Min(dp[i], dp[i - m_nine] + 1);
            }
            for (int m_six = 1; m_six <= i; m_six *= 6) {
                dp[i] = Math.Min(dp[i], dp[i - m_six] + 1);
            }
        }
        var answer = dp[^1];
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 27852
n = int(input())
ns = input().split(" ")
for i in range(n):
    ns[i] = int(ns[i])

count = 0
for i in range(n-2):
    area = [ns[i], ns[i+1], ns[i+2]]
    if ns[i+1] != min(area) and ns[i+1] != max(area):
        count += 1

print(count)


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String winner;
        List<Integer> strengthOrder = new ArrayList<>(Arrays.asList(2,3,4,5,6,7,8,9,10,11,12,13,1));
        int Alice = strengthOrder.indexOf(A);
        int Bob = strengthOrder.indexOf(B);
        if(Alice > Bob) winner = "Alice";
        else if(Alice == Bob) winner = "Draw";
        else winner = "Bob";
        System.out.println(winner);
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}

Measured memory_bytes: 21200
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n,m;
	cin>>n>>m;
	ll res=0;
	if(n*2<=m){
		res+=n;
		m-=2*n;
		res+=m/4LL;
	}
	else res=m/2LL;
	cout<<res<<'\n';
}



Measured memory_bytes: 3568
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();
    let d: i64 = input();
    println!("{}", std::cmp::min(a, b) + std::cmp::min(c, d));
}


Measured memory_bytes: 4352
import math

#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

x = int(input())
boolean = True
while boolean:
    if is_prime(x):
        print(x)
        break
    x += 1 

Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int n, ans=0;
    cin >> n;
    vector <int> v(n, 0), c(n,0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) ans += v[i] - c[i];
    }   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		boolean flag =true;
		int h;
		int w;
		String mark = "#";
		while(flag){
			h = sc.nextInt();
			w = sc.nextInt();
			if(h == 0 && w == 0){
				break;
			}
			for(int i = 0;i < h;i++){
				if(i == 0 || i == h-1){
					for(int j = 0;j < w;j++){
						System.out.print(mark);
					}
				}else{
					for(int j = 0;j < w;j++){
						if(j == 0 || j == w-1){
							mark = "#";
						}else{
							mark = ".";
						}
						System.out.print(mark);
					}
					
				}
				System.out.println();
			}
			System.out.println();
		}	
	}
}


Measured memory_bytes: 34972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  int x;
  cin >> x;
  cout << (x/500)*1000+(x%500)/5*5 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

vector<int> bfs(const vector<vector<int>> &G, int s) {
    vector<int> ret(G.size(),-1);
    ret[s] = 0;
    queue<int> que;
    que.emplace(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (ret[nv] != -1) continue;
            ret[nv] = ret[v] + 1;
            que.emplace(nv);
        }
    }

    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<int>> G(N);
    rep(i,N-1) {
        int u,v; cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    auto dist = bfs(G,0);
    int s = max_element(all(dist)) - dist.begin();
    auto dfs=[&](auto&& self, int v, int pv)->int {
        int ret = 0;
        int cnt0 = 0;
        for (auto nv : G[v]) {
            if (nv==pv) continue;
            int val = self(self,nv,v);
            ret += val;
            if (!val) cnt0++;
        }
        ret += max(0,cnt0-1);
        return ret;
    };
    cout << dfs(dfs,s,-1)+1 << ln;
}


Measured memory_bytes: 9600
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int a,b,c;
	public void solve() {
		a = nextInt();
		b = nextInt();
		c = nextInt();

		if(b - a == c - b)out.println("YES");
		else out.println("NO");
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int n,m;
int a[200005];
int v1[200005];
vector<int> v2[200005];

signed main(){
    int ans=INF;
    cin>>n>>m;
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<n;++i){
        if(i){
            v2[a[i]].PB(i);
        }
    }
    for(int i=0;i<n-1;++i){
        int l = a[i],r = a[i+1];
        if(l>r)r+=m;
        v1[l+2]++;
        v1[r+1]--;
    }
    for(int i=1;i<=2*m;++i){
        v1[i]+=v1[i-1];
    }
    int tmp;
    int x = 1;
    int init=0;
    for(int i=1;i<n;++i){
        if(a[i]==x)init++;
        else if(a[i-1]<a[i]){
            if(a[i-1]<x-1&&a[i]>x)init+=1+(a[i]+m-x)%m;
            else init+=(a[i]+m-a[i-1])%m;
        }
        else {
            if(a[i]>x&&a[i-1]<x+m-1)init+=1+(a[i]+m-x)%m;
            else init+=(a[i]+m-a[i-1])%m;
        }
    }
    tmp=init;
    ans=min(ans,tmp);
    for(int i=2;i<=m;++i){
        int a0 = 0,a1 = 0,a2=0;
        int val = 0;
        a0 = v1[i],a1 = v1[i+m];
        for(int j=0;j<v2[i-1].size();++j){
            int id = v2[i-1][j];
            a2 += (a[id]+m-a[id-1])%m-1;
        }
        val += a2-a0-a1;
        tmp+=val;
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;

    return 0;
}

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

int R,S,P;

int Point(char x){
  if(x=='r'){
    return P;
  }
  if(x=='s'){
    return R;
  }
  if(x=='p'){
    return S;
  }
}

int main(){
  int N,K;
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;
  int ans=0;
  for(int i=0;i<K;i++){
    int count=1;
    char current=T[i];
    for(int j=1;j<=N/K+1;j++){
      if(K*j+i>=N){
        ans=ans+(count+count%2)/2*Point(current);
        break;
      }
      if(T[K*j+i]==current){
        count++;
      }
      else{
        ans=ans+(count+count%2)/2*Point(current);
        current=T[K*j+i];
        count=1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <list>


using namespace std;

void print_list(list<int> &ls){
    for(list<int>::iterator itr=ls.begin();itr!=ls.end();++itr){
        cout<<*itr;
        
        list<int>::iterator itr2=ls.end();
        list<int>::iterator itr3=--itr2;
        
        if(itr!=itr3){
            cout<<" ";
        }
    }
    
    cout<<endl;
}


int main(int argc, const char * argv[]) {
    
    int n;
    cin>>n;
    
    list<int> L[n];
    
    int q;
    cin>>q;
    
    int j=0;
    while(j!=q){
        
        int query;
        cin>>query;
        
        
        switch(query){
            case 0:
                int t1;
                cin>>t1;
                int x;
                cin>>x;
                L[t1].insert(L[t1].end(),x);
                break;
                
            case 1:
                int t2;
                cin>>t2;
                print_list(L[t2]);
                break;
                
            case 2:
                int s,t3;
                cin>>s>>t3;
                //print_list(L[s]);
                //print_list(L[t3]);
                
                L[t3].splice(L[t3].end(),L[s]);
                
                //print_list(L[t3]);
                
                break;
        }
        ++j;
    }
    
    
    
    return 0;
}




Measured memory_bytes: 18660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int cnt = 0;
	double n, d;
	cin >> n >> d;
	for (int i = 1; i <= n; i ++){
		double x, y;
		cin >> x >> y;
		if (sqrt(x * x + y * y) <= d)   cnt ++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		a+=b;
		c+=d;

		//Left を、釣り合うなら Balanced を、右に傾くなら Right を出力してくださ
if(a>c){
	System.out.println("Left");
}else if(a==c){
	System.out.println("Balanced");
}else{System.out.println("Right");}
	}}

Measured memory_bytes: 22868
//https://www.luogu.org/problem/AT3621
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
#define fi first
#define se second
using namespace std;

inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ri x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

const int N=1e6+5;
int n;
bool vis[N];
deque<pii> q;
int main()
{
	n=read();q.push_front(mp(1,1));
	while(1){
		pii t=q.front();q.pop_front();
		if(vis[t.fi]) continue;
		vis[t.fi]=1;
		if(!t.fi) return write(t.se),0;
		q.push_front(mp(t.fi*10%n,t.se));
		q.push_back(mp((t.fi+1)%n,t.se+1));
	}
	return 0; 
}

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

using namespace std;

int main()
{
  char a;
  cin>>a;
   if(a>=65 && a<97)
   {
       cout<<"A"<<"\n";
   }
     else
   {
       cout<<"a"<<"\n";
   }
        return 0;
}

Measured memory_bytes: 3632
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


n, d = map(int, input().split())
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    if x*x + y*y <= d*d:
        ans+=1
print(ans)




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

int main(void){

    string a,b;

    cin >> a >> b;

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    reverse(b.begin(),b.end());

    if(a < b) 
    cout << "Yes" <<endl;

    else
    cout << "No" <<endl;
    

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)


int main(){
    int N,a,b,c;
    cin >> N;
    a = N/100;
    b = (N-a*100)/10;
    c = (N-a*100-b*10);
    if (a==7 || b==7 || c==7) cout << "Yes"<< endl;
    else cout<< "No" << endl;
}

Measured memory_bytes: 3636
import math 

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

ax = a[0] * math.sin(2 * math.pi * (30 * (a[2] + a[3]/60)) / 360)
ay = a[0] * math.cos(2 * math.pi * (30 * (a[2] + a[3]/60)) / 360)
bx = a[1] * math.sin(2 * math.pi * (360 * a[3] / 60) / 360)
by = a[1] * math.cos(2 * math.pi * (360 * a[3] / 60) / 360)

print(math.sqrt((ax-bx)**2+(ay-by)**2))

Measured memory_bytes: 9540
import bisect

n=int(input())
v = list(map(int,input().split()))
x = []
y = []

for i in range(n):
    if i %2 ==0:
        x.append(v[i])
    else:
        y.append(v[i])
x.sort()
y.sort()
xk = list(set(x))
yk= list(set(y))
xk.sort()
yk.sort()

a = []
b = []
k = 0
l = 0
while k < len(x) :
    aa = bisect.bisect_right(x,x[k])
    a.append(aa-k)
    k = aa
while l < len(y) :
    bb = bisect.bisect_right(y,y[l])
    b.append(bb-l)
    l = bb

c = sorted(a)
d = sorted(b)

aaa = [i for i, xx in enumerate(a) if xx == c[-1]]
bbb = [i for i, xx in enumerate(b) if xx == d[-1]]

#print(x,xk,y,yk)
#print(a,b)
#print(c,d)
#print(aaa,bbb)

if len(aaa)>= 2 or len(bbb)>= 2:
    print(n-c[-1]-d[-1])
else:
    jkl = a.index(c[-1])
    jkll= b.index(d[-1])
    if xk[jkl] == yk[jkll]:
        ans = 100000000000000
        if len(d) >= 2:
            ans = n-c[-1]-d[-2]
        if len(c) >= 2:
            ans = min(ans,n-c[-2]-d[-1])
        if ans == 100000000000000:
            ans = n//2
        print(ans)
    else:
        print(n-c[-1]-d[-1])
        
    

Measured memory_bytes: 14816
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
signed main() {
	int n, i, j;
	cin >> n;
vector<int> l(n);
	rep(i, n) cin >> l[i];
    sort(l.begin() , l.end());
	int ans = 0;
	rep(i, n) {
		for (j = i + 1; j < n; j++) {
			int a = l[i] + l[j];
			int id1 = lower_bound(l.begin() , l.end(), a) - l.begin();
			int cnt = id1 - (j + 1);
			ans += cnt;
		}
	}
	cout << ans << endl;
	return 0;
}


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

namespace AtTest.ABC_102
{
    class ABC_102_D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            long[] array = new long[n];
            long[] sums = new long[n];//累積和
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(input[i]);
                if (i == 0)
                {
                    sums[i] = array[i];
                }
                else
                {
                    sums[i] = sums[i - 1] + array[i];
                }
            }

            long min = 0;
            int leftIndex = 0, rightIndex = 2;
            long[] rangeSums = new long[4];
            for (int i = 2; i < n - 1; i++)//真ん中の区切り数ループ
            {
                while (leftIndex < i - 1
                    && Math.Abs(sums[i - 1] - 2 * sums[leftIndex + 1])
                    < Math.Abs(sums[i - 1] - 2 * sums[leftIndex]))
                {
                    leftIndex++;
                }
                while (rightIndex < n - 1
                    && Math.Abs(sums[n - 1] - 2 * sums[rightIndex + 1] + sums[i - 1])
                    < Math.Abs(sums[n - 1] - 2 * sums[rightIndex] + sums[i - 1]))
                {
                    rightIndex++;
                }
                rangeSums[0] = sums[leftIndex];
                rangeSums[1] = sums[i - 1] - sums[leftIndex];
                rangeSums[2] = sums[rightIndex] - sums[i - 1];
                rangeSums[3] = sums[n - 1] - sums[rightIndex];
                Array.Sort(rangeSums);
                if (i == 2 || rangeSums[3] - rangeSums[0] < min)
                {
                    min = rangeSums[3] - rangeSums[0];
                }
            }

            Console.WriteLine(min);
        }
    }
}


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

int main(){
  long long N,M;
  cin>>N>>M;
  vector<pair<long long,long long>> AB(N);
  for(int i=0;i<N;i++){
    cin>>AB.at(i).first>>AB.at(i).second;
  }
  sort(AB.begin(),AB.end());

  int i=0;
  long long ans=0;
  while(M>0){
    if(AB.at(i).second>=M){
      ans+=M*AB.at(i).first;
      M=0;
    }else{
      ans+=AB.at(i).second*AB.at(i).first;
      M-=AB.at(i).second;
    }
    i++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.sort()

l = a[0]
r = a[0]

li=1
ri=len(a)-1

res = 0

while ri>=li:
  ln = abs(l-a[li])
  lx = abs(l-a[ri])
  rn = abs(r-a[li])
  rx = abs(r-a[ri])

  x = max(ln, max(lx, max(rn, rx)))
  
  if x == ln:
    res = res + ln
    l=a[li]
    li=li+1
  elif x == lx:
    res = res + lx
    l=a[ri]
    ri=ri-1
  elif x == rn:
    res = res + rn
    r=a[li]
    li=li+1
  else:
    res = res + rx
    r=a[ri]
    ri=ri-1

print(res)


Measured memory_bytes: 7512
#include <iostream>
using namespace std;
using ll = long long;

const ll MOD = 1000000007;

ll modinv(ll a,ll m){
  ll b = m,u = 1,v = 0;
  while(b){
    ll t = a/b;
    a -= t * b;
    swap(a,b);
    u -= t * v;
    swap(u,v);
  }
  u %= m;
  if(u<0) u += m;
  return u;
}

int main(){
  ll x,y;
  cin >> x >> y;

  ll a,b;
  a = (2*y-x)/3;
  b = (2*x-y)/3;

  bool flag = true;
  if((2*y-x)%3 != 0 || a < 0){
    flag = false;
  }
  if((2*x-y)%3 != 0 || b < 0){
    flag = false;
  }

  ll ans = 0;
  if(flag){
    ll x = a+b;

    // x!/(a!b!)を逆元を用いて求める
    ans = 1;

    for(ll i=1;i<=x;i++){
      ans *= i;
      ans %= MOD;
    }

    for(ll i=1;i<=a;i++){
      ans = ans * modinv(i,MOD) % MOD;
    }

    for(ll i=1;i<=b;i++){
      ans = ans * modinv(i,MOD) % MOD;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))

import collections
A_c = collections.Counter(A)
A_A = A_c.most_common()

ans = 0
for i in range(len(A_A)):
  if i >K-1:
    ans += list(A_A[i])[1]

if len(A_A)<=K:
  print(0)
else:
  print(ans)

Measured memory_bytes: 102088
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line;
            while((line = br.readLine()) != null){
            	String[] list = line.split(" ", 0);
            	int a = Integer.parseInt(list[0]);
            	int b = Integer.parseInt(list[1]);
            	
            	if(a == 0 && b == 0){
            		break;
            	}else if(a < b){
            		System.out.println(a + " " + b);
            	}else if(a > b){
            		System.out.println(b + " " + a);
            	}else if(a == b){
            		System.out.println(a + " " + b);
            	}
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 27100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.rbegin(), c.rend()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, _cnt = 0, cnt = 0, ans = 1, k;
    cin >> n >> k;
    vll b, c;
    vector<pair<ll, ll>> a;
    fr(i, 0, n)
    {
        ll v;
        cin >> v;
        if (v < 0)
        {
            b.pb(-v);
            a.pb({-v, 1});
            continue;
        }
        c.pb(v);
        a.pb({v, 0});
    }
    sort(all(c));
    sort(all(b));
    sort(all(a));
    if (k == n)
    {
        fr(i, 0, n)
        {
            ans = (ans * a[i].F) % mod;
            if (a[i].S)
            {
                cnt++;
            }
        }
        if (cnt % 2 == 0)
        {
            cout << ans << "\n";
        }
        else
        {
            ans = (-ans + mod) % mod;
            cout << ans << "\n";
        }
        return 0;
    }
    fr(i, 0, k)
    {
        ans = (ans * a[i].F) % mod;
        if (a[i].S)
        {
            cnt++;
        }
        else
        {
            _cnt++;
        }
    }
    if (cnt % 2)
    {
        ans = 1;
        if (sz(c) == 0)
        {
            sort(b.begin(), b.end());
            fr(i, 0, cnt)
            {
                ans = (ans * b[i]) % mod;
            }
            ans = (-ans + mod) % mod;
            cout << ans << "\n";
            return 0;
        }
        if (_cnt < sz(c) && cnt < sz(b))
        {
            if (_cnt == 0 || c[_cnt] * c[_cnt - 1] >= b[cnt] * b[cnt - 1])
            {
                cnt--;
                _cnt++;
            }
            else
            {
                cnt++;
                _cnt--;
            }
        }
        else if (cnt == sz(b))
        {
            cnt--;
            _cnt++;
        }
        else if (_cnt == sz(c))
        {
            cnt++;
            _cnt--;
        }
        fr(i, 0, cnt)
        {
            ans = (ans * b[i]) % mod;
        }
        fr(i, 0, _cnt)
        {
            ans = (ans * c[i]) % mod;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    int a[5], k;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

    int min_val = 1000;
    int max_val = -1;

    for(int i = 0; i < 5; i++){
        min_val = min(min_val, a[i]);
        max_val = max(max_val, a[i]);
    }

    if(max_val - min_val <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main() {
	cin.sync_with_stdio(0);

	ll d, t, s;
	cin >> d >> t >> s;

	cout << (((t * s) >= d) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define OUT(s) cout << s << "\n";
#define S_LEN(s) s.length();
#define L_LEN(l) sizeof(l) / sizeof(l[0]);
using namespace std;
int X;


void Main(){
    int happy = 0;
    happy = X / 500 * 1000 + happy;
    happy = X % 500 /5 * 5 + happy;
    OUT(happy);
}

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

    cin >> X;

    Main();
    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

len_s = len(s)
len_t = len(t)
INF = float('inf')

dp = [[-INF] * (len_t+1) for _ in range(len_s+1)]

dp[0][0] = 0

for i in range(len_s+1):
    for j in range(len_t+1):
        if i+1 <= len_s and j <= len_t:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if i <= len_s and j+1 <= len_t:
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])
        if i+1 <= len_s and j+1 <= len_t and s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)

i = len_s
j = len_t
ans = ""
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i - 1]
        i -= 1
        j -= 1

print(ans[::-1])


Measured memory_bytes: 258440
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: f64,
        b: f64,
        h:f64,
        m:f64
    }

    let h_deg: f64 = h * 30.0 + (m / 60.0) * 30.0;
    let m_deg: f64 = m * 6.0;

    let mut max = 0.0;
    let mut min = 0.0;
    if h_deg > m_deg {
        max = h_deg;
        min = m_deg;
    } else {
        max = m_deg;
        min = h_deg;
    };

    let deg = max - min;

    let rad = (deg as f64 * PI) / 180.0;

    let c = (a * a + b * b - 2.0 * a * b * rad.cos()).sqrt();

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

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;
const PI: f64 = std::f64::consts::PI;

// @〜でsnippet


Measured memory_bytes: 3188
#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()
typedef long long ll;

int n,k,x,y;
string s,t;

int main() {
  cin >> x >> y;
  int ans=0;
  if(x==1 && y==1)
  ans+=400000;
  ans+=max(4-x,0)*100000+max(4-y,0)*100000;
  cout << ans << endl;
}

Measured memory_bytes: 256