akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Balls and Boxes 2
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_B&lang=ja

"""
import sys
from math import factorial

def solve(n, k):
    if n > k:
        return 0
    return factorial(k) // factorial(k-n) % (10**9 + 7)


def main(args):
    n, k = map(int, input().split())
    ans = solve(n, k)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



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


namespace A___Darker_and_Darker
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ');
            var H = int.Parse(read[0]);
            var W = int.Parse(read[1]);

            //マス目の配置を読み込む
            var map = new string[H];
            for(int i = 0 ; i < H ; i++) map[i] = Console.ReadLine();

            //何回目の操作で黒になるかを記録する配列を作成
            var steps = new int[H,W];
            for(int i = 0 ; i < H ; i++) for(int j = 0 ; j < W ; j++) steps[i,j] = int.MaxValue;

            //黒マスの位置をチェックし、処理用キューに格納する
            var checkGrids = new Queue<Grid>();
            for(int i = 0 ; i < H ; i++)
            {
                for(int j = 0 ; j < W ; j++)
                {
                    if(map[i][j] == '#')
                    {
                        checkGrids.Enqueue(new Grid(i,j));
                        steps[i,j] = 0;
                    }
                }
            } 

            //キューが空になる=白マスがなくなるまで操作を繰り返す
            while(checkGrids.Count != 0)
            {
                var grid = checkGrids.Dequeue();
                var h = grid.x;
                var w = grid.y;
                var step = steps[h,w];

                //上
                if(h > 0 && step + 1 < steps[h-1,w])
                {
                    steps[h-1,w] = step + 1;
                    checkGrids.Enqueue(new Grid(h-1,w));
                }
                //下
                if(h < H-1 && step + 1 < steps[h+1,w])
                {
                    steps[h+1,w] = step + 1;
                    checkGrids.Enqueue(new Grid(h+1,w));
                }
                //左
                if(w > 0 && step + 1 < steps[h,w-1])
                {
                    steps[h,w-1] = step + 1;
                    checkGrids.Enqueue(new Grid(h,w-1));
                }
                //右
                if(w < W-1 && step + 1 < steps[h,w+1])
                {
                    steps[h,w+1] = step + 1;
                    checkGrids.Enqueue(new Grid(h,w+1));
                }
            }

            Console.WriteLine(steps.Cast<int>().Max());
        }
    }
    class Grid
    {  
        public int x{get;}
        public int y{get;}

        public Grid(int _x,int _y)
        {
            x = _x;
            y = _y;
        }
    }
}


Measured memory_bytes: 56756
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
void solve(){
	int n;
	cin >> n;
	int count = 0;
	int a[n], e = 0;
	for(int & i : a){
	 cin >> i;
		if((i %3 == 0 || i % 5 == 0) && ~i&1)
		count ++;
		if(~i&1)
			e++;
	}
	if(count == e)
		cout << "APPROVED";
	else
		cout <<"DENIED";
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    int a, b, n;
    cin >> n >> a >> b;
    cout << min(n*a, b);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include<bitset>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const double EPS = 0.000000000001;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================


	int N, M;
	cin >> N;
	vector<int> odd, even;
	for (int i = 0; i < N; i++) {
		int temp;
		cin >> temp;
		if (i % 2 == 0) {
			even.emplace_back(temp);
		}
		else {
			odd.emplace_back(temp);
		}
	}

	if (N % 2 == 0) {
		for (int i = 0; i < odd.size(); i++) {
			cout << odd[odd.size() - 1 - i] << " ";
		}
		for (int i = 0; i < even.size(); i++) {
			cout << even[i] << " ";
		}
	}
	else {
		for (int i = 0; i < even.size(); i++) {
			cout << even[even.size() - 1 - i] << " ";
		}
		for (int i = 0; i < odd.size(); i++) {
			cout << odd[i] << " ";
		}
	}


}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}
vector<int> h;
int n;
map<int,int> loc;
ll dp[200005];
int a[200005];
ll tree[8000005];

void update(int node,int start,int End,ll val,int index)
{
    if(start == End)
    {
        tree[node] = val;
        return;
    }
    int mid = (start + End) / 2;
    if(start <= index && mid >= index)
        update(node*2,start,mid,val,index);
    else
        update(node*2+1,mid+1,End,val,index);
    tree[node] = max(tree[node*2],tree[node*2+1]);
}
long long query(int node,int start,int End,int l, int r)
{
    if(End < l || start > r || start > End)
        return 0;
    if(start >= l && End <= r)
        return tree[node];
    int mid = (start + End)/2;
    return max(query(node*2+1,mid+1,End,l,r),query(node*2,start,mid,l,r));
}

int main() {
    IO;
    cin >> n;
    h.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        loc[h[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        dp[h[i]] = query(1, 1, 1e6, 0, h[i]-1) + a[i];
        ans = max(ans, dp[h[i]]);
        update(1,1,1e6,dp[h[i]],h[i]);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 20352
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n,x,t;
    cin>>n>>x>>t;
	if(n%x == 0) cout<<n/x*t;
    else cout<<((n/x)+1)*t;
    return 0;
}

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

int main()
{
    int S, h, m, s;
    cin >> S;
    
    s = S % 60; S /= 60;
    m = S % 60; S /= 60;
    h = S;
    
    printf("%d:%d:%d\n", h, m, s);
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main(){
        long double pi = 2 * acos(0.0);
        int a, b, h, m; cin >> a >> b >> h >> m;

        long double hour_angle = 2 * pi * m / 720 + 2 * pi * h / 12;
        long double min_angle = 2 * pi * m / 60;
        //cout << hour_angle << " " << min_angle << endl;

        long double cos_angle = cos(abs(hour_angle - min_angle));
        //cout << cos_angle << endl;

        long double c = sqrt(a * a + b * b - 2 * a * b * cos_angle);
        cout << fixed << setprecision(20) << c << endl;
    return 0;
}


Measured memory_bytes: 4128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int f(int a, int k) {
    if (a < k) return 0;
    if (a % k == 0) return a / k;
    int diff = (a / k) + 1;

    int g = max((a % k) / diff, 1) * diff;

    return f(a - g, k);
}

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

    int nim = 0;
    rep(i, n) {
        int a, k;
        cin >> a >> k;
        nim ^= f(a, k);
    }

    string ans = (nim == 0) ? "Aoki" : "Takahashi";
    cout << ans << endl;

}


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

 
int main(){
	int a,b; cin >> a >> b;
	cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 3568
/// ****** Property of vipulks ****** \

#include <stdio.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ll long long
ll pos(ll n){
	if(n>0)
		return n;
	return 0;
}
int main(){
	ll n,i,j,k,q,a,b,c,ans;
	//scanf("%lld",&t);
	q=1;
	bool ok=true;
	while(q--){
		scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
		if(k<=a)
			ans=k;
		else if(k<=a+b)
			ans=a;
		else if(k<=a+b+c)
			ans=a-(k-a-b);
		printf("%lld\n",ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char , char> pcc;
#define pb push_back
#define mp make_pair
#define ft first
#define se second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)


int main()
{
	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	ll n;
  	cin >> n;
  	ll h[n+5];
	ll dp[n+5];
  	for(ll i=1;i<=n;i++)
	{
		cin >> h[i];
	}
	dp[n]=0;
	dp[n-1]=abs(h[n-1]-h[n]);
	for(ll i=n-2;i>0;i--)
	{
		dp[i]=min(abs(h[i]-h[i+2])+dp[i+2],abs(h[i]-h[i+1])+dp[i+1]);
	}
	cout << dp[1] << endl;
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll 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()
{
  int x; cin >> x;
  cout << (x+1)%2 << endl;
}

Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s; cin>>s;
    int n = s.size();

    vector<vector<ll>> dp(n+1, vector<ll>(13, 0));

    dp[0][0] = 1;
    for(int i=0; i<n; i++){
        for(int pre=0; pre<=12; pre++){
            if(s[i] == '?'){
                for(int j=0; j<=9; j++){
                    int num = pre * 10 + j;
                    dp[i+1][num%13] += dp[i][pre];
                    dp[i+1][num%13] %= MOD;
                }
            }
            else{
                int cur = s[i] - '0';
                int num = pre * 10 + cur;
                dp[i+1][num%13] += dp[i][pre];
                dp[i+1][num%13] %= MOD;
            }
        }
    }

    cout << dp[n][5] << endl;

    return 0;
}

Measured memory_bytes: 13648
#include<bits/stdc++.h>
using namespace std;
int n,mod,jc[11111],injc[11111],ans,ipw1[11111],ipw2[11111],ipw3[11111],i2,i3,ct,pw[11111];
int binpow(int a,int t)
{
	int res=1,p=a;
	for (int i=t;i;i>>=1)
	{
		if (i&1) res=1ll*res*p%mod;
		p=1ll*p*p%mod;
	}
	return res;
}
int main()
{
	scanf("%d%d",&n,&mod);
	jc[0]=1;
	for (int i=1;i<=3*n;i++)
	{
		jc[i]=1ll*jc[i-1]*i%mod;
	}
	injc[3*n]=binpow(jc[3*n],mod-2);
	for (int i=3*n-1;i>=0;i--)
	{
		injc[i]=1ll*injc[i+1]*(i+1)%mod;
	}
	ipw1[0]=ipw2[0]=ipw3[0]=1;i2=binpow(2,mod-2);i3=binpow(6,mod-2);
	for (int i=1;i<=3*n;i++)
	{
		ipw1[i]=1;ipw2[i]=1ll*ipw2[i-1]*i2%mod;
		ipw3[i]=1ll*ipw3[i-1]*i3%mod;
	}
	pw[0]=1;
	for (int i=1;i<=3*n;i++) pw[i]=2ll*pw[i-1]%mod;
	for (int i=0;i<=3*n;i++)
	{
		for (int j=0;j<=i;j++)
		{
			if (i+2*j>3*n || (i+2*j)%3) continue;
			ans=(1ll*jc[3*n]*ipw2[j]%mod*ipw3[(3*n-i-2*j)/3]%mod*injc[i]%mod*injc[j]%mod*injc[(3*n-i-2*j)/3]%mod*pw[(3*n-i-2*j)/3]+ans)%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
# 3 3   n: node, m: link
# 1 2   a_1   b_1
# 1 3
# 2 3   a_m   b_m

$n, $m = gets.split.map(&:to_i)
array_a_temp, array_b_temp = $m.times.map{ gets.split.map(&:to_i) }.transpose
$array_a = array_a_temp + array_b_temp
$array_b = array_b_temp + array_a_temp

reached_node = Array.new($n, false)
used_link = []
$ans = 0

# $binding = 0

def move(to, reached_node, used_link)
  # $binding += 1
  # puts "binding: #{$binding}"
  # p reached_node
  # p used_link
  if reached_node.count(true) == $n
    $ans += 1
    return true
  end
  if used_link.length == $m
    return false
  end

  indexes_to_a = []
  $array_a.each_with_index do |a, i|
    indexes_to_a << i if a == to && !(used_link.include?(i))
  end

  indexes_to_a.each do |i|
    reached_node_temp = []
    reached_node.each do |j|
      reached_node_temp << j
    end
    used_link_temp = []
    used_link.each do |j|
      used_link_temp << j
    end
    to = $array_b[i]
    next if reached_node[to-1]
    reached_node_temp[to-1] = true
    used_link_temp << i
    move(to, reached_node_temp, used_link_temp)
  end
end

indexes_1_a = []
$array_a.each_with_index do |a, i|
  indexes_1_a << i if a == 1
end

indexes_1_a.each do |i|
  reached_node = Array.new($n, false)
  from = $array_a[i]
  to = $array_b[i]
  reached_node[from-1] = true
  reached_node[to-1] = true
  used_link = [i]
  move(to, reached_node, used_link)
end

puts $ans


Measured memory_bytes: 14972
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

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

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

  int count = 0;
  while(1){
    if(a>b) break;
    else{
      if(c%a==0) count++;
      a++;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3092
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


W, H = map(int, input().split())
p = []
for i in range(W):
    p.append(int(input()))
q = []
for j in range(H):
    q.append(int(input()))


a = []
for i in range(W):
    a.append(("p", i, p[i]))
for j in range(H):
    a.append(("q", j, q[j]))


a.sort(key=lambda x: x[2])


p_used = 0
q_used = 0
count = 0
cost = 0
i = 0
while True:
    now = a[i]
    if now[0] == "p":
        now_count = H+1 - q_used
        if count + now_count > (W+1)*(H+1) - 1:
            now_count = (W+1)*(H+1) - 1 - count
        count += now_count
        cost += now[2] * now_count
        p_used += 1
    else:
        now_count = W+1 - p_used
        if count + now_count > (W+1)*(H+1) - 1:
            now_count = (W+1)*(H+1) - 1 - count
        count += now_count
        cost += now[2] * now_count
        q_used += 1
    if count == (W+1)*(H+1) - 1:
        break
    i += 1
debug(count)
print(cost)


Measured memory_bytes: 89900
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
typedef long long ll;
const ll MAXN=1e5+5,MAXM=2e5+5,P=1e9+7;
 
ll N,M,S,T;
 
struct E{ll next,to,val;} e[MAXM<<1];ll ecnt,G[MAXN];
void addEdge(ll u,ll v,ll w){e[++ecnt]=(E){G[u],v,w};G[u]=ecnt;}
void addEdge2(ll u,ll v,ll w){addEdge(u,v,w);addEdge(v,u,w);}
 
ll fS[MAXN],dS[MAXN],fT[MAXN],dT[MAXN];
 
struct HN{ll id,v;};
bool operator <(const HN &a,const HN &b){return a.v>b.v;}
std::priority_queue<HN> heap;
bool inS[MAXN];
void dijkstra(ll v0,ll *f,ll *d)
{
	memset(inS,0,sizeof inS);
	memset(d,0x3f,sizeof dS);
	d[v0]=0,f[v0]=1;heap.push((HN){v0,0});
	while(!heap.empty())
	{
		ll u=heap.top().id;heap.pop();
		if(inS[u]) continue;inS[u]=true;
		for(ll i=G[u];i;i=e[i].next)
		{
			ll v=e[i].to;
			if(inS[v]) continue;
			if(d[v]>d[u]+e[i].val)
			{
				f[v]=f[u];
				d[v]=d[u]+e[i].val;
				heap.push((HN){v,d[v]});
			}
			else if(d[v]==d[u]+e[i].val) f[v]=(f[v]+f[u])%P;
		}
	}
}
 
struct A{ll u,v,w;} a[MAXM];
int main()
{
	ll i;scanf("%d%d%d%d",&N,&M,&S,&T);
	for(i=1;i<=M;i++)
	{
		ll u,v,w;scanf("%d%d%d",&u,&v,&w);
		addEdge2(u,v,w);a[i]=(A){u,v,w};
	}
	dijkstra(S,fS,dS);
	dijkstra(T,fT,dT);
	ll ans=(ll)fS[T]*fS[T]%P;
	for(i=1;i<=N;i++)
		if(dS[i]==dT[i]&&dS[i]+dT[i]==dS[T])
			ans=(ans+P-(ll)fS[i]*fS[i]%P*fT[i]%P*fT[i]%P)%P;
	for(i=1;i<=M;i++)
	{
		ll u=a[i].u,v=a[i].v,w=a[i].w;
		if(dS[u]>dS[v]) std::swap(u,v);
		//if(dS[u]<dS[T]>>1&&dT[v]<dT[S]>>1&&dS[u]+dT[v]+w==dS[T])
		if(dS[u]+dT[v]+w==dS[T]&&std::max(dS[u],dT[v])<std::min(dS[u],dT[v])+w)
			ans=(ans+P-(ll)fS[u]*fS[u]%P*fT[v]%P*fT[v]%P)%P;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 20468
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VLL ct1(n, 0), ct2(n, 0);
  REP2(int, i, 1, n+1)
  {
    LL a;
    cin >> a;
    if (i+a <= n-1) ++ct1[i+a];
    if (i-a >= 2) ++ct2[i-a];
  }
  LL ans = 0;
  REP(int, i, n) ans += ct1[i] * ct2[i];
  cout << ans << endl;

  return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
ll C, X[100100], V[100100], Y[100100], W[100100];
ll cal1[100100], mx1[100100], cal2[100100], mx2[100100];

void f(ll (&X)[100100], ll (&V)[100100], ll (&cal)[100100], ll (&mx)[100100]){
    ll total = 0;

    for(int i=0;i<N;++i){
        total += V[i];

        cal[i] = total - X[i];
    }

    mx[0] = cal[0];

    for(int i=1;i<N;++i){
        mx[i] = std::max(mx[i - 1], cal[i]);
    }
}

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

    std::cin >> N >> C;

    for(int i=0;i<N;++i){
        std::cin >> X[i] >> V[i];
    }

    for(int i=0;i<N;++i){
        Y[i] = C - X[N - 1 - i];
        W[i] = V[N - 1 - i];
    }

    f(X, V, cal1, mx1);
    f(Y, W, cal2, mx2);

    ll mx = std::max<ll>({0, mx1[N - 1], mx2[N - 1]});

    for(int i=0;i+1<N;++i){
        mx = std::max({mx, cal1[i] - X[i] + mx2[N - i - 2], cal2[i] - Y[i] + mx1[N - i - 2]});
    }

    std::cout << mx << std::endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		// 行列Aを取得
		int matrixA[][] = new int[n][m];
		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				matrixA[i][j] = sc.nextInt();
			}
		}

		// ベクトルbを取得
		int vectorB[] = new int[m];
		for(int i=0; i<m; i++) {
			vectorB[i] = sc.nextInt();
		}

		sc.close();

		// 計算
		for(int i=0; i<n; i++) {
			int sum = 0;
			for(int j=0; j<m; j++) {
				sum += matrixA[i][j] * vectorB[j];
			}
			System.out.println(sum);
		}
	}

}


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

int main() {
  long long N,K,Q;
  cin >> N >> K >> Q;
  long long A[100000];
  for (long long i = 0; i < Q; i++) {
    cin >> A[i];
  }
  long long M[1000000];
  for (long long i = 0; i < Q; i++) {
    M[A[i] - 1]++;
  }
  for (long long i =0; i < N; i++) {
    if ((K - (Q - M[i])) <= 0) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
}

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

#define mod 998244353
using ll=long long;

ll fact[200002];
ll inv[200002];
ll invfact[200002];

ll modpow(ll n, ll m=mod-2) {
	ll r=1;
	while(m) r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;
	return r;
}

void calc_fact_invfact(){
  if(fact[0]==0){
    fact[0]=inv[1]=invfact[0]=1;
    for(int i=2;i<200002;i++) inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    for(int i=1;i<200002;i++) fact[i] = fact[i-1]*i%mod,invfact[i]=invfact[i-1]*inv[i]%mod;
  }
}
ll nCk(int n,int k){
  if(n<k || k<0) return 0;
  else return fact[n]*invfact[k]%mod*invfact[n-k]%mod;
}

int main(){

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

  ll ans = 0;

  calc_fact_invfact();
  for(int i=0;i<=k;i++) ans += nCk(n-1,i)*m%mod*modpow(m-1,n-1-i)%mod;

  cout << ans%mod << endl;

}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int ans=0;
    string s,t;
    cin>>s>>t;
    f1(i,0,s.size())
    {
    	if(s[i]==t[i])
    		ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf (1 << 30)

static const int N = 100;
static const int white = 0;
static const int gray = 1;
static const int black = 2;

int n;
int m[N][N];

int prim() {
	int color[N];
	int d[N], p[N];
	int u;
	for (int i = 0; i < n; i++) {
		color[i] = white;
		d[i] = inf;
		p[i] = -1;
	}
	//color[0] = black;
	d[0] = 0;
	p[0] = -1;
	u = 0;
	while (true) {
		int mincost = inf;
		for (int i = 0; i < n; i++) {
			if (color[i] != black && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == inf) {
			break;
		}
		color[u] = black;	
		for (int v = 0; v < n; v++) {
			if (color[v] != black) {
				if (m[u][v] < d[v]) {
					d[v] = m[u][v];
					color[v] = gray;
					p[v] = u;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (color[i] == black) {
			sum += d[i];
		}
	}
	return sum;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int v;
			cin >> v;
			v == -1 ? m[i][j] = inf : m[i][j] = v;
		}
	}
	prim();
	cout << prim() << endl;
	return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L.at(i);
    }

    int sum=0;
    for(int i=0; i<N; i++){
        sum = sum + L.at(i);
    }

    bool flag=true;
    for(int i=0; i<N; i++){
        if(2*L.at(i) >= sum){
            flag = false;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<ll> t(n), a(n);
    for(int i = 0; i < n; i++) {
        cin >> t[i] >> a[i];
    }
    ll f = 1, s = 1;
    for(int i = 0; i < n; i++) {
        ll z = max((f + t[i] - 1) / t[i], (s + a[i] - 1) / a[i]);
        f = z * t[i];
        s = z * a[i];
    }
    cout << f + s << endl;
}


Measured memory_bytes: 256
import math

A, B, H, M = list(map(int, input().split()))

temp = (H%12+M/60)/12 - M/60

angle = 2*math.pi*min(abs(temp), abs(2*math.pi - abs(temp)))

print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle)))

Measured memory_bytes: 9424
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9+7;

int main(void) {
  int n, l; cin >> n >> l;
  int sum = 0;
  bool f = false;
  for(int i=1; i<=n; i++) {
    int tmp = l + i -1;
    if(tmp == 0) f = true;
    sum += tmp;
  }
  if(f) cout << sum << endl;
  else{
    if(l > 0) {
      cout << sum - l << endl; 
    }else{
      cout << sum - (l + n - 1) << endl;
    }
  }


  return 0;
}

// EOF


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


int main() {
    string str;
    getline(cin, str);
    int i;
    for (i = 0; i < str.size(); i++) {
        if (str[i] >= 'a' && str[i] <= 'z') str[i] += 'A' - 'a';
        else if (str[i] >= 'A' && str[i] <= 'Z') str[i] += 'a' - 'A';
    }
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 3156
import sys
readline = sys.stdin.buffer.readline

from collections import deque

N, M = map(int, input().split())
UV = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())
INF = 10 ** 15

if M == 0:
  print(-1)
  exit()

graph = [[] for _ in range(3 * M + 1)]
for u, v in UV:
  graph[u].append(v + M)
  graph[u + M].append(v + 2 * M)
  graph[u + 2 * M].append(v)

queue = deque([S])
dist = [INF] * (3 * M + 1)
dist[S] = 0

while queue:
  q = queue.popleft()
  for g in graph[q]:
    if dist[g] > dist[q] + 1:
      dist[g] = dist[q] + 1
      queue.append(g)
print(dist[T] // 3 if dist[T] != INF else -1)

Measured memory_bytes: 99172
function solve(k,s)
  a=0
  for x=0:k,y=0:k
    if k>=s-x-y>=0
      a+=1
    end
  end
  a
end
function main()
  k,s=map(x->parse(Int,x),split(readline()))
  show(solve(k,s))
end
main()

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

int main ()
{
	int x, y;
	while ((cin >> x >> y), x, y)
	{
		for (int i=1; i<=x; i++)
		{
			if (i%2==1)
			{
				for (int k=1; k<=y; k++)
				{
					if (k%2==1) cout << "#";
					else if (k%2==0) cout << ".";
					if (k==y) cout << endl;
				}
			}
			else if (i%2==0)
			{
				for (int k=1; k<=y; k++)
				{
					if (k%2==1) cout << ".";
					else if (k%2==0) cout << "#";
					if (k==y) cout << endl;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n;i++) {
		cin >> a[i];
	}	
	for (int i = 0; i < n;i++) {
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(),greater<ll>());
	ll lb = -1, rb = 1e12 + 10;
	while(rb - lb > 1){
		ll mid = (lb + rb) / 2;
		ll cnt = 0;
		for (int i = 0; i < n;i++) {
			int c = max(0ll, a[i] - mid / b[i]);
			cnt += c;
		}
		if(cnt <= k){
			rb = mid;
		}else {
			lb = mid;
		}
	}
	dump(rb);
}

Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int a[200010];
int X[200010];
int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		X[i] = i + 1;
	}
	int j = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] != X[j]) {
			ans++;
		}
		else {
			j++;
		}
	}
	if (ans == N) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
}


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

long long int dp[2005][2005];
long long int ans[2005*2005]={0};


long long int min(long long int a,long long int b)
{
    if(a<b)
    return a;
    else
    return b;
}
int main()
{
    long long int n,x,y;
    cin>>n>>x>>y;
    
  long long int  a=x;long long int b=y;
    x=min(a,b);
    y=max(a,b);
 
 for(int i=1;i<=n;i++)
 {
     for(int j=i+1;j<=n;j++)
     {
         dp[i][j]  = min( j-i , abs(x-i)+abs(y-j)+1);
     }
 }
 
 for(int i=1;i<=n;i++)
 for(int j=i+1;j<=n;j++)
 ans[dp[i][j]]++;
 
 
 for(int i=1;i<n;i++)
 cout<<ans[i]<<endl;
    
}

Measured memory_bytes: 31360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x7fffffff
const int N = 100000+5;
const int Mod = 1e9+7;
map<string,int>mp;
int n,m,T,t;
stringstream ss;
string s;
vector<int>G[N];

 int main() {
    cin>>s;
    if(s[s.size()-1]=='s') s+="es";
    else s +='s';
    cout<<s<<endl;
    return 0;
 }

Measured memory_bytes: 5976
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    double sum=0;
    double a;
    for(int i=0;i<n;i++){
        scanf("%lf",&a);
        sum+=1/a;
    }
    printf("%lf",1/sum);
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

target = 'keyence'

if target in s:
    print('YES')
    sys.exit(0)

for start in range(len(s)):
    for end in range(start + 1, len(s) + 1):
        copy_s = list(s)
        copy_s[start:end] = ''
        if ''.join(copy_s) == target:
            print('YES')
            sys.exit(0)
print('NO')


Measured memory_bytes: 72956
#include <iostream>
using namespace std;
int main()
{
	int n, a, b, i, p, h = 0;
	long long t = 0;
	cin >> n >> a >> b;
	for (i = 1; i <= n; i++)
	{
		p = i;
		do
		{
			h += p % 10;
			p /= 10;
		} while (p != 0);
		if (h >= a&&h <= b) t += i;
		h = 0;
	}
	cout << t << endl;
	return 0;
}

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

int h, w;
vector<string> s;

int main() {
	cin >> h >> w;
	s.resize(h);
	for (int i = 0; i < h; ++i) cin >> s.at(i);

	vector<vector<int> > c(h, vector<int>(w, 0));

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

	for (int x = 0; x < h; ++x)
	{
		for (int y = 0; y < w; ++y)
		{
			if (s.at(x).at(y)=='#') {
				c.at(x).at(y) = -1;
				continue;
			}
			
			for (int dir = 0; dir < 8; ++dir)
			{
				int nx = x + dx[dir];
				int ny = y + dy[dir];
			
				if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
			
				if (s.at(nx).at(ny)=='#')
				{
					c.at(x).at(y)++;
				}
			}
		}
	}

	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (c.at(i).at(j)==-1)
			{
				cout << '#';
			} else {
				cout << c.at(i).at(j);
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[int(input())] = 1

    B = list(map(lambda x:d[x],A))

    if B[4]:
        if B[0] * B[8] + B[2] * B[6]:
            return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::3]) == 3:
            return 1
    
    return 0

print(["No","Yes"][a()])


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

int main(){
  int N,K,num=1e9+7;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  rep(i,N-K+1){
    num = min(num,h.at(i+K-1)-h.at(i));
  }
  cout << num << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	int s,h,m;
	scanf("%d",&s);
	/*cal*/
	h = s/3600;
	m = (s%3600)/60;
	s = (s%3600)%60;
	/*output*/
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i <= (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int a,b;
    cin >> a >> b;
    if(a < b) swap(a,b);
    if(a == 3 && b == 2) dunk(1);
    if(a == 3 && b == 1) dunk(2);
    if(a == 2 && b == 1) dunk(3);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
double abs(double a){return a<0?-a:a;}
int main(){
	double xa,xb,xc,xd,ya,yb,yc,yd;
	while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)){
		double t=(xa-xb)*(xc-xd)+(ya-yb)*(yc-yd);
		if(abs(t)<0.00001)printf("YES\n");
		else printf("NO\n");
	}
}

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

#define Bye return 0
const int MAX = 1e9+7;

void solve(){
    int n, res = 1; cin>>n;
    
    int a[n+1];
    memset(a, 0, sizeof a);

    for (int i=1; i<=n; i++){ int e; cin>>e; a[e]++;}
    int counter = (n%2^0) ? (n-1)/2 :  n/2;
    for (int i=1; i<=counter; i++) res = (res*2)%MAX;
    bool isValid = false;

    for (int i=0; i<n; i+=2){
        isValid += (i+2<n && a[i+2]^2 && n%2^0);
        isValid += (i+1<=n-1 && a[i+1]^2 && !(n%2^0));
    }
    
    cout<<((!isValid) ? res : 0)<<endl;
}

int main()
{
    solve();
    Bye;
}


Measured memory_bytes: 3952
use std::io;
use std::collections::HashSet;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let x = v[0];
	let y = v[1];
	let mut set1:HashSet<i32> = HashSet::new();
	set1.insert(1);
	set1.insert(3);
	set1.insert(5); 
	set1.insert(7);
	set1.insert(8);
	set1.insert(10);
	set1.insert(12);
	let mut set2:HashSet<i32> = HashSet::new();
	set2.insert(4);
	set2.insert(6);
	set2.insert(9);
	set2.insert(11);
	let mut set3:HashSet<i32> = HashSet::new();
	set3.insert(2);
	let mut flag = false;
	if !set1.insert(x) && !set1.insert(y) {
		flag = true;
	}
	if !set2.insert(x) && !set2.insert(y) {
		flag = true;
	}
	if !set3.insert(x) && !set3.insert(y) {
		flag = true;
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
while True:
    try:
        v = float(input())
        h = (v / 9.8) * (v / 9.8) * 4.9
        N = (h + 5) / 5
        N1 = (h + 5) // 5
        if (N - N1 > 0):
            N1 += 1
        print(int(N1))
    except EOFError:
        break


Measured memory_bytes: 5584
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B
// Elementary Number Theory - Power
// status: [solve][review]

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

ui64 power(ui64 x, ui64 n, ui64 mod) {
    ui64 res = 1;
    if (0 < n) {
        res = power(x, n / 2, mod);
        if (n % 2 == 0) res = (res * res) % mod;
        else res = (((res * res) % mod) * x) % mod;
    }
    return res;
}

const ui64 MOD = 1000000007;
ui64 m, n;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(5 8
)";
    stringstream stream(program_input_str);
#endif
    stream >> m >> n;
    auto ans = power(m, n, MOD);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std; 
const int MAXN=2e5+5;
long long a[MAXN],b[MAXN],ans=0;
int main(){
	ios::sync_with_stdio(false);
    int n;
    cin>>n;    
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=b[i-1]+a[i];
        ans+=a[i];
    }
    long long cmin=1e10;
    for(int i=1;i<n;i++)
        if(cmin>abs(2*b[i]-ans)) cmin=abs(2*b[i]-ans);
    cout<<cmin<<endl;
    return 0;
}

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

#define ll long long
#define mod 1e9+7
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll n;
ll arr[3001];
ll dp[3001][3001][2];

ll solve(ll i, ll j, ll p){
	if(i>j)
		return 0;
	if(i==j){
		if(p==0)
			return arr[i];
		else
			return -1*arr[i];
	}
	if(dp[i][j][p] != -1)
		return dp[i][j][p];
	if(p==0){
		dp[i][j][p]=-1*inf;
		dp[i][j][p]=max(dp[i][j][p],arr[i]+solve(i+1,j,1));
		dp[i][j][p]=max(dp[i][j][p],arr[j]+solve(i,j-1,1));
	}
	else{
		dp[i][j][p]=inf;
		dp[i][j][p]=min(dp[i][j][p],solve(i+1,j,0)-arr[i]);
		dp[i][j][p]=min(dp[i][j][p],solve(i,j-1,0)-arr[j]);
	}
	return dp[i][j][p];
}

int main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    for(int i=0;i<=3000;i++){
    	for(int j=0;j<3001;j++){
    		dp[i][j][0]=-1;
    		dp[i][j][1]=-1;
    	}
    }

    ll ans=solve(0,n-1,0);
    cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 141184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	while(true){
		
		int t;
		
		cin >> t;
		
		if(t == 0){
			break;
		}
		
		int n;
		
		cin >> n;
		
		for(int i = 0; i < n; i++){
			int num1, num2;
			cin >> num1 >> num2;
			t -= (num2 - num1);
		}
		
		if(t > 0){
			cout << t << endl;
		}else{
			cout << "OK" << endl;
		}
		
	}
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	ll N;
	cin>>N;
	ll ans = 0;
	for (ll k = 1;k*k <= N;++k) {
		if ((N-1)%k == 0) {
			if ((N-1)/k != k && N/k != 1) {
				ans += 1;
			}
		
			if (k != 1) {
				ans += 1;
			}
		}
	}

	function<void(ll)> compute = [&] (ll x) {
		if (x == 1) return;
		ll z = N;
		while (z%x == 0) {
			z /= x;
		}

		if (z%x == 1) {
			ans += 1;
		}
	};

	for (ll k = 1;k*k <= N;++k) {
		if (N%k == 0) {
			compute(k);
			if (N/k != k) {
				compute(N/k);
			}
		}
	}

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


Measured memory_bytes: 256
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	h := nextInts(n)
	sort.Ints(h)
	var ans int64
	for i := 0; i < n-k; i++ {
		ans = ans + int64(h[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5120