akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System;

class Prog
{
    public static void Main(string[] args)
    {
        new Prog().Solve();
    }

    //
    int N;
    int[][] happiness;

    long[][] dp;

    public void Solve()
    {
        N = int.Parse(Console.ReadLine());

        happiness = new int[N][];
        dp = new long[N + 1][];

        for (int i = 0; i < N;i++){
            var values = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            happiness[i] = values;

            dp[i] = new long[3];
        }


        dp[N] = new long[3];
        for (int day = 1; day <= N;day++){
            dp[day][0] = Math.Max(dp[day - 1][1], dp[day - 1][2]) + happiness[day - 1][0];

            dp[day][1] = Math.Max(dp[day - 1][0], dp[day - 1][2]) + happiness[day - 1][1];
            
            dp[day][2] = Math.Max(dp[day - 1][1], dp[day - 1][0]) + happiness[day - 1][2];

        }

        Console.WriteLine(dp[N ].Max());
    }
}

public struct Vector2
{
    public Vector2(double x, double y)
    {
        this.@this = new double[] { x, y };
    }


    public double[] @this;

    public double x
    {
        get
        {
            return @this[0];
        }
        set
        {
            @this[0] = value;
        }
    }

    public double y
    {
        get
        {
            return @this[1];
        }
        set
        {
            @this[1] = value;
        }
    }

    public double magnitude { get { return Math.Pow(sqrMagnitude, 1 / 2); } }

    public double sqrMagnitude { get { return Math.Pow(x, 2) + Math.Pow(y, 2); } }

    public Vector2 normalized { get { return this * (1 / this.magnitude); } }

    public static Vector2 operator +(Vector2 a, Vector2 b)
    {
        return new Vector2(a.x + b.x, a.y + b.y);
    }

    public static Vector2 operator -(Vector2 a, Vector2 b)
    {
        return new Vector2(a.x - b.x, a.y - b.y);
    }

    public static Vector2 operator *(Vector2 a, double b)
    {
        return new Vector2(a.x * b, a.y * b);
    }


    public static Vector2 operator /(Vector2 a, double b)
    {
        if (b == 0)
        {
            throw new DivideByZeroException();
        }
        else return new Vector2(a.x / b, a.y / b);
    }

    public bool Equals(Vector2 other)
    {
        return (@this[0] == other.@this[0] && @this[1] == other.@this[1]);
    }

}

Measured memory_bytes: 33936
<?php

$n = trim(fgets(STDIN));
$h = explode(' ', trim(fgets(STDIN)));

$m = 0;
$k = 0;
$b = $h[0];
for($i=0; $i<$n-1; $i++){
  if ($h[$i] >= $h[$i+1]) {
    $k++;
    if ($k > $m) $m = $k;
  } else {
    $k = 0;
  }
}
echo $m;
  
?>

Measured memory_bytes: 14840
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>
#include<deque>
#include<stdio.h>
typedef long long ll;

using namespace std;


vector<int>a;
int ans = 0;


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

int saiki(int id, int con, int n) {
	for (int i = id; i < n; i++) {
		if (a[i] == con) {
			id = i;
			con++;
			ans++;
			return saiki(id, con, n);
		}
	}
}

int main() {
	int n;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool ok = false;
	int id = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			ok = true;
			id = i;
		}
	}

	if (ok) {
		saiki(id, 2, n);
		cout << n-1-ans << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization ("Ofast")
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b) {
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if(a<b){a=b;return true;}
	return false;
}
template<class T> inline int getidx(vector<T> &v, T a) {
	return lower_bound(all(v), a) - v.begin();
}

constexpr int mod=998244353;
constexpr int inf=3e18;

struct Edge{
	int to,cost,tim;
};
int N,M,S;
vector<Edge>G[50];
int dist[50][2505];
int C[50],D[50];
struct Q{
	int tim,mon,v;
	bool operator<(const Q &a)const{return tim>a.tim;}
	bool operator>(const Q &a)const{return tim<a.tim;}
};
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N>>M>>S;
	rep(i,M){
		int a,b,c,d;cin>>a>>b>>c>>d;a--;b--;
		G[a].push_back({b,c,d});
		G[b].push_back({a,c,d});
	}
	rep(i,N){
		cin>>C[i]>>D[i];
	}
	rep(i,N)rep(j,2501)dist[i][j]=inf;
	dist[0][min(S,2500ll)]=0;
	priority_queue<Q>que;
	que.push({0,min(S,2500ll),0});
	while(!que.empty()){
		Q p=que.top();que.pop();
		if(dist[p.v][p.mon]<p.tim)continue;
		if(dist[p.v][min(2500ll,p.mon+C[p.v])]>p.tim+D[p.v]){
			dist[p.v][min(2500ll,p.mon+C[p.v])]=p.tim+D[p.v];
			que.push({dist[p.v][min(2500ll,p.mon+C[p.v])],min(2500ll,p.mon+C[p.v]),p.v});
		}
		for(Edge e:G[p.v]){
			if(e.cost>p.mon)continue;
			if(dist[e.to][p.mon-e.cost]>p.tim+e.tim){
				dist[e.to][p.mon-e.cost]=p.tim+e.tim;
				que.push({dist[e.to][p.mon-e.cost],p.mon-e.cost,e.to});
			}
		}
	}
	REP(i,N){
		int ans=inf;
		rep(j,2501)chmin(ans,dist[i][j]);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 7368
import itertools
n=int(input())

x,y=[],[]
for _ in range(n):
    a,b=map(int,input().split())
    x.append(a)
    y.append(b)
l=list(itertools.permutations(range(n)))
 
wrk=0
for p in l:
    for j in range(0,n-1):
        a=p[j]
        b=p[j+1]
        wrk+=((x[a]-x[b])**2+(y[a]-y[b])**2)**0.5
print(wrk/len(l))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n;
  cin >> n;
  vi l(n);
  rep(i, n) cin >> l[i];
  sort(ALL(l), greater<>());
  int ans = 0;
  for (int a = 0; a < n; a++) {
    for (int b = a+1; b < n; b++) {
      for (int c = b+1; c < n; c++) {
        if (l[a]==l[b] || l[b]==l[c] || l[c]==l[a]) continue;
        if (abs(l[b] - l[c]) < l[a] && l[a] < l[b] + l[c]) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
// きさま！ 見ているなッ！

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;


int main()
{
	int H, W, K;
	cin >> H >> W >> K;

	mat cho(H, vec(W));
	for (int h = 0; h < H; ++h)
	{
		string S; cin >> S;
		for (int w = 0; w < W; ++w)
		{
			cho[h][w] = (S[w] == '1');
		}
	}


	int ans = 1000000000;
	for (int i = 0; i < (1 << H); ++i)
	{
		int k = 0;
		int b = 0;
		mat cnt(H, vec(W));
		int tmp = 0;
		bool flag = true;
		for (int h = 0; h < H; ++h)
		{
			for (int w = 0; w < W; ++w)
			{
				cnt[k][w] += cho[h][w];
				if (cnt[k][w] > K) { flag = false; }
			}

			if (i&(1 << b))
			{
				tmp++;
				k++;
			}

			++b;
		}
		if (!flag)continue;

		/*
		for (int h = 0; h < H; ++h)
		{
			for (int w = 0; w < W; ++w)
			{
				cout << cnt[h][w];
			}
			cout << endl;
		}
		*/
		

		vec total(H,0);
		for (int w = 0; w < W; ++w)
		{
			bool kugiri = false;

			for (int h = 0; h < H; ++h)
			{
				if (total[h] + cnt[h][w] > K) { kugiri = true; break; }
			}

			if (kugiri)
			{
				for (int h = 0; h < H; ++h)
				{
					total[h] = cnt[h][w];
				}
				++tmp;
			}
			else
			{
				for (int h = 0; h < H; ++h)
				{
					total[h] += cnt[h][w];
				}
			}

			// cout << tmp;
		}
		// cout << "*" << endl;
		ans = min(ans, tmp);

		//cout << ans << endl;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    int cnt = 0;

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

    for(; a.at(0) <= a.at(2)-2; a.at(0) += 2){ cnt++; }
    for(; a.at(1) <= a.at(2)-2; a.at(1) += 2){ cnt++; }

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

    if(a.at(0) == a.at(1) && a.at(2) == a.at(1)){
        put(cnt);
    }else if(a.at(0) == a.at(1)){
        put(cnt+1);
    }else{
        put(cnt+2);
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	char s;
	
	scanf("%d", &a);
	while (1){
		scanf(" %c", &s);
		
		if (s == '='){
			break;
		}
		
		scanf("%d", &b);
		
		if (s == '+'){
			a += b;
		}
		else if (s == '-'){
			a -= b;
		}
		else if (s == '*'){
			a *= b;
		}
		else if (s == '/'){
			a /= b;
		}
	}
	
	printf("%d\n", a);
	
	return (0);
}

Measured memory_bytes: 596
H, W = map(int, input().split())
S = [input() for i in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == '.':
            left = False if w == 0 else True
            right = False if w == W - 1 else True
            up = False if h == 0 else True
            down = False if h == H - 1 else True

            count = 0
            count = count + 1 if left and up and S[h - 1][w - 1] == '#' else count
            count = count + 1 if up and S[h - 1][w] == '#' else count
            count = count + 1 if right and up and S[h - 1][w + 1] == '#' else count
            count = count + 1 if left and S[h][w - 1] == '#' else count
            count = count + 1 if right and S[h][w + 1] == '#' else count
            count = count + 1 if left and down and S[h + 1][w - 1] == '#' else count
            count = count + 1 if down and S[h + 1][w] == '#' else count
            count = count + 1 if right and down and S[h + 1][w + 1] == '#' else count

            print(str(count), end='')
        else:
            print("#", end='')
    print()

Measured memory_bytes: 3444
package main

import (
	"fmt"
)

func main() {
	var k, s, ans int
	fmt.Scan(&k, &s)

	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if 0 <= z && z <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.io.PrintWriter
import java.util.StringTokenizer
import kotlin.math.abs
import kotlin.math.min

fun main() {
    val reader = System.`in`.bufferedReader()
    val writer = PrintWriter(System.out, false)

    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun PrintWriter.solve() {
        var (k,n) = List(2){nextInt()}
        var arr = IntArray(n){nextInt()}

        var ans = k
        for (i in 1..n-1){
            ans = min(ans, k - abs( (arr[i] - arr[i-1])))
        }

        var final = (k - arr[n-1]) + (arr[0])
        ans = min(ans, k - final)

        println(ans)


    }

    writer.solve()
    writer.flush()


}




Measured memory_bytes: 56008
#include<iostream>
#include<cstring>
using namespace std ;
int n ;
const int N = 1e5 + 10 ;
const int M = 1 << 17 ;
int s[N] , S , ans , f[M] , inf , sum[20] ;

inline int dfs(int S) {
  if(! S) return 0 ;
  if(f[S] < inf) return f[S] ;
  for(register int i = 0 ; i < 16 ; i ++)
    if(S & (1 << i)) {
      for(register int j = 0 ; j < 16 ; j ++)
        if(i != j && (S & (1 << j))) {
          int p = i ^ j ;
          int x = S ^ (1 << i) ^ (1 << j) ^ (1 << p) ;
          if(S & (1 << p)) { f[S] = min(f[S] , dfs(x) + 2) ; }
          else { f[S] = min(f[S] , dfs(x) + 1) ; }
        }
    }
    return f[S] ;
}
signed main(){
  ios :: sync_with_stdio(false) ;
  cin.tie(0) ;
  cout.tie(0) ;
  cin >> n ;
  for(register int i = 1 ; i < n ; i ++) { int a , b , c ; cin >> a >> b >> c ; s[a] ^= c ; s[b] ^= c ; }
  for(register int i = 0 ; i < n ; i ++) { sum[s[i]] ++ ; }
  for(register int i = 1 ; i < 16 ; i ++)
    ans += (sum[i] >> 1) , S += (1 << i) * (sum[i] & 1) ;
  memset(f , 0x7f , sizeof(f)) ; inf = f[0] ;
  cout << ans + dfs(S) << '\n' ;
}
/*
5
0 1 1
0 2 3
0 3 6
3 4 4
*/

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

typedef long long ll;

int main(){
    ll S;
    cin >> S;
    ll l = 1;
    ll r = 1e+9;
    if(S == (ll)1e+18){
        cout << 0 << ' ' << 0 << ' ' << (ll)1e+9 << ' ' << 0 << ' ' << 0 << ' ' << (ll)1e+9 << endl;
        return 0;
    }
    while(r-l > 1){
        ll c = (l+r)/2;
        if(c*c < S) l = c;
        else r = c;
    }
    if(r == (ll)1e+9){
        if((r*(r-1) <= S)){
            cout << 0 << ' ' << 0 << ' ' << r << ' ' << 1 << ' ' << r*r-S << ' ' << r << endl;
            return 0;
        }else{
            cout << 0 << ' ' << 0 << ' ' << r-1 << ' ' << 1 << ' ' << S-(r-1)*(r-1) << ' ' << r-1 << endl;
            return 0;
        }
    }
    if((r*r)%2 == S%2){
        ll m = (r*r - S)/2;
        cout << 0 << ' ' << 0 << ' ' << r << ' ' << 2 << ' ' << m << ' ' << r << endl;
    }else{
        ll m = (r*r -1 - S)/2;
        cout << 0 << ' ' << 0 << ' ' << r+1 << ' ' << 2 << ' ' << m << ' ' << r-1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<pair<bool, int>> vp;
  int co = 1;
  rep2(i, 1, s.size()){
    if(s.at(i) != s.at(i-1)){
      vp.push_back({s.at(i-1) == '1', co});
      co = 1;
    }else co++;
  }
  vp.push_back({s.back() == '1', co});

  int ans = 0, ck = 0, stindex = -1;
  rep(i, vp.size()){
    if(vp.at(i).first == false){
      if(ck == k){
        stindex = i;
        break;
      }
      ck++;
    }
    ans += vp.at(i).second;
  }

  int tmp = ans;
  int reindex = 0;
  while(stindex < vp.size()){
    // cerr << reindex << " " << stindex << " " << tmp <<endl;
    while(vp.at(reindex).first != false){
      tmp -= vp.at(reindex).second;
      reindex++;
    }
    tmp -= vp.at(reindex).second;
    reindex++;
    int bf = stindex;
    while(bf == stindex || stindex != vp.size() && vp.at(stindex).first != false){
      tmp += vp.at(stindex).second;
      stindex++;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, first, to) for(ll i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)

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

vector<P> a;
int n;
void show(vector<P> ls) {
	rep(i, 0, n - 1) {
		cout << ls.at(i).second << ls.at(i).first << " ";
	}
	cout << ls.at(n - 1).second << ls.at(n - 1).first << endl;
}
void bubble_sort(vector<P> &ls) {
	rep(i, 0, n - 1) {
		bool isOk = true;
		rep(j, 1, n) {
			P p1 = ls.at(j - 1);
			P p2 = ls.at(j);
			if (p1.first > p2.first) {
				swap(ls.at(j - 1), ls.at(j));
				isOk = false;
			}
		}
		if (isOk) break;
	}
}

void selection_sort(vector<P> &ls) {
	rep(i, 0, n - 1) {
		int minj = i;
		rep(j, i + 1, n) {
			if (ls.at(minj).first > ls.at(j).first) {
				minj = j;
			}
		}
		swap(ls.at(minj), ls.at(i));
	}
}

void solve() {
	cin >> n;
	rep(i, 0, n) {
		string s;
		cin >> s;
		a.push_back(make_pair(s[1] - '0', s[0]));
	}
	vector<P> v1 = a;
	vector<P> v2 = a;
	bubble_sort(v1);
	show(v1);
	cout << "Stable" << endl;
	selection_sort(v2);
	show(v2);
	if (v1 != v2) {
		cout << "Not stable" << endl;
	} else {
		cout << "Stable" << endl;
	}
}

int main() {
	solve();
	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




int main() {
	int n;
	string a, b, c;
	cin >> n;
	cin >> a >> b >> c;
	int ans = 0;
	REP(i, n) {
		if (a[i] == b[i] && b[i] == c[i])continue;
		if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i])ans += 2;
		else ans++;
	}

	cout << ans << endl;
	
}



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

int main() {
int N;
cin >> N;
int a = N / 1000;
int b = (N - 1000 * a) / 100;
int c = (N - 1000 * a - 100 * b) / 10;
int d = N - 1000 * a - 100 * b - 10 * c;

  if(a == b && b==c){
    cout << "Yes" << endl;
  }
else if(b == c && c==d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

struct edge {
  int to, cost;
  edge(int t, int c) : to(t), cost(c) {}
};
vector<edge> G[3 * 100000];

#define INF 1000000
int d[3 * 1000000];

void dijkstra(int s) {
  priority_queue<pii, vector<pii>, greater<pii>> que;
  fill(d, d + 3 * 1000000, INF);
  d[s] = 0;
  que.push(pii(0, s));
  while (!que.empty()) {
    pii p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pii(d[e.to], e.to));
      }
    }
  }
}

int main() {
  //
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[3 * u].push_back(edge(3 * v + 1, 1));
    G[3 * u + 1].push_back(edge(3 * v + 2, 1));
    G[3 * u + 2].push_back(edge(3 * v, 1));
  }
  int s, t;
  cin >> s >> t;
  s--;
  t--;
  dijkstra(3 * s);
  if (d[3 * t] == INF) {
    cout << -1 << endl;
  } else {
    cout << d[3 * t] / 3 << endl;
  }
  return 0;
}


Measured memory_bytes: 28660
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int A,B;cin>>A>>B;
    if(A+B>=10) cout<<"error"<<endl;
    else cout<<A+B<<endl;
}


Measured memory_bytes: 256
//B Roller Coaster
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n,k,ans;
  cin>>n>>k;
  ans=0;
  vector<int> vec(n);
  for(int i=0;i<n;i++)
  {
    cin>>vec.at(i);
    if(vec.at(i)>=k)
    {
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int bubbleSort(int *,int);

int main()
{
  int N,A[100],i,j,cnt;

  scanf("%d",&N);
  if(N>100 || N<1) exit(1);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  cnt = bubbleSort(A,N);
  
  for(j=0;j<N;j++){
    if(j) printf(" ");
    printf("%d",A[j]);
  }
  printf("\n");
  printf("%d\n",cnt);

  return 0;
}

int bubbleSort(int A[],int N)
{
  int flag=1,cnt=0,i,tmp;

  while(flag)
    {
      flag=0;
      for(i=N-1;i>0;i--)
	{
	  if(A[i] < A[i-1])
	    {
	      tmp = A[i];
	      A[i] = A[i-1];
	      A[i-1] = tmp;
	      flag=1;
	      cnt++;
	    }
	}
    }
  return cnt;
}



Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 10;

ll N;
ll A[MAX_N], sum_A[MAX_N], bit[2 * MAX_N];

ll sum(ll i) {
    ll s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(ll i, ll x) {
    while (i <= 2 * N + 1) {
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> A[i];
    if (N == 1) {
        cout << A[1] << endl;
        return 0;
    }
    ll left = 1, right = 1e9 + 1;
    while (right - left > 1) {
        ll mid = (right + left) / 2;
        for (int i = 1; i <= N; i++) {
            sum_A[i] = A[i] < mid ? -1 : 1;
        }
        for (int i = 1; i <= N; i++) {
            sum_A[i] += sum_A[i - 1];
        }
        for (int i = 0; i <= 2 * N + 1; i++) bit[i] = 0;
        ll cnt = 0;
        for (int i = 0; i <= N; i++) {
            cnt += sum(sum_A[i] + N + 1);
            add(sum_A[i] + N + 1, 1);
        }
        if (cnt >= N * (N + 1) / 4) left = mid;
        else right = mid;
    }
    cout << left << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

long long fibo[100];

int main(){
    string s;
    cin >> s;
    for (int i = 0; i <= 1; i++){
        bool cur = true;
        for (int j = i + 1; j < i + 3; j++){
            if (s[j] != s[j - 1]){
                cur = false;
                break;
            }
        }
        if (cur == true){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define M 11451411451411451
using namespace std;
 
long long a[20],n,k;
 
long long F(long long q){
	bool t[20];
	long long r=2;
	for(int i=0;i<20;i++){
		if(q%r>=(r/2))t[i]=true;
		else t[i]=false;
		r*=2;
	}
	long long cnt=1,h=a[0],ret=0;
	for(int i=0;i<n-1;i++){
		if(t[i]){
			if(h+1>a[i+1]){
				ret+=h+1-a[i+1];
				h++;
			}
			else h=a[i+1];
			cnt++;
		}
		h=max(h,a[i+1]);
	}
	if(cnt>=k)return ret;
	return M;
}
 
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	long long ans=M;
	for(long long i=0;i<(1<<(n-1));i++){
		ans=min(ans,F(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0176

"""
import sys
from sys import stdin
from collections import namedtuple
from math import sqrt
input = stdin.readline


color = namedtuple('color', ['name', 'r', 'g', 'b'])
def main(args):
    references = [color('black',   0x00, 0x00, 0x00), color('blue', 0x00, 0x00, 0xff), color('lime',    0x00, 0xff, 0x00),
                  color('aqua',    0x00, 0xff, 0xff), color('red',  0xff, 0x00, 0x00), color('fuchsia', 0xff, 0x00, 0xff),
                  color('yellow', 0xff, 0xff, 0x00), color('white', 0xff, 0xff, 0xff)]

    while True:
        data = input().strip()
        if data[0] == '0':
            break
        my_r = int(data[1:3], 16)
        my_g = int(data[3:5], 16)
        my_b = int(data[5:7], 16)

        # distances = []
        #  for c in references:
        #      d = sqrt((c.r - my_r)**2 + (c.g - my_g)**2 + (c.b - my_b)**2)
        #      distances.append(d)
        distances = [((c.r - my_r)**2 + (c.g - my_g)**2 + (c.b - my_b)**2) for c in references]

        closest_distance = min(distances)
        closest_color = distances.index(closest_distance)
        print(references[closest_color].name)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7976
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int size = sc.nextInt();
		int[] array = new int[size];
		for(int i = 0; i < size; i++) array[i] = sc.nextInt();
		
		showArray(array);
	}
	
	static void showArray(int[] array) {
		StringBuilder builder = new StringBuilder();
		for(int i = array.length - 1; i >= 0; i -= 2) {
			builder.append(array[i] + " ");
		}
		
		for(int i = (array.length % 2 == 0)? 0: 1; i < array.length; i += 2) {
			builder.append(array[i] + " ");
		}
		
		builder.deleteCharAt(builder.length() - 1);
		System.out.println(builder.toString());
	}
}


Measured memory_bytes: 96208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

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

    int cnt = 0;
    for (int i = a; i <= b; i++) {
        int d0 = i%10;
        int d1 = ((i-d0)/10)%10;
        int d2 = ((i-d1*10-d0)/100)%10;
        int d3 = ((i-d2*100-d1*10-d0)/1000)%10;
        int d4 = (i-d3*1000-d2*100-d1*10-d0)/10000;
        if (d4 == d0 && d3 == d1) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
string s;
getline(cin,s);
for(int i=0;i<s.size();i++){
    if(s[i]==',')s[i]=' ';
}
cout<<s;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(a%3 == 0 || b % 3 == 0 || (a+b)%3 == 0) cout<<"Possible";
    else cout<<"Impossible";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 384
from collections import*
def s(s):
  f=[1]*-~n
  f[s]=0
  q=deque([(s,0)])
  while q:
    t,c=q.popleft()
    for v in e[t]:
      if f[v]:
        f[v]=0
        q.append((v,c+1))
  return t,c
n,*t=map(int,open(0).read().split())
e=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  e[a].append(b)
  e[b].append(a)
print('SFeicrosntd'[s(s(1)[0])[1]%3!=1::2])

Measured memory_bytes: 61020
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

bool color[8];

void solve(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i < 8; i++) color[i] = false;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        cnt += (x >= 3200);
        if(x < 3200){
            for(int j = 0; j <= 2800; j += 400){
                if(x >= j && x <= j + 399){
                    color[j / 400] = true;
                    break;
                }
            }
        }
    }

    int used = 0;
    for(int i = 0; i < 8; i++) used += color[i];
    if(used == 0){
        cout << 1 << ' ' << cnt;
        return;
    }
    cout << used << ' ' << used + cnt;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_N 1000
#define INF 100000000
#define MOD 1000000007
#define RANK 1000000000
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> IP;

struct UF{
	int par[MAX_N];
	int rank[MAX_N];
	int si[MAX_N];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			si[y] += si[x];
		} else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
			si[x] += si[y];
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
} uf;

int n, N;
int cnte = 0;
int dp[1001][1001][2];//1,2

int dfs(int ki, int gu, int res){
    if(dp[ki][gu][res] != -1) return dp[ki][gu][res];
    int ret = 0;
    int rec;
    if(ki >= 2){
        rec = dfs(ki-2,gu+1,res);
        if(rec == 0){
            dp[ki][gu][res] = 1;
            return 1;
        }
    }
    if(gu >= 1){
        rec = dfs(ki,gu-1,res^1);
        if(rec == 0){
            dp[ki][gu][res] = 1;
            return 1;
        }
    }
    if(gu >= 1){
        rec = dfs(ki,gu-1,res^1);
        if(rec == 0){
            dp[ki][gu][res] = 1;
            return 1;
        }
    }
    if(res == 1){
        rec = dfs(ki,gu,res-1);
        if(rec == 0){
            dp[ki][gu][res] = 1;
            return 1;
        }
    }
    dp[ki][gu][res] = 0;
    return 0;
}

int main(){
    cin >> n;
    memset(dp,-1,sizeof(dp));
    uf.init(n);
    rep(i,n) rep(j,n){
        char tmp; cin >> tmp;
        if(i == j) continue;
        if(tmp == 'Y'){
            uf.unite(i,j);
            cnte++;
        }
    }
    cnte /= 2;
    N = n*(n-1)/2;
    if(n%2){
        if((N-cnte)%2 == 0){
            cout << "Hanako" << endl;
        } else{
            cout << "Taro" << endl;
        }
        return 0;
    }
    int ki = 0;
    int sub = 0;
    int sum = 0;
    rep(i,n){
        if(uf.find(i) != i) continue;
        sub++;
        sum += (uf.si[i]-1)*uf.si[i]/2;
        if(uf.si[i]%2 == 1){
            ki++;
        }
    }
    dp[2][0][0] = 0; dp[2][0][1] = 1;
    dp[0][2][0] = 0; dp[0][2][1] = 1;
    dp[1][1][0] = 0; dp[1][1][1] = 1;
    int ans = dfs(ki,sub-ki,(sum-cnte)%2);
    if(ans%2){
        cout << "Taro" << endl;
    } else{
        cout << "Hanako" << endl;
    }
}

Measured memory_bytes: 11028
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  int r;
  cin >> r;
  cout << (3 * r * r) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
  //          int num = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int lim = int.Parse(input[0]);
            int before = int.Parse(input[1]);
            int after = int.Parse(input[2]);
            if( lim < -(before - after))
            {
                Console.WriteLine("dangerous");
            }
            else if(before < after)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("delicious");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double PI = acos(-1);

int main(){
    double a,b,x;
    cin >> a >> b>> x;
    double y = x/(a*a);
    double theta,ans;
    if(double(2*y - b) > 0){
        //cout << "dddd" << endl;
        theta = atan(2*(a*a*b-x)/(a*a*a));
    }else{
        //cout << "++++" << endl;
        theta = atan(b*b*a/(2*x));
        ans = PI/2 - atan(2*x/(a*b*b));
    }
    cout << fixed << setprecision(12) << theta*180/PI << endl;
}

Measured memory_bytes: 512
package main

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

func main() {
	N := readInt()
	K := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}
	F := make([]int, N)
	for i := 0; i < N; i++ {
		F[i] = readInt()
	}

	sort.Ints(A)
	sort.Sort(sort.Reverse(sort.IntSlice(F)))

	isOk := func(x int) bool {
		result := 0
		for i := 0; i < N; i++ {
			t := A[i] - x/F[i]
			if t > 0 {
				result += t
			}
		}
		return result <= K
	}

	l := -1
	r := A[N-1]*F[0] + 1
	for r-l > 1 {
		m := l + (r-l)/2
		if isOk(m) {
			r = m
		} else {
			l = m
		}
	}
	fmt.Println(r)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 6656
import java.util.BitSet;
import java.util.Scanner;

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

        char[] chars = (m + m).toCharArray();
        BitSet[] indexes = new BitSet[26];
        for (int i = 0; i < chars.length; i++) {
            int ch = chars[i] - 'a';
            BitSet index = indexes[ch];
            if (index == null) index = indexes[ch] = new BitSet(chars.length);
            index.set(i);
        }

        long start = 0;
        int ptr = -1;
        for (char ch : c.toCharArray()) {
            BitSet index = indexes[ch - 'a'];
            if (index == null) {
                System.out.println(-1);
                return;
            }

            ptr = index.nextSetBit(ptr + 1);
            if (ptr >= m.length()){
                ptr -= m.length();
                start += m.length();
            }
        }

        System.out.println(start + ptr + 1);
    }
}

Measured memory_bytes: 30064
package main

import "fmt"

func main() {
	a()
}

func a()  {
	var n int
	fmt.Scan(&n)

	// 1桁目取得
	x := n % 10

	switch x {
	case 2,4,5,7,9:
		fmt.Println("hon")
	case 0, 1, 6, 8:
		fmt.Println("pon")
	case 3:
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1772
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
string S;
int main(){
    cin >> S;
    int i=0;
    ll ans = 0;
    ll na = 0;
    while(S.size() > 2 && i<S.size()-2){
        if(S.substr(i, 3) == "ABC"){
            S.replace(i, 3, "BCA");
            ans += na+1;
            i+=2;
        } else if(S[i]=='A'){
            na++;
            i++;
        } else {
            na = 0;
            i++;
        }
        // cout << i << " " << ans << " " << S << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
W,H,N=list(map(int,input().split()))
L=[]
for h in range(H):
    L.append([])
    for w in range(W):
        L[h].append(0)

X=[]
Y=[]
A=[]
for i in range(N):
    x,y,a=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
    A.append(a)

for i in range(N):
    if A[i]==1:
        for h in range(H):
            for w in range(W):
                if 0<=w<X[i]:
                    L[h][w]=1
    elif A[i]==2:
        for h in range(H):
            for w in range(W):
                if X[i]<=w<=W-1:
                    L[h][w]=1
    elif A[i]==3:
        for h in range(H):
            for w in range(W):
                if 0<=h<Y[i]:
                    L[h][w]=1
    elif A[i]==4:
        for h in range(H):
            for w in range(W):
                if Y[i]<=h<=H-1:
                    #print(h,w)
                    L[h][w]=1
                    pass

count=0
for h in range(H-1,-1,-1):
    for w in range(W):
        if L[h][w]==0:
            count+=1
    #print(L[h])
print(count)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  string s,t; cin>>s>>t;
  vector<int> k1(26,-1);
  vector<int> k2(26,-1);

  rep(i,s.size()){
    int S=s[i]-'a';
    int T=t[i]-'a';
    if(k1[S]==-1) k1[S]=T;
    else{
      if(k1[S]!=T){
        puts("No");
        return 0;
      }
    }
    if(k2[T]==-1) k2[T]=S;
    else{
      if(k2[T]!=S){
        puts("No");
        return 0;
      }
    }
  }

  puts("Yes");

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef gp_hash_table<int, null_type,hash<int>, equal_to<int>, direct_mask_range_hashing<int>, linear_probe_fn<>,
    hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>,true>> hash_set;
typedef gp_hash_table<int,null_type> hash_map;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 19

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

const ld PI = (ld)4*atanl(1);

mt19937 g1(chrono::steady_clock::now().time_since_epoch().count());

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len,cards[MAXN][2],dp[1<<MAXN][MAXN][2];

int solve(int msk, int lst, int f){
    if(msk == (1<<len)-1) return 0;
    if(dp[msk][lst][f] != -1) return dp[msk][lst][f];
    vector<pii> v;
    int cnt = 0, res = INT_INF;
    for(int i=len-1; i>=0; i--){
        if(msk&(1<<i)) cnt++;
        else v.pb(mp(i,cnt%2));
    }
    reverse(all(v));
    for(int i=0; i<v.size(); i++){
        if(cards[v[i].first][(i%2)^v[i].second] >= cards[lst][f])
            res = min(res,solve(msk^(1<<v[i].first),v[i].first,(i%2)^v[i].second)+i);
    }
    return dp[msk][lst][f] = res;
}

int main(){
    scanf("%d",&len);
    for(int i=0; i<len; i++)
        scanf(" %d",&cards[i][0]);
    for(int i=0; i<len; i++)
        scanf(" %d",&cards[i][1]);
    memset(dp,-1,sizeof dp);
    printf("%d\n",solve(0,len,0)==INT_INF?-1:solve(0,len,0));
}

Measured memory_bytes: 78080
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

int N,n[200],d[200],p[200][2],dd[4][2]={{-1,0},{0,-1},{1,0},{0,1}},M[2],m[2];
const int INF=9999999;

int main() {
    while(cin>>N){
    	if(N==0)return 0;
    	M[0]=0;M[1]=0;m[0]=0;m[1]=0;
    	for(int i=1;i<N;i++)cin>>n[i]>>d[i];
    	for(int i=1;i<N;i++){
    		for(int j=0;j<2;j++){
    			p[i][j]=p[n[i]][j]+dd[d[i]][j];
    			M[j]=max(M[j],p[i][j]);
    			m[j]=min(m[j],p[i][j]);
    		}
    	}
    	cout<<(M[0]-m[0]+1)<<" "<<(M[1]-m[1]+1)<<endl;
    }
} 

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


bool prime(ll n){
    if(n == 2) return true;
    if(n == 1 || n % 2 == 0 ) return false;

    for(int i = 3; i <= sqrt(n); i += 2){
        if(n % i == 0) return false;
    }

    return true;

}

int main(){
    ll N;
    vector<bool> isPrime(100001,false);
    vector<ll> prob(100001,0);
    for(int i = 1; i < 100001; i++){
        isPrime[i] = prime(i);
    }

    for(int i = 1; i < 100000; i++){
        if(isPrime[((i + 1) + 1) / 2] && isPrime[i + 1]) prob[i + 1] = prob[i] + 1;
        else prob[i + 1] = prob[i];
    }

    cin >> N;
    for(int i = 0; i < N; i++){
        ll begin, end, ans = 0;
        cin >> begin >> end;

        cout << prob[end] - prob[begin - 1] << endl;
    }
}



Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,a,b;

int main(){
	cin>>n>>a>>b;
	int res=0;
	for(int i=1;i<=n;i++){
		int t=0,x=i;
		while(x){
			t+=x%10;
			x/=10;
		}
		if(a<=t&&t<=b) res+=i;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 256
//shivamkr21
//Chandigarh University
#include<bits/stdc++.h>
#define lli long long int
#define li long int
#define endl "\n"
#define mod 1000000007
#define pub push_back
#define fo freopen
using namespace std;

li n;
lli ar[100001][3];
lli ch[100001][3];

lli fun(char c,li x)
{
	if(x==n)
	{
		return 0;
	}
	if(c=='a')
	{
		if(ch[x][0]==-1)
		{
			ch[x][0]=max(fun('b',x+1)+ar[x+1][1],fun('c',x+1)+ar[x+1][2]);
		}
		return ch[x][0];
	}
	if(c=='b')
	{
		if(ch[x][1]==-1)
		{
			ch[x][1]=max(fun('a',x+1)+ar[x+1][0],fun('c',x+1)+ar[x+1][2]);
		}
		return ch[x][1];
	}
	if(c=='c')
	{
		if(ch[x][2]==-1)
		{
			ch[x][2]=max(fun('a',x+1)+ar[x+1][0],fun('b',x+1)+ar[x+1][1]);
		}
		return ch[x][2];
	}
	return 0;
}

int main()
{
	memset(ch,-1,sizeof(ch));
	cin>>n;
	for(lli i=0;i<n;i++)
	{
		cin>>ar[i][0];
		cin>>ar[i][1];
		cin>>ar[i][2];
	}
	lli a=fun('a',0)+ar[0][0];
	lli b=fun('b',0)+ar[0][1];
	lli c=fun('c',0)+ar[0][2];
	if(a>b)
	{
		if(a>c)
			cout<<a;
		else
			cout<<c;
	}
	else
	{
		if(b>c)
			cout<<b;
		else
			cout<<c;
	}
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef long long ll;

int main() {
    fastIO;
    double r;
    cin >> r;
    cout << 2 * r * acos(-1);
    return 0;
}


Measured memory_bytes: 3824
using System;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null){
                double second = double.Parse(input) / 9.8; 
                Console.WriteLine("{0:F0}", (second *  second * 4.9 + 5) / 5 + 0.5);
            }
        }
    }
}

Measured memory_bytes: 5764
package main

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

var (
	nstr   func() string
	stdout *bufio.Writer
	MOD    = 1000000007
)

func init() {
	nstr = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func main() {
	defer stdout.Flush()
	n := nint()
	k := nint()
	dList := getIntSlice(k)

	checker := make([]bool, 10)
	for _, v := range dList {
		checker[v] = true
	}

	for i:= n; ;i++{
		strI := strconv.Itoa(i)
		length := len(strI)
		f := true
		num := i
		for j:=1; j <= length; j++{
			num2 := num % 10
			num /= 10
			if checker[num2]{
				f = false
				break
			}
		}
		if f{
			fmt.Println(i)
			break
		}


	}


}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func nint64() int64 {
	i, err := strconv.ParseInt(nstr(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func nint() int {
	return int(nint64())
}

func getIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nint()
	}
	return b
}

func getStringSlice(n int) []string {
	b := make([]string, n)
	for i := 0; i < n; i++ {
		b[i] = nstr()
	}
	return b
}

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

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func bin(i int, prefix bool) string {
	i64 := int64(i)

	if prefix {
		return "0b" + strconv.FormatInt(i64, 2)
	} else {
		return strconv.FormatInt(i64, 2)
	}
}

func strReverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func exponentMod(a, b, p int) int {
	if b == 0 {
		return 1
	}
	if b&1 == 0 {
		d := exponentMod(a, b/2, p)
		return (d * d) % p
	} else {
		return (a * exponentMod(a, b-1, p)) % p
	}
}


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

int main() {
    long long N, ans = 0;
    cin >> N;
    if (N % 2 == 0) {
        long long X = 10;
        while (N >= X) {
            ans += N / X;
            X *= 5;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

N = int(input().rstrip())
a = list(map(int, input().rstrip().split()))
# print(a)

if not 1 in a:
  print(-1)
  exit()

ans = 1
for i in range(N):
  if a[i] == ans:
    ans += 1

print(N-ans+1)


Measured memory_bytes: 26268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
#include<set>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	char s[100010];
	cin >> s;
	for (int i = 0;i < strlen(s);i++) {
		if (i % 2 == 0) {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384