akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    string S, T;
    is >> S >> T;
    if(!is) return;
    unordered_map<char, vector<int>> spt;
    for (int i = 0; i < S.size(); ++i) {
        spt[S[i]].push_back(i);
    } // end i
    ll N = S.size();
    ll now = -1;
    ll ans = 0;
    for (auto &&t : T) {
        if(spt.count(t) == 0) {
            ans = -1;
            break;
        }
        auto p = lower_bound(ALL(spt[t]), now+1);
        if(p == spt[t].end()){
            ans += spt[t][0] + N - now;
            now = spt[t][0];
        }
        else {
            ans += *p - now;
            now = *p;
        }
    } // end t

    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_E.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 1228
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second
typedef tuple<lint, lint, lint, lint> t4l;
signed main(){
    lint X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<lint> A(X);
    vector<lint> B(Y);
    vector<lint> C(Z);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    sort(ALL(A), greater<lint>());
    sort(ALL(B), greater<lint>());
    sort(ALL(C), greater<lint>());
    vector<vector<vector<bool> > > used(X, vector<vector<bool> >(Y, vector<bool>(Z, false)));
    priority_queue<t4l> pq;
    pq.push(make_tuple(A[0]+B[0]+C[0], 0, 0 , 0));
    used[0][0][0] = true;
    while(K){
        t4l p = pq.top();
        pq.pop();
        lint v, i, j, k;
        v= get<0>(p);
        i = get<1>(p);
        j = get<2>(p);
        k = get<3>(p);
        if(i+1<X and !used[i+1][j][k]){
            pq.push(make_tuple(A[i+1]+B[j]+C[k], i+1, j, k));
            used[i+1][j][k] = true;
        } 
        if(j+1<Y and !used[i][j+1][k]){
            pq.push(make_tuple(A[i]+B[j+1]+C[k], i, j+1, k));
            used[i][j+1][k] = true;
        } 
        if(k+1<Z and !used[i][j][k+1]){
            pq.push(make_tuple(A[i]+B[j]+C[k+1], i, j, k+1));
            used[i][j][k+1] = true;
        } 
        cout << v;
        cout << '\n';
        K--;
    }
    cout << flush; 
    return 0;
}

Measured memory_bytes: 182272
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	n := nextInt() % 10

	ans := "hon"

	if n == 3 {
		ans = "bon"
	} else if n == 0 || n == 1 || n == 6 || n == 8 {
		ans = "pon"
	}

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ll n,i;
    cin>>n;
    if(n%2==0)cout<<-1;
    else
    {
        ll k=0;
        for(i=1; i<=n; i++)
        {

            k=k*10+7;
            k=k%n;
            if(k%n==0)
            {
                cout<<i;
                return 0;
            }
        }
        cout<<-1;
    }

    return 0;
}


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

int main(void){
  vector<int> p;
  p.push_back(105);
  p.push_back(135);
  p.push_back(165);
  p.push_back(189);
  p.push_back(195);
  int N; cin >> N;
  if(N < p[0]){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < p.size(); i++){
    if(p[i] <= N && N < p[i+1]){
      cout << i+1 << endl;
      return 0;
    }
  }
  if(p[p.size()-1] <= N){
    cout << p.size() << endl;
    return 0;
  }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;

int binary(int bina){
  int ans = 0;
  for (int i = 0; bina>0 ; i++)
    {
      ans = ans+(bina%2)*pow(10,i);
      bina = bina/2;
    }
  return ans;
}

int main() {
  int N,M;
  cin >> N >> M;
  int k[M];
  int s[M][N];
  for(int i=0; i<M; i++){
    cin >> k[i];
    for(int j=0; j<k[i]; j++){
      cin >> s[i][j];
    }
  }
  int p[M];
  for(int i=0; i<M; i++){
    cin >> p[i];
  }
  /*  for(int i=0; i<M; i++){
    cout << k[i] << endl;
    for(int j=0; j<k[i]; j++){
      cout  << s[i][j] << " " <<flush;
    }
    cout << " "<< endl;
    }*/

  
  int onoff=0;
  int ans=0;
  for(int i=0; i < pow(2,N); i++){
    int tmp = binary(onoff);
    //    cout << tmp << endl;
    int turnon[M];
    for(int j=0; j<M; j++){
      if(p[j]==0) turnon[j]=1;
      else turnon[j]=0;
    }
    int num=1;
    for(int j=0; j<N; j++){
      if(tmp%10==1){
	//	cout << "onoff "<< binary(onoff) << endl;
	for(int m=0; m<M; m++){
	  for(int l=0; l<k[m]; l++){
	    if(s[m][l]==num){
	      //	      cout << "num " << num << " " <<m << " "<< l << " " <<s[m][l] << flush;
	      turnon[m] +=1;
	      turnon[m] =turnon[m]%2;
	      //	      cout << turnon[m] << endl;
	    }
	  }
	}
      }
      tmp /=10;
      num++;
    }

    for(int j=0; j<M; j++){
      if(turnon[j]==0) break;
      if(j==M-1){
	ans++;
	//	cout << binary(onoff) << endl;
      }
    }
    onoff++;
  }

  cout << ans << endl;
  /*bitset<10> bs2("0000000000");


  for(int i=0; i<N; i++){
    bs2 = bs2 + 1;
    cout << bs2 << endl;
  }
  cout << bs2 << endl;
  */
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
using namespace std;
const LL Max=1e3+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
LL N,M,Flag,F[Max];
LL Dx[4]={1,-1,0,0};
LL Dy[4]={0,0,1,-1};
char CH[55][55];
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
void DFS(LL X,LL Y){
	LL I,J,K;
	Fp(I,0,3,1){
		if(X+Dx[I]>=1&&X+Dx[I]<=N&&Y+Dy[I]>=1&&Y+Dy[I]<=M){
			if(CH[X+Dx[I]][Y+Dy[I]]=='#'){
				CH[X+Dx[I]][Y+Dy[I]]='.';
				Flag=1;DFS(X+Dx[I],Y+Dy[I]);
			}
		}
	}
}
int main(){
	LL I,J,K;
	N=Read(),M=Read();
	Fp(I,1,N,1){
		scanf("%s",CH[I]+1);
	}
	Fp(I,1,N,1){
		Fp(J,1,N,1){
			if(CH[I][J]=='#'){
				Flag=0;
				DFS(I,J);
				if(Flag==1){
					CH[I][J]=='.';
				}
			}
		}
	}
	Fp(I,1,N,1){
		Fp(J,1,N,1){
			if(CH[I][J]=='#'){
				puts("No");
				return 0;
			}
		}
	}puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long ll;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}


int main() {
	int n,k,x,y; cin>>n>>k>>x>>y;
	cout << (n > k? k*x + (n-k)*y: n*x) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
	private static int selection(int a[]){
		int count=0;
		int mini=0;
		for(int i = 0 ; i < a.length-1 ; i++){
			mini=i;
			for(int j = i+1;j<a.length;j++){
				if(a[j]<a[mini]){
					mini=j;			
				}
			}
			if(mini!=i){
				int temp=a[i];
				a[i]=a[mini];
				a[mini]=temp;
				count++;
			}
		}
		return count;
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] strdata = new String[n];
		String str = br.readLine();
		strdata = str.split(" ");
		int[] data = new int[n];
		for(int i = 0 ; i < n ; i ++)
			data[i] = Integer.parseInt(strdata[i]);
		int count = selection(data);
		for(int i = 0 ; i < n-1; i++){
			System.out.print(data[i]+" ");
		}
		System.out.println(data[n-1]);
		System.out.println(count);
	}
}

Measured memory_bytes: 17020
#include <stdio.h>
int main(void){
    int i=0;
    int a;
    int y=0,z=0;
    for(;~scanf("%d",&a);){
        i++?a%2?z--:(a%4?y++:z++):0;
    }
    //printf("%d %d\n",y,z);
    puts((!y&&z>-2||y&&z+1)?"Yes":"No");
}

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

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

const long long INF = 1LL << 60;
const long long mod = 1000000007;

int main(void){
    int n;cin >> n;
    vector<int> k(n);
    vector<vector<P>> x(n);
    for(int i=0;i<n;i++){
	cin >> k[i];
	for(int j=0;j<k[i];j++){
	    int a,b;
	    cin >> a >> b;
	    x[i].push_back(make_pair(a-1,b));
	}
    }
    int ans = 0;
    vector<int> man(n,0);
    for(int bit = 0;bit < (1<<n);bit++){
	bool ok = true;
	int l = 0;
	for(int i=0;i<n;i++){
	    if(bit & (1<<i)){
		for(int j=0;j<k[i];j++){
		    if( ( ( bit & (1<<x[i][j].first)) == 0)  && ( x[i][j].second==1 ))ok = false;
		    if( (  bit & (1<<x[i][j].first) )  && ( x[i][j].second==0 ))ok = false;
		}
		l++;
	    }
	}
	if(ok){
	ans = max(ans,l);
	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
char a[1001][1001];
int dp[1001][1001];
int main()
{
  int h, w; cin >> h >> w;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> a[i][j];
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (i == 0 and j == 0) continue;
      else if (i == 0)
      {
        if (a[i][j] == '.') dp[i][j] = dp[i][j - 1];
      }
      else if (j == 0)
      {
        if (a[i][j] == '.') dp[i][j] = dp[i - 1][j];
      }
      else 
      {
        if (a[i][j] == '.') dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % 1000000007;
      }
    }
  }
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#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() {
    ll n;cin>>n;
    int mi=12;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            int j=n/i;
            string si=to_string(i);
            string sj=to_string(j);
            int f=max(sj.size(),si.size());
            mi=min(mi,f);
        }
    }
    cout<<mi<<endl;
}

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

using namespace std;

typedef long long ll;

ll answer;
int N, M;

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

    cin >> N >> M;

    priority_queue<int> pq;

    for (int i = 0; i < N; i++) {
        int temp = 0;
        cin >> temp;

        pq.push(temp);
    }

    for (int i = 0; i < M; i++) {
        int temp = pq.top();
        pq.pop();

        temp /= 2;
        pq.push(temp);
    }

    for (int i = 0; i < N; i++) {
        int temp = pq.top();
        answer += temp;
        pq.pop();
    }

    cout << answer << "\n";
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;
ll V[1010];

ll ma[51][51];
ll num[51][51];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	FOR(i,N) cin>>V[i];
	MINUS(ma);
	ma[0][0]=0;
	num[0][0]=1;
	
	FOR(i,N) {
		FOR(x,N) if(num[i][x]>0) {
			
			// take
			if(ma[i+1][x+1] < ma[i][x]+V[i]) ma[i+1][x+1] = ma[i][x]+V[i], num[i+1][x+1]=0;
			if(ma[i+1][x+1] == ma[i][x]+V[i]) num[i+1][x+1] += num[i][x];
			// not take
			if(ma[i+1][x] < ma[i][x]) ma[i+1][x] = ma[i][x], num[i+1][x]=0;
			if(ma[i+1][x] == ma[i][x]) num[i+1][x] += num[i][x];
		}
	}
	
	ll p=0,q=1;
	ll ret=0;
	for(i=A;i<=B;i++) {
		if(q*ma[N][i] > p*i) p=ma[N][i], q=i, ret=0;
		if(q*ma[N][i] == p*i) ret += num[N][i];
	}
	_P("%.12lf %lld\n",(double)p/q, ret);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e12 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], f[N];
ll ans, k;

inline bool check (ll x) {
   ll res = 0;
   for (int i = 1; i <= n; i ++) {
      ll need = a[i] - x / f[i];
      if (need <= 0) continue;  
      res += need;
   }
   return (res <= k);
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   for (int i=  1; i <= n; i ++) cin >> f[i];
   sort (a + 1, a + n + 1);
   sort (f + 1, f + n + 1);
   reverse (f + 1, f + n + 1);
   ll l = -1, r = inf + 1;
   while (r - l > 1) {
      ll mid = l + r >> 1;
      if (check (mid)) r = mid;
      else l = mid;
   }
   cout << r;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a[100];
	int n;
	int p=0,w=0,g=0,y=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]=='P') p++;
		if(a[i]=='W') w++;
		if(a[i]=='G') g++;
		if(a[i]=='Y') y++;
	}
	if(p!=0&&w!=0&&g!=0&&y!=0){
		cout<<"Four"<<endl;
	}
	else{
		cout<<"Three"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;

    return 0;
}


Measured memory_bytes: 256
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |__ ___| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve() {
    int n;
    cin>>n;
    double x[n],y[n];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    long double fact[10];
    fact[0]=1;
    for(ll i=1;i<10;i++){
        fact[i]=fact[i-1]*i;
    }
    long double ans=0;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            long double dis=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            ans+=dis*2.0;
        }
    }
    ans*=fact[n-1];
    ans/=fact[n];
    cout<<setprecision(12)<<ans<<endl;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}

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

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

	vector<int> kushi(101, 0);
	for(int i = 0; i < n * 2; ++i){
		cin >> l;
		kushi[l]++;
	}

	int length = 100;
	int count = 0;
	bool second = false;
	while(length > 0){
		if(kushi[length] >= 2){
			kushi[length] -= 2;
			count += length;
		}
		else if(kushi[length] == 1){
			if(second){
				second = false;
				count += length;
			}
			else{
				second = true;
			}
			--length;
		}
		else{
			--length;
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
using namespace std;
int main() {
    int n;
    cin >> n;
    int arr[n][3];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> arr[i][j];
        }
    }

    int dp[n][3];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            dp[i][j] = INT_MIN;
        }
    }
    dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2];
    for (int i = 1; i < n; ++i) {
        dp[i][0] = arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][1],dp[i-1][0]);
    }

    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 5968
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int N, A;
  cin >> N >> A;
  cout << N * N - A << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef std::vector<pii> vii;
#define INF 0x3f3f3f3f

int main(int argc, char const *argv[])
{
	//freopen("in.txt" , "r", stdin);
  	//freopen("out.txt" , "w", stdout);

  	string s; cin>>s;
  	if(s=="Sunny") cout<<"Cloudy"<<endl;
  	if(s=="Cloudy") cout<<"Rainy"<<endl;
  	if(s=="Rainy") cout<<"Sunny"<<endl;
  	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N, tmp;
  vector<int> a;
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  int res = 0;
  for (int i=0; i<N; i++){
    res += a[i] - 1;
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)]
int main(){
    int s, t, d; cin >> d >> t >> s;
    if (s*t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1; 
   // cin >> t;
    for(ll T = 0; T < t ; T++){
        ll n, ans = 0;
        cin >> n;
        if(n%2 == 0){
            n /= 10;
            ans += n;
            while(n){
                n /= 5;
                ans += n;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<long long> T(N), w(N - 1);
  for (int i = 0; i < N; i++)
  {
    cin >> T[i];
    if (i != 0)
      w[i - 1] = max(0LL, T[i] - T[i - 1] - 1);
  }
  sort(w.begin(), w.end(), greater<long long>());
  long long ans = T[N - 1] + 1 - T[0];
  for (int i = 0; i < K - 1; i++)
    ans -= w[i];
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 4424
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());

        Set<Integer> dSet = new HashSet<Integer>();

        for (int i=0; i<N; i++) {
            dSet.add(Integer.valueOf(sc.next()));
        }
        System.out.println(dSet.size());
    }
}


Measured memory_bytes: 23124
n = int(input())

if n == 111:
    print(999)
elif n == 119:
    print(991)
elif n == 199:
    print(911)
elif n == 999:
    print(111)
elif n == 991:
    print(119)
elif n == 911:
    print(199)
elif n == 191:
    print(919)
else:
    print(191)




Measured memory_bytes: 2940
#include<iostream>
using namespace std;
const int N=2e5+5;
int a[N*2];
int main() {
    int k,n;
    cin>>k>>n;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        a[i+n]=a[i]+k;
    }
    int ans=1e9;
    for(int i=0;i<n;i++) {
        ans=min(ans,a[i+n-1]-a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

long long gcd(long long a, long long b)
{
    int m;
    
    if(a < b)
    {
        gcd(b, a);
    }
//    
//    if(b <= 0)
//    {
//        return a;
//    }
//    
//    return gcd(b, a % b);
    while(b != 0)
    {
        m = a % b;
        a = b;
        b = m;
    }
    
    return a;
    
}

long long lcm(long long a, long long b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int a1, m1, a2, m2, a3, m3;
    long long x, y, z;
    
    while(cin>>a1>>m1>>a2>>m2>>a3>>m3, a1 && m1 && a2 && m2 && a3 && m3)
    {
        x = y = z = 1;
        
        for(int i = a1 % m1; i != 1; i = i * a1 % m1)
        {
            x++;
        }
        for(int i = a2 % m2; i != 1; i = i * a2 % m2)
        {
            y++;
        }
        for(int i = a3 % m3; i != 1; i = i * a3 % m3)
        {
            z++;
        }
        
        cout<<lcm(lcm(x, y), z)<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
	public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> V = new ArrayList<>();
        ArrayList<Integer> C = new ArrayList<>();
        int diff = 0;


        for(int i=0; i<n; i++){
            V.add(sc.nextInt());
        }
        for(int i=0; i<n; i++){
            C.add(sc.nextInt());
        }
        for(int i=0; i<n; i++){
            
            if((V.get(i)-C.get(i))>0){
                diff += V.get(i)-C.get(i);
            }            
        }

        System.out.println(diff);

        sc.close();

	}	
}

Measured memory_bytes: 22228
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int gusu=0;
		int check=0;
		
		for(int i=0;i<N;i++) {
			int A=sc.nextInt();
			if(A%2==0) {
				gusu++;
				if(A%3==0 || A%5==0) {
					check++;
				}
			}
		}
		if(check==gusu) {
			System.out.println("APPROVED");
		}
		else {
			System.out.println("DENIED");
		}
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vector<string> ss(n);
    cin>>ss;
    vector<LP> cs, ds;
    ll tot = 0;
    rep(i, n) {
        ll m = sz(ss[i]);
        ll b = 0, s = 0;
        rep(j, m) {
            if (ss[i][j] == ')') s--;
            else s++;
            chmin(b, s);
        }
        tot += s;
        if (s >= 0) cs.emplace_back(b, s);
        else ds.emplace_back(b - s, -s);
    }

    if (tot != 0) {
        cout<<"No"<<endl;
        return 0;
    }

    ll cur = 0;
    sort(rrng(cs));
    rep(i, sz(cs)) {
        if (cur + cs[i].fi < 0) {
            cout<<"No"<<endl;
            return 0;
        }
        cur += cs[i].se;
    }

    cur = 0;
    sort(rrng(ds));
    rep(i, sz(ds)) {
        if (cur + ds[i].fi < 0) {
            cout<<"No"<<endl;
            return 0;
        }
        cur += ds[i].se;
    }

    cout<<"Yes"<<endl;
}

Measured memory_bytes: 50212
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string s,t;cin>>s>>t;
  sort(all(s));sort(all(t),greater<char>());
  if(s < t)print("Yes");
  else print("No");
  return 0;
} 

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

public class Main {
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line="";
		while((line = br.readLine())!=null){
			String[] s =line.split(" ");
			long a = Long.parseLong(s[0]);
			long b = Long.parseLong(s[1]);
			if(a>b){
				System.out.println(gcd(b,a)+" "+lcm(b,a));
			}else{
				System.out.println(gcd(a,b)+" "+lcm(a,b));
			}
		}
	}
	public static long gcd(long m, long n){
		if(n == 0)
			return m;
		else
			return gcd(n, m % n);
	}
	public static long lcm(long m, long n){
		return m * n / gcd(m, n);
	}
}

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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    forn(i, m) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> par(n, -1);
    vector<int> q{0};
    par[0] = 0;
    forn(i, q.size()) {
        int u = q[i];
        for(int v : g[u]) {
            if(par[v] == -1) {
                par[v] = u;
                q.push_back(v);
            }
        }
    }
    cout << "Yes\n";
    for(int i = 1; i < n; i++) {
        cout << par[i]+1 << '\n';
    }
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


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

inline double square(double x) { return x * x;}
inline double distance2d(double x1, double y1, double x2, double y2)
{
    return sqrt(square(x1 - x2) + square(y1 - y2));
}
int main()
{
    int n;

    cin >> n;
    for (double x1, y1, x2, y2, x3, y3; n-- && cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;) {
        // r
        double d1 = distance2d(x1, y1, x2, y2);
        double d2 = distance2d(x2, y2, x3, y3);
        double d3 = distance2d(x3, y3, x1, y1);

        double r = d1 * d2 * d3 / sqrt((d1 + d2 + d3) *
                                       (-d1 + d2 + d3) *
                                       ( d1 - d2 + d3) *
                                       ( d1 + d2 - d3));

        // positions
        double d = 2 * (x1 * (y2 - y3) + x2 *(y3 - y1) + x3 * (y1 - y2));
        double px = ((x1 * x1 + y1 * y1) * (y2 - y3) +
                     (x2 * x2 + y2 * y2) * (y3 - y1) +
                     (x3 * x3 + y3 * y3) * (y1 - y2))/ d;
        double py = ((x1 * x1 + y1 * y1) * (x3 - x2) +
                     (x2 * x2 + y2 * y2) * (x1 - x3) +
                     (x3 * x3 + y3 * y3) * (x2 - x1)) / d;

        cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
    }

    return 0;
}

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

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

    int ans = 0;
    for (int i = 1; i<= n; i+=2) {
        int tot = 0;
        for(int j= 1; j<=i; j++) {
            if (i%j == 0) tot++;
        }
        if(tot == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
vector <int> a(100005);
void solve ()
{
	int n; cin >> n;
	ll sum = 0;
	for (int i = 0;i < n;i++)
	{
		int x; cin >> x;
		sum+=(ll)x;
		a[x]++;
	}
	int q;cin >> q;
	while (q--)
	{
		ll b,c;
		cin >> b >> c;
		sum-=(a[b] * b);
		sum+=(a[b] * c);
		a[c]+=a[b];
		a[b] = 0;
		cout << sum << "\n";
	}
}
int main ()
{
	solve();
	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{	
	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	cout << a[0] << " " << a[1] << " " << a[2] << endl;

	return 0;
}



Measured memory_bytes: 3152
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

ans = 0
# count for 0 ~ K
for i in range(N-K):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point

    if(T[i+K] == T[i]):
        T[i+K] = 'n'

# count for K ~ N
for i in range(N-K, N):
    if(T[i] == 'r'):
        point = P
    elif(T[i] == 's'):
        point = R
    elif(T[i] == 'p'):
        point = S
    else: # already used
        point = 0
    ans += point

print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main() {
    ll n,m; cin >> n >> m;
    
    if(n == 1 && m == 1) {
        cout << 1;
    }else if(n == 1 || m == 1){
        cout << n * m - 2;
    }else{
        cout << (n-2)*(m-2);
    }
}


Measured memory_bytes: 3572
sx,sy,tx,ty=[int(i) for i in input().split()]
w=tx-sx
h=ty-sy
ans=''

ans+='R'*w
ans+='U'*h
ans+='L'*w
ans+='D'*h

ans+='D'*1
ans+='R'*(w+1)
ans+='U'*(h+1)
ans+='L'*1
ans+='U'*1
ans+='L'*(w+1)
ans+='D'*(h+1)
ans+='R'*1
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

# define ll long long

const int N = 100001;
int dp[3][N];

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

	vector<int> a(n), b(n), c(n);
	for (int i = 1; i < n + 1; i++)
	{
		int A, B, C;
		cin >> A >> B >> C;
		a[i] = A;
		b[i] = B;
		c[i] = C;
	}
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	for (int i = 1; i < n + 1; i++)
	{
		dp[0][i] = a[i] + max(dp[1][i - 1], dp[2][i - 1]);
		dp[1][i] = b[i] + max(dp[0][i - 1], dp[2][i - 1]);
		dp[2][i] = c[i] + max(dp[0][i - 1], dp[1][i - 1]);
	}
	int ans = 0;
	for (int j = 0; j < 3; ++j) {
		ans = max(ans, dp[j][n]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5540
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  
  for(i=1;i<n+1;i++){
    scanf("%hd",&A[i]);
  }
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n+1;i++){
    if(i!=n)
    printf("%hd ",B[i]);
    else
       printf("%hd\n",B[i]);
  }

  return 0;
}



Measured memory_bytes: 9652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;
ll INF=1LL<<50;

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

  int nmax=1000;
  int mmax=2000;
  int a[mmax],b[mmax];
  ll c[mmax];

  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    c[i]=-c[i];
  }

  ll dist[nmax];

  for(int i=0;i<n;i++){
    dist[i]=INF;
  }
  dist[0]=0;

  for(int loop=0;loop<n-1;loop++){
    for(int i=0;i<m;i++){
      if(dist[a[i]-1]==INF) continue;
      if(dist[b[i]-1]>dist[a[i]-1]+c[i]){
        dist[b[i]-1]=dist[a[i]-1]+c[i];
      }
    }
  }

  ll ans=dist[n-1];

  bool negative[nmax];
  for(int i=0;i<n;i++){
    negative[i]=false;
  }

  for(int loop=0;loop<n;loop++){
    for(int i=0;i<m;i++){
      if(dist[a[i]-1]==INF) continue;
      if(dist[b[i]-1]>dist[a[i]-1]+c[i]){
        dist[b[i]-1]=dist[a[i]-1]+c[i];
        negative[b[i]-1]=true;
      }

      if(negative[a[i]-1]==true){
        negative[b[i]-1]=true;
      }
    }
  }

  if(negative[n-1]){
    cout<<"inf"<<endl;
  }else{
    cout<<-ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
int main()
{
	long long int n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	long long int p = 1000000007;
	long long int ans = modpow(2, n, p);
	ans = (ans - 1 + p) % p;
	long long int v = 1;
	long long int i;
	for (i = n; i > n - a; i--)
		v = v * i % p;
	for (i = 0; i < a; i++)
		v = v * modpow(i + 1, p - 2, p) % p;
	ans = (ans - v + p) % p;
	v = 1;
	for (i = n; i > n - b; i--)
		v = v * i % p;
	for (i = 0; i < b; i++)
		v = v * modpow(i + 1, p - 2, p) % p;
	ans = (ans - v + p) % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
let () =
  let a,b,ang = Scanf.scanf "%f %f %f\n" (fun x y z -> x,y,z) in
  let pi = 4. *. atan 1. in
  let rad = pi*.ang/.180. in
  let h = b*.(sin rad) in
  let s = (1./.2.) *. a*.h in
  let c = sqrt (a ** 2. +. b ** 2. -. 2.*.a*.b*.(cos rad)) in
  Printf.printf "%f\n%f\n%f\n" s (a+.b+.c) h

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
typedef long double ld;
const ll INF = 100100100;

int main(){
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    ll max_A = *max_element(ALL(A));

    vector<ll> dp(H + max_A, INF);
    dp[0] = 0;
    rep(i, H) rep(j, N) dp[i + A[j]] = min(dp[i + A[j]], dp[i] + B[j]);
    ll ans = *min_element(dp.begin()+H, dp.end());
    cout << ans << endl;
}

Measured memory_bytes: 384
S = input()[::-1]
W = []
for w in ['dreamer', 'eraser', 'erase', 'dream']:
    W.append(w[::-1])
while 1:
    flg = False
    for w in W:
        if S.startswith(w):
            S = S[len(w):]
            flg = True

    if not flg:
        print('NO')
        exit()
    if not S:
        break

print('YES')


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

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

  cout << 3*N*N << endl;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

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

graph = []

time = [-1] * N

now = 0
nex = 0
time[0] = 0
loop = 0

while True:
    now = nex
    nex = A[now] - 1

    if time[nex] == -1:
        time[nex] = time[now] + 1
    else:
        loop = nex
        break

if K > max(time):
    K -= time[loop]
    K %= (max(time) - time[loop] + 1)
    tmp = time[loop]
    for i in range(N):
        time[i] -= tmp

for i in range(N):
    if time[i] == K:
        print(i + 1)

# print(time, K)


Measured memory_bytes: 100132
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
ll A[MAXN];
ll tree[MAXN];

void update(int i, ll x) {
	while (i <= N) {
		tree[i] += x;
		i += i & -i;
	}
}

ll query(int i) {
	ll sum = 0ll;
	while (i > 0) {
		sum += tree[i];
		i -= i & -i;
	}
	return sum;
}

int main()
{
	int i, j;
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) {
		scanf("%lld", &A[i]);
	}
	ll ans = 0ll;
	for (i = 1; i <= N; ++i) {
		update(A[i], 1);
		if (query(A[i] - 1) == 0ll) ++ans;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3328
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//long int sieve(long long int a)
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    return ar[a];
//}

void Ok()
{
    long long int a,b,c,d,h,t,i,j,k,l,m,n;
    long int ans_1,ans_2,ans_3,ans_4,cnt = 0,Max,Min,flag,temp,sum = 0;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[113],bbb[113],ccc,ddd;
    string spc,in,store[13];

    cin>>a>>b>>c>>k;
    if(k>=a)
    {
        ans_1 = k - a;
        sum += (a * 1);
    }
    else if(k<a)
    {
        sum += (k * 1);
        cout<<sum<<endl;
        return;
    }
    if(ans_1>=b)
    {
        ans_2 = ans_1 - b;
        sum += (b * 0);
    }
    else if(ans_1<b)
    {
        sum += (ans_1 * 0);
        cout<<sum<<endl;
        return;
    }
    if(ans_2>=c)
    {
        ans_3 = ans_2 - c;
        sum += (c * (-1));
        cout<<sum<<endl;
        return;
    }
    else if(ans_2<c)
    {
        sum += (ans_2 * (-1));
        cout<<sum<<endl;
        return;
    }


    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<algorithm>
using namespace std;
struct Tea
{
    int cost;
    int vol;
}t[5];
bool cmp(Tea x,Tea y)
{
    if((double)x.cost>(double)y.cost*x.vol/y.vol)return false;
    else return true;
}
int main()
{
    int q,h,s,d,b=1,i;
    long long ans,n;
    for(i=1;i<=4;i++)
    {
        t[i].vol=b;
        scanf("%d",&t[i].cost);
        b=b*2;
    }
    sort(t+1,t+5,cmp);
    //for(i=1;i<=4;i++)
    //printf("%d %d\n",t[i].vol,t[i].cost);
    scanf("%d",&n);
    n=n*(long long)4;
    ans=0;
    for(i=1;i<=4;i++)
    {
        ans=ans+(long long)t[i].cost*(int)(n/t[i].vol);
        n=n%t[i].vol;
        //printf("%d %d\n",ans,n);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128