akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const int inf = 1e9;
const ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

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

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

class Combination
{
private:
    vector<mint> _fact, _inv_fact;
    
public:
    Combination(int size) : _fact(size + 1), _inv_fact(size + 1) {
        _fact[0] = 1;
        for (int i = 1; i <= size; i++) _fact[i] = _fact[i-1] * i;
        _inv_fact[size] = _fact[size].inv();
        for (int i = size - 1; i >= 0; i--) _inv_fact[i] = _inv_fact[i+1] * (i+1);
    }

    mint fact(int k) const {return _fact[k];}
    mint inv_fact(int k) const {return _inv_fact[k];}

    mint P(int n, int r) {
        if (r < 0 || n < r) return 0;
        else return fact(n) * inv_fact(n - r);
    }

    mint C(int n, int r) {
        if (r < 0 || n < r) return 0;
        else return fact(n) * inv_fact(r) * inv_fact(n - r);
    }

    mint H(int n, int r) {
        if (n < 0 || r < 0) return 0;
        else return r == 0 ? 1 : C(n + r - 1, r);
    }
};

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

    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

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

    Combination c(n);

    mint ans = 0;
    for (int i = k - 1; i < n; i++) {
        ans += mint(a[i]) * c.C(i, k - 1);
    }
    for (int i = 0; i < n - k + 1; i++) {
        ans -= mint(a[i]) * c.C(n - i - 1, k - 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, M, X, Y;
  vector<int> x(100), y(100);
  int tempx = -100, tempy = 100;
  cin >> N >> M >> X >> Y;
  tempx = X;
  tempy = Y;
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
    tempx = max(x[i], tempx);
  }
  for (int i = 0; i < M; i++) {
    cin >> y.at(i);
    tempy = min(y[i], tempy);
  }

  if (tempx < tempy) {
    cout << "No War";
  } else {
    cout << "War";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    int a,b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;

    return 0;
}


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

int h, w, k;
vector<string> s;
vector<vector<long long>> ans;
vector<vector<bool>> ch;

void solve();

int main() {
  cin >> h >> w >> k;
  s.resize(h);
  for(int i = 0; i < h; ++i) cin >> s[i];
  solve();
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(j != 0) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

void solve() {
  int now = 0, cnt = 0;
  ans.assign(h, vector<long long>(w, 0));
  ch.assign(h, vector<bool>(w, 0));
  for(int i = 0; i < h; ++i) {
    int nowcnt = 0;
    for(int j = 0; j < w; ++j)
      if(s[i][j] == '#') ++nowcnt;
    if(nowcnt == 0) {
      ++cnt;
      if(i == h - 1)
        for(int j = 0; j < w; ++j)
          for(int x = 0; x <= cnt; ++x)
            ans[i - x][j] = ans[i - cnt][j];
    }
    else {
      for(int j = 0; j < w; ++j) {
        int r = j;
        while(r < w && s[i][r] != '#') ++r;
        if(r != w) ++now;
        for(int l = j; l <= min(r, w - 1); ++l)
          for(int x = 0; x <= cnt; ++x) {
            ans[i - x][l] = now;
          }
        j = r;
      }
      cnt = 0;
    }
  }
}

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

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,a,n) for(int i=(a);i<(n);i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  //必要な数だけ埋める
  int left=0,right=0;
  rep(i,s.size()){
    if(s[i]=='(')++right;
    else{
      if(right==0)++left;
      else --right;
    }
  }

  //出力
  rep(i,left)cout<<'(';
  cout<<s;
  rep(i,right)cout<<')';
  cout<<endl;
}

Measured memory_bytes: 3616
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	double a,b;
	cin>>a>>b;
	cout<<shosu(9)<<a/b<<endl;
}






Measured memory_bytes: 256
N = gets.to_i

ac = 0
wa = 0
tle = 0
re = 0

N.times do
  str = gets.chomp
  case str
  when "AC"
    ac += 1
  when "WA"
    wa += 1
  when "TLE"
    tle += 1
  when "RE"
    re += 1
  end
end
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

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

namespace ABC126B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int FF = int.Parse(S.Substring(0, 2));
            int LL = int.Parse(S.Substring(2, 2));

            if (1 <= FF && FF <= 12 && 1 <= LL && LL <= 12)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (1 <= FF && FF <= 12)
            {
                Console.WriteLine("MMYY");
            }
            else if (1 <= LL && LL <= 12)
            {
                Console.WriteLine("YYMM");
            }
            else
                Console.WriteLine("NA");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
/*In the name of ALLAH, Most Gracious, Most Merciful*/
#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define FOR(x,n)                for (ll i=x,j=x,k=x;i<n,j<n,k<n;i++,j++,k++)
#define FORR(n,x)               for (ll i=n-1,j=n-1,k=n-1;i>=x,j>=x,k>=x;i--,j--,k--)
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;
ll tc=1;


void solve()
{
    ll x,n;
    cin>>x>>n;
    int cnt[205]={0};
    int arr[n];
    FOR(0,n)
    {
        ll a;cin>>a;
        cnt[a+100]++;
    }
    ll na,nb;
    for (int i=x;i<=200;i++)
    {
        if (cnt[i+100]==0)
        {
            na=i;
            break;
        }
    }
    for (int i=x;i>=-200;i--)
    {
        if (cnt[i+100]==0)
        {
            nb=i;
            break;
        }
    }
    //watch(na);watch(nb);
    if (na-x<x-nb)cout<<na<<endl;
    else cout<<nb<<endl;


}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}

Measured memory_bytes: 3604
from heapq import heappop,heappush
N,K = map(int,input().split())
A = []
for i in range(N):
    a = list(map(int,input().split()))
    heappush(A,a)
count = 0
while count < K:
    x,y = heappop(A)
    count += y
print(x)

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

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    List<Integer> a = new ArrayList<>();

    for (int i = 0; i < n; i++) {
      a.add(scanner.nextInt());
    }
    if(a.stream().filter(e -> e % 2 == 0).allMatch(e -> e% 3 == 0 || e% 5 == 0)) {
      System.out.println("APPROVED");
    } else {
      System.out.println("DENIED");
    }
  }
}


Measured memory_bytes: 27344
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;

    int a = -1, z = -1;
    FOR(i, 0, S.size())
        if (a < 0 && S[i] == 'A')
            a = i;
        else if (S[i] == 'Z')
            z = i;

    cout << (z - a + 1) << endl;
    return 0;
};


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A;
  int B;
  cin>>A;
  cin>>B;
  string C;
  cin>>C;
  string D;
  D="Yes";
  
  
  if(C.at(A)!='-'){
      D="No";
  }
  if(D=="Yes"){  
    for(int i=0;i<A;i++){
      char c=C.at(i);
      if(!(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9')){
        D="No";
      break;
      }
    }
  }
  if(D=="Yes"){
    for(int i=0;i<B;i++){
      char c=C.at(i+A+1);
      if(!(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9')){
        D="No";
       
       	break;
      }
    }
  }
  cout<<D<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
#include<iomanip>
#include <math.h>

using namespace std;
typedef long long ll;

int main(void)
{
    int r;
    cin >> r;

    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func f(a, b int) int {
	if a == 0 {
		return 0
	}
	if b == 1 {
		return a
	}
	if a == b {
		return a
	}

	if x := a % b; x == 0 {
		return a
	} else {
		return a + (b - x)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = ri()
		b[i] = ri()
	}

	cost := 0
	for i := n - 1; i >= 0; i-- {
		a[i] += cost
		cost += f(a[i], b[i]) - a[i]
	}
	fmt.Println(cost)
}


Measured memory_bytes: 2304
import math
A, B, H, M = map(int, input().split())
rH = 360 * (H + (M/60))/12
rM = 360 * (M/60)
if(rH >= rM):
  rHOM = min(rH-rM, 360-(rH-rM))
else:
  rHOM = min(rM-rH, 360-(rM-rH))
  
cos = math.cos(math.radians(rHOM))

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

Measured memory_bytes: 9516
/*
Reference : https://www.geeksforgeeks.org/maximum-product-subsequence-size-k/
 
 
*/
#include <bits/stdc++.h> 
using namespace std; 
 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 
 
/*
Mistakes
 
- while using pairs make sure you comparator datatype it's int by default change it as per the need
- Modify comparator if you want to
*/
#define f first
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll64 int64_t
#define pb push_back
#define pll pair<long long int,long long int>
#define pi pair<int,int>
#define mi map<int,int>
#define ll long long int
#define mll map<long long int,long long int>
#define umi unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long int,long long int>>
#define mod 1000000007
#define fp(i,x,n) for(int i=x;i<n;i++)
#define fn(i,x,n) for(int i=x;i>n;i--)
#define fpm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define asort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysec)
#define asort_vp_first(vect) sort(vect.begin(), vect.end())
#define dsort_vp_first(vect) sort(vect.begin(), vect.end(), sortinrev) 
#define dsort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysecdesc)
#define vi vector<int>
#define vll vector<long long int>
#define c(x) cout<<x<<endl;
#define M 1000000007
using namespace std; 
#define int long long int
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        ans = (ans*a)%M;
        a= (a*a)%M;
        b/=2;
    }
    return ans;
}
signed main()
{
    FIO;
    int n;
    cin>>n;
    
    int ans = 0;
    ans += power(10,n);
    ans -= power(9,n);
    while(ans<0)
    ans+=M;
    
    ans -= power(9,n);
    while(ans<0)
    ans+=M;
    
    ans = (ans + power(8,n))%M;
    cout<<ans;
   
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
#define NIL -1

int n,S[251];

void print(int u, int t){
    cout << "node " << t << ": ";
    cout << "key = " << u << ", ";
    if(t-1) cout << "parent key = " << S[t/2] << ", ";
    if(n>=2*t) cout << "left key = " << S[t*2] << ", ";
    if(n>=2*t+1) cout << "right key = " << S[t*2+1] << ", ";
    
    cout << endl;
}

int main(){
    cin >> n;
    
    for(int i=1; i<=n; i++){
        cin >> S[i];
    }
    
    for(int i=1; i<=n; i++){
        print(S[i], i);
    }
    
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

// https://poporix.hatenablog.com/entry/2019/03/25/203820#D---We-Like-AGC

int main()
{
    ll N; cin >> N;
    ll M = 1e9+7;
    vll dp[4][4][4];
    rep(i, 4) rep(j, 4) rep(k, 4) dp[i][j][k] = vector<ll>(N + 1, 0);

    rep(i, 4) rep(j, 4) rep(k, 4) {
        if (!((i == 0 && j == 1 && k == 2) ||
              (i == 1 && j == 0 && k == 2) ||
              (i == 0 && j == 2 && k == 1))) dp[i][j][k][3] = 1;
    }

    for (ll n = 3; n < N; n++) {
        rep(i, 4) rep(j, 4) rep(k, 4) rep(m, 4) {
            if (j == 0 && k == 2 && m == 1) continue;
            else if (((i == 0 && k == 1) || (i == 0 && j == 1) || (j == 0 && k == 1) || (j == 1 && k == 0)) && m == 2) continue;
            dp[j][k][m][n+1] = (dp[j][k][m][n+1] + dp[i][j][k][n]) % M;
        }
    }

    ll res = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) res = (res + dp[i][j][k][N])%M;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}


int main()
{      
  fastio();
  int n,m,i,j,t;
  deque<char> dq;
  string s;
  cin>>s;
  for(i=0;i<s.size();i++)
  {
  	dq.pb(s[i]);
  }
  cin>>n;
  int rev=0;
  while(n--)
  {
  	cin>>t;
  	if(t==1)
  	{
  		rev^=1;
  	}
  	else
  	{
  		int f;
  		char c;
  		cin>>f>>c;
  		if(rev)
  		{
  			if(f==1)
  				dq.pb(c);
  			else
  				dq.push_front(c);
  		}
  		else
  		{
  			if(f==1)
  				dq.push_front(c);
  			else
  				dq.pb(c);
  		}
  	}
  }
  string final;
  for(char c:dq)
  {
  	final.pb(c);
  }
  if(rev)
  	reverse(final.begin(),final.end());
  cout<<final;
  return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_N = 1e2+10;

int main(int argc, char const *argv[])
{
	int n, h[MAX_N];
	cin >> n;

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

	int imos[MAX_N]={0};
	
	while (1){
		int l=0, r=0;
		bool tf = false;
		for (int i = 0; i < n; ++i) {
			if (h[i]>0) {
				l = i;
				tf = true;
				break;
			}
		}
		if (!tf) break;
		int minh = 1000;
		for (int i = l; i < n; ++i) {
			if (h[i]>0) {
				r = i;
				minh = min(minh, h[i]);
			}
			else break;
		}
		for (int i = l; i <= r; ++i) h[i] -= minh;
		ans+=minh;
	}

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

Measured memory_bytes: 256
#include <iostream>
#define rep(i,a) for(i = 0; i < a; i++)

using namespace std;

int main(void) {

  int i, j, count = 0, N,save;

  cin >> N;

  int A[N];

  rep(i,N) {
    cin >> A[i];
  }

  rep(i,N) {
    for(j = N-1; j > i; j--) {
      if (A[j] < A[j-1]) {
	save = A[j];
	A[j] = A[j-1];
	A[j-1] = save;
	count++;
      }
    }
  }

  rep(i,N) {
    cout << A[i];
    if(i == N-1) break;
    cout << " ";
  }

  cout << endl;
  cout << count << endl;

  return 0;

}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;

//#define int long long 
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(v) v.begin(),v.end()

int dp[2][1<<24];

void solve() {
	int N, M; cin >> N >> M;
	if(N==0)exit(0);
	vector<string>B(N);
	REP(i, N)cin >> B[i];

	if (M <= 22) {
		vector<int>v(N);
		REP(i, N) {
			REP(j, M) {
				if (B[i][j] == '1')v[i] |= (1 << j);
			}
		}
		REP(i, 2) {
			REP(bit, 1 << M)dp[i][bit] = -1e9;
		}
		dp[0][0] = 0;
		REP(i, N) {
			int pos = i%2;
			int nxt=(pos+1)%2;
			REP(bit,1<<M){
				dp[nxt][bit]=dp[pos][bit];
			}
			REP(bit, 1 << M) {

				if(dp[pos][bit]<0)continue;
				int nxt_bit = bit ^ v[i];
				dp[nxt][nxt_bit] = max(dp[nxt][nxt_bit], dp[pos][bit] + 1);
			}
		}
		cout << dp[N%2][0] << endl;
	}
	else {
		int ans = 0;
		vector<bitset<500>>v(N);
		REP(i, N) {
			REP(j, M) {
				if (B[i][j] == '1')v[i][j]=true;
			}
		}
		REP(bit, 1 << N) {
			bitset<500>tmp;
			REP(i, N) {
				if (bit&(1 << i)) {
					tmp^=v[i];
				}
			}
			bool ok = true;
			if(tmp.count())ok=false;
			if (ok)ans = max(ans, (int)__builtin_popcount(bit));
		}
		cout << ans << endl;
	}
}
signed main() {
	while (true)
		solve();
}


Measured memory_bytes: 35960
import numpy as np
N, L = map(int, input().split())
total_taste = 0
pi = []
result = []
for i in range(1, N+1):
    taste = i + L - 1
    total_taste = taste + total_taste
for i in range(1, N+1):
    taste = i + L - 1
    pi.append(total_taste - taste)
for i in pi:
    result.append(total_taste - i)
print(pi[np.argmin(np.abs(result))])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin>>a>>b;
	if(a+b==15){
		cout<<'+';
	}
	else if(a*b==15){
		cout<<'*';
	}
	else{
		cout<<'x';
	}
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, k; cin >> n >> k;
    VL a(n); cin >> a;

    ll sum = 0;
    each(i, a)sum += i;
    VL divs;
    for (ll i = 1; i * i <= sum; ++i) {
        if (sum % i == 0) {
            divs.push_back(i);
            if (i * i != sum)divs.push_back(sum / i);
        }
    }

    ll ans = 0;
    each(num, divs) {
        VL d(n);
        FOR(i, 0, n)d[i] = a[i] % num;
        SORT(d);

        bool ok = false;
        ll U = 0, D = 0;
        FOR(i, 0, n)U += num - d[i];
        FOR(i, 0, n) {
            U -= num - d[i];
            D += d[i];
            ok |= U <= k && U == D;
        }
        if (ok)chmax(ans, num);
    }

    cout << ans << "\n";
}

Measured memory_bytes: 384
### main

while true
  n = gets.strip.to_i
  break if n == 0

  cards = gets.strip

  plyrs = n.times.map{0}
  fld = 0

  for i in (0...100)
    pi = i % n

    case cards[i]
    when 'M'
      plyrs[pi] += 1
    when 'S'
      fld += plyrs[pi] + 1
      plyrs[pi] = 0
    when 'L'
      plyrs[pi] += fld + 1
      fld = 0
    end
  end

  puts (plyrs.sort + [fld]).join(' ')
end

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

s_list=[]
for i in s:
    if i=="L":s_list.append(0)
    else:s_list.append(1)
start_num=s_list[0]
i=0
while k>0:
    if i>=n:break
    if s_list[i]!=start_num:
        k-=1
        while i<n and s_list[i]!=start_num:
            s_list[i]=start_num
            i+=1
    i+=1
ans=0
for i in range(n):
    if i+1<n and s_list[i]==1 and s_list[i+1]==1:
        ans+=1
    if i-1>=0 and s_list[i]==0 and s_list[i-1]==0:
        ans+=1
print(ans)

Measured memory_bytes: 78776
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 1010;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt[MAX_N][MAX_N] = {};
    for(int i = 0; i < N; i++)
    {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        cnt[y1][x1]++;
        cnt[y2][x2]++;
        cnt[y1][x2]--;
        cnt[y2][x1]--;
    }
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 1; j < MAX_N; j++) cnt[i][j] += cnt[i][j - 1];
    }
    for(int i = 1; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++) cnt[i][j] += cnt[i - 1][j];
    }
    int ans = 0;
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++) ans = max(ans, cnt[i][j]);
    }
    cout << ans << endl;
    return 0;
}




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

int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xs {x};
  vector<int> ys {y};
  for (auto i = 0; i < n; i++) {
    int xx;
    cin >> xx;
    xs.push_back(xx);
  }
  for (auto j = 0; j < m; j++) {
    int yy;
    cin >> yy;
    ys.push_back(yy);
  }
  int xs_max = *max_element(begin(xs), end(xs));
  int ys_min = *min_element(begin(ys), end(ys));
  cout << (xs_max < ys_min ? "No War" : "War") << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    boolean flag = false;
    for(int i = 0;i <= x;i++){
      if(2 * i + 4 * (x - i) == y){
        flag = true;
        break;
      }
    }
    if(flag){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35676
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll pr[mx],ar[mx],br[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    vector<int>v;
    int s;
    cin>>s;
    v.PB(s);
    int n=1000000;
    while(n--){
        if(s%2==0)
        {
            s/=2;
            v.PB(s);
        }
        else
        {
            s=3*s+1;
            v.PB(s);
        }
    }
    set<int>st;
    for(int i=0; i<v.size(); i++){
        if(st.count(v[i])){
            cout<<i+1<<endl;
            break;
        }
        else
            st.insert(v[i]);
    }


    return 0;
}



Measured memory_bytes: 7432
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	rep(i, X) cin >> A[i];
	rep(i, Y) cin >> B[i];
	rep(i, Z) cin >> C[i];

	sort(A.begin(), A.end(), greater<ll>());
	sort(B.begin(), B.end(), greater<ll>());
	sort(C.begin(), C.end(), greater<ll>());

	vector<ll> alpha;
	rep(i, X) rep(j, Y) rep(k, Z) if ((i+1)*(j+1)*(k+1) <= K) alpha.push_back(A[i]+B[j]+C[k]);

	sort(alpha.begin(), alpha.end(), greater<ll>());

	rep(i, K) cout << alpha[i] << endl;


	return 0;
}



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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if ( (A + B) % 2 == 0 ){
		cout << (A + B)/2 << "\n";		
	} else {
		cout << "IMPOSSIBLE" << "\n";
	}


	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    ans += vec.at(i);
  }
  cout << ans + vec.at(N-1)/2 << endl;
}




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

int main() {
  int A,B,C;
  cin >> A>>B;

  if (A < B) {
  int C=B--;
    cout << B+C << endl;
  }
  else if (B < A) {
  int C=A--;
    cout << A+C << endl;
  }
  else if (B == A) {
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
"""
1 以上 3 以下の整数 A,B
が与えられます。
A×B×C
が奇数となるような 1 以上 3 以下の整数 C が存在するか判定してください。

入力がすべて奇数なら、Cも奇数で存在する
"""
a, b = map(int, input().split())

ans = a * b

if (ans % 2) != 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
chomp (my $n = <STDIN>);
chomp (my $s = <STDIN>);
my (@e, @w);
$e[0] = (substr($s, 0, 1) eq 'E' ? 1 : 0);
$w[0] = (substr($s, 0, 1) eq 'W' ? 1 : 0);
for my $i (1..$n-1) {
  if (substr($s, $i, 1) eq 'E') {
    $e[$i] = $e[$i - 1] + 1;
    $w[$i] = $w[$i - 1];
  } else {
    $e[$i] = $e[$i - 1];
    $w[$i] = $w[$i - 1] + 1;
  }
}
unshift @w, 0;
my $min = inf;
for my $i (0..$n-1) {
  $min = $e[-1] - $e[$i] + $w[$i] if $min > $e[-1] - $e[$i] + $w[$i];
}
print "$min\n";

Measured memory_bytes: 22604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    map<char, int> cnt;
    rep(i, s.size()) cnt[s[i]]++;
    bool ans = true;
    for (auto p : cnt) {
        if (p.second % 2 == 1) {
            ans = false;
            break;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, k;
    cin >> n >> k;
    double sum = 0.0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 17; j++){
            if(pow(2, j)*i >= k){
                double a = 1/(double)n * pow(0.5, j);
                sum += a;
                break;
            }
        }
    }
    printf("%.9f\n", sum);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define     SZ  50500
#define     LIM 2500005
#define     pii pair<int, int>
#define     pb  push_back
#define     ff  first
#define     ss  second


int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i, j, k;
    cin>>i>>j;
    if (i == 1) i = 100;
    if (j == 1) j = 100;
    if (i > j) cout<<"Alice\n";
    else if (i < j) cout<<"Bob\n";
    else cout<<"Draw\n";

    return 0;
}



Measured memory_bytes: 256
#inport
import sys
import numpy as np
from math import gcd

#input
K = int(sys.stdin.readline())
sum = 0
#3つ同じ場合..
sum = int((K+1)/2*K)
#print(sum)
#print(K) 
for i in range(1,K+1):
    for j in range(i+1,K+1):
        sum = sum + gcd(i,j) * 6
#        print(str(i) + ", " + str(j))
    #2つが同じ場合
        for l in range(j+1, K+1):
            sum = sum + gcd(gcd(i,j),l) * 6

print(int(sum)) 



Measured memory_bytes: 27156
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a; cin >> a;
    cout << (a%2==0 ? a : 2*a) << endl;
}


Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var s = next();
	if(N >= 3200){
		myout(s);
	}else{
		myout("red");
	}
}


Measured memory_bytes: 30040
#include <unordered_map>
#include <iostream>
#include <vector>

using namespace std;

string S;
int N, A, B;
int sb, s;

int main() {
    cin >> N >> A >> B;
    cin >> S;
    for (auto ch: S) {
        if (ch == 'c') {
            cout << "No" << endl;
        }else if (ch == 'a') {
            if (s < A + B) {
                cout << "Yes" << endl;
                s += 1;
            }else {
                cout << "No" << endl;
            }
        }else if (ch == 'b') {
            if (s < A + B && sb < B) {
                cout << "Yes" << endl;
                s += 1;
                sb += 1;
            }else {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
#include <queue>
#include <iomanip>
#include <tuple>
using namespace std;
using ll = long long int; using i64 = int64_t;
using P = pair<int, int>;
using vi = vector<int>; using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
const ll INF = 1LL << 60;
int mod = (int)1e9 + 7;

int main() {
    int k;
    cin >> k;
    string s;
    rep(i,k) s += "ACL";
    cout << s << endl;
}


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

using namespace std;

double dp[305][305][305];

int main() {
  int N;
  cin >> N;
  vector<int> cnt(4);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  for (int k = 0; k <= N; k++) {
    for (int j = 0; j <= N; j++) {
      for (int i = 0; i <= N; i++) {
        if (i + j + k > N) {
          break;
        }
        if (i == 0 and j == 0 and k == 0) {
          continue;
        }
        if (i > 0) {
          dp[i][j][k] += dp[i - 1][j][k] * i;
        }
        if (j > 0) {
          dp[i][j][k] += dp[i + 1][j - 1][k] * j;
        }
        if (k > 0) {
          dp[i][j][k] += dp[i][j + 1][k - 1] * k;
        }
        dp[i][j][k] += N;
        dp[i][j][k] /= (i + j + k);
      }
    }
  }
  cout << fixed << setprecision(10);
  cout << dp[cnt[1]][cnt[2]][cnt[3]] << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 219392
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int a,p;
	cin >> a >> p;
	cout << (p + 3 * a)/2 << endl;
}


Measured memory_bytes: 256
// Problem : C - Lamps
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,K;
	cin>>N>>K;
	vi v(N);
	F0R(x,N)
		cin>>v[x];
	if(K>=3*log2((ld)N))
	{
		F0R(x,N)
			cout<<N<<' ';
		return 0;
	}
	F0R(k,K)
	{
		vi rq(N);
		F0R(x,N)
		{
			rq[max(0,x-v[x])]++;
			if(x+v[x]+1<N)
				rq[x+v[x]+1]--;
		}
		F0R(x,N-1)
		{
			rq[x+1]+=rq[x];
		}
		v=rq;
	}	
	F0R(x,N)
		cout<<v[x]<<' ';
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 5040
#include<stdio.h>
#include<malloc.h>
#include<string.h>
typedef struct node{
	int val;
	struct node *next, *prev;
}DList;

void insertData(DList *&head, int data)
{
	DList *p = (DList *)malloc(sizeof(DList));
	p->val = data;
	p->next = p->prev = NULL;
	
	if(head == NULL)
	{
		head = p;
		head->next = head->prev = head;
	}
	else
	{
		p->next = head;
		head->prev->next = p;
		p->prev = head->prev;
		head->prev = p;
		head = p;
	}
}
void deleteData(DList *&head, int data)
{
	DList *p = head;
	if(head == NULL)
		return;
	if(head->next == head && head->val == data)
	{
		free(head);
		head = NULL;
		return;
	}
	while(p->val != data)
	{
		p = p->next;
		if(p == head)//cannot find
			return;
	}
	if(p == head)
		head = p->next;
	p->next->prev = p->prev;
	p->prev->next = p->next;
	free(p);
}
void deleteFirstData(DList *&head)
{
	if(head->next == head)
	{
		free(head);
		head = NULL;
	}
	else
	{
		DList *p = head->next;
		p->prev = head->prev;
		head->prev->next = p;
		free(head);
		head = p;
	}
}
void deleteLastData(DList *&head)
{
	if(head->next == head)
	{
		free(head);
		head = NULL;
	}
	else
	{
		DList *p = head->prev;
		p->prev->next = head;
		head->prev = p->prev;
		free(p);
	}
} 
int main()
{
	int n;
	char cmd[20];
	int data;
	
	DList *head = NULL;
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%s", cmd);
		if(strcmp(cmd, "insert") == 0)
		{
			scanf("%d", &data);
			insertData(head, data);
		}
		else if(strcmp(cmd, "delete") == 0)
		{
			scanf("%d", &data);
			deleteData(head, data);
		}
		else if(strcmp(cmd, "deleteFirst") == 0)
			deleteFirstData(head);
		else
			deleteLastData(head);
	}
	DList *p = head;
	if(p != NULL)
	{
		while(p != head->prev)
		{
			printf("%d ", p->val);
			p = p->next;
		}
		printf("%d\n", p->val);
	}
}



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

int main()
{
  int A,B;
  bool res=false;
  cin >> A>>B;

  if(A%3==0) res=true;
  if(B%3==0) res=true;
  if((A+B)%3==0) res=true;

  if(res) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int a,b;
  cin>>a>>b;
  int x=a+b,y=a-b,z=a*b;
  int s=max(x,y);
  int t=max(s,z);
  cout<<t<<endl;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    st s ;
    getline (cin , s) ;

    for (lli i = 0 ; i < s .size() ; i++)
    {
        s[i] = 'x' ;
    }
    cout << s ;


    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256