akhauriyash/Code-Regression huggingface dataset:
/*
 *  Created on: 14 / 6 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)
#define test(t)      while(t--)

//ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ld PI = acos(-1);
//const ll mod = 1e15 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
    loop(i, 0, 5)
    {
        ll a; cin >> a;
        if (a == 0)
        {
            cout << i + 1;
        }
    }
}

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

int main(){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2] && s[2] == 'R')
    cout << 3 << endl;
  else if(s[1] != 'R'){
    if(s[0] == 'R' || s[2] == 'R')
      cout << 1 << endl;
    else cout << 0 << endl;
  }
  else if(s[1] == 'R'){
    if(s[0] == 'R' || s[2] == 'R')
      cout << 2 << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define M_PI  3.1415926535
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }

 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin );
  ll t = 1;
  //cin>>t;
   while(t--)
  {
     string s,st;
     cin>>s>>st;
     ll cnt = 0 ;
     ll n = s.length();
     for( ll i = 0 ; i<n ; i++ ){
        if( s[i]!=st[i])
        cnt++;
     }
     cout<<cnt;
  }
  return 0;

}


Measured memory_bytes: 3808
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    int d;
    cin >> x >> y >> d;
    ans = 0;
    for(i=x;i<=y;i++) {
        if(i%d==0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string s; cin >> s;
    int a = 0, b = 0, c = 0, d = 0;
    rep(i,0,s.length()) {
        if(s[i] == 'N') a++;
        else if(s[i] == 'S') b++;
        else if(s[i] == 'W') c++;
        else if(s[i] == 'E') d++;
    }
    if(a == 0 && b != 0) cout << "No" << endl;
    else if(a != 0 && b == 0) cout << "No" << endl;
    else if(c != 0 && d == 0) cout << "No" << endl;
    else if(c == 0 && d != 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int):
    if 13 <= A:
        return B
    elif 6 <= A:
        return B // 2
    return 0


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    result = solve(A, B)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5744
A,B,K = map(int,input().split())
"""
for i in range(K):
    if(A >= 1):
        A -= 1
    elif(B >= 1):
        B -= 1
    else:
        continue
"""

"""
if K >= A:
    _A = 0
else:
   _A = A - K

if K-A >= 1:
    _B = B-(K-A)
print(_A,_B)
"""

if K <= A:
    A_ = A - K
    B_ = B
elif K >= A + B:
    A_ = 0
    B_ = 0
else:
    A_ = 0
    B_ = B - (K - A)
print(A_,B_)


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

std::vector<bool> UpFlags(int n, int size) {
  std::vector<bool> up_flags(size);
  for (int i = 0; i < size; ++i) {
    if (n & (1<<i)) up_flags[i] = true;
    else            up_flags[i] = false;
  }
  return up_flags;
}

template<typename T>
void PrintList(const T& list) {
  for (auto v : list) std::cout << v << " ";
  std::cout << std::endl;
}

enum Type {kUnknown, kHonest, kUnHonest};

bool Check(const std::vector<bool>& flags, const std::vector<std::map<int, bool>>& info) {
//  PrintList(flags);

  int N = info.size();
  for (int n = 0; n < N; ++n) {
    if (!flags[n]) continue;

    for (const auto& p : info[n]) {
      if (flags[p.first] != p.second) {
//        std::cout << "  -> NG" << std::endl;
        return false;
      }
    }
  }
//  std::cout << "  -> OK" << std::endl;
  return true;
}

int main() {
  int N; std::cin >> N;
  std::vector<std::map<int, bool>> info(N);
  for (int n = 0; n < N; ++n) {
    int A; std::cin >> A;
    std::map<int, bool>& m = info[n];
    for (int a = 0; a < A; ++a) {
      int x, y; std::cin >> x >> y;
      m[x-1] = (y == 1) ? true : false;
    }
  }

  int max_honest = 0;
  for (int i = 0; i < (1 << N); ++i) {
    std::vector<bool> flags = UpFlags(i, N);
    if(Check(flags, info)) {
      int num_honest = 0;
      for (int v : flags) num_honest += v;
      max_honest = std::max(max_honest, num_honest);
    }
  }
  std::cout << max_honest << std::endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const MOD = 1001;

int[] CalcFib(int V) {
    int[] Ret = new int[V];
    Ret[0] = 2; Ret[1] = 3;
    for (int i = 2; i < V; i++) {
        Ret[i] = (Ret[i - 1] + Ret[i - 2]) % MOD;
    }
    return Ret;
}
 
void main() {
    int V, d;

    const fib = CalcFib(1000);

    void solve() {
        //writeln([V, d]);
        bool[][] G = new bool[][](V, V);
        foreach (i; 0 .. V) {
            foreach (j; 0 .. V) {
                if (abs(fib[i] - fib[j]) < d) {
                    G[i][j] = true;
                }
            }
        }

        bool[] used = new bool[V];
        void dfs(int v) {
            used[v] = true;
            foreach (i; 0 .. V) {
                if (!used[i] && G[v][i]) {
                    dfs(i);
                }
            }
        }

        int Ans = 0;
        foreach (i; 0 .. V) {
            if (!used[i]) {
                //write([i]);
                dfs(i);
                Ans++;
            }
        }
        writeln(Ans);
    }

    while (readf("%d %d\n", &V, &d)) {
        //writeln(fib[0 .. V]);
        solve();
    }
}

Measured memory_bytes: 4396
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int magic = 1000000007;

void add (int & a, int b) {
    a += b;
    if (a >= magic)
        a -= magic;
}

int mul (int a, int b) {
    return (int64)a * b % magic;
}

int FastPow(int a, int p) {
    if (p == 1) return a;
    int res = FastPow(a, p >> 1);
    res = mul(res, res);
    if (p & 1) res = mul(a, res);
    return res;
}

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

    int N, A, B;
    cin >> N >> A >> B;

    int tot_res = FastPow(2, N);

    add(tot_res, magic - 1);

    // C(N, A) = (N - A + 1) .. N / (A!)

    auto Comb = [&] (int K) {
        int factorial = 1;
        for (int i = N - K + 1; i <= N; i++)
            factorial = mul(factorial, i);
        int down = 1;
        for (int i = 1; i <= K; i++)
            down = mul(down, i);
        return mul(factorial, FastPow(down, magic - 2));
    };

    add(tot_res, magic - Comb(A));
    add(tot_res, magic - Comb(B));

    cout << tot_res << "\n";

    return 0;
}


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

int n,m;//n人 mチャック
int main(){
	scanf("%d%d",&n,&m);
	long long ax[n+5];
	long long ay[n+5];
	long long bx[m+5];
	long long by[m+5];
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&ax[i],&ay[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%lld%lld",&bx[i],&by[i]);
	}
	long long dist[n+5];
	for(int i=0;i<n;i++)dist[i]=1234567891;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
		int small=0;
		small=abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
			if(small<=dist[i]){
				dist[i]=small;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if((abs(ax[i]-bx[j])+abs(ay[i]-by[j]))==dist[i]){
				printf("%lld\n",j+1);	
				break;
			}
		}
	}
/*
for(int i=1;i<=x;i++){
	ans++;
	plus+=i;
	if(plus>=x)break;
}
printf("%d\n",ans);
*/
	
//	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  auto rd = readln.split.map!(to!size_t);
  auto n = rd[0], m = rd[1], l = rd[2];
  auto aij = iota(n).map!(_ => readln.split.map!(to!long)).array;
  auto bij = iota(m).map!(_ => readln.split.map!(to!long)).array;

  auto cij = new long[][](n, l);
  foreach (i; 0..n)
    foreach (j; 0..l)
      cij[i][j] = iota(m).map!(k => aij[i][k] * bij[k][j]).sum;

  cij.each!(ci => ci.map!(to!string).join(" ").writeln);
}

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

using namespace std;

int main()
{
  string s;
  cin>>s;
  int i,cnt=0;
  for(i=0;i<4;++i)
  {
    if(s[i]=='+')
        cnt++;
    
    else
       cnt--;
  }
  printf("%d",cnt);
}

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

int main () {

    int N;
    scanf("%d", &N);

    if (N % 2 == 1) {
        printf("%.10lf\n", (double)((N+1)/2)/N);
    }
    else {
        printf("%.10lf\n", (double)(N/2)/N);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    int a,b,c;
    cin>>a>>b>>c;
    int x,y;
    cin>>x>>y;
    int k = a+b;
    if(k<=(2*c))
    {
        cout<<x*a + y*b<<endl;
    }
    else
    {
        int p = min(x,y);
        c*=2;
        if(p==x)
        {
            int j = y-p;
                cout<<p*c + j*min(b,c)<<endl;
        }
        else
        {
         int j = x-p;
          cout<<p*c + j*min(a,c)<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define MAXN 100005

#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    double r;
    cin>>r;
    double ans;
    ans=3.1415926*2*r;
    cout<<fixed<<setprecision(7)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3800
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int i, number_n, number_a, number_b;
    Scanner sc = new Scanner(System.in);
    number_n = Integer.parseInt(sc.next());
    number_a = Integer.parseInt(sc.next());
    number_b = Integer.parseInt(sc.next());
    if(number_n * number_a < number_b) System.out.println(number_n * number_a);
    else System.out.println(number_b);
  }
}


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

#define ll long long
using namespace std;

const int N = 3005, M = 1e9 + 7;
int n;
ll dp[N][N];
string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> s;
    s = "$" + s;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        ll sum = 0;
        for(int v = 0; v <= i; v++) {
            dp[i][v] = sum;
            if(v < i) sum = (sum + dp[i - 1][s[i - 1] == s[i] ? v : i - v - 1]) % M;
        }
    }
    cout << dp[n][n] << endl;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define MAXN 100005

using namespace std;
int n,m,root[MAXN];
int get_root(int u)
{
    if(root[u] == 0) return u;
    root[u] = get_root(root[u]);
    return root[u];
}
long long ans;
void Merge(int x, int y)
{
    x = get_root(x);
    y = get_root(y);
    if(x == y) return;
    root[y] = x;
}
int main()
{
    ans = 0;
    cin >> n >> m;
    for(int i = 1; i<= m; i++)
    {
        int u,v;
        cin >> u >> v;
        Merge(u,v);
    }
    for(int i = 1; i<= n; i++)
    {
        if(!root[i])
        ans += 1;
    }
    cout << ans - 1;
    return 0;
}


Measured memory_bytes: 4020
N = int(input())
xy = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        xy_ = tuple(map(int,input().split()))
        xy[i].append(xy_)

bN = 2**N
ans = 0
for b in range(bN):
    lis = [int(("00000000000000"+bin(b)[2:])[-1-i]) for i in range(N)]
    #lis は0,1で表される不親切、正直者
    for n,l in enumerate(lis):
        #nは今見ている人、lは1なら正直者
        if l:
            for x,y in xy[n]:
                if y != lis[x-1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans,lis.count(1))
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
char n[20000000];
int main()
{
    long long int  i, max=0;
    scanf("%s", n);
    for(i=0; i<strlen(n); i++)
    {
        max=max+n[i]-48;
    }
    if(max==0)
    {
        printf("Yes\n");
    }
    else if(max%9==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1816
n = input()
array = []
base = 0
for i in xrange(n):
    inst = raw_input().split()
    if inst[0][0] == 'i':
        array.append(int(inst[1]))
    elif inst[0] == "delete":
        if int(inst[1]) in array:
            x = array[::-1].index(int(inst[1]))
            if x != -1 and int(inst[1]):
                del array[-x-1]
    elif inst[0][6] == 'F':
        array.pop()
    else:
        base += 1
print (" ".join(map(str,array[base:][::-1])))

Measured memory_bytes: 48564
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 100001;
const int mod = 1000000007;


int main(){
        int n, m;
        cin>>n>>m;
        string s;
        cin>>s;
        ll dp[n+1];
        int par[n+1];
        fill(dp, dp+n, n+1);
        fill(par, par+n+1, -1);
        dp[n] = 0;
        set < pair< int, int> > st;
        st.insert({dp[n], n});

        for(int i= n-1; i >= 0; i--){
            if(i < n-m){
                if(st.find({dp[i+m+1], i+m+1}) != st.end())st.erase({dp[i+m+1], i+m+1});
            }
            if(s[i] == '1' || st.empty())continue;

            auto beg = *st.begin();
            par[i] = beg.second;
            dp[i] =  1 + beg.first;
            st.insert({dp[i], i});
        }
   // fro(i,0,n)cout<<dp[i]<<' '; cout<<endl; fro(i,0,n)cout<<par[i]<<' ';
        if(dp[0] > n || par[0] == -1){
            cout<< -1 << endl;
        }
        else{
            int x = 0;
            while(x != n && x != -1){
                cout<< par[x] - x <<' ';
                x = par[x];
            }
        }

}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> H(n);
  rep(i,n) cin>>H[i];
  vector<bool> good(n,true);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    if(H[a]<=H[b]) good[a]=false;
    if(H[a]>=H[b]) good[b]=false;
  }
  int ans=0;
  rep(i,n) if(good[i]) ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
vi a, b, c;
int n;
inline void CountingSort(int k) {
	rep(i, 0, n) ++c[a[i]];
	rep(i, 1, k + 1) c[i] = c[i] + c[i - 1];
	rrep(j, n - 1, -1) {
		b[--c[a[j]]] = a[j];
	}
}
int main() {
	cin >> n;
	a.resize(n); rep(i, 0, n) cin >> a[i];
	b.resize(n);
	int max_a = *max_element(all(a));
	c.resize(max_a + 1);
	CountingSort(max_a);
	rep(i, 0, n) cout << b[i] << (i + 1 == n ? "\n" : " ");
	return 0;
}

Measured memory_bytes: 18620
#include"bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){

    fast
    ll n;
    cin>>n;
    ll k = n*n;
    ll kk = n*n*n;
    cout<<n+k+kk;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, N, A, B);
  int diff = B - A - 1;
  OUTL((diff % 2) ? "Alice" : "Borys");

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main(){
    map<string,int>m={
        {"SUN",7},
        {"MON",6},
        {"TUE",5},
        {"WED",4},
        {"THU",3},
        {"FRI",2},
        {"SAT",1}
    };
    string s;
    cin>>s;
    cout<<m[s]<<endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ Volume 1 Problem 0143

#include <stdio.h>
#include <string.h>

typedef struct {
	double x1;
	double y1;
	double x2;
	double y2;
} LINE;

int cross(LINE *l1, LINE *l2)
{
	double ta, tb, tc, td;

	ta = (l2->x1 - l2->x2) * (l1->y1 - l2->y1) + (l2->y1 - l2->y2) * (l2->x1 - l1->x1);
	tb = (l2->x1 - l2->x2) * (l1->y2 - l2->y1) + (l2->y1 - l2->y2) * (l2->x1 - l1->x2);
	tc = (l1->x1 - l1->x2) * (l2->y1 - l1->y1) + (l1->y1 - l1->y2) * (l1->x1 - l2->x1);
	td = (l1->x1 - l1->x2) * (l2->y2 - l1->y1) + (l1->y1 - l1->y2) * (l1->x1 - l2->x2);

	if ((ta * tb <= 0) && (tc * td <= 0)){
		return (1);    // cross
	}
	return (0); // no cross
}

int main(void)
{
    int n;
    int xp1, yp1, xp2, yp2, xp3, yp3;
    int xk, yk, xs, ys;
    int i;
    double xp, yp;
    LINE p1, p2, p3, k, s;
    int flag_in_k, flag_in_s;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d%d%d%d%d%d", &xp1, &yp1, &xp2, &yp2, &xp3, &yp3);
        scanf("%d%d%d%d", &xk, &yk, &xs, &ys);
    
        xp = (xp1 + xp2 + xp3) / 3.0;
        yp = (yp1 + yp2 + yp3) / 3.0;
    
        p1.x1 = xp1;
        p1.y1 = yp1;
        p1.x2 = xp2;
        p1.y2 = yp2;
        
        p2.x1 = xp2;
        p2.y1 = yp2;
        p2.x2 = xp3;
        p2.y2 = yp3;
    
        p3.x1 = xp3;
        p3.y1 = yp3;
        p3.x2 = xp1;
        p3.y2 = yp1;

        k.x1 = xk;
        k.y1 = yk;
        k.x2 = xp;
        k.y2 = yp;

        s.x1 = xs;
        s.y1 = ys;
        s.x2 = xp;
        s.y2 = yp;

        flag_in_k = 0;
        if (cross(&p1, &k) + cross(&p2, &k) + cross(&p3, &k) == 0){
            flag_in_k = 1;
        }
        
        flag_in_s = 0;
        if (cross(&p1, &s) + cross(&p2, &s) + cross(&p3, &s) == 0){
            flag_in_s = 1;
        }

        if (flag_in_k != flag_in_s){
            printf("OK\n");
        }
        else {
            printf("NG\n");
        }
    }
    return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-15;
ld PI = acos(-1.0);

void solve() {
    ll n, k;
    cin >> n >> k;
    vld a(n);
    rep(i, n) cin >> a[i];

    ld high = 1e9, low = 1.0;
    ll cnt = 0;
    while(cnt < 100) {
        ld mid = (high + low) / 2.0;
        ll sum = 0;
        rep(i, n) {
            ll m = a[i] / mid;
            if(a[i] / mid - (ld)m > EPS) ++m;
            sum += m;
        }
        if(sum <= k + n) high = mid;
        else low = mid;
        ++cnt;
    }
    ld ans = (high + low) / 2.0;
    ll ans2 = ans;
    if(ans - (ld)ans2 > EPS) ++ans2;
    cout << ans2 << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 6300
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**10 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(k):
        if i + j + 1 < n:
            dp[i+j+1] = min(dp[i+j+1], dp[i] + abs(h[i] - h[i+j+1]))
print(dp[n - 1])

Measured memory_bytes: 56544
N = int(input())
ls = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            check = [ls[i],ls[j],ls[k]]
            point = {ls[i],ls[j],ls[k]}
            t = max(check)
            if len(point)==3:

                if sum(check)-t >t:
                    ans+=1
print(ans)

Measured memory_bytes: 69188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  set<char> se;
  for(char c: S) se.insert(c);
  cout << (S.size()==se.size() ? "yes" : "no") << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int N = 200000 + 5, mod = 1000000007;
inline int add (int u, int v) { return u + v >= mod ? u + v - mod : u + v; }
inline int mns (int u, int v) { return u - v < 0 ? u - v + mod : u - v; }
inline int mul (int u, int v) { return 1LL * u * v % mod; }
inline int qpow (int u, int v) {
	int tot = 1, base = u % mod;
	while (v) {
		if (v & 1) tot = mul (tot, base);
		base = mul (base, base);
		v >>= 1;
	}
	return tot;
}

char info[N];
int n, cnt[N];

int main () {
	scanf ("%d%*c", &n);
	scanf ("%s", info + 1);
	n = strlen (info + 1);
	for (int i = 1; i <= n; ++i) {
		cnt[i] = info[i] == 'B';
	}
	int lef = 0, ans = 1;
	for (int i = 1; i <= n; ++i) {
		if (cnt[i]) {
			if (lef % 2 == 0) {
				if (n - i < lef + 1) { puts ("0\n"); return 0; }
				else {
					lef++;
					continue;
				}
			}
			else {
				if (!lef) { puts ("0\n"); return 0; }
				ans = mul (ans, lef);
				lef--;
				continue;
			}
		}
		else {
			if (lef % 2 == 0 ) {
				if (!lef) { puts ("0\n"); return 0; }
				ans = mul (ans, lef);
				lef--;
				continue;
			}
			else {
				if (n - i < lef + 1) { puts ("0\n"); return 0; }
				lef++;
				continue;
			}
		}
	}
	for (int i = 2; i <= n / 2; ++i) ans = mul (ans, i);
	printf ("%d\n", ans);
	return 0;
}



























Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll H,W,N;
    cin >> H >> W >> N;
    map<pll, int> m;
    vector<ll> ans(10);
    ans[0] = (H-2)*(W-2);
    REP(i, N){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        int dx[8]={-1,1,0,0,1,1,-1,-1}, dy[8]={0,0,-1,1,1,-1,1,-1};
        int t = m[pll(a,b)];
        REP(j, 8){
            ll x = a + dx[j];
            ll y = b + dy[j];
            if(0<=x&&x<H&&0<=y&&y<W){
                int mt = m[pll(x,y)];
                if(0<x&&x<H-1&&0<y&&y<W-1){
                    ans[mt]--;
                    ans[mt+1]++;
                }
                m[pll(x,y)]++;
            }
        }
        if(0<a&&a<H-1&&0<b&&b<W-1){
            ans[t]--;
            ans[t+1]++;
        }
        m[pll(a,b)]++;
    }

    for(auto&& a : ans){
        pr(a);
    }
}

Measured memory_bytes: 56448
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; string s;
    cin >> n >> s;

    rep(i,s.length()){
        s[i] = n+s[i]-'A' >= 26 ? 'A'+((n+s[i]-'A')%26) : n+s[i];
    }

    cout << s << endl;

    return 0;
}

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

int main(void){
    int h, w, n, masu[100][100], a[10010], cnt=0, co=1;
    cin >> h >> w >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<h;++i){
        if(i%2==0){
            for(int j=0;j<w;++j){
                masu[i][j] = co;
                ++cnt;
                if(cnt >= a[co-1]){
                    ++co;
                    cnt = 0;
                }
            }
        }else{
            for(int j=w-1;j>=0;--j){
                masu[i][j] = co;
                ++cnt;
                if(cnt >= a[co-1]){
                    ++co;
                    cnt = 0;
                }
            }
        }
    }
    for(int i=0;i<h;++i){
        cout << masu[i][0];
        for(int j=1;j<w;++j){
            cout << " " << masu[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void) {
  string s1, s2;
  cin >> s1 >> s2;
  cout << (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0] ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin, stderr

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort(reverse=True)

    ans = 0
    cnt = 0

    for i in range(3*N):
        if i % 2:
            ans += A[i]
            cnt += 1

            if cnt == N:
                break

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 37084
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 1000000007
using namespace std;
int f[3005][3005][2]={0};
int main(void)
{
	int i,j,k,n,m,ans=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)f[0][i][0]=1;
	f[0][0][1]=1;
	for(i=1;i<=n;++i)f[0][i][0]=1;
	for(i=0;i<=m;++i)
	{
		for(j=0;j<=n;++j)
		{
			for(k=0;k<=1;++k)
			{
				if(j)
				{
					f[i+1][j-1][k|(j==1)]=(f[i+1][j-1][k|(j==1)]+f[i][j][k])%mod;
					f[i+1][j][k|(j==1)]=(f[i+1][j][k|(j==1)]+f[i][j][k])%mod;
				}
				if(n-j)
				{
					f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k])%mod;
					f[i+1][j+1][k]=(f[i+1][j+1][k]+f[i][j][k])%mod;
				}
			}
		}
	}
	for(i=0;i<=n;++i)ans=(ans+f[m][i][1])%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  ll a;
  string b;
  cin >> a >> b;
  int c = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0') * 1;
  cout << a * c / 100 << endl;
  return 0;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())

    ans = 0
    mi = float("inf")

    if A % 10 != 0:
        mi = min(mi, A % 10)
    if B % 10 != 0:
        mi = min(mi, B % 10)
    if C % 10 != 0:
        mi = min(mi, C % 10)
    if D % 10 != 0:
        mi = min(mi, D % 10)
    if E % 10 != 0:
        mi = min(mi, E % 10)


    ans += (-(-A // 10)) * 10
    ans += (-(-B // 10)) * 10
    ans += (-(-C // 10)) * 10
    ans += (-(-D // 10)) * 10
    ans += (-(-E // 10)) * 10

    if mi == float("inf"):
        print(ans)
        exit()
    print(ans - (10 - mi))



if __name__ == '__main__':
    main()



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

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

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

  int zero=0;
  for(int i=0;i<n;i++){
    if(a[i]==0) zero++;
  }

  if(zero>0){
    cout << 0;
    return 0;
  }
  else{
    long long ans = 1;
    for(int i=0;i<n;i++){
      if(a[i]<=1000000000000000000/ans){
        ans *= a[i];
      }
      else{
        ans = -1;
        break;
      }
    }

    cout << ans;
  }

  return 0;
}

Measured memory_bytes: 4404
class Bit:
    """1-indexed"""

    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def max(self, i):
        m = 0
        while i > 0:
            m = max(m, self.tree[i])
            i -= i & -i
        return m

    def update(self, i, x):
        while i <= self.size:
            self.tree[i] = max(x, self.tree[i])
            i += i & -i


def solve():
    N = int(input())
    H = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))

    S = sorted([(h, i) for i, h in enumerate(H)])

    dp = Bit(N)
    for h, i in S:
        dp.update(i + 1, dp.max(i) + A[i])
    print(dp.max(N))


solve()


Measured memory_bytes: 58444
def main():
    n,m=map(int,input().split())
    ab=[]
    for _ in range(n):
        a,b=map(int,input().split())
        ab.append((a,b))
    ab=sorted(ab,key=lambda x: x[0])
    c=0
    for a,b in ab:
        if m>b:
            c+=a*b
            m-=b
        else:
            c+=a*m
            print(c)
            return
main()

Measured memory_bytes: 18964
import sys
from collections import deque


MOD = 10 ** 9 + 7
fin = sys.stdin.readline
N, K = [int(elem) for elem in fin().split()]
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(elem) for elem in fin().split()]
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

num_patterns = K
que = deque()
que.append((0, -1))
while que:
    node, parent = que.popleft()
    num_available_color = K - 1 if parent == -1 else K - 2
    for i in range(len(adj[node]) - (0 if parent == -1 else 1)):
        if (i >= num_available_color):
            print(0)
            exit(0)
        num_patterns *= num_available_color - i
        num_patterns %= MOD
    for neighbor in adj[node]:
        if neighbor == parent:
            continue
        que.append((neighbor, node))
print(num_patterns)


Measured memory_bytes: 62512
import java.util.Scanner

fun main (args: Array<String>) {
  val s = Scanner(System.`in`).next()
  val l = mutableListOf<Char>()
  s.forEach { c ->
    when (c) {
      '0', '1' -> { l.add(c) }
      'B' -> {
        if (l.isNotEmpty()) {
          l.removeAt(l.size - 1)
        }
      }
    }
  }
  println(l.joinToString(""))
}

Measured memory_bytes: 31520
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
const int N=1e5+5;
int tot,head[N],vet[N<<1],Next[N<<1];
void add(int x,int y){
	tot++;
	Next[tot]=head[x];
	vet[tot]=y;
	head[x]=tot;
}
int n,k;ll cnt[N];
queue< pair<int,int> >q;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		int x,y;scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	q.push(make_pair(1,0));
	while(!q.empty()){
		int u=q.front().first,fa=q.front().second;
		q.pop();
		ll res=k-1-(fa!=0);
		for(int i=head[u];i;i=Next[i]){
			int v=vet[i];
			if(v==fa)continue;
			cnt[v]=res--;
			q.push(make_pair(v,u));
		}
	}
	ll ans=1;cnt[1]=k;
	for(int i=1;i<=n;i++)ans=ans*cnt[i]%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3840
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(N - K):
        if A[i] < A[i + K]:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


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

Measured memory_bytes: 604
(let ((s (concatenate 'list (read-line)))
      (lst '()))

  (loop for i in s
        if (char= i #\0) do (push "0" lst)
        else if (char= i #\1) do (push "1" lst)
        else do (if (not (equal lst '())) (pop lst)))

  (format t "~a~%" (reverse (apply #'concatenate 'string lst))))



Measured memory_bytes: 10980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int m = in.nextInt();
		out.println((n - 1) * (m - 1));
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  int a = S.size();
  if (a <= K) {
    cout << S << endl;
  }
  else if (a > K) {
    string s;
    for (int i = 0; i < K ; i++) {
      s += S.at(i);
    }
    cout << s + "..." << endl;
  }
}

Measured memory_bytes: 3604
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);




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

	int N, K;
	cin >> N >> K;
	vector<int>asum(100001, 0);
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		asum[a] += b;
	}
	rep(i, 100001) {
		K -= asum[i];
		if (K <= 0) {
			cout << i << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 1024
n, l = map(int, input().split())
m = []
for i in range(1, n+1):
    m.append(l+i-1)
su = 0
for i in m:
    su += i
e = 10**8
ans = 0
for i in range(n):
    tmp = 0
    for j in range(n):
        if i == j: continue
        tmp += m[j]
    if e > abs(su-tmp):
        e = abs(su-tmp)
        ans = tmp
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;


int main(){
  int N; cin >> N; string S[N];
  rep(i, N){
    cin >> S[i];
  }
  bool can[N] = {}, tmp[N];
  rep(i, N){
    tmp[i] = true;
  }
  rep(j, N){
    rep(i, N){
      if(S[i][j]=='#') can[j] = true;
      if(S[i][j]!='#') tmp[j] = false;
    }
  }
  bool ca = false;
  rep(i, N){
    rep(j, N){
      if(S[i][j]=='#') ca = true;
    }
  }
  if(!ca){
    cout << -1 << endl; return 0;
  }
  int cn = 0;
  rep(i, N){
    if(tmp[i]) cn++;
  }
  int ans = 0; pair<int, int> cnt[N] = {};
  rep(i, N){
    cnt[i].second = i;
    rep(j, N){
      if(S[i][j]!='#') cnt[i].first++; 
    }
    if(!can[i]) cnt[i].first++;
  }
  sort(cnt, cnt+N);
  if(cnt[0].first!=0){
    rep(i, N){ 
      ans+=cnt[i].first; break;
    }
  }
  ans+=(N-cn);
  cout << ans << endl;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

int dfs(string s) {
  vector<int> arr;
  int lv = 0, index = 0;
  rep(i, s.size()) {
    if (s[i] == '[') {
      if (lv == 0) index = i;
      lv++;
    } else if (s[i] == ']') {
      lv--;
      if (lv == 0) arr.push_back(dfs(s.substr(index + 1, i - index - 1)));
    }
  }
  if (arr.size() == 0) return toInt(s) / 2 + 1;
  sort(all(arr));
  int res = 0;
  rep(i, arr.size() / 2 + 1) { res += arr[i]; }
  return res;
}

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

  int n;
  cin >> n;
  rep(_, n) {
    string s;
    cin >> s;

    cout << dfs(s.substr(1, s.size() - 2)) << "\n";
  }

  return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b, c, d);

  cout << max(0, min(b, d) - max(a, c)) << endl;

  return 0;
}

Measured memory_bytes: 256