akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define bp __builtin_popcount
#define vi vector<int>
#define cr const reg&
using namespace std;
const int mod = 998244353, N = 1e6 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

I int pow_mod(reg a, reg k) {reg ans = 1; for(; k; k >>= 1, a = (LL)a * a % mod) if(k & 1) ans = (LL)ans * a % mod; return ans;}

int main() {
	reg a = read(), c = read(), b = read(), d = read(), k = read();
	reg sum = 0, o = 1;
	if(a < b || (a == b && c < d));
	else o = -1, swap(a, b), swap(c, d), sum -= 24 * 60;
	if(c <= d) {
		sum += (b - a) * (60);
		sum += d - c;
	} else {
		sum += (b - a - 1) * 60;
		sum += 60 + d - c;
	} sum *= o;
	pr2(sum - k);
	return 0;
}




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

int main() {
  string s,t; cin >> s >> t;
  int S=s.size(), T=t.size();
  int dp[S+1][T+1];
  memset(dp, 0, sizeof(dp));

  REP(i,S) REP(j,T) {
    dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
    if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
  }

  int i=S,j=T;
  string ans;
  while (i>0 && j>0) {
    if(dp[i][j] == dp[i-1][j]) i--;
    else if (dp[i][j] == dp[i][j-1]) j--;
    else {
      i--; j--; ans.push_back(s[i]);
    }
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    int max=1;
    int ans=n;
    for(int i=0;i<n;i++){
        if(a[i]==max){
            max++;
            ans--;
        }
    }
    if(ans==n)ans=-1;
    cout << ans;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	if N%10 == 3 {
		fmt.Println("bon")
	} else if N%10==0 || N%10==1 || N%10==6 || N%10==8{
		fmt.Println("pon")
	} else {
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1752
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

double N, K;

int main() {
  cin >> N >> K;
  int ans = K;
  ans *= pow(K - 1, N - 1);
  cout << ans << endl;
}


Measured memory_bytes: 4144
import math
N, K = map(int,input().split())
if  K == 1:
    print(1)
elif K > N:
    ANS = 0
    for i in range(1,N+1):
        ANS += 1/(N*(2**(int(math.log2((K-1)/i)) + 1)))
    print(ANS)
else:
    ANS =(N-K+1)/N
    for i in range(1,K):
        ANS += 1/(N*(2**(int(math.log2((K-1)/i)) + 1)))
    print(ANS)

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

int main() {
	int n,x;
	cin >> n;
	int count = 0;
	for(int i=0; i<n; i++){
		cin >> x;
		if(x == 2 || x == 3){
			count++;
			continue;
		}
		if(x%2 == 0)
			continue;
		int sq = static_cast<int>(sqrt(x));
		bool flag = false;
		for(int a=3; a <= sq; a+=2){
			if(x%a == 0){
				flag = true;
				break;
			}
		}
		if(!flag){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3108
import java.util.*

fun main(args:Array<String>) {
    val scanner= Scanner(System.`in`)
    val n = scanner.nextLong()
    var ae=LongArray(5)
    for (i in 0 until 5){
        ae[i]=scanner.nextLong()
    }
    val m=ae.min()!!
    var x=n/m
    if (n%m!=0L) x++
    println(4+x)
}


Measured memory_bytes: 35952
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below

void solve(){
	int n,k;
    cin>>n>>k;
    vi arr(n),dp(n);
    FOR(i,n)
        cin>>arr[i];
    // fill the base cases for last k array
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--){
        int Min=INT_MAX;
        int count=0;
        // int bound=i+1+min(k,n-i);
        for(int j=i+1;j<n and count<k;j++){
            Min=min(Min,dp[j]+abs(arr[i]-arr[j]));
            count++;
        }
        // dp[i]=min(dp[i+1]+abs(arr[i]-arr[i+1]),dp[i+2]+abs(arr[i]-arr[i+2]));
        dp[i]=Min;
    }

    // for(int d:dp)
    //     cout<<d<<" ";
    // cout<<endl;
    cout<<dp[0]<<endl;
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n;
    cin >> n;
    vector<int> p(n);
    rep (i, n) {
        cin >> p[i];
        p[i]--;
    }

    int ans = 0;
    rep (i, n - 1) {
        if (p[i] == i) {
            ans++;
            swap(p[i], p[i + 1]);
            i++;
        }
    }
    if (p[n - 1] == n - 1) ans++;

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int v[32]={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 k;cin>>k;
  cout<<v[k-1]<<endl;
  return 0;
}


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

int main() {
  int N, a,b,c,d;
  cin >> N ;
  a = N / 1000 ;
  b = (N - a*1000) /100 ;
  c =(N - a*1000 -b*100) /10;
  d = N -a*1000 -b*100 - c*10;
  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
s = gets.chomp
data1 = s[0..1].to_i
data2 = s[2..3].to_i

mmyy = (1 <= data1 && data1 <= 12)
yymm = (1 <= data2 && data2 <= 12)

if yymm && mmyy
  puts "AMBIGUOUS"
elsif yymm
  puts "YYMM"
elsif mmyy
  puts "MMYY"
else
  puts "NA"
end

Measured memory_bytes: 3836
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
	ll out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
const int K = 62, N = 200 + 10;
ll a[N], b[K];
char buf[N];
int n;
bool ins(ll x)
{
	for (int i = K - 1; i >= 0; --i)
		if (x >> i & 1LL)
		{
			if (!b[i])
			{
				b[i] = x;
				return true;
			}
			x ^= b[i];
		}
	return false;
}
bool solve()
{
	n = read();
	for (int i = 1; i <= n; ++i)
		a[i] = read();
	memset(b, 0, sizeof b);
	scanf("%s", buf + 1);
	for (int i = n; i >= 1; --i)
		if (buf[i] == '0')
			ins(a[i]);
		else
		{
			bool f = ins(a[i]);
			if (f)
				return true;
		}
	return false;
}
int main()
{
	int T = read();
	while (T--)
		puts(solve() ? "1" : "0");
	return 0;
}


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

int main()
{
    char s[101], t[101], rez[201];
    int n;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i)
    {
        strcpy(rez + 2 * i, s + i);
        strcpy(rez + 2 * i + 1, t + i);
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		String[] split = s.split(" ");

		if (split[1].equals("+")) {
			System.out.println(Integer.parseInt(split[0]) + Integer.parseInt(split[2]));
		} else {
			System.out.println(Integer.parseInt(split[0]) - Integer.parseInt(split[2]));
		}

		return;
	}
}

Measured memory_bytes: 23764
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		pii good[3], bad[3];
		fill_n(good, 2, pii(10003600, 0));
		fill_n(bad, 2, pii(-10000000, 0));
		
		rep(i, n){
			pii team(0, 0);
			scanf("%d", &team.second);
			rep(j, 4){
				int m, s;
				scanf("%d%d", &m, &s);
				team.first += m * 60 + s;
			}
			good[2] = team;
			sort(good, good+3);
			bad[2] = team;
			sort(bad, bad+3, greater<pii>());
		}
		
		printf("%d\n", good[0].second);
		printf("%d\n", good[1].second);
		printf("%d\n", bad[1].second);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

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

    if (A > B)
        cout << A * 2 - 1;
    else if (A < B)
        cout << B * 2 - 1;
    else if (A == B)
        cout << A + B;

    return 0;
}

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

int main() {
    int N,M;
    cin >> N >> M;
    priority_queue<int> q;
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        q.push(A);
    }
    
    for (int i = 0; i < M; i++) {
        A = q.top();
        q.pop();
        q.push(A/2);
    }
    
    long long ans = 0;
    while (q.size() > 0) {
        ans += q.top();
        q.pop();
    }
    
    cout << ans;
}

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

const int mo=int(1e9+7);
struct matrix{int a[3][3];}A,B,C,_,ans;
int n,m,x[100010];

void mul(matrix &a,matrix &b)
{
	for (int i=0; i<3; i++)
		for (int j=0; j<3; j++)
			{
				_.a[i][j]=0;
				for (int k=0; k<3; k++)
					_.a[i][j]=(_.a[i][j]+1LL*a.a[i][k]*b.a[k][j])%mo;
			}
	a=_;
}

void pow(int b)
{
	C=A;
	while (b)
		{
			if (b&1)  mul(ans,C);
			mul(C,C),b>>=1;
		}
}

void work()
{
	scanf("%d %d",&n,&m);
	for (int i=1; i<=m; i++)  scanf("%d",&x[i]);
	x[m+1]=n-x[m]-1;
	for (int i=m; i; i--)  x[i]=x[i]-x[i-1]-1;
	ans=(matrix){{{1,2,1},{0,0,0},{0,0,0}}};
	A=(matrix){{{1,2,1},{0,1,1},{1,2,2}}};
	B=(matrix){{{1,2,1},{0,1,1},{0,0,1}}};
	for (int i=1; i<=m; i++)
		pow(x[i]),mul(ans,B);
	pow(x[m+1]);
	printf("%d",ans.a[0][2]);
}

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


Measured memory_bytes: 640
//
// Created on 2020/06/27.
//

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

int main() {
    int n;
    cin>>n;
    ll ans = 0;
    vector<ll>yakusu(n+1,0);
    for (ll i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i){
            yakusu[j] ++;
        }
    }
    for (ll k = 1; k <= n; ++k) {
        ans += k * yakusu[k];
    }
    cout<<ans<<endl;
    return 0;
}



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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<61)

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

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N;
  vector<int> P;

  cin >> N;
  P.resize(N);

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

  int ans = 0;
  rep(i, N) {
    if (P[i] != i) continue;

    ans++;

    if (i == 0) {
      swap(P[i], P[i+1]);
      continue;
    }

    if (i == N - 1) {
      swap(P[i], P[i-1]);
      continue;
    }

    if (P[i+1] > i) swap(P[i], P[i+1]);
    else swap(P[i], P[i-1]);
  }

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


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

int n,m, s = 0;
long long res = 0;
unordered_map<int, long long> a;

int main(){
	cin >> n >> m;
	a[0] = 1;
	for (int i=1; i<=n; ++i){
		int tmp;
		cin >> tmp;
		s = (s+tmp)%m;
		if (a.find(s) == a.end()){
			a[s] = 1;
		}
		else{
			res += a[s];
			a[s]++;
		}
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3596
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define next(P, i) P[(i+1) % P.size()]

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_point_on_line(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
         (dot(b-a, c-a) > -EPS) &&
         (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}

int contain(point p, vector<point> ps){
  point a(p.x,p.y),b(1000000,p.y);

  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<ps.size();i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(a.y<=ymn||a.y>=ymx)return 0;

  int cnt1=0;
  for(int i=0;i<ps.size();i++)
    if(is_point_on_line(a,b,ps[i]))cnt1++;
  
  int cnt=0;
  for(int i=0;i<ps.size();i++)
    if(is_intersected_ls(ps[i],next(ps,i),a,b))cnt++;

  return (cnt-cnt1)%2;
}

int crossPol(vector<point> pol1, vector<point> pol2){
  
  for(int i=0;i<pol1.size();i++)
    if(contain(pol1[i],pol2))return 1;
  
  for(int i=0;i<pol2.size();i++)
    if(contain(pol2[i],pol1))return 1;
  
  for(int i=0;i<pol1.size();i++)
    for(int j=0;j<pol2.size();j++)
      if(is_intersected_ls(pol1[i],next(pol1,i),pol2[j],next(pol2,j)))return 1;
  
  return 0;
}

vector<point>convex_hull(point* ps, int n){
  sort(ps,ps+n,cmp_x);
  int k=0;
  vector<point>qs(n*2);
 
  for(int i=0;i<n;i++){
    while(k>1&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
 
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}

int main(void){
  int n,m;
  point black[100],white[100];

  while(cin >> n >> m,n|m){

    for(int i=0;i<n;i++)
      cin >> black[i].x >> black[i].y;
    
    for(int i=0;i<m;i++)
      cin >> white[i].x >> white[i].y;

    if(n<2||m<2){
      if(n<2 && m<2)cout << "YES" << endl;
      else {
	bool fg=false;
	for(int i=0;i<n;i++){
	  for(int j=0;j<m;j++){
	    if(is_intersected_ls(black[i],black[(i+1)%n],white[j],white[(j+1)%n]))fg=true;
	  }
	}
	if(fg)cout <<"NO"<<endl;
	else cout << "YES" << endl;
      }
      continue;
    }

    vector<point>Black,White;

    Black=convex_hull(black,n);
    White=convex_hull(white,m);
    
    if(crossPol(Black,White))cout << "NO" << endl;
    else cout << "YES" << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
program main
  implicit none
  integer :: A(5),ind(5)
  integer :: i
  integer :: i1,i2,i3,i4,i5
  integer :: tmin,tmp
  do i = 1,5
     read(*,*) A(i)
  end do
  tmin = sum(A) + 60
  do i1 = 1,5
     do i2 = 1,5
        if ( i2 == i1 ) cycle
        do i3 = 1,5
           if ( i3 == i2 .or. i3 == i1 ) cycle
           do i4= 1,5
              if ( i4 == i3 .or. i4 == i2 .or. i4 == i1 ) cycle
              do i5= 1,5
                 if ( i5 == i4 .or. i5 == i3 .or. i5 == i2 .or. i5 == i1 ) cycle
                 ind=(/i1,i2,i3,i4,i5/)
                 call tmesure(tmp,ind)
                 if (tmp < tmin) tmin = tmp
              end do
           end do
        end do
     end do
  end do
  write(*,'(i0)') tmin
  stop
contains

  subroutine tmesure(t,ind)
    integer,intent(out) :: t
    integer,intent(in) :: ind(5)
    t=0
    do i = 1,5
       if ( mod(t,10) /=0 ) t = t+10-mod(t,10)
       t = t+A(ind(i))
    end do
  end subroutine tmesure
end program main


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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> S(8);
    for (int i=0;i<8;++i) cin >> S[i];
    int seq=0;
    for (int t=0;;++t){
        if (seq==2) break;
        int M=0,sx,sy;
        for (int i=0;i<8;++i){
            for (int j=0;j<8;++j){
                if (S[i][j]!='.') continue;
                int cnt=0;
                for (int k=0;k<8;++k){
                    int x=i+dx[k],y=j+dy[k],cnt0=0;
                    while(0<=x&&x<8&&0<=y&&y<8&&S[x][y]==(t&1?'o':'x')){
                        ++cnt0; x+=dx[k],y+=dy[k];
                    }
                    if (0<=x&&x<8&&0<=y&&y<8&&S[x][y]==(t&1?'x':'o')) cnt+=cnt0;
                }
                if (M<cnt) M=cnt,sx=i,sy=j;
                else if ((t&1)&&M==cnt) sx=i,sy=j;
            }
        }
        if (!M){++seq; continue;}
        seq=0;
        S[sx][sy]=(t&1?'x':'o');
        for (int k=0;k<8;++k){
            int x=sx+dx[k],y=sy+dy[k];
            while(0<=x&&x<8&&0<=y&&y<8&&S[x][y]==(t&1?'o':'x')){
                x+=dx[k],y+=dy[k];
            }
            if (0<=x&&x<8&&0<=y&&y<8&&S[x][y]==(t&1?'x':'o')){
                while(x!=sx||y!=sy){
                    x-=dx[k],y-=dy[k];
                    S[x][y]=(t&1?'x':'o');
                }
            }
        }
    }
    for (int i=0;i<8;++i) cout << S[i] << '\n';
}


Measured memory_bytes: 3252
#include <stdio.h>

int main() {
  int x,a,b,c;
  scanf("%d %d %d %d",&a,&b,&c,&x);
  int i,j,k;
  int p = 0;
  for (i=0;i<a+1;i++) {
    for (j=0;j<b+1;j++) {
      for (k=0;k<c+1;k++) {
        if(500*i+100*j+50*k==x) {
          p++;
        }
      }
    }
  }
  printf("%d\n",p);
  return 0;
}


Measured memory_bytes: 128
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

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

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

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()

	maxk := (N - 1) * (N - 2) / 2
	maxm := N * (N - 1) / 2

	if maxk < K {
		out(-1)
		return
	}

	m := maxm - K
	fmt.Println(m)
	cnt := 0
	for i := 1; i <= N; i++ {
		for j := i + 1; j <= N; j++ {
			if cnt < K && j != N {
				cnt++
				continue
			}
			fmt.Println(i, j)
		}

	}

}


Measured memory_bytes: 1852
#include <string>/*{{{*/
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#define FOR(i, b, e) for (typeof(b) i = (b); i != (e); ++i)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;/*}}}*/

int main(int argc, char const* argv[])
{
	int N;
	cin >> N;
	FOR(tt, 0, N) {
		string str;

		cin >> str;
		int a = 0;
		int buf = 1;
		FOR(i, 0, str.length()) {
			switch (str[i]) {
				case 'm':
					a += buf * 1000;
					buf = 1;
					break;
				case 'c':
					a += buf * 100;
					buf = 1;
					break;
				case 'x':
					a += buf * 10;
					buf = 1;
					break;
				case 'i':
					a += buf * 1;
					buf = 1;
					break;
				default:
					buf = str[i] - '0';
					break;
			}
		}
		int b = 0;
		buf = 1;
		cin >> str;
		FOR(i, 0, str.length()) {
			switch (str[i]) {
				case 'm':
					b += buf * 1000;
					buf = 1;
					break;
				case 'c':
					b += buf * 100;
					buf = 1;
					break;
				case 'x':
					b += buf * 10;
					buf = 1;
					break;
				case 'i':
					b += buf * 1;
					buf = 1;
					break;
				default:
					buf = str[i] - '0';
					break;
			}
		}
		int ans = a + b;
		if (ans / 1000) {
			if (ans / 1000 > 1) {
				cout << ans / 1000;
			}
			cout << 'm';
		}
		ans %= 1000;
		if (ans / 100) {
			if (ans / 100 > 1) {
				cout << ans / 100;
			}
			cout << 'c';
		}
		ans %= 100;
		if (ans / 10) {
			if (ans / 10 > 1) {
				cout << ans / 10;
			}
			cout << 'x';
		}
		ans %= 10;
		if (ans) {
			if (ans > 1) {
				cout << ans;
			}
			cout << 'i';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
H = list(map(int,input().split()))
step = 0
answer = 0
for i in range(N-1):
    if H[i]>=H[i+1]:
        step += 1
    if H[i]<H[i+1] or i==N-2:
        answer = max(answer,step)
        step = 0
print(answer)

Measured memory_bytes: 85384
#include<stdio.h>
int main(void){
	int N,i,j,k,sum=0;
	int a[100]={0};
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<N-1;i++){
		for(j=i+1;j<N;j++){
			if(a[i]>a[j]){
				k=a[i];
				a[i]=a[j];
				a[j]=k;
			}
		}
	}
	for(i=0;i<N;i++){
		if(a[i]==a[i+1]){
			continue;
		}else{
			sum++;
		}
	}
	printf("%d\n",sum);
	
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n,k;
	cin>>n>>k;
	vector<string> vs(n);
	rep(i,n)cin>>vs[i];
	
	
	int mp[30]={};
	rep(i,n){
		mp[vs[i][0]-'A']++;
	}
	
	vector<int> num;
	rep(i,30){
		if(mp[i]!=0)num.pb(mp[i]);
	}
	
	int ans=0;
	while(1){
		sort(all(num),greater<int>());
		rep(i,k){
			if(num[i]==0)goto end;
			num[i]--;
		}
		ans++;
	}
end:;
	cout<<ans<<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define pb push_back
#define pf push_front
#define ft first
#define sc second
#define all(v) v.begin(), v.end()
using namespace std;
const int maxn = 201001;
signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int k, n;
    cin >> k >> n;
    vector<int> mas(n, 0);
    for (int d = 0; d < n; d++) {
        cin >> mas[d];
    }
    int ans = mas.back() - mas[0];
    for (int d = 1; d < n; d++) {
        int ans1 = mas.back() - mas[d] + k + mas[d - 1] - mas.back();\
        //cout << ans1 << "\n";
        ans = min(ans, ans1);
    }
    cout << ans;
}


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

const int MOD = 1e9 + 7;
const int MAXN = 2e5;
int N;
int cnt[MAXN];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		cnt[a]++;
	}

	for (int i = 0; i < N; i++) {
		int v = abs(i - (N-1-i));
		if (cnt[v] != 2 - (v == 0)) {
			cout << 0 <<endl;
          	return 0;
		}
	}

	int ans = 1;
	for (int i = 0; i < N/2; i++) {
		ans = 2 * ans % MOD;
	}
	cout << ans <<endl;;

	return 0;
}

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

int main () {
  int n; cin >> n;
  vector<int64_t> a(n+1);
  for (int i=0;i<n+1;i++)
    cin >> a.at(i);
  vector<int64_t> b(n);
  for (int i=0;i<n;i++)
    cin >> b.at(i);
  int64_t ans = 0;
  for (int i=0;i<n;i++) {
    int p = min(a.at(i), b.at(i));
    ans += p;
    a.at(i) -= p;
    b.at(i) -= p;
    int q = min(a.at(i+1), b.at(i));
      ans += q;
    a.at(i+1) -= q;
    b.at(i) -= q;
  }
  cout << ans;
}

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

int main(){
    int H, W, h ,w; cin >> H >> W >> h >> w;
    if( !(H%h) && !(W%w) ) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        rep(i,H) rep(j,W){
            if( !(i%h) && !(j%w) ) cout << (h*w-1)*(-1000)-1;
            else cout << 1000;
            if(j == W) cout << endl;
            else cout << " ";
        }
    }
}

Measured memory_bytes: 3484
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int array[] = new int[N];
    for (int i=0;i<N;i++){
      array[i] = sc.nextInt();
    }
    boolean possible = true;
    int nowarray = array[0];
    for (int i=0;i<N;i++){
      if (nowarray+1 <array[i]){
        nowarray = array[i]-1;
    }
      if (nowarray>array[i]){
        possible = false;
      }
    }
    if(possible){
     System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 51768
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = ll(1e9 + 7);

vector<ll> A;

ll solve(const int N) {
    ll twos = 1;
    ll ans = 0;
    for (int i = 0; i <= 60; i++) {
        ll one_count = 0;
        for (auto &a : A) {
            // printf("i: %d, a: %lld, %lld\n", i, a, a & (1 << i));
            if (a & (1LL << i)) {
                one_count++;
            }
        }
        ll x = ((N - one_count) * one_count) % MOD;
        x = (x * twos) % MOD;
        // cout << x << endl;
        ans = (ans + x) % MOD;
        twos = (twos * 2) % MOD;
    }
    return ans;
}

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

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
// typedef pair<int,int> P;
const int  WHITE = 0;
const int GRAY =1;
const int BLACK =2;
const int NIL = -1;
const int MAX = 100;

// 配列のサイズを大きく取りすぎるとエラーが出ないが、実行できなくなる.
vector<vector<int>> M(MAX,vector<int>(MAX,INF));
vector<int> color(MAX,WHITE), P(MAX,NIL),D(MAX,INF);
int n;


int prim(){
    int s = 0;
    int u;
    D[0]=0;
    while(1){
        int d_min = INF;
        // 線の内、始点を選ぶ
        rep(i,n){
            if(color[i]!=BLACK && D[i]<d_min){
                d_min = D[i];
                u=i;
            }
        }
        
        if(d_min==INF)break;
        color[u]=BLACK;
        // 終点を選ぶかつ、選び終えたら、Dへ最小値を保存
        rep(v,n){
            if(M[u][v]!=INF && color[v]!=BLACK){
                if(M[u][v]<D[v]){
                    D[v]=M[u][v];
                    P[v]=u;
                    color[v]=GRAY;
                    
                }
            }
        }        
    }
    int sum=0;
    rep(i,n){
        if(P[i]!=NIL)sum+=M[i][P[i]];
    }
    return sum;
}

int main(){
    cin >> n; 
    rep(i,n){
        
        rep(j,n){
          int x;
          cin >> x;
          if(x==-1)x=INF;
          M[i][j]=x;  
          
        }
    }
    printf("%d\n",prim());
    return 0;
}


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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        ds: [(i64, i64, i64); n],
    }

    for cx in 0..101 {
        for cy in 0..101 {
            let ch = {
                let (x, y, h) = *ds.iter().find(|t| t.2 > 0).unwrap();
                h + (x - cx).abs() + (y - cy).abs()
            };
            if ds
                .iter()
                .all(|&(x, y, h)| h == std::cmp::max(ch - (x - cx).abs() - (y - cy).abs(), 0))
            {
                println!("{} {} {}", cx, cy, ch);
                return;
            }
        }
    }
    panic!();
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

template<typename T>
class WUnionFind
{
	public:
	vector<T> parent;
	vector<T> dweight;
	
	WUnionFind(T n):parent(n),dweight(n)
	{
		for(int i=0;i<n;i++)
		{
			parent[i]=i;
			dweight[i]=0;
		}
	}
	
	bool unite(T a,T b,T w)
	{
		w=w+weight(a)-weight(b);

		a=root(a);
		b=root(b);
		if(a==b)return false;
		if(a>b)
		{
			swap(a,b);
			w=-w;
		}

		dweight[b]=w;
		parent[b]=a;
		return true;
	}
	
	T root(T n)
	{
		if(parent[n]==n)
			return n;
	
		T ret=root(parent[n]);
		dweight[n]+=dweight[parent[n]];
		parent[n]=ret;
		return ret;		
	}

	T weight(T n)
	{
		root(n);
		return dweight[n];
	}

	T diff(T a,T b)
	{
		return weight(b)-weight(a);
	}
};

int main()
{
	lint N,M;

	cin >> N >> M;

	WUnionFind<lint> uf(N);
	string ans="Yes";
	for(lint i=0;i<M;i++)
	{
		lint L,R,D;
		cin >> L >> R >> D;
		L--;
		R--;
		
		if(uf.root(L)!=uf.root(R))
			uf.unite(L,R,D);
		else
		{
			if(uf.diff(L,R)!=D)
			{
				ans="No";
				break;
			}
		}
	}

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


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATheNumberOfEvenPairs solver = new ATheNumberOfEvenPairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATheNumberOfEvenPairs {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            out.println((n * (n - 1) / 2) + ((m * (m - 1) / 2)));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int[][] list = new int[2][n];
        
        for (int i = 0; i < 2; i++) {
          for (int index = 0; index < n; index++) {
                list[i][index] = sc.nextInt();
             }
        }
      
        int ans = 0;
        
        for (int i = 0; i < n; i++) {
          int sum = 0;
          for (int index = 0; index < n + 1; index++) {
            int add = 0;
            if (i == 0 && index == 0) {
              add = list[0][0];
            } else {
              add = index >= i ? list[1][index - 1] : list[0][index];
            }
      
            sum += add;
          }

          if (sum > ans) {
            ans = sum;
          }
        }
        
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static int n;
    static int q;
    static char[] s;
    static char[] t;
    static char[] d;
    static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        n = sc.nextInt();
        q = sc.nextInt();
        s = sc.next().toCharArray();
        t = new char[q];
        d = new char[q];
        for (int i = 0; i < q; i++) {
            t[i] = sc.next().charAt(0);
            d[i] = sc.next().charAt(0);
        }
        int lft = bsearchl()+1;
        if(!isOkl(0)) {
            lft = 0;
        }
        int rgt = bsearchr();
        if(!isOkr(n-1)) {
            rgt = n;
        }
        int sum = lft + (n - rgt);
        System.out.println(Math.max(0, n - sum));

    }
    static int bsearchl() {
        int lft = 0;
        int rgt = n;
        int mid = 0;
        while(rgt - lft > 1) {
            mid = (lft + rgt) / 2;
            if(isOkl(mid)) {
                lft = mid;
            }
            else {
                rgt = mid;
            }
        }
        return lft;
    }

    static boolean isOkl(int index) {
        for (int i = 0; i < q; i++) {
            if(index == -1) {
                return true;
            }
            if (index == n){
                return false;
            }
            if(t[i] == s[index]) {
                if(d[i] == 'L') {
                    index--;
                }
                else {
                    index++;
                }
            }
        }
        if(index == -1) {
            return true;
        }
        return false;
    }

    static int bsearchr() {
        int lft = -1;
        int rgt = n-1;
        int mid = 0;
        while(rgt - lft > 1) {
            mid = (lft + rgt) / 2;
            if(isOkr(mid)) {
                rgt = mid;
            }
            else {
                lft = mid;
            }
        }
        return rgt;
    }

    static boolean isOkr(int index) {
        for (int i = 0; i < q; i++) {
            if(index == n) {
                return true;
            }
            if(index == -1) {
                return false;
            }
            if(t[i] == s[index]) {
                if(d[i] == 'L') {
                    index--;
                }
                else {
                    index++;
                }
            }
        }
        if(index == n) {
            return true;
        }
        return false;
    }
}



Measured memory_bytes: 66328
#include<iostream>
#include<map>

using namespace std; 

int main(){
	long long n;
	cin >> n;
	map<int,int> m;
	for( int i=0; i<n;i++){
		int a;
		cin >> a;
		m[a]++;
	}
	int ans = 0;
	int even=0;
	for(auto &&it:m){
		if(it.second%2)ans++;
		else even++;
	}
	ans+=even;
	ans-=even%2;
	cout <<  ans<<endl;
}


Measured memory_bytes: 4864
function main()
    a,b,c,d = reads(Int,Int,Int,Int)
    println(max(a*c, a*d, b*c, b*d))
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end

function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 195480
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int N , L;
    cin >> N >> L;

    vector<string> s(N);
    for(int i = 0; i < N; i++) cin >> s[i];

    sort( all(s) );
    for(int i = 0; i < N; i++){
        cout << s[i];
    }
        cout << endl;



}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,tmp;
	int tatesen,yokosen;
	int change1,change2;
	int line[30];
	
	scanf("%d",&tatesen);
	for(i=0;i<tatesen;i++)
		line[i]=i+1;
	
	scanf("%d",&yokosen);
	for(i=0;i<yokosen;i++)
	{
		scanf("%d,%d",&change1,&change2);
		tmp=line[change1-1];
		line[change1-1]=line[change2-1];
		line[change2-1]=tmp;
	}

	for(i=0;i<tatesen;i++)
		printf("%d\n",line[i]);
		
	return 0;
}

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

long long n;

long long solve();

int main() {
  cin >> n;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 100000;
  for(long long i = 1; i * i <= n; ++i)
    if(n % i == 0) {
      long long l = i, r = n / i, cntl = 0, cntr = 0;
      while(l > 0) {
        ++cntl;
        l /= 10;
      }
      while(r > 0) {
        ++cntr;
        r /= 10;
      }
      ans = min(ans, max(cntl, cntr));
    }
  return ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
lld N;
lld A[200010];
lld sum[200010];

bool solve(lld mid){
  for(int i=0;i<N;i++){
    int a = distance(sum,lower_bound(sum+i+1,sum+N+i+1,sum[i] + mid));
    if(a == N + i + 1) continue;
    int b = distance(sum,lower_bound(sum+a+1,sum+N+i+1,sum[a] + mid));
    if(b == N + i + 1) continue;
    int c = distance(sum,lower_bound(sum+b+1,sum+N+i+1,sum[b] + mid));
    if(c == N + i + 1) continue;
    return true;
  }
  return false;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[N+i] = A[i];
  }
  sum[0] = A[0];
  for(int i=1;i<2*N;i++){
    sum[i] = sum[i-1] + A[i];
  }
  lld left = 0, right = sum[2*N-1] / 3;
  while(left != right){
    lld mid = (left + right + 1) / 2;
    if(solve(mid) == true) left = mid;
    else right = mid - 1;
  }
  cout << left << endl;
}
  

Measured memory_bytes: 4284
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;
vector<PLL> as;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n);
    bool flg = true;
    ll num = 0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0)flg = false;
    }
    if(flg){
        rep(i,n){
            if(i==n-1)continue;
            as.pb(mp(i+1,i+2));
        }
    }else{
        ll max=-INF,min = INF;
        ll tpx,tpi;
        rep(i,n){
            if(chmax(max,a[i]))tpx = i;
            if(chmin(min,a[i]))tpi = i;
        }
        if(abs(max)>=abs(min)){
            rep(i,n){
                if(i==tpx)continue;
                as.pb(mp(tpx+1,i+1));
            }
            rep(i,n){
            if(i==n-1)continue;
            as.pb(mp(i+1,i+2));

        }
        }else{
            rep(i,n){
                if(i==tpi)continue;
                //cout<<tpi+1<<" "<<i+1<<endl;
                as.pb(mp(tpi+1,i+1));
            }
            for(int i=n-1;i>=0;i--){
                if(i==0)continue;
                //cout<<i+1<<" "<<i<<endl;
                as.pb(mp(i+1,i));
            }
        }
    }
    print(as.size());
    rep(i,as.size()){
        cout<<as[i].first<<" "<<as[i].second<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 256;
const int N = 1e6 + 555;


void solve()
{
	int n, d;
	cin >> n >> d;
	int a[n][d];
	rep(i, n){
		rep(j, d) cin >> a[i][j];
	}
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			ll sum = 0;
			for(int k = 0; k < d; ++k){
				sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			ll cur = sqrt(sum);
			if(cur * cur == sum) cnt++;
		}
	}
	cout << cnt;
}
int main()
{
	Red;
	solve();
	return 0;
}

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

vi gr[100100];
map<ii, int> w;
int visi[100100], ans[100100];

void dfs(int at, int color){
    visi[at] = 1;
    ans[at] = color;

    for(int l : gr[at]){
        if(!visi[l]){
            if(w[{at, l}]%2) dfs(l, color^1);
            else dfs(l, color);
        }
    }
}   

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n-1; ++i){
        int x, y, z; cin >> x >> y >> z;
        gr[x].pb(y);
        gr[y].pb(x);
        w[{x, y}] = z;
        w[{y, x}] = z;
    }
    dfs(1, 0);
    for (int i = 1; i <= n; ++i){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 23424