akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
string s[2000];
ll tate[2000][2000];
ll yoko[2000][2000];
int main()
{
	int h,w;
	ll ans=1;
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>s[i];
	
	//横を調べる
	for(int i=0;i<h;i++)
	{
		int j=0;
		while(j<w)
		{
			if(s[i][j]=='#')
			{
				yoko[i][j]=0;
				j++;
			}else{
				ll cnt=0;
				while(j<w && s[i][j]=='.')
				{
					cnt++;
					yoko[i][j]=cnt;
					j++;
				}
			}
		}
		//逆から見る
		j=w-1;
		while(j>-1)
		{
			if(yoko[i][j]>0)
			{
				ll cnt=yoko[i][j];
				while(j>-1 && yoko[i][j]>0)
				{
					yoko[i][j]=cnt;
					j--;
				}
			}else{
				j--;
			}
		}
	}
	//縦を調べる
	for(int j=0;j<w;j++)
	{
		int i=0;
		while(i<h)
		{
			if(s[i][j]=='#')
			{
				tate[i][j]=0;
				i++;
			}else{
				ll cnt=0;
				while(i<h && s[i][j]=='.')
				{
					cnt++;
					tate[i][j]=cnt;
					i++;
				}
			}
		}
		//逆から見る
		i=h-1;
		while(i>-1)
		{
			if(tate[i][j]>0)
			{
				ll cnt=tate[i][j];
				while(i>-1 && tate[i][j]>0)
				{
					tate[i][j]=cnt;
					i--;
				}
			}else{
				i--;
			}
		}
	}
	//調べ終わ 
	//全座標について調べる
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(s[i][j]=='.')
			{
				if(ans<tate[i][j]+yoko[i][j]-1)
				{
					ans=tate[i][j]+yoko[i][j]-1;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 66816
package main

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

var n int
var a = make([]int, 0)
var p, q string
var ss = make([]string, 0)

func dfs(s string, a []int) {
	if len(a) == 0 {
		ss = append(ss, s)
		return
	}

	for i := range a {
		b := make([]int, len(a))
		copy(b, a)
		dfs(s+strconv.Itoa(a[i]), append(b[:i], b[i+1:]...))
	}
}

func main() {
	n = readInt()
	for i := 0; i < n; i++ {
		p += strconv.Itoa(readInt())
	}
	for i := 0; i < n; i++ {
		q += strconv.Itoa(readInt())
	}

	for i := 0; i < n; i++ {
		a = append(a, i+1)
	}

	dfs("", a)

	sort.Strings(ss)

	x, y := 0, 0
	for i := range ss {
		if ss[i] == p {
			x = i
		}
		if ss[i] == q {
			y = i
		}
	}

	fmt.Println(abs(x - y))
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

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

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 6656
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> dp(n + 200, INF);
  dp[0] = 0;
  rep(i, n) loop(j, 1, k + 1) cmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
  cout << dp[n - 1] << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int B[N-1];
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }
  long long int sum=0;
  sum+=B[0];
  for(int i=0;i<N-2;i++){
    sum+=min(B[i],B[i+1]);
  }
  sum+=B[N-2];
  cout << sum;
}


Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var n,k,d,m int
  var x []int
  Scan(&n,&k)
  x = make([]int,n)
  for i:=0;i<n;i++ { Scan(&x[i]) }
  m = 2*(x[n-1]-x[0]) + 1
  for i:=0;i<n-k+1;i++ {
    d = x[i+k-1] - x[i] + min(abs(x[i+k-1]),abs(x[i]))
    if m > d { m = d }
  }
  Println(m)
}
func abs(n int) int {
  if n < 0 {
    return -n
  } else {
    return n
  }
}
func min(n int,m int) int {
  if n < m {
    return n
  } else {
    return m
  }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> H(N);
  int count = 1;
  
  for (int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  
  int maxH = H.at(0);
  
  for (int i = 1; i < N; i++){    
    if (H.at(i) >= maxH){
      count++;
      maxH = H.at(i);
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

void main()
{
	auto N = RD!long;
	auto K = RD!long;
	
	auto dp = new long[](N+1);
	foreach (i; 1..N+1)
	{
		dp[i] = dp[i-1];
		if (i > K)
		{
			dp[i] += (N / i) * (i - K) + (N % i >= K ? (N % i) - max(1, K) + 1 : 0);
		}
	}
	stderr.writeln(dp);

	writeln(dp[N]);
	stdout.flush();
}

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

int max(int a,int b);

int main() {
  int q;
  cin >> q;
  for (int i=0;i<q;++i) {
    string str1,str2;
    cin >> str1 >> str2;
    int size1 = str1.size();
    int size2 = str2.size();
    int matrix[size1+1][size2+1];
    for (int j=0;j<=size1;++j)
      matrix[j][0] = 0;
    for (int j=0;j<=size2;++j)
      matrix[0][j] = 0;
    for (int j=1;j<=size1;++j) {
      for (int k=1;k<=size2;++k) {
	if (str1[j-1]==str2[k-1]) {
	  matrix[j][k] = 1 + matrix[j-1][k-1];
	}
	else {
	  matrix[j][k] = max(matrix[j][k-1],matrix[j-1][k]);
	}
      }
    }
    cout << matrix[size1][size2] << endl;
  }
}

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

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

int my_kaijyou(int n){
    int x = 1;
    for(int i = 1; i <= n ; i++){
        x *= i;
    }
    return x;
}

double my_cos(double x){
    double cos = 0;
    for(int i = 0; i < 10000; i++){
        if(i % 2 == 0){
            cos += pow(x,2*i)/my_kaijyou(2*i);
        }else{
            cos -= pow(x,2*i)/my_kaijyou(2*i);
        }
    }
    return cos;
}

int main(){
    double A,B,H,M;
    cin >> A >> B >> H >> M;
    double theta,theta_A,theta_B;
    double PI = 3.1415926535897932384626433832795028841971;
    theta_A = H/12 + M/720;
    theta_B = M/60;
    double ans;
    if(theta_A >= theta_B){
        if(theta_A - theta_B <= 1 - theta_A + theta_B){
            theta = 2*PI*(theta_A-theta_B);
        }else{
            theta = 2*PI*(1 - theta_A + theta_B);
        }
    }else{
        if(theta_B - theta_A <= 1 - theta_B + theta_A){
            theta = 2*PI*(theta_B-theta_A);
        }else{
            theta = 2*PI*(1 - theta_B + theta_A);
        }
    }
    ans = sqrt(A*A + B*B - 2*A*B*cos(theta));
    cout << fixed << setprecision(15) << ans << endl;
}

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

#define C

#ifdef C

int main(void) {
	int num[30] = {};
	string str;
	while(getline(cin, str))
	{
	for (size_t i = 0; i < str.size(); i++)
	{
		str[i] -= 0x41;
		if (str[i] < 0)
			continue;
		else if (str[i] > 0x1f)
			str[i] -= 0x20;
		num[str[i]]++;

	}
}
	for (size_t i = 0; i < 0x1A; i++)
	{

		cout << static_cast<char>(i + 0x61) << " : " << num[i] << endl;

	}


	return 0;
}
#endif // C

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

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

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define all(x) x.begin(),x.end()

ll n;
vll a;

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

  cin >> n;
  a.resize(n);
  rep(i,0,n) cin >> a[i];
  sort(all(a),greater<ll>());
  
  ll res=0;
    rep(i,0,n/2) res+=2*(a[i]-a[n-1-i]);
    if(n%2==0) res+=(a[n-n/2]-a[n/2-1]);
    else res+=max(a[n-n/2]-a[n/2],a[n/2]-a[n/2-1]);
  
  cout << res << endl;
}

Measured memory_bytes: 1024
def main(n):
	flg = False
	s = "." + input()
	ans = 0
	tempans = 0
	blk = 0
	wht = 0
	for i in range(n+1):
		if s[i] == "#":
			blk += 1
			if s[i-1] == ".":
				flg = True
		else:
			if flg:
				wht += 1
			if blk <= wht:
				ans += blk
				blk = 0
				wht = 0
				flg = False
	print(ans + wht)
main(int(input()))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> m;
  rep(i, n) {
    cin >> v[i];
    m[v[i]]++;
  }
  int ans = 0;
  rep(i, n) {
    if (m[v[i]] % 2 == 1) {
      ans++;
      m[v[i]] = 0;
    }
  }

  cout << ans;
}


Measured memory_bytes: 5376
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  int S = 0;

  vector<int> res;
  for (int i = 1; i <= N; ++i) {
    S += i;
    if (S >= N) {
      for (int j = i; j >= 1; --j) {
        if (N >= j) {
          N -= j;
          res.push_back(j);
        }
      }
    }
  }
  sort(res.begin(), res.end());

  for (const int a : res) {
    printf("%d\n", a);
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n;
	cin>>n;
	cout<<n/3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define ENDL endl
using namespace std;
int main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (i == 4)
      cout << ' ' << s[i];
    else
      cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <string>

using namespace std;

int n, m;
string s, t;

int gcd(int a, int b) {
	if (a%b == 0)
		return b;

	return gcd(b, a%b);
}

int main() {

	cin >> n >> m;
	cin >> s >> t;

	long long len = n;
	len = len * m;

	int g = gcd(n, m);

	len /= g;

	int a = len/n, b = len/m;

	bool flag = true;
	long long idx1 = 0, idx2 = 0;
	int count1 = 0, count2 = 0;
	while (count1 < n && count2 < m) {
		if (idx1 == idx2)
		{
			if (s[count1] != t[count2])
			{
				flag = false;
				break;
			}

			idx1 += a;
			idx2 += b;

			++count1;
			++count2;
		} else 
			if (idx1 < idx2)
			{
				idx1 += a;
				++count1;
			}
			else
			{
				idx2 += b;
				++count2;
			}
	}

	if (flag)
		cout << len << endl;
	else
		cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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



int main() {
	llong N,A,B,C,D,E;
    cin >> N;
    LV a(5);
    REP(i,5){
        cin >>a[i];
    }
    long long mf,m=INF;
    REP(i,5){
        if(a[i]<m){
            mf=i;
            m=a[i];
        }
    }
    double c=ceil((double)N/m);
    llong ans=4+ceil((double)N/m);
    cout << ans<<endl;






}


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

int main() {
    int n,a,b;

    cin >> n >> a >> b;

    int cnt = 0;
    rep(i,n+1){
        vector<int> d;
        int nx = i;
        while(nx){
            d.push_back(nx%10);
            nx /= 10;
        }

        int total = 0;
        for(auto x: d){
            total += x;
            //cout << "t" << x << endl;
        }
        
        if(total >=a && total <=b){
            cnt += i;
            //cout << i << ',' << total<< endl;
        }

    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define repeq(i,r) for (int i = 0; i <= r; i++)

int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  rep(i,N) cin >> A[i];
  float sum = 0;
  rep(i,N) sum += A[i];
  
  int selectable = 0;
  rep(i,N) {
    if (A[i] >= sum / M / 4) selectable++;
  }
  cout << (selectable >= M ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


int main() {
  int V, E, R;
  scanf("%d %d %d", &V, &E, &R);
  WeightedGraph< int > g(V);
  for(int i = 0; i < E; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    g[a].emplace_back(b, c);
  }
  for(auto &dist : dijkstra(g, R)) {
    if(dist == numeric_limits< int >::max()) puts("INF");
    else printf("%d\n", dist);
  }
}


Measured memory_bytes: 15392
# 素数生成器
def generate_primes():
    from collections import defaultdict
    from itertools import count
    D = defaultdict(list)

    q = 2
    for q in count(2):
        if q in D:
            for p in D[q]:
                D[p+q].append(p)
            del D[q]
        else:
            yield q
            D[q*q].append(q)

N = int(input())
res = []
cnt = 0
for p in generate_primes():
    if p % 5 == 1:
        cnt += 1
        res.append(p)
    if cnt >= N:
        break

print(*res)

Measured memory_bytes: 68332
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000000;
const int MAX = 300000;

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
//------------------------------------------------------------------------------------------------------------------------------
vector<vector<int>> G;
vector<int> d, f;
int t;
void dfs(int v) {
    d[v] = ++t;
    for(auto nv : G[v]){
        if(d[nv]>0){
            continue;
        }
        dfs(nv);
    }
    f[v] = ++t;
}

int main(void) { 
    int N;
    cin >> N;
    G.resize(N);
    d.resize(N);
    f.resize(N);
    for (int i = 0; i < N; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for(int i = 0; i < k; i++) {
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }
    for(int i = 0; i < N; i++) {
        if(d[i]==0){
            dfs(i);
        }
    }
    for(int i = 0; i < N; i++) {
        cout << i + 1 << ' ' << d[i] << ' ' << f[i] << endl;
    }
}


Measured memory_bytes: 3176
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        class node
        {
            public List<long> ko = new List<long>();
            public long oya = -1;
        }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var nodes = new node[N];
            for (var i = 0; i < N; ++i)
                nodes[i] = new node();
            for (var i = 0; i < N; ++i)
            {
                var ninfo = Slist();
                nodes[ninfo[0]].ko.Add(ninfo[1]);
                nodes[ninfo[0]].ko.Add(ninfo[2]);
                if (ninfo[1] != -1)
                    nodes[ninfo[1]].oya = ninfo[0];
                if (ninfo[2] != -1)
                    nodes[ninfo[2]].oya = ninfo[0];
            }
            var root = -1;
            for (var i = 0; i < N; ++i)
            {
                if (nodes[i].oya == -1)
                {
                    root = i;
                    break;
                }
            }

            StringBuilder preorder = new StringBuilder();
            StringBuilder inorder = new StringBuilder();
            StringBuilder postorder = new StringBuilder();
            Action<long> deepwalk = null;
            deepwalk = (u) =>
              {
                  if (u == -1) return;
                  preorder.Append($" {u}");
                  deepwalk(nodes[u].ko[0]);
                  inorder.Append($" {u}");
                  deepwalk(nodes[u].ko[1]);
                  postorder.Append($" {u}");
              };
            deepwalk(root);
            WriteLine("Preorder");
            WriteLine(preorder.ToString());
            WriteLine("Inorder");
            WriteLine(inorder.ToString());
            WriteLine("Postorder");
            WriteLine(postorder.ToString());
        }
    }
}


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

struct State{
  string s;
  int c;
  State(string s, int c) : s(s), c(c){}
};

bool check(string s){
  for(int i = 0 ; i < (int)s.size()-1 ; i++){
    if(s[i] != s[i+1]) return false;
  }
  return true;
}

string change(string s){
  sort(s.begin(), s.end());
  if(s[0] == 'b' && s[1] == 'g') return "rr";
  if(s[0] == 'b' && s[1] == 'r') return "gg";
  if(s[0] == 'g' && s[1] == 'r') return "bb";
}

int bfs(string s){
  queue<State> que;
  que.push(State(s, 0));
  
  set<string> S;
  
  while(!que.empty()){
    State q = que.front(); que.pop();
    if( check(q.s) ) return q.c;
    
    if(S.find(q.s) != S.end()) continue;
    S.insert(q.s);
    
    for(int i = 0 ; i < (int)q.s.size()-1 ; i++){
      string t = q.s.substr(i, 2);
      if(t != "rr" && t != "gg" && t != "bb"){
	que.push(State(q.s.substr(0, i) + change(t) + q.s.substr(i+2), q.c+1));
      }
    }   
  }
  return -1;
}

int main(){
  string s;
  while(cin >> s && s != "0"){
    int ans = bfs(s);
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  } 
  return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    vector<vector<int>> h(n,vector<int>(3)), dp(n, vector<int>(3, 0));
    for(int i=0;i<n;i++) {
        for(int j=0;j<3;j++){
            int t;
            cin>>t;
            h[i][j] = t;
        }
    }
    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];
    for(int i=1;i<n;i++) {
        for(int j=0;j<3;j++){
            dp[i][j] = h[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
        }
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
}


Measured memory_bytes: 11136
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

def f(x):
    if x % 2 == 1:
        # one_num
        tmp = (x + 1) / 2
        if tmp % 2 == 0:
            return 0
        else:
            return 1
    else:
        return f(x-1) ^ x
print(f(A-1) ^ f(B))

exit()
if A % 2 == 0 and B % 2 != 0:
    dist = B - A
    one_num = dist // 2 + 1
    if one_num % 2 == 0:
        ans = 0
    else:
        ans = 1
if A % 2 == 0 and B % 2 == 0:
    dist = B - 1 - A
    one_num = dist // 2 + 1
    if one_num % 2 == 0:
        ans = 0
    else:
        ans = 1
    ans = ans ^ B
if A % 2 != 0 and B % 2 != 0:
    dist = B - (A + 1)
    one_num = dist // 2 + 1
    if one_num % 2 == 0:
        ans = 0
    else:
        ans = 1
    ans = ans ^ A
if A % 2 != 0 and B % 2 == 0:
    dist = B - 1 - (A + 1)
    one_num = dist // 2 + 1
    if one_num % 2 == 0:
        ans = 0
    else:
        ans = 1
    ans = ans ^ A ^ B


print(ans)





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

vector<int> sieveOfEratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i) primes[i] = i;
  for (int i = 2; i * i < n; ++i) {
    if (primes[i]) {
      for (int j = i * i; j < n; j += i) primes[j] = 0;
    }
  }
  primes.erase(remove(begin(primes), end(primes), 0), end(primes));
  return primes;
}

map<int, int> mp;

void prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i <= n; i++) {
    while (n % i == 0) {
      ++mp[i];
      n /= i;
    }
  }
}

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

  for (int i = 2; i <= N; i++) {
    prime_factor(i);
  }

  vector<int> p = sieveOfEratosthenes(N + 1);
  int sz = p.size();

  map<int, int> rev; 
  for (int i = 0; i < sz; i++) {
    rev[p[i]] = i;
  }
  
  vector<int> v(25, 0);
  for (auto x : mp) {
    v[rev[x.first]] = x.second;
  }

  int ans = 0;
  for (int i = 0; i < sz; i++) {
    if (v[i] >= 74) ans++;
    for (int j = 0; j < sz; j++) {
      if (j == i) continue;
      if (v[i] >= 2 && v[j] >= 24) ans++;
      if (v[i] >= 4 && v[j] >= 14) ans++;
      for (int k = 0; k < sz; k++) {
        if (k == i) continue;
        if (k <= j) continue;
        if (v[i] >= 2 && v[j] >= 4 && v[k] >= 4) ans++;
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cout << (N - A + 1)*(N - B + 1);
}


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

#define ll long long
#define ar array

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    double ans = 0;;
    cin >> n >> k;

    for (int i = 1; i <= n; i++){
        double temp = 1.0/n;
        int face = i;
        while (face < k){
            face *= 2;
            temp /=2;
        }
        ans += temp;
    }
    cout << fixed << setprecision(12) << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int x,pares,impares;
	scanf("%d", &x);
	if(x%2){
		impares = x/2+1;
		pares = x/2;
	}
	else {
		pares = x/2;
		impares = pares;
	}
	printf("%d\n", impares*pares);
	return 0;
}


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

int main() {
	int a, b;
	int d, r;
	double f;

	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / b;

	cout.precision(6);
	cout << d << " " << r << " " << fixed << f << endl;

	return 0;
}



Measured memory_bytes: 3292
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2600
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))
    U = list(map(int, input().split()))
    V = list(map(int, input().split()))

    range_N = range(N)
    ans = [[0]*N for _ in range_N]
    # 論理積
    for i in range_N:
        if S[i] == 0:
            for j in range_N:
                ans[i][j] = ans[i][j] | U[i]
        if T[i] == 0:   
            for j in range_N:
                ans[j][i] = ans[j][i] | V[i]
    for i in range_N:
        for j in range_N:
            if (U[i] & V[j]):
                ans[i][j] = ans[i][j] | (U[i] & V[j])

    # 論理和
    for x in range_N:
        if S[x] == 0:
            continue
        x_sum = ans[x][0]
        for y in range_N:
            x_sum = x_sum | ans[x][y]
        if x_sum == U[x]:
            continue
        up = U[x] - x_sum
        for y in range_N:
            if T[y]:
                continue
            y_mul = ans[0][y]
            for i in range_N:
                if i == x:
                    continue
                y_mul = y_mul & ans[i][y]
            up_y = (~y_mul) & up
            ans[x][y] += up_y
            up -= up_y
            if up == 0:
                break

    for y in range_N:
        if T[y] == 0:
            continue
        y_sum = ans[0][y]
        for x in range_N:
            y_sum = y_sum | ans[x][y]
        if y_sum == V[y]: 
            continue
        up = V[y] - y_sum
        for x in range_N:
            if S[x]:
                continue
            x_mul = ans[x][0]
            for j in range_N:
                if y == j:
                    continue
                x_mul = x_mul & ans[x][j]
            up_x = (~x_mul) & up
            ans[x][y] += up_x
            up -= up_x
            if up == 0:
                break

    # チェック
    for i in range_N:
        check_xs = ans[i][0]
        check_ys = ans[0][i]
        check_xm = ans[i][0]
        check_ym = ans[0][i]
        for j in range_N:
            check_xs = check_xs | ans[i][j]
            check_ys = check_ys | ans[j][i]
            check_xm = check_xm & ans[i][j]
            check_ym = check_ym & ans[j][i]
        if (S[i] and U[i] != check_xs) \
        or (T[i] and V[i] != check_ys) \
        or (S[i] == 0 and U[i] != check_xm) \
        or (T[i] == 0 and V[i] != check_ym) :
            print(-1)
            return       

    for i in range_N:
        print(*ans[i])

main()


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

int func(int n)
{
    if (n <= 1)
        return 1;
    return n * func(n - 1);
}

int calc(int n)
{
    bool done[10] = {};
    int x, ans = 1;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        int c = 0;
        for (int j = 1; j < x; ++j)
        {
            if (!done[j])
                ++c;
        }
        ans += c * func(n - i);
        done[x] = true;
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    int a = calc(n);
    int b = calc(n);
    if (a > b)
        cout << a - b << endl;
    else
        cout << b - a << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
#define INF 100000000
#define min(a,b) (a<b?a:b)
int main(){
	int i,j,k,n,m,bit,next,cur,r,newCost,ret;
	int land[200][200] , ship[200][200] , R[1000] ,dp[2][200];
	while(scanf("%d%d",&n,&m) && n){
		rep(i,n)rep(j,n)land[i][j] = ship[i][j] = INF;
		rep(i,n)land[i][i] = ship[i][i] = 0;
		
		rep(i,m){
			char t;
			int a,b,c;
			scanf("%d %d %d %c\n",&a,&b,&c,&t);
			a--,b--;
			if(t=='L')land[a][b] = land[b][a] = min(c,land[a][b]);
			else  ship[a][b] = ship[b][a] = min(c,ship[a][b]);
		}
		rep(k,n)rep(i,n)rep(j,n)land[i][j] = min(land[i][j],land[i][k]+land[k][j]);
		rep(k,n)rep(i,n)rep(j,n)ship[i][j] = min(ship[i][j],ship[i][k]+ship[k][j]);
		
		scanf("%d",&r);	
		rep(i,r)scanf("%d",&R[i]) , R[i]--;
		
		rep(j,2)rep(k,n)dp[j][k] = INF;
		dp[0][R[0]] = 0;
		
		rep(bit,r-1){
			rep(cur,n){
				rep(next,n){
					newCost = dp[bit&1][cur] + land[R[bit]][cur] + ship[cur][next] + land[next][R[bit+1]];
					dp[!(bit&1)][next] = min( dp[!(bit&1)][next],newCost);
				}
				dp[!(bit&1)	][cur] = min(dp[!(bit&1)][cur],dp[bit&1][cur]+land[R[bit]][R[bit+1]]);
			}
			rep(j,n)dp[bit&1][j] = INF;
		}
		ret = INF;
		rep(i,n)ret = min(dp[(r-1)&1][i],ret);
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 728
taro_point = 0
hanako_point = 0
N = int(input())
for _ in range(N):
    taro,hanako = input().split()
    list = [taro,hanako]
    list_new = sorted(list)
    if taro == hanako:
        taro_point += 1
        hanako_point += 1
    elif list_new[1] == hanako:
        hanako_point +=3
    elif list_new[1] == taro:
        taro_point += 3
print(str(taro_point),str(hanako_point))


Measured memory_bytes: 5596
#include<stdio.h>
int main(void){
  int k,l,m,n=0,h[101];
  char a[201][101];
  while(1){
    n = 0;
    for(k=1;k<=200;k++){
      for(l=0;l<=100;l++){
        a[k][l]=0; //????????????'0'??§?????????
      }
    }
    scanf("\n");
    for(k=1;k<=200;k++) {
      scanf("%c",&a[k][0]); //????????????????????£???
      if(a[k][0]=='\n') break;//????????§?????????????????????
      n++;
    }
    if(a[1][0]=='-') break; //'-'??§????????°????????????
    scanf("%d",&m);
    for(k=1;k<=m;k++){
    scanf("%d",&h[k]);
    }
    for(l=1;l<=m;l++){
      for(k=1;k<=h[l];k++){
        if(1<=k<=h[l]){
          a[n-k+1][l] = a[h[l]-k+1][l-1];
        }
      }
      for(k=1;k<=n-h[l];k++){
        if(h[l]<k<=n){
          a[k][l] = a[h[l]+k][l-1];
        }
      }
    }
    for(k=1;k<=n;k++){
      printf("%c",a[k][m]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
#include <cstring>
typedef long long int ll;
using namespace std;

int main() {
	int A, B; cin >> A >> B;
	const int a = A - 1;
	int ans = 0;
	if (B == 0) {
		cout << ans << endl;
		return 0;
	}
	int Plag = 1;
	while (Plag < B) {
		ans++;
		Plag += A - 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n, k = gets.strip.split.map { |v| v.to_i }
r, s, p = gets.strip.split.map { |v| v.to_i }
t = gets.strip.split('').map { |v| v.to_sym }

hand_to_point = { :r => r, :p => p, :s => s }

def hand(hands, index)
  return hands[index] if index.between?(0, hands.size - 1) 
  :no_hand
end

def which_hand_and_win?(opp_hand, disable_hand, opp_next_hand)
  case opp_hand
  when :r
    return [:p, true] if disable_hand != :p
    return [:s, false] if opp_next_hand == :s
    return [:r, false]
  when :p
    return [:s, true] if disable_hand != :s
    return [:r, false] if opp_next_hand == :r
    return [:p, false]
  when :s
    return [:r, true] if disable_hand != :r
    return [:p, false] if opp_next_hand == :p
    return [:s, false]
  end
end

your_hands = []
points = 0
(0..n-1).each do |i|
  hand, win = which_hand_and_win?(hand(t, i), hand(your_hands, i - k), hand(t, i + k))
  your_hands.push(hand)
  points += hand_to_point[hand] if win
end

puts points


Measured memory_bytes: 12924
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();

    let (a,b) = {
        let mut input = String::new();
        stdin.read_line(&mut input).unwrap();
        let mut input = input.trim().split_whitespace();
        (
            input.next().unwrap().parse::<i32>().unwrap(),
            input.next().unwrap().parse::<i32>().unwrap(),
        )
    };

    if a >= 13 {
        println!("{}", b);
    } else if a >= 6 {
        println!("{}", b/2);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int n,A[2000];

int ju(int i,int x){
  if( x == 0) return 1;
  if( i >= n) return 0;

  int result = ju(i+1,x) || ju(i+1,x-A[i]);
  return result;
}

int main(){
  int m,i,q;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(ju(0,m)) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



Measured memory_bytes: 2108
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int h,w;
typedef long long LL;
LL k;
const int MX=1011,md=1000000007;
char s[MX][MX];

struct Matrix{
	int a[2][2];
	Matrix(){memset(a,0,sizeof(a));}
	Matrix operator *(const Matrix &x)const{
		Matrix R;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
				for(int k=0;k<2;k++)
					R.a[i][j]=((LL)R.a[i][j]+(LL)a[i][k]*x.a[k][j])%md;
		return R;
	}
};
inline int pw(int x,int y){
	int r=1;
	while(y){
		if(y&1)r=(LL)r*x%md;
		x=(LL)x*x%md;
		y>>=1;
	}
	return r;
}

int wk1(){
	int C=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			C+=s[i][j];
	return pw(C,(k-1)%(md-1));
}
int wk(int lr,int ud){
	int C=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			C+=s[i][j];
	int V=pw(C,(k-1)%(md-1));
	int E0=0;
	if(lr){
		for(int i=0;i<h;i++)
			for(int j=0;j<w-1;j++)
				E0+=(s[i][j]&s[i][j+1]);
	}else{
		for(int i=0;i<h-1;i++)
			for(int j=0;j<w;j++)
				E0+=(s[i][j]&s[i+1][j]);
	}
	Matrix S,T;
	S.a[0][0]=E0,S.a[0][1]=C;
	T.a[0][0]=lr+ud,T.a[1][0]=E0,T.a[1][1]=C;
	LL t=k-2;
	while(t){
		if(t&1)S=S*T;
		T=T*T;t>>=1;
	}
	return (V-S.a[0][0]+md)%md;
}
int main(){
	scanf("%d%d%lld",&h,&w,&k);
	for(int i=0;i<h;i++)scanf("%s",s[i]);
	if(k==1)return puts("1"),0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)s[i][j]=(int)(s[i][j]=='#');
	int lr=0,ud=0;
	for(int i=0;i<w;i++)ud+=(s[0][i]&s[h-1][i]);
	for(int i=0;i<h;i++)lr+=(s[i][0]&s[i][w-1]);
	if(lr&&ud)puts("1");
	else if(!lr&&!ud)printf("%d\n",wk1());
	else printf("%d\n",wk(lr,ud));
	return 0;
}


Measured memory_bytes: 1152
from collections import deque
H,W=map(int,input().split())
s=[['#']*(W+2)for _ in range(H+2)]
count=0
for i in range(1,H+1):
  S=list(input())
  s[i]=['#']+S+['#']
  count+=S.count('.')
move=[(1,0),(-1,0),(0,1),(0,-1)]
que=deque([(1,1)])
s[1][1]=1
while que:
  a,b=que.popleft()
  if (a,b)==(H,W):
    break
  for my,mx in move:
    ny=my+a
    nx=mx+b
    if s[ny][nx]=='#':
      continue
    elif s[ny][nx]=='.':
      que.append((ny,nx))
      s[ny][nx]=s[a][b]+1
ans=-1
if s[H][W]!='.':
  ans=count-s[H][W]
print(ans)

Measured memory_bytes: 3316
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#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 inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}


signed main() {
	vector<int>v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<v[n-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::map<int,int> map;
	rep(i,n) {
		int x;
		std::cin >> x;
		map[x]++;
	}
	int xo=0,cnt=0,max=0;
	for(auto x:map) {
		if((x.first-max)&1) {
			if(cnt==0) {
				xo^=2-n%2;
			} else {
				xo^=(n-cnt)%2;
			}
		}
		cnt+=x.second;
		max=x.first;
	}
	if(xo) print("First");
	else print("Second");
	return 0;
}



Measured memory_bytes: 15420
var cc : array ['a'..'z',0..200000] of longint ;
    a,b,c,d,e,f,g,h,i,j : longint ;
    so :ansistring ;
    gg : char ;
    sum : int64 ;
begin
 readln(so);
 j:=length(so);
 for a:=1 to j do
  cc[so[a],a]:=cc[so[a],a]+1;
 for gg:='a' to 'z' do
  for a:=1 to j do
   begin
    cc[gg,a]:=cc[gg,a]+cc[gg,a-1];
   end;
  for a:=2 to j do
   begin
    sum:=sum+(a-(cc[so[a],a]-1)-1);
 //   writeln(cc[so[a],a],' ',cc[so[a],a-1]);
   end;
  writeln(sum+1);
end.


Measured memory_bytes: 20608
import math

N, K = map(int, input().split())
h = [0] + list(map(int, input().split()))

DP = [math.inf] * (N+1)

for i in range(1, N+1):
    if i == 1:
        DP[i] = 0
        continue
    if i == 2:
        DP[i] = abs(h[1] - h[2])
        continue
    for j in range(1, min(i, K) + 1):
        DP[i] = min(DP[i], DP[i-j] + abs(h[i-j] - h[i]))


print(DP[N])



Measured memory_bytes: 85616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		int[] tarray = new int[n];
		int count = 0;

		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			tarray[i] = i+1;
		}

		for (int i = 0; i < n; i++) {
			if (array[i] != tarray[i]) {
				count += 1;
			}
		}

		String message = (count == 0 || count == 2) ? "YES" : "NO";
		System.out.println(message);

	}

}


Measured memory_bytes: 25172
import java.util.Scanner;

public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] cell=new int[r+1][c+1];
		for (int i=0 ;i<r ;i++) {
			for (int j=0; j < c ; j++) {
				cell[i][j]=sc.nextInt();
				cell[i][c]+=cell[i][j];
				cell[r][j]+=cell[i][j];
				cell[r][c]+=cell[i][j];
			}
		}
		for (int i = 0;i<r+1;i++) {
			for(int j=0;j<c+1;j++) {
				System.out.print(cell[i][j]);
				if(j!=c) System.out.print(" ");

			}
			System.out.println();
		}

	}
}


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

ll arr[100001];

int main() {
	int n;
	cin>>n;
	for(int i = 0; i < n+1; i++) {
		cin>>arr[i];
	}
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		ll b;
		cin>>b;
		ll c = min(arr[i],b);
		ans+=c;
		b-=c;
		ll d = min(arr[i+1],b);
		ans+=d;
		arr[i+1]-=d;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a,b,count,sum;
	while(scanf("%d %d",&a,&b)!=EOF){
		count=0;
		sum=a+b;
		while(sum>9){
			sum=sum/10;
			count++;
		}
		printf("%d\n",count+1);
	}
	return 0;
}

Measured memory_bytes: 1028
x1, y1, x2, y2 = list(map(int, input().split()))
x3 = x2 - y2 + y1
y3 = y2 + x2 - x1
x4 = x1 - y2 + y1
y4 = y1 + x2 - x1
print(x3, y3, x4, y4)


Measured memory_bytes: 9164
#include<bits/stdc++.h>
#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 rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll X, t;
  cin >> X >> t;

  cout << max((ll)0, X - t) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int r = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		
		int past = x;;
		for(int i=1;i<=10;i++){
			past = past*r - d;
			
			System.out.println(past);
			
		}
		
		
		
	}
}

Measured memory_bytes: 22740
import math

#(a,b)(c,d)(e,f)の3点で考える


#同一の点が存在するかの判定(存在する→True/しない→False)
def exist_same_point(a,b,c,d,e,f):
    
    return (a,b)==(c,d) or (c,d)==(e,f) or (e,f)==(a,b)



#3点が一直線上にあるかの判定(ある→True/無い→False)
def three_points_on_a_line(a,b,c,d,e,f):

    dx1 = a-c
    dy1 = b-d
    dx2 = a-e
    dy2 = b-f

    return dx2*dy1 == dx1*dy2



#三角形の外心(1直線上に3点があるor同じ点がある場合はNoneを返す)

def circumcenter(a,b,c,d,e,f):

    if exist_same_point(a,b,c,d,e,f) or three_points_on_a_line(a,b,c,d,e,f):
        return None,None,None

    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f

    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

    r = math.hypot(px - a, py - b)

    return px,py,r


def in_c(x,y,r):

    for i in range(N):

        if math.hypot(x-xy[i][0],y-xy[i][1]) > r+10**(-6):
            return False

    return True


N = int(input())

xy = []
ans = float("inf")

for i in range(N):
    x,y = map(int,input().split())
    xy.append([x,y])

for i in range(N):
    for j in range(i):

        nx = (xy[i][0] + xy[j][0]) / 2
        ny = (xy[i][1] + xy[j][1]) / 2
        nr = math.hypot(xy[i][0] - xy[j][0],xy[i][1] - xy[j][1]) / 2

        if in_c(nx,ny,nr):
            ans = min(ans,nr)

for i in range(N):
    for j in range(i):
        for k in range(j):

            nx,ny,nr = circumcenter(xy[i][0],xy[i][1],xy[j][0],xy[j][1],xy[k][0],xy[k][1])
            if nx != None and in_c(nx,ny,nr):
                ans = min(ans,nr)

print (ans)

Measured memory_bytes: 51416
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int N;
		cin >> N;

		vector<int> L( N );
		for( int i = 0; i < N; ++i ) { cin >> L[i]; }
		sort( L.begin(), L.end() );

		int ans = 0;
		for( int i = 0; i < N; ++i ) {
			for( int j = i+1; j < N; ++j ) {
				if( L[i] == L[j] ) { continue; }
				for( int k = j+1; k < N; ++k ) {
					if( L[j] == L[k] ) { continue; }

					if( L[i] + L[j] > L[k] ) {
						ans += 1;
					}
				}
			}
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3580
K = int(input())

lunlun = [1,2,3,4,5,6,7,8,9]
p = 0

def lunlun_generator(now_lunlun):
    last = now_lunlun%10
    if last-1>=0:
        yield 10*now_lunlun+last-1
    yield 10*now_lunlun+last
    if last+1<=9:
        yield 10*now_lunlun+last+1 

while 1:
    for new_lunlun in lunlun_generator(lunlun[p]):
       lunlun.append(new_lunlun)

    p += 1
    if p == K:
        break

print(lunlun[p-1])




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


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

  int sum=0;
  for(int i=1;i<=n;i++){
        if(i%3==0 and i%5 ==0){

        }else if(i%3 ==0){

        }else if(i%5==0){

        }else{
        	sum+=i;
        }
  }

  cout<<sum<<endl;

	return 0;
}



Measured memory_bytes: 3632
from collections import deque

N, M = map(int, input().split())
graph = [[] for i in range(3*N)]
for i in range(M):
  u, v = map(int, input().split())
  u -= 1; v -= 1
  graph[3*u].append(3*v+1)
  graph[3*u+1].append(3*v+2)
  graph[3*u+2].append(3*v)

S, T = map(int, input().split())
S -= 1; T -= 1
dist = [-1] * (3*N)
dist[3*S] = 0
d = deque([3*S])
while d:
  node = d.popleft()
  children = graph[node]
  for child in children:
    if dist[child] < 0:
      dist[child] = dist[node] + 1
      d.append(child)

if dist[3*T] > 0:
  print(dist[3*T] // 3)
else:
  print(-1)

Measured memory_bytes: 60100