akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll n;
    ll sum = 0;
    cin>>n;
    ll aaa =9;
    vector<ll> v;
    while(1){
        v.push_back(aaa);
        aaa*=9;
        if(aaa>100000) break;
    }
    aaa = 6;
    while(1){
        v.push_back(aaa);
        aaa*=6;
        if(aaa>100000) break;
    }
    v.push_back(1);
    sort(alll(v));
    reverse(alll(v));
//    int i = 0;
//    while (n!=0) {
//        while (v[i] > n) {
//            i++;
//        }
//        n-=v[i];
//        sum++;
//    }
    vector<ll> ff(100001,LONG_MAX);
    ff[0]=0;
    for(auto it:v) ff[it]=1;
//    sum+=v.size();
    rep(i, 100000){
        for(auto it:v) if(i+it <= 100000) ff[i+it] = min(ff[i+it],ff[i]+1);
    }
    pr(ff[n]);
}



Measured memory_bytes: 1656
r1 = list(map(int,input().split()))
r2 = list(map(int,input().split()))
r3 = list(map(int,input().split()))
N = int(input())
array = []
for i in range(N):
    temp = int(input())
    array.append(temp)
#
if r1[0] in array and r1[1] in array and r1[2] in array or r2[0] in array and r2[1] in array and r2[2] in array or r3[0] in array and r3[1] in array and r3[2] in array:
    print("Yes")
    exit()
elif r1[0] in array and r2[0] in array and r3[0] in array or r1[1] in array and r2[1] in array and r3[1] in array or r1[2] in array and r2[2] in array and r3[2] in array:
    print("Yes")
    exit()
elif r1[0] in array and r2[1] in array and r3[2] in array or r1[2] in array and r2[1] in array and r3[0] in array:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3064
import sys

def finish(a, b):
    print('%d %d' % (a, b))
    sys.exit()

s = raw_input().strip()
if s[0] == s[1]:
    finish(1, 2)
for i in range(2, len(s)):
    a, b, c = s[i - 2], s[i - 1], s[i]
    if a == b or a == c or b == c:
        finish(i - 1, i + 1)
finish(-1, -1)


Measured memory_bytes: 15852
N, M = map(int, input().split())
XYZs = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(1 << 3):
    signs = []
    for j in range(3):
        if i >> j & 1:
            signs.append(1)
        else:
            signs.append(-1)
    t = []
    for xyz in XYZs:
        x, y, z = xyz
        t.append(x * signs[0] + y * signs[1] + z * signs[2])
    ans = max(ans, sum(sorted(t, reverse=True)[:M]))
print(ans)

Measured memory_bytes: 3260
#include <stdio.h>
int main(void){
	int n,m;
	int sum=0;
	int time[100];
	int a,b;
	int ans[100];
	int i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&time[i]);
		sum += time[i];
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		ans[i]=sum+b-time[a-1];
	}
	for(i=0;i<m;i++)
	    printf("%d\n",ans[i]);
	return 0;
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	ll N, K;
	cin >> N >> K;
	vector<bool> s(N, false);
	vector<ll> d(K);
	vector<vector<ll>> A(K);
	for (ll i = 0; i < K; ++i)
	{
		cin >> d[i];
		A[i] = vector<ll>(d[i]);
		for (ll j = 0; j < d[i]; ++j)
		{
			cin >> A[i][j];
			s[A[i][j] - 1] = true;
		}
	}
	ll sum = 0;
	for (ll i = 0; i < N; ++i)
	{
		if (!s[i])	++sum;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

const lint mod = 1e9+7;
const lint INF = mod;
const int MAX = 30010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    lint ans=1;
    int cnt[n+1];
    rep(i, n+1) cnt[i]=0;
    cnt[0]=3;
    rep(i, n){
        (ans*=(lint)cnt[a[i]]) %= mod;
        --cnt[a[i]]; ++cnt[a[i]+1];
    }
    printf("%lld\n", ans);
}

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

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

    vector<int>l(n);
    rep(i,0,n){
        cin>>l[i];
    }

    sort(l.begin(),l.end());

    int answer=0;

    rep(i,n-k,n){
        answer+=l[i];
    }

    cout<<answer<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r){
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b) cout << c;
	else if(a == c) cout << b;
	else if(b == c) cout << a;
	return 0;
}

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

typedef long long ll;

const int N = 1e5 + 5;

int n, a, mx, vis[N], ara[N];

int main()
{
#ifdef TooLazy
    freopen("in.txt", "r", stdin);
#endif // TooLazy

    map<int, int> mp;


    cin >> n;

    for(int i=0; i<n; i++) {
        cin >> ara[i];
        mp[ara[i]]++;
    }

    for(int i=0; i<n; i++) {
        if( !vis[ara[i]] ) {
            vis[ara[i]] = 1;
            int x = mp[ara[i]];
            int b = mp[ara[i] - 1];
            int c = mp[ara[i] + 1];
            int d = x + b + c;
            mx = max(mx, d);
        }
    }

    cout << mx << "\n";

    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, std::vector<long long> A){
    LL memo[N+1];
    memo[0] = 0;
    REP(i, N) {
        memo[i+1] = (memo[i] + A[i]) % M; 
    }

    map<LL, LL> memo2;
    LL ans = 0;
    REP(i, N+1) {
        memo2[memo[i]]++;
    }
    
    for( auto i = memo2.begin(); i != memo2.end() ; ++i ) {
        ans += i->second * (i->second - 1) / 2;
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


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

int main() {
  vector<pair<int, int>> n(26);
  string s;
  cin >> s;
  for(int i = 0; i < 26; i++)
    n.at(i).second = i;
  for(int i = 0; i < s.length(); i++)
    n.at(s.at(i) - 'a').first++;
  sort(n.begin(), n.end());
  if(n.at(0).first)
    printf("None\n");
  else
    printf("%c\n", n.at(0).second + 'a');
}

Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<sys/time.h>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, bb;
    cin >> n >> a >> b;
    bb = b;
    vector<int> ans;
    int s = n - a + 1;
    for(int _ = 0; _ < n; _++){
        int j;
        for(j = 0; j < a; j++){
            ans.push_back(s + j);
            bb -= j == 0;
            if(bb == n - (int)ans.size()){
                j++;
                break;
            }
        }
        int idx = j;
        if(j < a){
            for(int i = 0; i < min((int)ans.size(), idx); i++){
                (*(ans.rbegin() + i)) += a - j;
            }
        }
        s -= j;
        if(bb == n - (int)ans.size()){
            break;
        }
        // s -= a;
    }
    while((int)ans.size() < n){
        ans.push_back(n - ans.size());
    }
    if((int)ans.size() != n){
        cout << -1 << '\n';
        return 0;
    }
    for(int i = 0; i < 2; i++){
        vector<int> dp(n + 1, M);
        for(auto& e : ans){
            *lower_bound(dp.begin(), dp.end(), e) = e;
        }
        for(int j = 0; j <= n; j++){
            if(dp[j] == M){
                if((i == 0 && j != a) || (i == 1 && j != b)){
                    cout << -1 << '\n';
                    return 0;
                }
                break;
            }
        }
        reverse(ans.begin(), ans.end());
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4572
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < k; i++) {
        vll imos(n + 1, 0);
        for (ll j = 0; j < n; j++) {
            imos[max(0LL, j - a[j])]++;
            imos[min(n, j + a[j] + 1)]--;
        }
        bool alln = true;
        for (ll j = 1; j <= n; j++) {
            imos[j] += imos[j - 1];
            alln &= imos[j - 1] == n;
        }

        imos.pop_back();
        a = imos;
        if (alln) break;
    }
    for (ll i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n': ' ');
    return 0;
}


Measured memory_bytes: 6364
/*input
10 6
1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=1e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fac[maxn];
ll arr[maxn];
int main(){
    int n,k;
    cin>>n>>k;
    fac[0]=1;
    REP1(i,maxn-1) fac[i]=(fac[i-1]*(ll)i)%MOD;
    REP(i,n) cin>>arr[i];
    sort(arr,arr+n);
    ll big=0,small=0;
    REP(i,n){
        ll x=arr[i];
        if(i>=k-1) big+=mult(x,mult(mult(fac[i],mypow(fac[k-1],MOD-2)),mypow(fac[i-k+1],MOD-2)));
        if(i<=n-k) small+=mult(x,mult(mult(fac[n-i-1],mypow(fac[k-1],MOD-2)),mypow(fac[n-i-1-k+1],MOD-2)));
    }
    cout<<sub(big,small);

}

Measured memory_bytes: 1792
def resolve():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    max_distance = 0

    for i in range(N - 1):
        max_distance = max(max_distance, A[i + 1] - A[i])

    max_distance = max(max_distance, A[0] + K - A[N - 1])
    print(K - max_distance)


resolve()

Measured memory_bytes: 26436
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    string s,t; cin>>s>>t;
    Sort(s); Sort(t); Reverse(t);
    if(s<t) Out("Yes");
    else Out("No"); 
}

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

const int INF = 1 << 28;
int n, m;
int a[3010], b[3010], c[3010], t[3010];
int dis0[210][210], dis1[210][210];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n >> m, n) {
    for (int i = 0; i < n; i++) {
      cin >> a[i] >> b[i] >> c[i] >> t[i];
      a[i]--, b[i]--;
    }
    fill_n((int*)dis0, 210 * 210, INF);
    fill_n((int*)dis1, 210 * 210, INF);
    for (int i = 0; i < m; i++) {
      dis0[i][i] = dis1[i][i] = 0;
    }
    for (int i = 0; i < n; i++) {
      dis0[a[i]][b[i]] = dis0[b[i]][a[i]] = c[i];
      dis1[a[i]][b[i]] = dis1[b[i]][a[i]] = t[i];
    }
    for (int k = 0; k < m; k++) {
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          dis0[i][j] = min(dis0[i][j], dis0[i][k] + dis0[k][j]);
          dis1[i][j] = min(dis1[i][j], dis1[i][k] + dis1[k][j]);
        }
      }
    }
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;
      p--, q--;
      if (r == 0) cout << dis0[p][q] << endl;
      else cout << dis1[p][q] << endl;
    }
  }  

  return 0;
}


Measured memory_bytes: 3556
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  scanf("%d %d",&n,&q);
  int sum =0 ;
  for ( int i = 0 ; i < n; i++ ) {
    scanf("%d",a+i);
    sum += a[i];
  }
  int cnt = 0 ;
  for ( int i = 0; i < n; i++ ) {
    if ( 4*q*a[i] >= sum ) {
        cnt++;
    }
  }
  if ( cnt >= q ) printf("Yes\n");
  else printf("No\n");
return 0 ;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int res = 0;
  int ab = 0, a = 0, b = 0;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size() - 1; j++) {
      if (s[j] == 'A' && s[j + 1] == 'B') res++;
    }
    if (s[0] == 'B' && s[s.size() - 1] == 'A')
      ab++;
    else if (s[0] == 'B')
      b++;
    else if (s[s.size() - 1] == 'A')
      a++;
  }
  if (a + b == 0)
    res += max(0, ab - 1);
  else
    res += ab + min(a, b);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;



int main(){
  ios_base::sync_with_stdio(false);

  int f[28] = {};

  char s[111111];
  scanf(" %s",s);

  int len = strlen(s);
  for(int i=0;i<len;i++){
    f[s[i]-'a'] = 1;
  }

  int j;
  for(j=0;j<26;j++){
    if(f[j] == 0){
      printf("%c\n",'a'+j);
      break;
    }
  }
  if(j == 26)printf("None\n");

  return 0;
}


Measured memory_bytes: 384
import collections

N = int(input())
A = list(map(int, input().split()))
AA = collections.Counter(A)

ans = sum(A)

Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    count = AA[B]
    ans += (C-B) * count
    AA[C] += count
    AA[B] -= count
    print(ans)

Measured memory_bytes: 94836
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int  div(char * res,char *s1,int divisor)
{
 int tempval=0,currpos=0,currres=0;
 while(tempval<divisor && s1[currpos]!='\0')
 {
  tempval=tempval*2+s1[currpos++]-48;
 }
 while(s1[currpos]!='\0')
 {
  res[currres++]=tempval/divisor+48;
  tempval%=divisor;
  tempval=tempval*2+s1[currpos++]-48;
 }
 res[currres++]=tempval/divisor+48;
 res[currres]='\0';
 return tempval%divisor;
}
int main()
{
  int t,n;
  cin>>n;
  int arr[200001]={0};
  arr[1]=1;
  reps(i,2,200001){
      arr[i]=arr[i%__builtin_popcount (i)]+1;
  }
  lli brr[200001][2]={0};
  string s;
  cin>>s;
  int c=0;
 // int l=strlen(s);
  rep(i,s.length()){
      if(s[i]=='1') c++;
  }
  lli l1=1,l2=1;
  lli fans[2]={0};
  rep(i,s.length()){
      brr[i][0]=l1;
      brr[i][1]=l2;
      if(s[s.length()-1-i]=='1') {
          fans[0]=(fans[0]+l1)%(c+1);
          if(c-1)fans[1]=(fans[1]+l2)%(c-1);}
      l1=(l1*2)%(c+1);
      if(c-1)l2=(l2*2)%(c-1);
  }
  int cc=c,val;
  
  //strcpy(str,s);
  rep(i,s.length()){
      cc=c;
      if(s[i]=='1') {
           cc--;
           if(cc==0) {cout<<"0\n";continue;}
           val=(fans[1]-brr[s.length()-1-i][1]+cc)%cc;
           //cout<<"vw"<<val<<" "<<fans[1]<<" "<<brr[s.length()-1-i][1]<<" "<<cc<<endl;
           if(val) cout<<1+arr[val]<<"\n";
           else cout<<"1\n";
          }
      else {
          cc++;
           val=(fans[0]+brr[s.length()-1-i][0])%cc;
           //cout<<"vq"<<val<<" "<<fans[0]<<" "<<brr[s.length()-1-i][0]<<" "<<cc<<endl;
           if(val) cout<<1+arr[val]<<"\n";
           else cout<<"1\n";
      }
  }
  return 0;
}


Measured memory_bytes: 7636
x, y = map(int, input().split())
MOD = 10 ** 9 + 7

if (x+y) % 3 != 0:
    print(0)
    exit()

#m: (i+2, j+1), n (i+1, j+2)

m = (2*x - y) // 3
n = (2*y - x) // 3

if m < 0 or n < 0:
    print(0)
    exit()

ans = 1
i = 1

if n > m:
    n, m = m, n

while i <= n:
    ans *= (m+i) * pow(i, MOD-2, MOD)
    ans %= MOD
    i += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  vector<vector<char>> c(3, vector<char>(3));
  rep(i, 3) {
    rep(j, 3) { cin >> c[i][j]; }
  }

  rep(i, 3) { cout << c[i][i]; }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	double arr[50], arr2[50], result = 0;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	result = arr[0];
	for (int i = 0; i < n - 1; i++)
		result = (result + arr[i + 1]) / 2;
	cout << result << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int n;

int main(){
	while(scanf("%d", &n),n){
		int num = 0,dis = -1;
		for(int i = 0; i < n; i++){
			int p,d1,d2;
			scanf("%d%d%d", &p, &d1, &d2);
			if(d1+d2 > dis){
				dis = d1+d2;
				num = p;
			}
		}
		printf("%d %d\n", num, dis);
	}
}

Measured memory_bytes: 1028
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxx=1e5+6;
 
class point {
public:
    double x,y;
    point(double x=0,double y=0):x(x),y(y){}
 
    bool operator < (const point &u)const{
        if(x!=u.x) return x<u.x;
        return y<u.y;
    }   
};
point a[maxx],b[maxx];
 
inline double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); }
inline bool cmp(point a,point b){return a.y<b.y;}
double solve(int left,int right){
    if(left+1==right) return dis(a[left],a[right]);
    double xl,xr,xm;
    int mid=(left+right)>>1;
    xl=solve(left,mid);
    xr=solve(mid,right);
    xm=min(xl,xr);
    int k=1;
    for(int i=left;i<=right;i++){
        if(fabs(a[mid].x-a[i].x)<=xm) b[k++]=a[i];
    }
    sort(b+1,b+k,cmp);
    for(int i=1;i<k;i++){
        for(int j=i+1;j<k && (b[j].y-b[i].y<xm);j++){
            xm=min(xm,dis(b[i],b[j]));
        }
    }
    return xm;
}
 
int main() {
    int n;
    double x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lf%lf",&x,&y);
        a[i]=point(x,y);
    }
    sort(a+1,a+1+n);
    double ans=solve(1,n);
    printf("%.6f\n",ans);
    return 0;
}


Measured memory_bytes: 6372
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

kabu, yen = 0, 1000

for x, y in zip(A, A[1:] + [0]):
    # 円にもどす
    kabu, yen = 0, yen + x * kabu
    if x < y:
        # 買う
        kabu, yen = divmod(yen, x)

print(yen)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n, r;
	cin >> n >> r;
	
	if(n >= 10)
		cout << r << endl;
	else
		cout << r + 100ll * (10ll - n) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	ll n,num[10]={},ans=0;
	cin>>n;
	REP(i,n){
		string s;
		cin>>s;
		if(s[0]=='M'){
			num[0]++;
		}
		else if(s[0]=='A'){
			num[1]++;
		}
		else if(s[0]=='R'){
			num[2]++;
		}
		else if(s[0]=='C'){
			num[3]++;
		}
		else if(s[0]=='H'){
			num[4]++;
		}
	}
	REP(Bit,1<<5){
		ll e=1,count=0;
		bitset<5> b(Bit);
		REP(i,5){
			if(b[i]==1){
				count++;
				e*=num[i];
			}
		}
		if(count==3){
			DEB(b)END
			ans+=e;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
h,w=gets.split.map(&:to_i)

arr=[]

arr2=Array.new(h+2).map{Array.new(w+2,"0")}


h.times{

    arr<<gets.chomp.split("")}
j=1    
h.times{
   arr2[j][1..w]=arr[j-1]
    j+=1
}





 i=0   
(h*w).times{
    point=0
    tate=i/w+1
    yoko=i%w+1
    
    
    
    if arr2[tate][yoko]=="."
      point+=1
elsif    arr2[tate+1][yoko]=="#" 
point+=1

elsif    arr2[tate-1][yoko]=="#" 
point+=1

elsif    arr2[tate][yoko+1]=="#" 
point+=1

elsif   arr2[tate][yoko-1]=="#" 
point+=1
    
end
    
    
 if point==0  
     puts "No"
     exit
 end
    
    
 i+=1 
 

}
   
   
   puts "Yes" 
    


Measured memory_bytes: 2044
n=int(input())
lst=[int(input()) for i in range(n)]
a=max(lst)
aind=lst.index(a)
if aind==0:
  b=max(lst[1:])
elif aind==n-1:
  b=max(lst[:n-2])
else:
  tempa=max(lst[:aind])
  tempb=max(lst[aind+1:])
  b=max(tempa, tempb)
bind=lst.index(b)
for j in range(n):
  if j==aind:
    print(b)
  else:
    print(a)

Measured memory_bytes: 13064
#include<stdio.h>
#define NMAX 200000
int UF_find(int, int*);
int main(void)
{
  int i, j, n, k, l, rdgrp = 0;
  int droot[NMAX], troot[NMAX], dleaf[NMAX], dnext[NMAX], trgrp[NMAX], trgcnt[NMAX], ans[NMAX] = {0};
  scanf("%d %d %d", &n, &k, &l);
  for (i = 0; i < n; i++) {
    droot[i] = troot[i] = i;
    dleaf[i] = dnext[i] = -1;
    trgrp[i] = trgcnt[i] = 0;
  }
  for (i = 0; i < k; i++) {
    int p, q, proot, qroot;
    scanf("%d %d", &p, &q);
    proot = UF_find(p - 1, droot);
    qroot = UF_find(q - 1, droot);
    if (proot != qroot) {
      if (proot < qroot) droot[qroot] = proot;
      else droot[proot] = qroot;
    }
  }
  for (i = 0; i < l; i++) {
    int r, s, rroot, sroot;
    scanf("%d %d", &r, &s);
    rroot = UF_find(r - 1, troot);
    sroot = UF_find(s - 1, troot);
    if (rroot != sroot) {
      if (rroot < sroot) troot[sroot] = rroot;
      else troot[rroot] = sroot;
    }
  }
  for (i = 0; i < n; i++) {
    int rd = UF_find(i, droot);
    if (i == rd) dleaf[i] = i;
    else {
      dnext[i] = dleaf[rd];
      dleaf[rd] = i;
    }
  }
  for (i = 0; i < n; i++) {
    if (dleaf[i] >= 0) {
      rdgrp++;
      for (j = dleaf[i]; j >= 0; j = dnext[j]) {
        int rt = UF_find(j, troot);
        if (trgrp[rt] == rdgrp) trgcnt[rt]++;
        else {
          trgrp[rt] = rdgrp;
          trgcnt[rt] = 1;
        }
      }
      for (j = dleaf[i]; j >= 0; j = dnext[j]) {
        int rt = UF_find(j, troot);
        ans[j] = trgcnt[rt];
      }
    }
  }
  for (i = 0; i < n; i++) printf("%d%c", ans[i], i == n - 1 ? '\n': ' ');
}

int UF_find(int a, int *ufp)
{
  if (ufp[a] == a) return a;
  else {
    ufp[a] = UF_find(ufp[a], ufp);
    return ufp[a];
  }
}


Measured memory_bytes: 6144
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    p=[]
    for i in range(n):
        p.append(INT())
    print(int(sum(p)-max(p)/2))
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const R = Number(input[0][0]);

  return 2 * Math.PI * R;
};

console.log(main(read()));


Measured memory_bytes: 29652
#include <iostream>
#include <algorithm>

int main() {
  int N, M, X, Y, flag = 0;
  int x[120], y[120];

  std::cin >> N >> M >> X >> Y;

  for(int i=0; i<N; ++i)
    std::cin >> x[i];
  for(int i=0; i<M; ++i)
    std::cin >> y[i];

  std::sort(x, x+N);
  std::sort(y, y+M);

  for(int i=x[N-1]+1; i<=y[0]; ++i) {
    if(X < i && i <= Y) flag = 1;
  }

  if(flag) std::cout << "No War" << "\n";
  else std::cout << "War" << "\n";

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    C = list(input())

    W = deque()
    R = deque()
    for i in range(n):
        if C[i] == "W":
            W.append(i)
        if C[i] == "R":
            R.appendleft(i)

    res = 0
    i = 0
    cnt = 0
    while R:
        if C[i] == "W":
            cnt += 1
        if cnt:
            r = R.popleft()
            w = W.popleft()
            C[r], C[w] = C[w], C[r]
            cnt -= 1
            res += 1
        else:
            R.pop()
        i += 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 18776
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

conf = 0
from heapq import heapify, heappop, heappush
As.sort(reverse=True)
m = As.pop(0)
s = As.pop(0)
conf += m
Q = []
heappush(Q, -s)
heappush(Q, -s)
for a in As:
    s = heappop(Q)
    conf -= s
    heappush(Q, -a)
    heappush(Q, -a)
print(conf)

Measured memory_bytes: 105704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int D=365;
vector<int> c(26);
vector<vector<int>> s(365, vector<int>(26));

ll calc(const vector<int>& t, int d, int q){
  ll res = 0;
  vector<int> lst(26,-1);
  rep(i,D){
    if(i!=d){
      if(t[i]!=-1){
        res += s[i][t[i]];
        lst[t[i]] = i;
      }
    }
    else{
      res += s[i][q];
      lst[q]=i;
    }
    rep(j,26){
      res -= c[j]*(i-lst[j]);
    }
  }
  //cerr << res << '\n';
  return res;
}



int main(){
  /*
  ifstream in("input.in");
  cin.rdbuf(in.rdbuf());
  ofstream ofs("output.txt");
  cout.rdbuf(ofs.rdbuf());
  //*/
  chrono::system_clock::time_point start, end;
  start = chrono::system_clock::now();
  mt19937 mt(184);
  cin >> D;
  rep(i,26) cin >> c[i];
  rep(y,D) rep(x,26) cin >> s[y][x];
  vector<int> t(D,-1);
  ll now = calc(t, -1, -1);
  rep(d,D){
    int k=-1;
    ll prenow=-1;
    rep(q,26){
      ll pre = calc(t,d,q);
      if(now < pre){
        if(mt()&1 || mt()&1 || mt()&1) {
          now = pre;
          t[d] = q;
        }
        if(k==-1) {k=q; prenow = pre;}
      }
      if(chmax(now,calc(t,d,q))){
        t[d]=q;
      }
      end = chrono::system_clock::now();
      double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
      if(ela>1900) break;
    }
    if(t[d]==-1) {
      t[d]=k;
      now = prenow;
    }
    // timer
    end = chrono::system_clock::now();
    double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
    if(ela>1900) break;
  }
  while(1){
    int d=mt()%365, q=mt()%26;
    if(chmax(now,calc(t,d,q))){
      t[d]=q;
    }
    end = chrono::system_clock::now();
    double ela = chrono::duration_cast<chrono::milliseconds> (end-start).count();
    if(ela>1970) break;
  }
  rep(i,D) cout << t[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3688
import java.util.*;

class Main {

    static private int A;
    static private long B;
    static private long N;

    private static long func(long x) {
        return (A * x / B) - (A * (x / B));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextLong();
        N = sc.nextLong();

        long x = N;
        if (N >= B-1) x = B - 1;

        System.out.println(func(x));
    }

}

Measured memory_bytes: 35604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		
		int n = Integer.parseInt(reader.readLine());
		int m = Integer.parseInt(reader.readLine());
		int[] number = new int[n];
		
		String[] tag = reader.readLine().split(" ");
		int[] target = new int[m];
		for(int i = 0; i < m; i++)
			target[i] = Integer.parseInt(tag[i]);
		
		for(int i = 0; i < m; i++){
			String[] vote = reader.readLine().split(" ");
			for(int j = 0; j < n; j++){
				int targ = Integer.parseInt(vote[j]);
				
				if(targ == target[i]){
					number[j]++;
				}else{
					number[target[i] - 1]++;
				}
			}
		}
		for(int i = 0; i < n; i++)
			System.out.println(number[i]);
			
		reader.close();
	}
}

Measured memory_bytes: 26788
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Dodecagon
            int r = int.Parse(Console.ReadLine());
 
            Console.WriteLine(r * r * 3);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9+7;
signed main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>>vec(N);
    for(int i = 0; i < M; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    for(int i = 0; i < vec[0].size(); i++) {
        int X = vec[0][i];
        for(int j = 0; j < vec[X].size(); j++) {
            if(vec[X][j] == N-1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12776
using System;
using System.Linq;

class CinaRec
{
    static void Main()
    {
            string str;
            for (int i=1; ;i++ )
            {
                str = Console.ReadLine();
                int a = int.Parse(str);
                if (a == 0)
                {
                    break;
                }
                Console.WriteLine("Case "+i+": " + a);
            }
    }
}

Measured memory_bytes: 5820
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define FAIL0 {cout << "0\n"; return 0;}
#define FAIL1 {cout << "-1\n"; return 0;}
#define FAILNO {cout << "No\n"; return 0;}
#define YES {cout << "Yes\n"; return 0;}

const int MAXN = 2e5+3;
const int MOD = 1e9+7;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s,t;
    cin >> s >> t;
    
    int ans = 0;
    fori(i,3) ans += s[i] == t[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0; i<N; i++){
   cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  int ans = v.at(N-1)-v.at(0);
  

  cout << ans << endl;
    
	
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b;
    int i,m,min;
    scanf("%d %d",&a,&b);
    if(a>b){
        m=a;min=b;
    }else{
        m=b;min=a;
    }
    for(i=1;i<=m;i++){
        printf("%d",min);
    }
    return 0;
}


Measured memory_bytes: 128
def main():
    X, Y = map(int, input().split())
    ans = 'No'
    # i: tsuru
    for i in range(X+1):
        if 2 * i + 4 * (X - i) == Y:
            ans = 'Yes'
            break

    print(ans)

if __name__ == '__main__':
    main()

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

#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int n , x , y ;

main( ) {
	cin >> n >> x >> y;
	x--; y--;
	map<int , int> mp;
	repi( i ,0, n ) {
		repi( j , i + 1 , n ) {
			int dis = min( j - i , abs( x - i ) + abs( y - j ) +1);
			mp[ dis ]++;
		}
	}
	repi( i ,1, n  ) cout<< mp[ i ] <<endl;
}


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

struct st {
	int t, s, d;
};
bool b[20000];
st p[20000];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, m) {
			int t, s, d; scanf("%d%d%d", &t, &s, &d);
			p[i] = { t,s - 1,d - 1 };
		}
		sort(p, p + m, [](st a, st b) {return a.t < b.t; });
		memset(b, 0, sizeof(b));
		b[0] = 1;
		rep(i, m)b[p[i].d] |= b[p[i].s];
		printf("%d\n", count(b, b + n, 1));
	}
}

Measured memory_bytes: 3404
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, p;
    string s;
    cin >> n >> p >> s;
    reverse(ALL(s));
    int ten = 1;
    VI cnt(p);
    cnt[0] = 1;
    int r = 0;
    ll ans = 0;
    REP(i,n){
        int x = s[i] - '0';
        r = (r + x * ten) % p;
        ans += cnt[r];
        cnt[r]++;
        ten = (10 * ten) % p;
    }
    if (p == 2 || p == 5){
        ans = 0;
        ll c = 0;
        REP(i,n){
            int x = s[i] - '0';
            if (x % p == 0) c++;
            ans += c;
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace xcubic
{
    class Program
    {
        static void Main(string[] args)
        {
           // var str = Console.ReadLine(); // ユーザーの入力した文字列を1行読み込む
            var n = int.Parse(Console.ReadLine());  // ユーザーの入力した整数を読み込む
            Console.WriteLine(  n * n * n );

        }

    }
}



Measured memory_bytes: 15928
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

long solve (in long n, in long a, in long b) {
  long r1, r2;
  long x = a, y = b;
  r1 += a - 1;
  x -= a - 1;
  y -= a - 1;
  r1++;
  y--;
  r1 += (y - 1) / 2;

  x = a; y = b;
  r2 += (n - b);
  y = n;
  x += (n - b);
  r2++;
  x++;
  r2 += (n - x) / 2;
  return min (r1, r2);
}

long test () {
  long n, a, b;
  readf (" %d %d %d", &n, &a, &b);
  if (a == b) return 0;
  long d = abs (a - b);
  if ((d % 2) == 0) return d / 2;
  if (a > b) swap (a, b);
  return solve (n, a, b);
  /*
  long r1 = max (a, b) - 1;
  long r2 = n - min (a, b);
  return min (r1, r2);
  */
}

void main() {
  writeln (test ());
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	int w;
	cin >> s >> w;

	string ans;
	for (int i = 0; i < s.size(); i += w) {
		ans += s[i];
	}

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


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

bool is_prime[50001];
vector<int> prime;

void eratos(){
	fill(is_prime,is_prime+50001,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=50000; ++i){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2; j*i<=50000; ++j) is_prime[j*i]=false;
		}
	}
}

int main(){
	int N;
	eratos();
	while(cin >> N&&N){
		int count=0;
		int size=prime.size();
		for(int i=0; i<size; ++i){
			if(prime[i]>=N) break;
			if(prime[i]*2==N) count+=2;
			else if(binary_search(prime.begin(),prime.end(),N-prime[i])) ++count;	
		}
		if(count%2==0) count/=2;
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1320
#include <stdio.h>
#include <stdlib.h>
#define N 10



int main(void){
    int d,t,s;
    scanf("%d %d %d",&d,&t,&s);

    if(t < d / s){
        printf("No\n");
    }
    else if(d % s != 0 && t == d / s){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1644
#include <iostream>
#include <cstring>

using namespace std;

int main(void) {
	
	int n;
	cin >>n;
	
	int p[n],i,max=0,maxid,sum=0;
	for (i=0 ; i<n ; i++) {
		cin >>p[i];
		if (p[i]>max) {
			max=p[i];
			maxid=i;
		}
	}
	
	p[maxid]=p[maxid]/2;
	for (i=0 ; i<n ; i++) {
		sum+=p[i];
	}
	cout <<sum <<endl;
	
	return 0;
}

Measured memory_bytes: 256