akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = input()

t = [set() for _ in range(n)]
t[-1] = {int(s[-1])}

for i in range(1, n):
    base = t[n - i].copy()
    base.add(int(s[n - i - 1]))
    t[n - i - 1] = base

ans = 0
for a in range(10):
    ai = 0

    if a not in t[ai]:
        continue

    while ai < n:
        if s[ai] == str(a):
            break
        else:
            ai += 1
    if ai >= n - 2:
        continue
    for b in range(10):
        bi = ai + 1

        if b not in t[bi]:
            continue

        while bi < n:
            if s[bi] == str(b):
                break
            else:
                bi += 1
        if bi >= n - 1:
            continue
        for c in range(10):
            ci = bi + 1

            if c not in t[ci]:
                continue

            while ci < n:
                if s[ci] == str(c):
                    break
                else:
                    ci += 1
            if ci == n:
                continue
            else:
                ans += 1

print(ans)
exit(0)


x = int(input())
dp = [False for _ in range(x + 1)]
dp[0] = True
for item in [100, 101, 102, 103, 104, 105]:
    for i in range(x + 1):
        if i - item >= 0:
            if dp[i - item]:
                dp[i] = True

print(1 if dp[x] else 0)
exit(0)


Measured memory_bytes: 25332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  ll ans = 0;
  ll m = MAX_I;
  bool issame = true;
  rep(i,N){
    ll x,y;cin >> x >> y;
    if(x!=y)issame = false;
    if(x>y)m = min(m,y);
    ans += x;
  }
  if(issame)cout << 0 << endl;
  else cout << ans - m << endl;
  return 0;
}


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

int main(void) {
    int64_t N;
    int64_t key;
    int64_t maxcount = 0;
    int64_t sum;
    int64_t last;
    cin >> N;

    map<int64_t,int64_t> a;
    for(int i=0;i<N;i++) {
        cin >> key;
        a[key-1]++;
    }

    for(map<int64_t,int64_t>::iterator it = a.begin();it != a.end();++it) {
        sum = it->second;
        last = it->first;
//printf("sum:%ld\n", sum);
        auto it2 = it;
        ++it2;
        if(it2 != a.end() && ((last+2) >= it2->first)){
            sum+=it2->second;
            ++it2;
            if(it2 != a.end()&&((last+2) >= it2->first))  sum+=it2->second;
        }
        if(maxcount < sum) maxcount = sum;
    }
    
    cout << maxcount << "\n";
    return 0;
}


Measured memory_bytes: 4224
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	arr := make([]float64, n)
	for i := 0; i < n; i++ {
		arr[i] = float64(sc.NextInt())
	}
	sort.Float64s(arr)
	prev := arr[0]
	for i := 1; i < len(arr); i++ {
		prev = (prev + arr[i]) / 2
	}

	fmt.Printf("%v\n", prev)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#define COS60 (1.0 / 2.0)
#define SIN60 (1.73205080757 / 2.0)

typedef struct point { double x, y; } p_t;

static void koch(int d, p_t p1, p_t p2) {
  p_t s, t, u;

  if (d-- <= 0) return;

  /*
   *  m * x2 + n * x1
   * -----------------
   *       m + n
   */
  s.x = (1.0 * p2.x + 2.0 * p1.x) / (1.0 + 2.0);
  s.y = (1.0 * p2.y + 2.0 * p1.y) / (1.0 + 2.0);
  t.x = (2.0 * p2.x + 1.0 * p1.x) / (2.0 + 1.0);
  t.y = (2.0 * p2.y + 1.0 * p1.y) / (2.0 + 1.0);
  /*
   * (cosX, -sinX) (x)
   * (sinX,  cosX) (y)
   */
  u.x = COS60 * (t.x - s.x) - SIN60 * (t.y - s.y) + s.x;
  u.y = SIN60 * (t.x - s.x) + COS60 * (t.y - s.y) + s.y;

  koch(d, p1, s);
  printf("%f %f\n", s.x, s.y);
  koch(d, s, u);
  printf("%f %f\n", u.x, u.y);
  koch(d, u, t);
  printf("%f %f\n", t.x, t.y);
  koch(d, t, p2);
}

int main(int argc, char **argv) {
  int d, ret;
  p_t p1 = {0.0, 0.0};
  p_t p2 = {100.0, 0.0};

  ret = scanf("%d", &d);
  if (errno != 0) perror("scanf: d");
  if (ret < 1) exit(1);

  printf("%f %f\n", p1.x, p1.y);
  koch(d, p1, p2);
  printf("%f %f\n", p2.x, p2.y);

  exit(0);
}


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

#define NL '\n'
#define sz(x) x.size()
#define INF LONG_MAX
#define IINF LLONG_MAX
#define PI (2.0*acos(0.0))

#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define sfd2(x,y) scanf("%lf %lf",&x,&y);

#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))

#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Rof(i, j, k) for(int i = j; i >= k; i--)
#define all(x) x.begin(),x.end()
#define asort(x) sort(all(x));
#define dsort(x) sort(all(x), greater<int>())
#define unq(x) x.erase(unique(x.begin(),x.end()),x.end())

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair <int,int> PII;
typedef pair <LL,LL> PLL;

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

int main()
{
    int arr[6];
    for(int i=1; i<=5; i++) sfi(arr[i]);
    for(int i=1; i<=5; i++)
    {
        if(arr[i]==0)
        {
            cout<<i<<NL;
            break;
        }
    }
}


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

int main(){
    map< char , int > count;
    string str;
    while( cin>>str ){
        for(int i=0;i<(int)str.size();i++){
            if( isupper(str[i]) ){
                str[i]=tolower(str[i]);
            }
        }
        for(int i=0;i<(int)str.size();i++){
            count[ str[i] ]++;
        }
    }
    for(char ch='a';ch<='z';ch++){
        cout<<ch<<" : "<<count[ch]<<endl;
    }
    return 0;
}


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

#define forn(i,m,n) for(int i=m;i<n;i++)
#define vv vector
#define vi vv<int>
#define ii pair<int,int>
#define vii vv<ii>
#define mp make_pair
#define pb push_back
#define PI 3.141592653589
#define ll long long
#define pll pair<ll,ll>
#define vl vv<ll>
#define ff first
#define ss second
#define MOD 1000000007

bool is_prime[1000001];
vi prime;
void sieve(int n)
{
    memset(is_prime,true,sizeof(is_prime));
    for(int i=2;i*i<=n;i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {
                is_prime[j]=false;
            }
        }
    }
    forn(i,2,n+1)
    {
        if(is_prime[i])
            prime.pb(i);
    }
}


ll ex(ll a,ll b)
{
    ll res=1;
    a=a%MOD;
    while(b)
    {
        if(b%2){res=(res*a)%MOD;b--;}
        b/=2;
        a=(a*a)%MOD;
    }
    return res;
}

ll fermat_inv(ll a){ return ex(a,MOD-2); }
ll max(ll a,ll b){ return a>b?a:b; }
ll min(ll a,ll b){ return a<b?a:b; }


int main()
{
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        #endif
    //sieve(1000000);
    int te=1;
    //cin>>te;
    while(te--)
    {
        int n;
        cin>>n;
        ll a[n];
        forn(i,0,n)
            cin>>a[i];
        ll dp[n][n];
        forn(i,0,n)
            forn(j,0,n)
                dp[i][j]=0;
        for(int l=n-1;l>=0;l--)
        {
            for(int r=l;r<n;r++)
            {
                if(l==r)
                    dp[l][r]=a[l];
                else
                    dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
            }
        }
        cout<<dp[0][n-1];
    }
}


Measured memory_bytes: 73880
# D Road to Millionaire
N = int(input())
A = list(map(int, input().split()))
i = 0
M =1000
while i in range(N - 1):
    if A[i] >= A[i+1]:
        i = i + 1   
    else:
        m = (A[i+1] - A[i]) * (M // A[i])
        M = M + int(m)
        i = i + 1
print(M)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,k,q;
	cin >> n>>k>>q;
    int a[q];
    fr(i,q){
      cin >>a[i];
    }
    int b[n];
    fr(i,n){
      b[i]=0;
    }
    fr(i,q){
      b[a[i]-1]++;
    }
    fr(i,n){
      if(k-q+b[i]>0)cout << "Yes" << endl;
      else cout << "No" << endl;
    }
}


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

int main(){
  int K;
  cin >> K;
  string S;
  cin >> S;
  int len = S.size();
  
  if(len <= K){
    cout << S << endl;
  }
  else{
   S=S.substr(0,K);
     cout << S << "..." << endl;
  }
  
}

Measured memory_bytes: 3628
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


void main() {
  mixin(readAsInto!(int, "N, K"));
  auto A = readln.chomp.split.to!(int[]);

  ceil((N - 1).to!float / (K - 1)).writeln;
}


string readAsInto(T, string D)() {
  return
    T.stringof ~ " " ~ D ~ ";"
  ~ "foreach(tup; zip("
    ~ "[" ~ (D.split(",").map!(s => "&" ~ s.strip).join(",")) ~ "],"
    ~ "readln.chomp.split.to!(" ~ T.stringof ~ "[])"
  ~ ")) *tup[0] = tup[1];";
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000
#define VMAX 10000

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve() {
  int ans = 0;

  bool V[MAX];
  for( int i = 0; i < n; i ++ ) {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B+n);
  for (int i = 0;i<n;i++)T[B[i]] = i;
  // for (int i = 0;i<n;i++)cout << A[i]<< " " << B[i]<< " "<< T[B[i]] << endl;
  for (int i =0;i < n; i ++) {
    if (V[i]) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;//サイクルの要素数
    while (1) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m,v);
      S += v;//サイクルのコストの総和
      cur = T[v];//上記で正しい順序のIndexバケツ？でサイクルができる
      if ( V[cur] ) break;
    }
    ans += min(S + (an - 2)*m, m+S + (an+1)*s);//左:サイクル内の最小値
  }
  return ans;
}

int main() {
  cin >> n;
  s = VMAX;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    s = min(s, A[i]);
  }
  int ans = solve();
  cout << ans << endl;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

const int mod = 1000000007;
class mint {
  long long x;
  public:
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const {
    return mint(-x);
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const  mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint& a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res/=a;
  }

  friend ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
  }
};

struct combination{
  vector<mint> fact,ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1;i <= n;i++) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1;i--) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n,int k){
    if(k < 0 || n < k) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint ans;
int n,k;
combination comb(1101010);

vvint to(110101);
void dfs(int v,int p = -1){
  for(int v2:to[v]){
    if(v2 == p) continue;
    dfs(v2,v);
  }
  int n = (p == -1) ? k : k-2;
  int k = (p == -1) ? to[v].size()+1 : to[v].size()-1;
  if(n < 0 || (n-k) < 0){
    ans = 0;
  }
  ans *= comb.fact[n];
  ans *= comb.ifact[(n-k)];
}

signed main(){
  cin >> n >> k;
  rep(i,0,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = 1;
  dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 26624
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void EatingSymbolsEasy(){
	string S;
	cin >> S;
	int c = 0;
	for (size_t i = 0; i < 4; i++)
	{
		c += (S[i] == '+') ? 1 : -1;
	}
	cout << c << "\n";
}
int main() {
	EatingSymbolsEasy();
	return 0;
}

Measured memory_bytes: 256
// C - Lowwer
#include <stdio.h>

int main(void){
    int n, i, cnt=0, ans=0;
    int h[100000];
    scanf("%d", &n);
    for(i=0; i<n; i++){scanf("%d", &h[i]);}
    for(i=0; i<n-1; i++){
        if(h[i]>=h[i+1]){
            cnt++;
            if(ans<cnt){ans=cnt;}
        }else{
            cnt=0;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int A,B,result;
    scanf("%d %d",&A,&B);
    result=A*B;
    if(A>=1 && B<=9 && B>=1 && A<=9)
    {
        printf("%d\n",result);
    }
    else{
        printf("-1\n");
    }

    return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>  #include<random>  
#define int long long  
#define pp pair<int,int>  
#define ss second  
#define ff first  
#define pb push_back  
#define mod 1000000007  
using namespace std;  
void fastio()  
{    
  
  #ifndef ONLINE_JUDGE                  
  freopen("INPUT.txt","r",stdin);              
  freopen("OUTPUT.txt","w",stdout);              
  #endif    
     ios_base :: sync_with_stdio(false);   
     cin.tie(NULL) ;                             
      cout.tie(NULL);                              
   } 
   
signed main()  {    
        fastio();         
         int t=1;           
          // cin>>t;                
           while(t--)                  
              {                        
                string s,t;                          
                cin>>s;
                if(s=="Rainy")        
                t="Sunny";
                else if(s=="Sunny")    
                t="Cloudy";
                else
                t="Rainy";
                 cout<<t;
                        
             }          
    }     

Measured memory_bytes: 3536
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

D = lines[0][0]
Inf = 10 ** 10

last_date = []
for i in 1..26 do
  last_date.push(0)
end

for i in 1..D do
  max_satis = - Inf
  best_contest = 0
  for k in 1..26 do
    now_satis = 0
    now_satis += lines[i+1][k-1]
    now_satis += lines[1][k-1] * (i - last_date[k-1])
    if i < D - 10 then
      for j in 1..10 do
        now_satis -= lines[i+j+1][k-1] / 10
      end
    end
    if now_satis > max_satis then
      max_satis = now_satis
      best_contest = k
    end
  end
  last_date[best_contest-1] = i
  if i < D then
    puts best_contest
  else
    print best_contest
  end
end

Measured memory_bytes: 14288
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int n;
  ll t;
  cin >> n >> t;

  vector<ll> a(n);

  REP(i, n) {
    cin >> a[i];
  }

  ll ans = t;
  REP(i, n-1) {
    ans += t;
    if(a[i+1] - a[i] < t) ans -= t-(a[i+1] - a[i]);
  }

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


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int N,K,A[1001]={0},i,j,t,w=0;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
		
		for(i=0;i<N;i++){
			for(j=i+1;j<N;j++){
				if(A[i]>A[j]){
					t=A[i];
					A[i]=A[j];
					A[j]=t;
				}
			}
		}
		for(i=0;i<K;i++)
		w+=A[i];
		
		printf("%d\n",w);
		return 0;
}
		

Measured memory_bytes: 1736
main = do
        a <- getLine
        putStrLn $ show (ans a)

ans :: String -> Int
ans a = case a of 
                "SUN" -> 7
                "MON" -> 6
                "TUE" -> 5
                "WED" -> 4
                "THU" -> 3
                "FRI" -> 2
                "SAT" -> 1


Measured memory_bytes: 380
from heapq import heappop,heappush
n,m=map(int,input().split())
a=list(map(int,input().split()))
h=[]
for i in a:heappush(h,-i)
for i in range(m):heappush(h,-((-heappop(h))//2))
s=0
for i in range(n):s+=-heappop(h)
print(s)

Measured memory_bytes: 14180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int f=0;

void print(char *n, char *m){
  int i;
  printf("%d",n[0]-'0');
  for(i=0;i<3;i++) printf("%c%d",m[i+1],n[i+1]-'0');
  printf("=7\n");
  f=1;
  return;
}

void ari(char *n, char *m, int a, int sum){
  //printf("mark: %d, %d\n",a, sum);
  if(a==4){
    if(sum==7) print(n, m); 
    return;
  }
  m[a]='+';
  ari(n,m,a+1,sum+n[a]-'0');
  if(f==1) return;
  if(a!=0){
    m[a]='-';
    ari(n,m,a+1,sum-n[a]+'0');
  }
  return;
}

int main(void){
  char n[4], m[4];
  scanf("%s",n);
  //printf("%d %d %d %d\n",n[0]-'0',n[1]-'0',n[2]-'0',n[3]-'0');
  ari(n,m,0,0);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)

using namespace std;


void solve(int W, int H, int N, vector<int> x, vector<int> y, vector<int> a) {
  int left(0), right(W), top(H), bottom(0);
  REP(i, N) {
    switch (a[i]) {
    case 1:
      left = max(left, x[i]);
      break;
    case 2:
      right = min(right, x[i]);
      break;
    case 3:
      bottom = max(bottom, y[i]);
      break;
    case 4:
      top = min(top, y[i]);
      break;
    }
  }
  cout << max(0, right - left) * max(0, top - bottom) << endl;
}

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

  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  REP(i, N)
    cin >> x[i] >> y[i] >> a[i];

  solve(W, H, N, move(x), move(y), move(a));

  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n=0,ans=0;
    bool check=true;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    while(true){
        for(int i=0;i<n;i++){
            if(a.at(i)%2==0)a.at(i) /= 2;
            else check=false;
        }
        if(check)ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vec<ll> v(N);
  REP(i, N) cin >> v[i];
  sort(ALL(v));

  ld answer = v[0];
  for (int i = 1; i < N; i++) {
    answer = (answer + v[i]) / 2.0;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3844
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  string S; cin>>S;
  int Q; cin>>Q;
  
  //string s = S;
  deque<char> dq;
  int N = S.size();
  REP(i,N) dq.push_back(S[i]);

  bool head = true;
  REP(i,Q) {
    int T; cin>>T;
    if (T == 1) {
      head = !head;
    } else { assert(T == 2);
      int F; char C; cin>>F>>C;
      if (head) {
        if (F == 1) {
          //s = C + s;
          dq.push_front(C);
        } else {
          //s = s + C;
          dq.push_back(C);
        }
      } else { assert(!head);
        if (F == 2) {
          //s = C + s;
          dq.push_front(C);
        } else {
          //s = s + C;
          dq.push_back(C);
        }
      }
    }
  }
  //if (!head) reverse(s.begin(), s.end());
  if (!head) reverse(dq.begin(), dq.end());

  //string ans = s;
  string ans = "";
  while (!dq.empty()) {
    ans += dq.front(); dq.pop_front();
  }  
  cout << ans << endl;


  return 0;
}


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

using namespace std;


#define MAXN 100001
typedef long long ll;

int n, m, a[MAXN];
vector<int> g[MAXN];
int bio[MAXN];
set<pair<int, int>> S;

pair<int, int> dfs(int u) {
  bio[u] = 1;
  pair<int, int> ret = {a[u], u};
  for (auto &v : g[u]) {
    if (bio[v]) continue;
    ret = min(ret, dfs(v));
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int u = 0; u < n; ++u) {
    cin >> a[u];
    S.insert({a[u], u});
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int N = 0;
  ll ans = 0;
  for (int u = 0; u < n; ++u) {
    if (bio[u]) continue;
    auto cmn = dfs(u);
    S.erase(cmn);
    ans += (ll)cmn.first;
    N++;
  }
  if (N==1) {
    cout << 0 << endl;
    return 0;
  }
  if (2*N-2>n) {
    cout << "Impossible" << endl;
    return 0;
  }
  auto it = S.begin();
  for (int i = 0; i < N-2; ++i, ++it) {
    ans += (ll)it->first;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,d-P[f]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(n=0);Z[a=H[P[n]]-n?n:0];n++)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38104
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int X, Y;
    cin >> X >> Y;
    if (Y % 2 != 0) {
        cout << "No\n";
        return 0;
    }
    int B = Y/2 - X, A = X-B;
    if (A >= 0 and B >= 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}


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

using namespace std;

int main() {
    int n, a, count = 0;
    vector < bool > table(1000000001, false);

    /*
    for (int i=0; i<1000000001; i++) {
        table[i] = false;
    }
    */

    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%d", &a);
        if (table[a]) count--;
        else count++;

        table[a] = !table[a];
    }

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

    return 0;
}

Measured memory_bytes: 122368
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
int main(){
int n,m;
cin>>n>>m;
n--;m--;
if(m%n==0)cout<<m/n<<endl;
else cout<<m/n+1<<endl;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n, m;
char a[1010][1010];
int cache[1010][1010];

int dp(int i, int j)
{
	if(i>n || j>m)
		return 0;
	if(a[i][j]=='#')
		return 0;
	if(i==n && j==m)
		return 1;
	int &ans=cache[i][j];
	if(ans!=-1)
		return ans;
	ans=dp(i+1, j) + dp(i, j+1);
	ans%=mod;
	return ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
            cin>>a[i][j];
    mst(cache,-1);
	int ans=dp(1, 1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9344
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    REP(i, n){
        ll p;
        cin >> p;
        if(p != i + 1) cnt++;
    }
    if(cnt <= 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace std;
int main(int argc,char** argv){
  int n,k;
  cin >> n >> k;
  long ret;
  if(k % 2 == 0){
    long tmp = n / k;
    long tmp2 = ( n + k / 2) / k;
    ret = tmp * tmp * tmp + tmp2 * tmp2 * tmp2;
  }else{
    long tmp = n/k;
    ret = tmp * tmp * tmp;
  }
  cout << ret << endl;
  return 0;
}


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

int main(){
    //input
    long long N, Y;
    cin >> N >> Y;

    //calc
    bool honma=0;
    long long x,y;
    for(x=0; x<=N && 10000*x<=Y; x++){
        for(y=0; x+y<=N && 10000*x+5000*y<=Y; y++){
            if((Y-10000*x-5000*y)/1000==N-x-y){
                honma=1;
                break;
            }
        }
        if(honma) break;
    }

    //answer
    if(honma){
        cout << x << " " << y << " " << N-x-y << endl;
    }else{
        cout << "-1 -1 -1" << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 0;
    REP(i, N) cin >> A[i];

    for (int i = 1; i < N; ++i) {
        ans += max(0ll, A[i - 1] - A[i]);
        A[i] = max(A[i], A[i - 1]);
    }
    cout << ans << endl;
//    cerr << A << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 4432
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



int main()
{
    int a,b,c,d,ans=0,cnt=0,sum=0;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    cout<<"Yes";
    else
    cout<<"No";
    //system("pause");
    return 0;
}  

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int b1,b2,b3;

    std::cin >> b1;
    std::cin >> b2;
    std::cin >> b3;

    if (b3 == 1) {
        std::cout << "Open" << std::endl;
    } else if (b1 == 1 && b2 == 1){
        std::cout << "Open" << std::endl;
    } else {
        std::cout << "Close" << std::endl;
    }

    return 0;


}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  map<string, int> kuji;
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, n) {
    string s;
    cin >> s;
    if(kuji[s] == 0) {
      ans++;
      kuji[s] = 1;
    }

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 19188
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
st = [[xl[i][0] + xl[i][1], xl[i][0] - xl[i][1]] for i in range(n)]
st.sort()
ans = 1
t = st[0][0]
for i in range(1, n):
  if st[i][1] >= t:
    ans += 1
    t = st[i][0]
print(ans)

Measured memory_bytes: 41440
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define ll long long

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

	if ((a+ b) % 2 == 0)
	{
		cout << (a + b) / 2;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
   int t,a;
   while(scanf("%d",&t)!=EOF)
   {
       a=2;
   int n,ans=1;
   scanf("%d",&n);
  while(a>0)
    {
        if(a%2==1)
        {
            ans*=t;
        }
        t*=t;
        a/=2;
    }
   printf("%d\n",ans-n);
   }
   return 0;
}


Measured memory_bytes: 256
#include<iostream>



using namespace std;



int n;

int prime[1000000];

int checked[1000000];

int primesum[1000000];

int result[30];

int datasets;



int main()

{

	prime[0] = 0;

	prime[1] = 0;

	primesum[0] = 0;

	primesum[1] = 0;



	for (int a = 2; a<1000000; a++)

	{

		prime[a] = 1;

	}



	for (int a = 2; a<1001; a++)

	{

		if (checked[a] == 0)

		{

			checked[a] = 1;

			for (int b = 2; b<a; b++)

			{

				if (a%b == 0)

				{

					prime[a] = 0;

					break;

				}

			}

			if (prime[a] == 1)

			{

				for (int c = 2 * a; c<1000000; c += a)

				{

					checked[c] = 1;

					prime[c] = 0;

				}

			}

		}

	}



	for (int a = 2; a<1000000; a++)

	{

		primesum[a] = primesum[a - 1] + prime[a];

	}



	while (cin >> n)

	{

		cout << primesum[n] << endl;

	}



	return 0;

}

Measured memory_bytes: 12880
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M;
  cin >> N >> M;
  cout << (N - 1) * (M - 1) << "\n";
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int  H, W;
	
	while(1)
	{
		cin >> H;
		cin >> W;
		
		if( (0 == H) && (0 == W) )
		{
			break;
		}
		
		for(int i = 0; i < H; i++)
		{
			cout << "#";
			
			for(int j = 1; j < W - 1; j++)
			{
				if( (0 == i) || (H - 1 == i) )
				{
					cout << "#";
				}
				else
				{
					cout << ".";
				}
			}
			
			cout << "#" << endl;
		}
		cout << endl;
	}
	
	return 0;
}


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

int main() {
	const long long mod = pow(10, 9) + 7;
	int n; cin >> n;

	long long power = 1;
	for (int i = 1; i <= n; i++) {
		power = (power * i) % mod;
	}

	cout << power % mod << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);) {
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			List<Integer> list = new ArrayList<>();
			list.add(a);
			list.add(b);
			list.add(c);
			
			list.sort(Comparator.naturalOrder());
			
			System.out.println(list.get(0) + " " + list.get(1) + " " + list.get(2));
		}
	}

}


Measured memory_bytes: 26132
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
 
void solve(){
	int n;
	cin >> n;
	pii a[n];
	rep(i, n) {
		cin >> a[i].F;
		a[i].S = i;
	}
	sort(a, a + n);
	rep(i, n) {
		cout << a[i].S + 1 << ' ';
	}
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

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

class ABC142
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var d = new SortedDictionary<int, int>();
        for (int i = 1; i <= n; i++)
        {
            d.Add(s[i - 1], i);
        }
        Console.WriteLine(string.Join(" ", d.Values));
    }
}

Measured memory_bytes: 35580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string S; cin>>S;
  string ans="NO";
  int N=S.size();
  REP(i,0,7){
    string X;
    rep(j,0,i)
      X+=S[j];
    rep(j,N+i-7,N)
      X+=S[j];
    if(X=="keyence"){
      ans="YES";
      break;
      }
    }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            a.add(Integer.parseInt(sc.next()));
        }

        // 主処理
        int result = 0;
        int[] target = a.stream().mapToInt(t -> t).filter(t -> t % 2 == 0).toArray();
        for (int i = 0; i < target.length; i++) {
            while (target[i] % 2 == 0) {
                target[i] /= 2;
                result++;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 33316
def solve():
    M, D = map(int, input().split())
    ans = 0
    for m in range(1, M + 1):
        for d in range(22, D + 1):
            d1 = d % 10
            if d1 < 2:
                continue
            d10 = d // 10
            if d10 < 2:
                continue
            if d1 * d10 == m:
                ans += 1
    print(ans)
solve()


Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
using namespace std;
static const int MAX=246914;
int primes[MAX];

bool isPrime(const int & n) {
    if (primes[n] != -1) return (primes[n] == 1);
    if (n % 2 == 0 || n % 3 == 0) {
        primes[n] = 0;
        return false;
    }
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0) {
            primes[n] = 0;
            return false;
        }
    primes[n] = 1;
    return true;
}

int main() {
    int left, right, sum;
    fill(primes, primes+MAX, -1);
    primes[0] = primes[1] = 0;
    primes[2] = primes[3] = 1;
    for (; ;) {
        scanf("%d", &left);
        if (left == 0) break;
        right = left*2; sum = 0;
        for (int i = left+1; i <= right; i++) {
            if (isPrime(i)) sum++;
        }
        std::printf("%d\n", sum);
    }
    return 0;
}



Measured memory_bytes: 4128
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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


Measured memory_bytes: 256
n = int(input())
a = sorted([int(i) for i in input().split()],reverse=True)
A = [a[0]]
B = []
for i in range(1,n):
  if i % 2 == 0:
    A.append(a[i])
  else:
    B.append(a[i])
print(sum(A)-sum(B))

Measured memory_bytes: 3060
/*
  ICPCの解答提出のログが与えられたとき， 各チームの順位を表示
 */

#include <stdio.h>

#define T_MAX 50 // チーム数の上限
#define P_MAX 10 // 問題数の上限

// フラグ
#define SORTED 0 
#define NOT_SORTED -1

/* 構造体Team_score: チームあたりのデータ */
typedef struct {
  long time; // 所要時間
  int num; // 回答問題数
  int penalty[P_MAX]; // 問題
} Team_score;

int main(void) {
  int M, T, P, R; // コンテストの始まりから終わりまでの時間、チーム数、問題数、提出記録の数
  
  while (scanf("%d %d %d %d", &M, &T, &P, &R) != EOF) { // 一行ずつデータを読み込む
    int i, k;
    int m, t, p, j; // 経過時間、チーム番号、問題番号、正誤
    Team_score scores[T_MAX];
    int ranking[T_MAX]; // 順位の順番にチーム番号を格納（ただしチーム番号は-1されている）
    int flag_sorted;
    
    if (M==0 && T==0 && P==0 && R==0) // 終了判定
      break;

    /* チーム記録（構造体）を0で初期化 */
    for (i=0; i<T; i++) {
      scores[i].time = 0;
      scores[i].num = 0;
      for (k=0; k<P; k++) {
	scores[i].penalty[k] = 0;
      }
    }


    /* 提出記録を順番に読み込んで、各チームの正解数、所要時間などを計算 */
    for (i=0; i<R; i++) {
      
      scanf("%d %d %d %d", &m, &t, &p, &j); // 提出記録を読み込む
      if (j == 0) { // もし問題に正解していれば
	scores[t-1].time += m + scores[t-1].penalty[p-1] * 20; // 所要時間を加算
	scores[t-1].num += 1; // 正解問題数をインクリメント
      } else { // もし誤答だったら
	scores[t-1].penalty[p-1] += 1; // 問題あたりの誤答数をインクリメント
      }
    }

    /* 順位を表す配列を初期化 */
    for (i=0; i<T; i++) 
      ranking[i] = i;

    /* 順位付け: 順位の基準にしたがって、チームの順番をソートして順位付け */
    do {
      flag_sorted = NOT_SORTED;
      
      for (k=0; k<=T-2; k++) {
	if (/* 正答数が多いか */
	    (scores[ranking[k]].num < scores[ranking[k+1]].num)
	    /* 正当数は同じであるが、所要時間が短いか */
	    || (scores[ranking[k]].num == scores[ranking[k+1]].num
		&& scores[ranking[k]].time > scores[ranking[k+1]].time)
	    /* 同じ順位であるが、後ろのほうがチーム番号が多いとき */
	    || (scores[ranking[k]].num == scores[ranking[k+1]].num
		&& scores[ranking[k]].time == scores[ranking[k+1]].time
		&& ranking[k] < ranking[k+1])) {
	  /* チーム番号を入れ替え */
	  int tmp = ranking[k];
	  ranking[k] = ranking[k+1];
	  ranking[k+1] = tmp;

	  flag_sorted = SORTED; // 入れ替えられた
	}
      }
    } while (flag_sorted == SORTED); // 入れ替えられなくなったら終了

    /* 順位を表示 */
    printf("%d", ranking[0]+1); // トップのチームの番号を表示 
    for (i=1; i<T; i++) {
      if (scores[ranking[i-1]].num == scores[ranking[i]].num
	  && scores[ranking[i-1]].time == scores[ranking[i]].time) { // 前のチームと同順だったら
	printf("=%d", ranking[i]+1); // '='を使って表示
      } else { //そうでなかったら
	printf(",%d", ranking[i]+1); // ','を使って表示
      }
    }
    putchar('\n');
  }
  
  return 0;
}

Measured memory_bytes: 608