akhauriyash/Code-Regression huggingface dataset:
import sys

# import re
import math
import collections
# import decimal
import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()

    white, black = 0, 1
    s = [int(i) for i in list(input().replace(".", "0").replace("#", "1"))]
    s.insert(0, 0)
    black_total = s.count(1)

    cnt = [0, 0]  # [white,black]
    ans = INF
    for i in range(n, -1, -1):
        ans = min(ans, black_total - cnt[black] + cnt[white])
        cnt[s[i]] += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8528
// finish date: 2018/03/10

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout<<s1[0]<<s2[1]<<s3[2]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char a[13];
    int i;
    scanf("%s",a);
    
    for(i=0;i<=3;i++){
        printf("%c",a[i]);
    }
    printf(" ");
    for(i=4;i<=11;i++){
        printf("%c",a[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/


int main(){
    ll N,M; cin >> N >> M;
    if (N == 1){
        cout << M << endl;
        return 0;
    }
    if (N == 2){
        if (M % 2 == 1){
            cout << 1 << endl;
        } else {
            cout << M/2 << endl;
        }
        return 0;
    }
    ll mx = 1;
    for (ll i = 2; i*N <= M; i++){
        if ((M-i*N)% i == 0){
            mx = i;
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
s = gets.chomp.chars
flag = true
s.each_with_index do |c,i|
  if i.odd?
    break flag = false unless c == "L" || c == "U" || c == "D"
  else
    break flag = false unless c == "R" || c == "U" || c == "D"
  end
end

puts flag ? "Yes" : "No"


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const ll mod = 1000000007;
const int A = 0, C = 1, G = 2, T = 3;

const int MAXN = 105;
ll dp[MAXN][4][4][4];

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

  rep(j, 4) rep(k, 4) rep(l, 4) dp[3][j][k][l] = 1LL;
  dp[3][A][C][G] = 0LL;
  dp[3][G][A][C] = 0LL;
  dp[3][A][G][C] = 0LL;

  rep(len, n) {
    rep(i, 4) rep(j, 4) rep(k, 4) {
      if(dp[len][i][j][k] == 0) continue;
      for(int a : {A, G, C, T}) {
        if(j == A && k == G && a == C) continue;
        if(j == A && k == C && a == G) continue;
        if(j == G && k == A && a == C) continue;
        if(i == A && j == G && a == C) continue;
        if(i == A && k == G && a == C) continue;

        dp[len + 1][j][k][a] =
          (dp[len + 1][j][k][a] + dp[len][i][j][k]) % mod;
      }
    }
  }

  ll ans = 0;
  rep(j, 4) rep(k, 4) rep(l, 4) ans =
    (ans + dp[n][j][k][l]) % mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N,C,ct; cin >> N >> C;
    ll D[C][C], c[N][N];
    rep(i,C) rep(j,C) cin >> D[i][j];
    rep(i,N) rep(j,N) cin >> ct, ct--, c[i][j] = ct;

    ll d[3][30];
    rep(i,3) rep(j,30) d[i][j] = 0;

    rep(i,3) rep(j,C) rep(n,N) rep(m,N) if((n+m)%3 == i){
            d[i][j] += D[c[n][m]][j];
    }

    ll ans = 1e15;
    rep(i,C) rep(j,C) rep(k,C){
        if(i != j && j != k && k != i){
            ans = min(ans,d[0][i]+d[1][j]+d[2][k]);
        }
    } 
    pr(ans);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {

    int N,M;
    cin >> N >> M;

    vector<int> s(M), c(M);
    map<int, int> mp;

    int ans = -1;
    string ans_ = "1";
    bool no_match = false;

    if (N == 1) ans_ = "0";
    

    for (int i = 0; i < N-1; i++) {
        ans_ += "0";
    }
    

    for (int i = 0; i < M; i++) {
        cin >> s.at(i) >> c.at(i);


        if (mp.find(s.at(i)) == mp.end() ) {
            mp[s.at(i)] = c.at(i);
        } else if(mp[s.at(i)] == c.at(i)) {
            mp[s.at(i)] = c.at(i);
        } else {
            no_match = true;
        }
        
    }

    

    if (mp.find(1) != mp.end()) {
        if (mp[1] == 0 && N != 1) {
            
            no_match = true;
        }
    }

    if (no_match) {
        cout << ans << endl;
        return 0;
    }
    
    

    for (int i = 0; i < M; i++) {
        ans_.replace(s.at(i)-1, 1, to_string(c.at(i)));
    }
    
    cout << ans_ << endl;

    
    return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func del(a []int) int {
	ret := -1
	for i := len(a) - 1; i >= 0; i-- {
		if a[i] == i {
			ret = i
			break
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt() - 1
	}

	ans := make([]int, 0, N)
	for i := 0; i < N; i++ {
		remove := del(a)
		if remove == -1 {
			out(-1)
			return
		}
		a = append(a[:remove], a[remove+1:]...)
		ans = append(ans, remove)
	}
	for i := len(ans) - 1; i >= 0; i-- {
		out(ans[i] + 1)
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
int id1[maxn],id2[maxn],p[maxn];
struct point{
	int l,r;
}a[maxn];
bool cmpr(const int &A,const int &B){
	return a[A].r<a[B].r;
}
bool cmpl(const int &A,const int &B){
	return a[A].l>a[B].l;
}
int main(){
	int n=read();
	REP(i,1,n) a[i].l=read(),a[i].r=read(),id1[i]=id2[i]=i;
	sort(id1+1,id1+n+1,cmpr);
	sort(id2+1,id2+n+1,cmpl);
	ll tmp=0,ans=0;
	int flag=0,i=1,j=1,lst=0;
	REP(k,1,n){
		while(i<=n && p[id1[i]]) ++i;
		while(j<=n && p[id2[j]]) ++j;
		if(flag){
			if(a[id1[i]].r<lst) p[id1[i]]=1,tmp+=lst-a[id1[i]].r,lst=a[id1[i]].r;
		}
		else{
			if(a[id2[j]].l>lst) p[id2[j]]=1,tmp+=a[id2[j]].l-lst,lst=a[id2[j]].l;
		}
		flag^=1;
	}
	tmp+=abs(lst);ans=max(ans,tmp);
	tmp=0;
	flag=1,i=1,j=1,lst=0;
	memset(p,0,sizeof(p));
	REP(k,1,n){
		while(i<=n && p[id1[i]]) ++i;
		while(j<=n && p[id2[j]]) ++j;
		if(flag){
			if(a[id1[i]].r<lst) p[id1[i]]=1,tmp+=lst-a[id1[i]].r,lst=a[id1[i]].r;
		}
		else{
			if(a[id2[j]].l>lst) p[id2[j]]=1,tmp+=a[id2[j]].l-lst,lst=a[id2[j]].l;
		}
		flag^=1;
	}
	tmp+=abs(lst);ans=max(ans,tmp);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
dr = [-1, 0, 1, 0]
dc = [ 0, 1, 0,-1]

H,W = map(int,input().split())
s = [None] * H
for i in range(H):
	s[i] = input()

ok = True
for i in range(H):
	for j in range(W):
		if s[i][j] == '#':
			curr = False
			for k in range(4):
				nr = i + dr[k]
				nc = j + dc[k]
				if nr < 0 or nr >= H or nc < 0 or nc >= W:
					continue
				if s[nr][nc] == '#':
					curr = True
			if curr == False:
				ok = False

print("Yes" if ok == True else "No")

Measured memory_bytes: 3064
#! /usr/bin/env python
import sys
from functools import reduce

def main():
    line = sys.stdin.readlines()
    index = int(line[0].strip())
    line1 = line[1].strip()
    line2 = line[2].strip()
    listA = [int(x) for x in line1.split(' ')]
    listB = [int(x) for x in line2.split(' ')]
    
    maxA = max(listA)
    maxB = max(listB)

    if maxA < maxB:
        print(-1)
        return

    diff = [listA[i] - listB[i] for i in range(index)] 
    diff.sort()

    if not checkBeMinus(diff):
        print(0)
        return

    # Split minus and plus item
    plus = [x for x in diff if x >= 0]
    plus.sort(reverse=True)
    minus = [x for x in diff if x < 0]

    changeCount = len(minus)
    allMinus = reduce((lambda x, y: x + y), minus)
    allPlus = reduce((lambda x, y: x + y), plus)
    if allPlus + allMinus < 0:
        print(-1)
        return
    accm = 0
    for p in plus:
        accm += p
        changeCount += 1
        if accm >= abs(allMinus):
            break

    print(changeCount)
    

def checkBeMinus(list):
    return min(list) < 0

main()


Measured memory_bytes: 22352
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}


typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
 
int main(void){
    string S,T;
    cin >> S >> T;
    int ans = 0;
    for(int i=0; i<=S.size()-T.size(); i++){
        int cnt = 0;
        FOR(j,0,T.size()){
            if(S[i+j] == T[j]) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << T.size()-ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

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

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	string s;
	cin >> n >> s;
	int r = 0,g = 0,b = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == 'R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	int ans = r * g * b;
	for(int i = 0;i < n;i++){
		for(int j = 1;;j++){
			if(i - j < 0 || i + j >= n) break;
			if(s[i] != s[i - j] && s[i - j] != s[i + j] && s[i] != s[i + j]) ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    long long n,a[200005],i,total=0;
    cin>>n;
    cin>>a[1];
    for(i=2;i<=n;i++)
    {
        cin>>a[i];
        if(a[i-1]>a[i])
        {
            total+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    cout<<total<<endl;
    return 0;  
}

Measured memory_bytes: 5156
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );

vector<ll> nums;
vector< vector<ll> > t;
map<ll,vector<ll>> m;

void dfs(ll x,ll val){

  for(auto y: m[x] ) val+=y;

  nums[x]=val;

  for(auto y:t[x]){

    dfs( y, val );

  }

}

int main(void){

  ll n,q;
  cin>>n>>q;

  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> p(q);
  vector<ll> x(q);

  

  rep(i,n+1){
    nums.push_back(0);
    t.push_back( vector<ll>(0) );
  }

  rep(i,n-1){
    cin>>a[i]>>b[i];

    t[ a[i] ].push_back(  b[i]  );

  }


  ll ans=0;

  

  rep(i,q){
    cin>>p[i]>>x[i];

    m[ p[i] ].push_back(x[i]);

  }

  dfs( 1 ,0);

  //cout << ans << endl;
  for(int i=1;i<=n;i++) cout << nums[i] << " ";
  cout << endl;
  

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 58400
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

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

    for(int i = 1; i <= b; ++i){
        if((a * i) % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        r: i32
    }
    println!("{}", 2.0*3.141592653589*(r as f64));

}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[10004];
int main()
{
 int n;
 cin>>n;
 cin>>s;
 ll ans=0;
 int r[10004],g[10004],b[10004];
 int ri=0,gi=0,bi=0;
 for(int i=0;i<n;i++)
 {
  if(s[i]=='G')
  g[gi++]=i;
  else if(s[i]=='B')
  b[bi++]=i;
  else
  r[ri++]=i;
 }
 for(int i=0;i<n;i++)
 {
  char x1=s[i];
  char x2,x3;
  for(int j=i+1;j<n;j++)
  {
   if(s[j]!=x1)
   {
    x2=s[j];
    if(x1!='G'&&x2!='G')
    {
     int y1=upper_bound(g,g+gi,j+j-i)-g;
     ans+=(ll)(gi-y1);
    }
    else if(x1!='R'&&x2!='R')
    {
     int y2=upper_bound(r,r+ri,j+j-i)-r;
     ans+=(ll)(ri-y2);
    }
    else if(x1!='B'&&x2!='B')
    {
     int y3=upper_bound(b,b+bi,j+j-i)-b;
     ans+=(ll)(bi-y3);
    }
   }
  }
 }
 char ss[10004];
 for(int i=0;i<n;i++)
 ss[i]=s[n-i-1];
 ri=0,gi=0,bi=0;
 for(int i=0;i<n;i++)
 {
  if(ss[i]=='G')
  g[gi++]=i;
  else if(ss[i]=='B')
  b[bi++]=i;
  else
  r[ri++]=i;
 }
 for(int i=0;i<n;i++)
 {
  char x1=ss[i];
  char x2,x3;
  for(int j=i+1;j<n;j++)
  {
   if(ss[j]!=x1)
   {
    x2=ss[j];
    if(x1!='G'&&x2!='G')
    {
     int y1=upper_bound(g,g+gi,j+j-i)-g;
     ans+=(ll)(gi-y1);
    }
    else if(x1!='R'&&x2!='R')
    {
     int y2=upper_bound(r,r+ri,j+j-i)-r;
     ans+=(ll)(ri-y2);
    }
    else if(x1!='B'&&x2!='B')
    {
     int y3=upper_bound(b,b+bi,j+j-i)-b;
     ans+=(ll)(bi-y3);
    }
   }
  }
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
const int N = 2e5 + 87;
ll a[N],b[N];
int f[N];
int n,k,m;
int g(ll v)
{
	return lower_bound(b,b+m,v) - b + 1;
}
void add(int i)
{
	for ( ; i <= m; i += i & -i)
		++f[i];
}
int qry(int i)
{
	int ans = 0;
	for ( ; i; i ^= i & -i)
		ans += f[i];
	return ans;
}
int main()
{
	RD(n,k);
	RP1(i,n) RD(a[i]), a[i] -= k;
	RP1(i,n) a[i] += a[i-1];
	copy_n(a,n+1,b);
	sort(b,b+n+1);
	m = n + 1;
	ll ans = 0;
	add(g(0));
	RP1(i,n) {
		int k = g(a[i]);
		ans += qry(k);
		add(k);
	}
	PL(ans);
}


Measured memory_bytes: 4096
def li():
    return list(map(int, input().split()))


if __name__ == '__main__':
    n = int(input())
    sp = [input().split() for _ in range(n)]
    for index, spi in enumerate(sp):
        spi[1] = int(spi[1])
        spi.append(index + 1)

    sp.sort(key=lambda x: x[1], reverse=True)
    sp.sort(key=lambda x: x[0])

    for spi in sp:
        print(spi[2])


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int n,t;
	int a=0,b=0;
	long long int s=0;
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>b;
		if(a>b)s-=a-b;
		s+=t;
		a=b+t;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    int d;
    ll g;
    cin >> d >> g;
    vector<int> p(d, 0);
    vector<int> c(d, 0);
    
    for(int i=0; i<d; i++){
        cin >> p[i] >> c[i];
    }
    
    int ans=1000;
    for(int bit=0; bit<(1 << d); bit++){
        int question=0;
        int order=0;
        ll score=0;
        while(order<d){
            if((bit>>order)&1){
                score += p[order] * 100 * (order+1) + c[order];
                question += p[order];
            }
            order++;
        }
        
        if(score>=g){
            ans =  min(ans, question);
            continue;
        }
        
        order=d-1;
        int count=0;
        while(order>=0){
            if(!(bit>>order&1)){
                score += (order+1)*100;
                question++;
                if(score>=g){
                    ans =  min(ans, question);
                    break;
                }
            }
            count++;
            if(p[order]<count){
                order--;
                count=0;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())
town = list(map(int,input().split()))
cnt = 1
step = 1
now = town[0]
via = [1]
s = {1}
while True:
  now = town[via[-1]-1]
  if not now in s:
    via.append(now)
    s.add(now)
  else:
    start = via.index(now)
    roop = len(via) - start
    break
 
 
if len(via) == 1:
    print(1)
    exit()
 
elif len(via) > k:
    print(via[k])
    exit()
 
else:
    roop_remainder = (k + 1 - start) % roop
    if roop_remainder == 0:
        print(via[-1])
    else:
        print(via[start + roop_remainder -1])

Measured memory_bytes: 125020
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N;
    cin >> N;
    vector<int> data(N + 1, 0);
    for (int i = 0; i <= N; i++) {
        data[i] = i;
    }
    int div = 6;
    while (div <= N) {
        for (int i = 1; i <= N; i++) {
            if (i - div >= 0) {
                data[i] = min(data[i - div] + 1, data[i]);
            }
        }
        div *= 6;
    }
    div = 9;
    while (div <= N) {
        for (int i = 1; i <= N; i++) {
            if (i - div >= 0) {
                data[i] = min(data[i - div] + 1, data[i]);
            }
        }
        div *= 9;
    }
    cout << data[N] << endl;
    return 0;
}


Measured memory_bytes: 640
--{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import Data.List
--import Data.Char
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  getLine
  s <- map read . words <$> getLine
  --a `traceShow`
  print $ solve s


solve :: [Int] -> Int
solve s = search 0 [] [head s', head s'] (tail s')
  where
    s' = sortBy (\a b -> b `compare` a)  s

search :: Int -> [Int] -> [Int] -> [Int] -> Int
search !k _ _ [] = k
search !k qs [b] ss = search k [] (reverse (b:qs)) ss
search !k qs (b1:b2:bs) (s:ss) = search (k + min b1 b2) (s:b1:qs) (b2:bs) ss


Measured memory_bytes: 95800
#include <iostream>
using namespace std;
int gcd(int a, int b);
int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    cout << gcd(a, b) << endl;
}

int gcd(int a, int b) {
    int temp;
    while (b != 0) {
        temp = a;
        a = b;
        b = temp % b;
    }
    return a;
}

Measured memory_bytes: 1160
/** @Date    : 2017-05-14 19:17:01
  * @FileName: ${saved_filename}
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;
const LL neg = -(1LL << 60);
int n, m, a[N], b[N], c[N];
LL dis[1010];


int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++)
		scanf("%d%d%d", a + i, b + i, c + i);
	for(int i = 0; i <= n; i++)
		dis[i] = neg;
	int negcle = 0;
	LL ans1 = 0;
	LL ans2 = 0;
	dis[1] = 0;
	for(int i = 0; i < 2 * n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			dis[b[j]] = max(dis[b[j]], dis[a[j]] + c[j]);
		}
		if(i == n - 1)
			ans1 = dis[n];
		else if(i == 2 * n - 1)
			ans2 = dis[n];
	}

	if(ans1 != ans2)
		printf("inf\n");
	else printf("%lld\n", ans1);
    return 0;
}

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

using namespace std;

int main(){
	while(true){
		int n, m, p;
		cin >> n >> m >> p;
		if(n == 0)break;
		vector<int> x(n);
		int sum = 0;
		for(int i= 0; i < n; i++){
			cin >> x[i];
			sum += x[i];
		}
		m--;
		int ans = 0;
		if(x[m] != 0){
		ans = (100 - p)*sum/x[m];
		}
		cout << ans << endl;
	}
	return 0;
}




Measured memory_bytes: 3080
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

template <int MaxN = 100000, long long mod = 1000000007LL>
class Modlib {
    long long _fact[MaxN + 1];
    long long _fact_inv[MaxN + 1];

public:
    // x^n
    long long pow(long long x, long long n) const {
        long long ret = 1LL;
        long long t = x % mod;
        while (n > 0) {
            if (n & 1LL) {
                ret *= t;
                ret %= mod;
            }
            t *= t;
            t %= mod;
            n >>= 1;
        }
        return ret;
    }
    // xの逆元
    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    constexpr long long inv(long long a) const {
        long long b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            a ^= b;
            b ^= a;
            a ^= b;

            u -= t * v;
            u ^= v;
            v ^= u;
            u ^= v;
        }
        u %= mod;
        if (u < 0)
            u += mod;
        return u;
    }
    // n!
    long long fact(long long n) const {
        return _fact[n];
    }
    // nPk
    long long perm(long long n, long long k) const {
        return fact(n) * _fact_inv[n - k] % mod;
    }
    // nCk
    long long comb(long long n, long long k) const {
        return perm(n, k) * _fact_inv[k] % mod;
    }

    constexpr Modlib() : _fact{}, _fact_inv{} {
        _fact[0] = _fact[1] = 1LL;
        for (int i = 2; i <= MaxN; ++i) {
            _fact[i] = _fact[i - 1] * i % mod;
        }
        _fact_inv[MaxN] = inv(_fact[MaxN]);
        for (int i = MaxN - 1; i >= 0; --i) {
            _fact_inv[i] = _fact_inv[i + 1] * (i + 1) % mod;
        }
    }
};

constexpr ll mod = 998244353LL;
constexpr auto modlib = Modlib<300000, mod>();

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        ll j = k - a * i;
        if (j % b != 0)
            continue;
        j /= b;
        if (!(0 <= j && j <= n))
            continue;
        ans += modlib.comb(n, i) * modlib.comb(n, j) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class c
{
    static void Main()
    {
        var s = Console.ReadLine();
        var x = new long[s.Length + 11];
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '<') x[i + 1] = x[i] + 1;
        }
        for (int i = s.Length-1; i >= 0; i--)
        {
            if (s[i] == '>')
            {
                x[i] = Math.Max(x[i + 1] + 1, x[i]);
            }
        }
        Console.WriteLine(x.Sum());
    }
}


Measured memory_bytes: 16864
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll h;
    cin >> h;

    ll cnt = 0;
    while (h >1) {
        ++cnt;
        h = h/2;
    }
    ll m = pow(2,cnt);
    ll s = 0;
    rep(i,cnt) {
        s += pow(2,i);
    }
    cout << (m+s) << endl;
    return 0;
}


































Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int a[3];
    rep0(i,3) cin>>a[i];
    sort(a,a+3);
    if(a[0]+a[1]==a[2]) cout<<"Yes";
    else cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, d[16][16], dp[(1<<16)][20], ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    rep(i, 0, 16) rep(j, 0, 16) d[i][j] = INF;
    rep(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
    }
    rep(i, 0, (1 << n)) rep(j, 0, n) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, 0, (1<<n)) {
        rep(j, 0, n) {
            if (!((1<<j) & i)) {
                rep(k, 0, n) 
                    dp[i | (1<<j)][j] = min(dp[i | (1<<j)][j], dp[i][k] + d[k][j]);
            }
        }
    }
    if (dp[(1<<n)-1][0] == INF) ans = -1;
    else ans = dp[(1<<n)-1][0];
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
ll n;
double dp[300+1][300+1][300+1];
int sum[4]={0,0,0,0};
string add1(string s){
  int carry=1;
  for(int i=s.size()-1; i>=0; i--){
    if (carry==0) return s;
    else if(s[i]=='0' && carry==1) {s[i]='1'; carry=0;}
    else if(s[i]=='1' && carry==1) {s[i]='0'; carry=1;}   
  }
}
double cal(int i,int j, int k){
  if(dp[i][j][k]>-1.0) return dp[i][j][k];
  double ans=double(n);
  if(i) ans+=cal(i-1,j+1,k)*i;
  if(j) ans+=cal(i,j-1,k+1)*j;
  if(k) ans+=cal(i,j,k-1)*k;
  ans/=(i+j+k);
  return dp[i][j][k]=ans;
}  
int main() {
  for(int i=0; i<=300; i++)
    for(int j=0; j<=300; j++)
      for(int k=0; k<=300; k++) dp[i][j][k]=-300;
  cin>>n;
  for(int i=0; i<n; i++) {
    int x;
    cin>>x;
    sum[x]++;
  }
  dp[0][0][0]=0;
  cout<<setprecision(11)<<cal(sum[3],sum[2],sum[1])<<"\n";
  return 0;
}


Measured memory_bytes: 213376
#include <iostream>

using namespace std;

int main(){
  int N, Q, i;
  cin >> N >> Q;
  char c[N+1];
  int l[Q+1], r[Q+1], ans[N+1], tmp;
  for(i=1; i<=N; i++){
    cin >> c[i];
    ans[i] = 0;
  }
  for(i=1; i<=Q; i++){
    cin >> l[i] >> r[i];
  }
  for(i=1; i<=N; i++){
    if(c[i] == 'A' && c[i+1] == 'C') ans[i+1] = ans[i]+1;
    else ans[i+1] = ans[i];
  }
  for(i=1; i<=Q; i++){
    //cout << ans[i] << endl;
    cout << ans[r[i]] - ans[l[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

int n,k;
char s[100005];
vector < int > v;

int max( int a, int b ){
	if ( a < b ) return b;
	return a;
}

int main(){
	
	scanf("%d%d",&n,&k);
	scanf("%s",&s);
	if ( s[0] == '0' ) v.push_back(0);

	int ans = 1;
	for ( int i = 1; i < n; i++ ){
		if ( s[i] == s[i-1] ){
			ans++;
		} else {
			if ( s[i-1] == '0' ) v.push_back(-ans);
			else v.push_back(ans);
			ans = 1;
		}
	}
	if ( s[n-1] =='0' ) v.push_back(-ans);
	else v.push_back(ans);
	if ( s[n-1] == '0' ) v.push_back(0);

	ans = 0;
	for ( int a : v ) ans = max( ans, a );

	n = v.size();
	int sum = v[0];
	int sz = 0;
	for ( int i = 1; i < v.size(); i += 2){
		sum -= v[i];
		sum += v[i+1];
		sz++;
		if ( sz > k ){
			sz--;
			sum -= v[i+1-2*(k+1)];
			sum += v[i+2-2*(k+1)];
		}
		ans = max( ans, sum );
	}

	printf("%d\n",ans);
	return 0;
}

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

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

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

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

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

	vector<int> v;
	v.push_back(A);
	v.push_back(B);
	v.push_back(C);
	sort(v.begin(), v.end());

	int p1 = v[2] - v[1];
	v[0] += p1; v[1] += p1;

	int p2 = (v[2] - v[0]) / 2;
	v[0] += p2 * 2;

	int p3 = (v[2] - v[0]) * 2;
	cout << p1 + p2 + p3 << endl;
	return 0;
}


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

int main(){
    double A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<double> water(0);
    vector<double> sugar(0);
    rep(i,31){
        rep(j,31){
            if (i == 0 && j == 0) continue;
            else if (i * 100 * A + j * 100 * B <= F){
                water.push_back(i * 100 * A + j * 100 * B);
            }
        }
    }
    rep(i,3001){
        rep(j,3001){
            if (i * C + j * D <= F){
                sugar.push_back(i * C + j * D);
            }
        }
    }
    double max_density = 0;
    pair<double, double> ans;
    ans.first = 0;
    ans.second = 0;
    int len_water = water.size();
    int len_sugar = sugar.size();
    rep(i,len_water){
        rep(j,len_sugar){
            double density = sugar[j] * 100 / water[i];
            if (water[i] + sugar[j] <= F && density <= E){
                if (max_density <= density){
                    ans.first = water[i];
                    ans.second = sugar[j];
                    max_density = density;
                }
            }
        }
    }
    cout << ans.first + ans.second << " " << ans.second << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>
#include <unordered_map>
#include <map>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;

int main(){
    int n,t;
    cin >> n >> t;
    int c[n], ti[n];
    rep(i,n){
	cin >> c[i] >> ti[i];
    }
    int mi_cost=10000;
    int mi_time=10000;
    rep(i,n){
	if(ti[i] <= t){
	    if(c[i] <= mi_cost){
		mi_cost = c[i];
		mi_time = ti[i];
	    }
	}
	else continue;
    }
    if(mi_time == 10000){
	cout << "TLE" << endl;
    }
    else{
	cout << mi_cost << endl;
    }
}


Measured memory_bytes: 256
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        sp: [(String,usize);n]
    }
    let mut v: Vec<_> = (1_usize..=n).zip(sp.iter()).collect();
    v.sort_by(
        |&a, &b| {
            (a.1)
                .0
                .cmp(&(b.1).0) // sort by name
                .then((b.1).1.cmp(&(a.1).1))
        }, // then sort by score
    );
    for i in v.iter() {
        println!("{}", i.0);
    }
}


Measured memory_bytes: 2204
import numpy as np

N,WIDTH = list(map(int, input().split()))

hight_arr = np.array(list(map(int, input().split())))
cost_arr = np.zeros(N,dtype=int)

for i in range(1,N):
    start = max(i-WIDTH,0)
    cost_arr[i] = np.min(np.abs(hight_arr[i] - hight_arr[start:i]) + cost_arr[start:i])
print(cost_arr[-1])

Measured memory_bytes: 22900
import collections

N = int(input())
s = input()

maxx = 0

for i in range(N - 1):
    left = s[: i + 1]
    right = s[i + 1 :]
    
    CNT_left = collections.Counter(left)
    CNT_right = collections.Counter(right)
    
    cnt = 0
    
    for k in CNT_left.keys():
        num = CNT_right[k]
        
        if (num >= 1):
            cnt += 1
    
    maxx = max(maxx, cnt)
    
print(maxx)


Measured memory_bytes: 3316
#include <stdio.h>
#define N 100

int C[N],d[N],f[N],tt;
int n,G[N][N];

void DFS_visit(int u){
  int v;
  C[u] = 1;
  d[u] = tt++;
  for(v=0;v<n;v++){
    if(G[u][v] == 1 && C[v] == 0) {
      DFS_visit(v);
    }
  }
  C[u] = 2;
  f[u] = tt++;
}

void DFS(void){
  int u;
  for(u=0;u<n;u++) C[u] = 0;
  tt = 1;

  for(u=0;u<n;u++){
    if(C[u] == 0) DFS_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
    

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k;j++){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }
  DFS();

  return 0;
}




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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;

int n;

int32_t main(){
	fastio;
	int k;
	cin>> n>> k;
	string s;
	cin>> s;
	int h = 0;
	for(int i = 0; i<n -1 ; ++i) if(s[i] == s[i+1]) h++;
	cout<< min(h+2*k, n-1) << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

template<typename T>
void fin(T const& v){ std::cout << v << std::endl; exit(0); }
int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<std::vector<char>> a(N, std::vector<char>(N));
  for(auto& av: a) for(auto& ai: av) std::cin >> ai;
  bool ok = false;
  for(int i = 0; i < N; ++i) {
    for(auto ai: a[i]) if(ai=='#') { ok = true; break; }
    if(ok) break;
  }
  if(!ok) fin(-1);
  int c = 0;
  for(int j = 0; j < N; ++j) {
    bool ok = true;
    for(int i = 0; i < N; ++i) if(a[i][j] != '#') { ok = false; break; }
    if(!ok) ++c;
  }

  int ans = N+N;
  for(int i = 0; i < N; ++i) {
    int j = 0;
    for(; j < N; ++j) if(a[j][i] == '#') break;
    int k = 0;
    if(j == N) ++k;
    for(auto ai: a[i]) if(ai != '#') ++k;
    ans = std::min(ans, k);
  }
  ans += c;
  fin(ans);
  return 0;
}


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

using namespace std;

int main(void) {
  int N; cin >> N;
  
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    
    if (a % 2 == 0) {
      if (a % 5 != 0 && a % 3 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256