akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);

    string s;
    cin >> s;

    cout << (s[1] == 'B' ? "ARC" : "ABC") << "\n";

    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }

    bool flag = true;
    rep(i,N){
        if(A[i] == B[i]) continue;
        flag = false;
    }
    if(flag) cout << 0 << endl;
    else{
        ll sum = 0;
        ll rem = 10000000000;
        rep(i,N){
            sum += A[i];
            if(A[i] > B[i]) rem = min(rem,B[i]);
        }
        cout << sum - rem << endl;
    }
}

Measured memory_bytes: 3604
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func pop_count(x int) int {
	cnt := 0
	for x > 0 {
		if x&1 == 1 {
			cnt++
		}
		x = x >> 1
	}
	return cnt
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	A := make([]int, n)
	B := make([]int, n)
	C := make([]int, n)
	for i := range A {
		fmt.Fscan(read, &A[i])
		b, c := 0, 0
		for j := 0; j < A[i]; j++ {
			var x, y uint
			fmt.Fscan(read, &x, &y)
			if y == 1 {
				b |= 1 << (x - 1)
			} else {
				c |= 1 << (x - 1)
			}
		}
		B[i] = b
		C[i] = c
	}

	ans := 0
	for mask := 0; mask < (1 << uint(n)); mask++ {
		chk := true
		for i := 0; i < n; i++ {
			if (mask>>uint(i))&1 == 0 {
				continue
			}
			if mask&B[i] != B[i] || mask&C[i] != 0 {
				chk = false
			}
		}
		if chk {
			cnt := pop_count(mask)
			if cnt > ans {
				ans = cnt
			}
		}
	}
	fmt.Fprintln(write, ans)
}


Measured memory_bytes: 640
"use strict"

function Main(input) {
  const args = input.split("\n");
  const cards = args[1].split(" ").map(n => parseInt(n, 10));

  var aSum = 0;
  var bSum = 0;

  cards.sort((a, b) => (a < b ? 1 : -1)).forEach((n, i) => {
    (i % 2 === 0) ? aSum += n : bSum += n;
  });
  console.log(aSum - bSum);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin>>D;
    V<ll> c(26);
    V<ll> lst(26,1);
    cinf(26,c);
    V<P> p(26);
    set<P> st;
    ll sum=0;
    rep(i,26){
        p[i]=make_pair(c[i],i);
    }
    sort(all(p));
    ll s[D][26];
    rep(i,D){
        rep(j,26)cin>>s[i][j];
    }
    V<ll> ans(D);
    ll now=0;
    rep(i,D){
        set<P> ss;
        ll cnt=-1;
        ll res=-INF;
        rep(j,26){
            ll cc=0;
            rep(k,26){
                if(j==k) continue;
                cc+=lst[k]*c[k];
            }
            if(s[i][j]-cc>res){
                res=s[i][j]-cc;
                cnt=j;
            }
        }
        now+=res;
        ans[i]=cnt;
        lst[cnt]=1;
        rep(j,26){
            if(j!=cnt) lst[j]++;
        }
    }
    rep(i,D) cout<<ans[i]+1<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3720
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<pair<pair<int, int>, pair<int, string> > > team(n);
        for(int i=0; i<n; ++i){
            team[i].second.first = -i;
            cin >> team[i].second.second;
            for(int j=0; j<n-1; ++j){
                int a;
                cin >> a;
                if(a == 0)
                    ++ team[i].first.first;
                else if(a == 1)
                    -- team[i].first.second;
            }
        }
        sort(team.rbegin(), team.rend());

        for(int i=0; i<n; ++i)
            cout << team[i].second.second << endl;
    }
}

Measured memory_bytes: 0
#include <cstdio>

const int maxS = 2000;
const int mod = 1000000007;

int res[maxS + 1];

int main() {
  int s;
  scanf("%d", &s);
  res[0] = 1;
  for (int x = 1; x <= s; ++x) {
    res[x] = 0;
    for (int c = 3; c <= x; ++c) {
      res[x] = (res[x] + res[x - c]) % mod;
    }
  }
  printf("%d\n", res[s]);
  return 0;
}


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;
using System.IO;

namespace Hill
{
    class Program
    {
        static void Main()
        {
            var list = new List<double>();
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            string tmp;
            Console.SetOut(sw);

            while (!String.IsNullOrEmpty(tmp = Console.ReadLine()))
            {
                var str = tmp.Split(' ');
                list.Add(Math.Log10(double.Parse(str[0]) + double.Parse(str[1])));
            }

            foreach (double t in list)
            {
                Console.WriteLine((int)t + 1);
            }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 9648
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	string S;
	cin >> S;
	int a = 0;
	for(int i = 0; i <= 2; i++){
		if(S[i] == 'o'){
			a++;
		}
	}
	cout << 700 + 100 * a << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))
M=max(X)
X.remove(M)
m=min([abs(2*x-M) for x in X])
if (M+m)//2 in X:
    m=(M+m)//2
else:
    m=(M-m)//2
print(M,m)


Measured memory_bytes: 14432
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}


int main() {
  int n; cin >> n;
  vi a(n,0);
  int ans = 0;
  int now = 0;
  rep(i,n) {
    int t;cin >> t;
    a.at(i) = t-1;
  }

  rep(i,n) {
    if(a.at(i) == now) {
      now++;
      continue;
    }
    ans++;
  }

  if(ans != n) cout << ans << endl;
  else cout << -1 << endl;


  return 0;
}


Measured memory_bytes: 4060
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int L;
    scan(L);
    auto ans = (L / 3.0)^^3;
    writefln("%.12f", ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
//_Hala Madrid_//

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

typedef long long            ll;
typedef double               db;
typedef long double          ldb;
typedef vector<int>          vi;
typedef pair<int, int>       pii;
#define fio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,start,end)     for(ll i=start;i<=end;i++)
#define FORD(i,start,end)    for(ll i=start;i>=end;i--)
#define br                   cout<<"\n"
#define test(t)              int t;cin>>t;while(t--)
#define rz                   return 0
#define all(s)               s.begin(),s.end()
#define sz                   size()
#define pb                   push_back
#define F                    first
#define S                    second

const int mod=1e9+7;

void solve(){
    bool flag=0,flag1=0;
    int m,n,k,l,r,sum=0,ans=0,pos,pos1,c1=0,c2=0,c3=0,c4=0,x,y,z,cnt=0,mx=0,mn=INT_MAX;
    string s,t,s1,s2;
    string str="";
    vi v;
    cin>>n>>m;
    int h[n];
    vector <ll> dp(n+m+5,INT_MAX);
    FOR(i,0,n-1)
    cin>>h[i];
    dp[0]=0;
    FOR(i,0,n-1){
        FOR(k,1,m){
            dp[i+k]=min(dp[i+k],dp[i]+abs(h[i+k]-h[i]));
        }
    }
    cout<<dp[n-1];
}
int main(){
    fio
    bool notc=0;
    int t=1;
    if(notc){
        cin>>t;
    }
    while(t--){
        
        #ifdef _DEBUG
	        freopen("input.txt", "r", stdin);
	        freopen("output.txt", "w", stdout);
        #endif
        
        solve();
    }
    rz;    
}

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

using namespace std;

int64_t solve(const std::vector<int>& as) {
  int64_t max = 0;
  int prev_a = 0;
  for (auto const a : as) {
    if (a != prev_a) {
      prev_a = a;
      continue;
    }
    if (max) {
      return max * a;
    }
    max = a;
    prev_a = 0;
  }
  return 0;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::sort(as.rbegin(), as.rend());
  std::cout << solve(as) << std::endl;
  return 0;
}

Measured memory_bytes: 640
from bisect import bisect

a,b,q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for i in range(a)]+[INF]
t=[-INF]+[int(input()) for i in range(b)]+[INF]

for i in range(q):
  x=int(input())
  s_inx=bisect(s,x)
  t_inx=bisect(t,x)

  s_l=s[s_inx-1]
  s_r=s[s_inx]

  t_l=t[t_inx-1]
  t_r=t[t_inx]

  ans=10**18
  for i in [s_l,s_r]:
    for j in [t_l,t_r]:
      d1=abs(i-x)+abs(j-i)
      d2=abs(j-x)+abs(i-j)
      ans=min(ans,d1,d2)

  print(ans)

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

int main()
{
    int n,m, cnt=0;
    cin>>n>>m;
    string s[n+2];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(s[i][j]=='.')
            {
                cnt = 0;
                if((i!=0&&j!=0)&&(s[i-1][j-1]=='#'))
                    cnt++;
                if((i!=0)&&(s[i-1][j]=='#'))
                    cnt++;
                if((i!=0&&j!=m-1)&&(s[i-1][j+1]=='#'))
                    cnt++;
                if((j!=0)&&(s[i][j-1]=='#'))
                    cnt++;
                if((j!=m-1)&&(s[i][j+1]=='#'))
                    cnt++;
                if((i!=n-1&&j!=0)&&(s[i+1][j-1]=='#'))
                    cnt++;
                if((i!=n-1)&&(s[i+1][j]=='#'))
                    cnt++;
                if((i!=n-1&&j!=m-1)&&(s[i+1][j+1]=='#'))
                    cnt++;
                cout<<cnt;
            }
            else
                cout<<"#";
        }
        printf("\n");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2001
using namespace std;
int M[100][100],d[100],p[100];
bool vist[100]={0};
void prim(int n){
	for(int i=0;i<n;i++) d[i] = INF;
	d[0] = 0;
	p[0] = -1;
	int mincost, u;
	while(1){
		mincost = INF;
		for(int i=0;i<n;i++)
			if(!vist[i] && d[i]<mincost)
				mincost = d[i], u = i;
		if(mincost == INF) break;
		vist[u] = 1;
		for(int i=0; i<n; i++)
			if(!vist[i] && M[u][i]!=-1 && M[u][i]<d[i])
				d[i] = M[u][i],
				p[i] = u;
	}
}
int main()
{	int n; cin>>n;
	for(int i = 0;i < n;i++)
		for(int j = 0;j < n;j++)
			scanf("%d",&M[i][j]);
	prim(n);
	long long ans = 0;
	for(int i=1; i<n; i++)
		ans += M[i][p[i]];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std;
ll N = pow(10,10);
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n,k;cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++){
		ll h;cin>>h;
		arr[i] = h;
	}
	ll dp[n];
	dp[0] = 0;
	for(int i=1;i<min(n,k);i++){
		ll mini =N;
		for(int j=0;j<i;j++){
			mini = min(mini,dp[j]+abs(arr[i]-arr[j]));
		}
		dp[i] = mini;
	}
	for(int i=k;i<n;i++){
		ll mini=N;
		for(int j=i-1;j>=i-k;j--){
			mini = min(mini,dp[j]+abs(arr[i]-arr[j]));
		}
		dp[i] = mini;
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let s = sc.chars();
    let mut xs: Vec<usize> = vec![0; n];
    let mut ys: Vec<usize> = vec![0; n];
    for i in 0..n - 1 {
        xs[i + 1] = xs[i] + if s[i] == 'W' { 1 } else { 0 };
    }
    for i in (1..n).rev() {
        ys[i - 1] = ys[i] + if s[i] == 'E' { 1 } else { 0 };
    }
    // trace!(&xs);
    // trace!(&ys);
    put!((0..n).map(|i| xs[i] + ys[i]).min().unwrap());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 14588
from itertools import permutations

N, M, R = (int(i) for i in input().split())
#print(N, M, R)

r=[int(i) for i in input().split()]
#print(r)

dist=[[float('inf') for i in range(201)] for j in range(201)]
for i in range(201):
    dist[i][i] = 0

for i in range(M):
  a,b,c=(int(i) for i in input().split())
  dist[a][b]=c
  dist[b][a]=c

for k in range(200+1):
  for i in range(200+1):
      for j in range(200+1):
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])

dict0=float('inf')
mylist=list(permutations(r,len(r)))
#print(mylist)

for i in range(len(mylist)):
    tmp=0
    for j in range(len(mylist[i])-1):
        x=mylist[i][j]
        y=mylist[i][j+1]
        tmp+=dist[x][y]
    if tmp < dict0:
      dict0=tmp

print(dict0)

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

int main(){
    long n;
    cin >> n;
    long a = 1, b = 1, c = 1;
    long long ans = 0;
    while(a < n){
        while(b < n){
            if(a*b < n){
                //cout << a << " : " << b << endl;
                ans++;
            }else{
                break;
            }
            b++;
        }
        a++;
        b = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll> MAP;

  ll sum=0;
  REP(i,n){
    cin >> a[i];
    MAP[a[i]]++;
    sum += a[i];
  }
  
  ll q;
  cin >> q;

  REP(i,q){
    ll b,c;
    cin >> b >> c;
    sum += (c-b)*MAP[b];
    cout << sum << endl;

    MAP[c] += MAP[b];
    MAP[b]=0;
  }
  
}

Measured memory_bytes: 9992
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void Fairness() {
	long long A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K % 2 == 0) {
		cout << (A - B);
	}
	else {
		cout << (B - A);
	}
	//long long res = pow(-1,K) * (A - B);

	//cout << res;
}

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

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>//157B
#define ll long long
#define fixed cout.setf(ios::fixed);
#define rep1    for( i=0; i<n; i++)
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll i,j;
    double n;
    cin>>n;
    n/=3;
    fixed
    Precise
    cout<<pow(n,3)<<endl;
    return 0;
}





Measured memory_bytes: 4236
/* به نام یزدان */
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 16 + 3, MAX_MSK = (1 << 16) + 3;
long long n, a[MAX_N][MAX_N], dp[MAX_MSK];

void read_input() {
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
}

void solve() {
	for (int msk = 0; msk < 1 << n; msk++) {
		for (int u = 0; u < n; u++)
			for (int v = u + 1; v < n; v++)
				if (msk >> u & 1 && msk >> v & 1)
					dp[msk] += a[u][v];
		for (int sub = msk; sub; sub = (sub - 1) & msk)
			dp[msk] = max(dp[msk], dp[sub] + dp[msk ^ sub]);
	}
}

void print_output() {
	cout << dp[(1 << n) - 1];
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[m];
		int d[] = new int[m];

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

		for (int i = 0; i < m; i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++){
			int min = 0;
			int chkPoint =0;
			for (int j = 0; j < m; j++){
				int man = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if (j == 0){
					min = man;
					chkPoint = 0;
				} else {
					if (min > man){
						min = man;
						chkPoint = j;
					}
				}
			}
			System.out.println(chkPoint + 1);
		}
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int now = 0;
    rep(i, 0, s.size()){
        if(now == 0 && s[i] == 'C') now++;
        if(now == 1 && s[i] == 'F') now++;
    }
    cout << (now == 2 ? "Yes" : "No") << endl;
}

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

int main() {
    string s; cin >> s;
    string t;
    for (int i = 0, N=s.size(); i < N; i++)
    {
        if(s[i]!='B') t+=s[i];
        else {
            if(t.size()!=0){
                t.erase(t.size()-1);
            }
        }
    }
    cout << t << endl;
        
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int factor = scan.nextInt();
        int minDist = scan.nextInt();
        int maxDist = scan.nextInt();

        for(int i = minDist; i <= maxDist; ++i) {
            if(i % factor == 0) {
                System.out.println("OK");
                scan.close();
                return;
            }
        }
        System.out.println("NG");
        scan.close();
        return;
    }
}

Measured memory_bytes: 35608
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Amidakuji
// 2013/09/10
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int n, m;
	int[] a;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		a=new int[m];
		for(int i=0; i<m; i++){
			a[i]=sc.nextInt()-1;
		}
		solve();
	}

	void solve(){
		int[] _=new int[m];
		for(int i=0; i<m; i++){
			_[i]=i;
		}
		int min=m;
		for(;;){
			int[] b=new int[m];
			for(int i=0; i<m; i++){
				b[i]=a[_[i]];
			}
			if(Arrays.equals(f(a), f(b))){
				min=min(min, height(b));
			}
			if(!nextPermutation(_)){
				break;
			}
		}
		println(min+"");
	}

	int height(int[] a){
		int[] last=new int[n];
		for(int i : a){
			int max=last[i];
			if(i-1>=0){
				max=max(max, last[i-1]);
			}
			if(i+1<n){
				max=max(max, last[i+1]);
			}
			last[i]=max+1;
		}
		int max=0;
		for(int i : last){
			max=max(max, i);
		}
		return max;
	}

	int[] f(int[] a){
		int[] is=new int[n];
		for(int i=0; i<n; i++){
			is[i]=i;
		}
		for(int i : a){
			swap(is, i, i+1);
		}
		return is;
	}

	boolean nextPermutation(int[] is){
		int n=is.length;
		for(int i=n-1; i>0; i--){
			if(is[i-1]<is[i]){
				int j=n;
				for(; is[i-1]>=is[--j];);
				swap(is, i-1, j);
				rev(is, i, n);
				return true;
			}
		}
		rev(is, 0, n);
		return false;
	}

	void swap(int[] is, int i, int j){
		int t=is[i];
		is[i]=is[j];
		is[j]=t;
	}

	void rev(int[] is, int i, int j){
		for(j--; i<j; i++, j--)
			swap(is, i, j);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 33164
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
d = 'abcdefghij'
x = ['a']
cnt = 1

while cnt<N:
    y = []
    for i in x:
        for j in d[:len(set(i))+1]:
            y.append(i+j)
    x = y
    cnt += 1
print('\n'.join(x))

Measured memory_bytes: 61788
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    int a,b;
    string u;

    cin >> s >> t >> a >> b >> u;

    if(s == u){
        a--;
    }
    else
    {
        b--;
    }
    

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long lli;

string str;
int L;
map<lli, int> used;

lli stol(string& s){
  lli r = 1, res = 0;
  for(int i=L-1;i>=0;i--,r*=10) res += (s[i] - '0') * r;
  return res;
}

string ltos(lli n){
  string res;
  for(int i=0;i<L;i++,n/=10) res += (char)(n % 10) + '0';
  reverse(res.begin(), res.end());
  return res;
}

main(){
  while(cin >> str >> L){
    if(str == "0" && L == 0) break;
    used.clear();
    for(int i=str.size();i<L;i++) str += '0';
    int p = 0;
    used[stol(str)] = p++;
    while(1){
      lli a, b, c;
      sort(str.begin(), str.end());
      b = stol(str);
      reverse(str.begin(), str.end());
      a = stol(str);
      c = a - b;
      if(used.find(c) != used.end()){
        cout << used[c] << ' ' << c << ' ' << p - used[c] << endl;
        break;
      }
      used[c] = p++;
      str = ltos(c);
    }
  }
}

Measured memory_bytes: 1236
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);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; }


int main(){
    int n; cin >> n;
    vector<ll> X(n), Y(n), h(n);
    int si = -1;
    rep(i, n){
        cin >> X[i] >> Y[i] >> h[i];
        if(h[i] > 0) si = i;
    }

    ll res[3];
    rep(i, 101){
        rep(j, 101){
            ll H = h[si] + abs(X[si]-i) + abs(Y[si]-j);
            bool ok = true;
            rep(k, n){
                if(h[k]>0 && H-h[k] != abs(X[k]-i) + abs(Y[k]-j)) ok = false;
                if(h[k]==0 && H > abs(X[k]-i) + abs(Y[k]-j)) ok = false;
            }
            if(ok) res[0] = i, res[1] = j, res[2] = H;
        }
    }
    cout << res[0] << " " << res[1] << " " << res[2] << ln;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    println!("{}", read::<f64>() * 2.0 * std::f64::consts::PI);
}


Measured memory_bytes: 2196
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
 	int a[100005],n,cnt;
   	   	
     	cin >> n;
     	for (int i=0; i<n; i++){     		
	 		cin >> a[i];
	 	}		
	 	sort(a,a+n);
	 	cnt = a[n/2] - a[n/2-1]; 
	    cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int x = 1, y = 1;
	for (x = 1; x <= 9; x++)
	{
		for (y = 1; y <= 9; y++)
		{
			printf("%dx%d=%d\n", x, y, x*y);
		}
	}
	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> a(3*N);
    for(int i=0;i<3*N;i++){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    ll ans =0;
    for(int i=0;i<2*N;i++){
        if(i%2 ==1){
            ans += a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

// warshall_floyd
void warshall_floyd(vvint &d, int n) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (d[j][i] == inf || d[i][k] == inf) continue;
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
}

int main() {
    int n, m; cin >> n >> m;
    vvint d(n,vint(n,inf));
    vvint data(m);
    rep(i,n) d[i][i] = 0;
    rep(i,m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        d[a][b] = d[b][a] = c;
        data[i].push_back(a);
        data[i].push_back(b);
        data[i].push_back(c);
    }
    warshall_floyd(d,n);
    int ans = 0;
    rep(i,m) {
        if (d[data[i][0]][data[i][1]] != data[i][2]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

S = str(input())
N = len(S)+1
a = [0]*N
ans = int(0)

SUMI = [0]*N
for i in range(N-1):
    SUMI[i+1] = SUMI[i] + (i+1)
#print(SUMI)

k = 1
if S[0]==">":
    k*=(-1)
cur1 = int(0)
cur2 = int(0)
for i in S:
    if k==1:
        if i=="<":
            cur1 +=1
        else:
            k*=(-1)
            cur2 +=1
    else:
        if i==">":
            cur2 +=1
        else:
            k *=(-1)
            ans +=(SUMI[max(cur1,cur2)]+SUMI[max(min(cur1,cur2)-1,0)])
            cur1=1
            cur2=0
#            print(ans)

ans += (SUMI[max(cur1,cur2)]+SUMI[max(min(cur1,cur2)-1,0)])

print(ans)

Measured memory_bytes: 51784
#include<bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define smin(x,y) ((x)=min((x),(y)))
#define smax(x,y) ((x)=max((x),(y)))
#define all(x) x.begin(),x.end()
#define CS ios_base::sync_with_stdio(false);
#define show(x) cerr << #x << " is " << x <<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi; 
int32_t main()
{
	int n; cin>>n;
	cout << 800 * n - 200 * (n/15) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,p;
  cin>>n>>p;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int dp[2][n+1];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      dp[j][i+1]+=dp[j][i];
      dp[(j+a[i])%2][i+1]+=dp[j][i];
    }
  }
  cout<<dp[p][n]<<endl;
  return 0;
}


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

using namespace std;

int main()
{
	long long N, cnt = 0, tmp, ans = 0;

	cin >> N;

	long long a1 = 1, t1 = 1, a2, t2;
	for (int i = 0; i < N; i++) {
		cin >> a2 >> t2;
		cnt = max(a1/a2 + bool(a1%a2), t1/t2 + bool(t1%t2));
		a1 = cnt*a2;
		t1 = cnt*t2;
	}

	cout << a1 + t1;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = [0]*8
c = 0
for a in A:
    if a <= 399:
        cnt[0] += 1
    elif a >= 400 and a <= 799:
        cnt[1] += 1
    elif a >= 800 and a <= 1199:
        cnt[2] += 1
    elif a >= 1200 and a <= 1599:
        cnt[3] += 1
    elif a >= 1600 and a <= 1999:
        cnt[4] += 1
    elif a >= 2000 and a <= 2399:
        cnt[5] += 1
    elif a >= 2400 and a <= 2799:
        cnt[6] += 1
    elif a >= 2800 and a <= 3199:
        cnt[7] += 1
    else:
        c += 1
        
Min = len([i for i in cnt if i != 0])
if c == 0:
    print(Min, Min)
else:
    Max = Min+c
    if Min == 0:
        print(1, Max)
    else:
        print(Min, Max)

Measured memory_bytes: 9204
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

transmitList = [A, B, C, D, E]
minTransmit = min(transmitList)

answer = 5 + N // minTransmit

if minTransmit == 1:
    answer -= 1
    
print(answer)

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

int main() {
  int n, a, b, c;
  cin >> n >> a >> b;
  c = n * a;
  cout << min(c, b)<< endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class  Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(n*a>b){
            System.out.println(b);
        }else{
            System.out.println(a*n);
        }

    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int mod=1e9+7;
int m1[4][4]={
    {1,0,0,0},
    {1,1,0,0},
    {1,0,1,0},
    {1,1,1,1}
};
int m2[4][4]={
    {2,1,1,1},
    {1,1,0,0},
    {1,0,1,0},
    {1,1,1,1}
};
struct matrix{
    LL a[4][4];
    matrix(int op=0){
        if(op==0){
            MEM(a);
            for(int i = 0;i<4;i++)a[i][i]=1;
        }
        else if(op==1){
            for(int i = 0;i<4;i++)
                for(int j=0;j<4;j++)
                    a[i][j]=m1[i][j];
        }
        else{
            for(int i = 0;i<4;i++)
                for(int j=0;j<4;j++)
                    a[i][j]=m2[i][j];
        }
    }
};
matrix operator*(const matrix &a,const matrix &b){
    matrix c;
    MEM(c.a);
    for(int i =0;i<4;i++)
        for(int j=0;j<4;j++)
            for(int k = 0;k<4;k++){
                c.a[i][j]+=a.a[i][k]*b.a[k][j]%mod;
                c.a[i][j]%=mod;
            }
    return c;
}
matrix f_pow(LL b){
    matrix res(0),temp(2);
    while(b){
        if(b&1) res= res*temp;
        temp=temp*temp;
        b>>=1;
    }
    /*for(int i = 0;i<4;i++,printf("\n"))
            for(int j =0;j<4;j++)
                printf("%d",res.a[i][j]);*/
    return res;
}
int main(){ 
    int n,m;
    scanf("%d %d",&n,&m);
    int x[100005];
    for(int i = 0;i<m;i++)
        scanf("%d",&x[i]);
    x[m]=n;
    int last=0;
    matrix res(0);
    /*for(int i = 0;i<4;i++,printf("\n"))
        for(int j =0;j<4;j++)
            printf("%d",res.a[i][j]);*/
    for(int i = 0;i<=m;i++){
        res=f_pow(x[i]-last-1)*res;
        res=matrix(1)*res;
        /*for(int i = 0;i<4;i++,printf("\n"))
            for(int j =0;j<4;j++)
                printf("%d",res.a[i][j]);*/
        last=x[i];
    }
    printf("%lld\n",res.a[3][0]);
}
/*
1 2 2 3 3 3 4
2 2 1
3 2 3
4 2 4 4 7
 
1 1
*/

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 100001
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N, K;
int A[100];
int dp[MAXN], B[MAXN];

int f(int k) {
    //printf("k = %d\n", k);
    if (B[k]) return dp[k];
    B[k] = 1;

    int &r = dp[k];
    if (k < A[0]) return r = 0;

    for (int i = 0; i < N && A[i] <= k; i++)
        if (f(k-A[i]) == 0) return r = 1;

    return r = 0;
}

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);

    dp[0] = 1;
    if (f(K)) printf("First\n");
    else printf("Second\n");

    //for (int i = 0; i <= K; i++)
        //printf("%d %d\n", i, dp[i]);
    return 0;
}


Measured memory_bytes: 5760
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		char[] tile = sc.next().toCharArray();
		int a = 0, b = 0;
		for(int i = 0; i < tile.length; i++) {
			char ch = tile[i];
			if (i % 2 == 0) {
			if (ch == '0') a++;
			else b++;
			} else {
				if (ch == '1') a++;
				else b++;			
			}
		}
		out.println(Math.min(a, b));
		
		out.close();
	}

	//2点間の距離を返す
	static double distance(int x1, int y1, int x2, int y2) {
		double w = Math.pow(x1- x2, 2);
		double h = Math.pow(y1- y2, 2);
		return Math.sqrt(w + h);
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 23636
#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;

bool flags[128][128];

int w, h;
char in[128][128];

static const int margin = 2;

class hoge {
	public:
		int x;
		int y;
		int cost;

	public:
		hoge() {x = -1; y = -1; cost = -1; };
		hoge(int X, int Y, int Cost) {
			x = X; y = Y; cost = Cost;
		}
};

bool operator<(hoge a, hoge b) {
	return a.cost > b.cost;
}

void init() {
	for(int i = 0; i < 128; i++) {
		for(int j = 0; j < 128; j++) {
			flags[i][j] = false;
		}
	}

	for(int i = 0; i < 128; i++) {
		for(int j = 0; j < 128; j++) {
			in[i][j] = '1';
		}
	}
}

bool input() {
	cin >> w >> h;
	if(!w && !h)
		return false;

	while(getchar() != '\n');
	for(int i = 0; i < h * 2 - 1; i++) {
		int j = 0;
		for(;;) {
			char c;

			c = getchar();
			if(c == '\n')
				break;

			in[margin + i][margin + j++] = c;
		}
	}

	return true;
}

int solve() {
	priority_queue<hoge> table;
	int end_x = 2 * (w - 1) + margin, end_y = 2 * (h - 1) + margin;

	table.push(hoge(margin, margin, 1));
	flags[margin][margin] = false;

	while(!table.empty()) {
		hoge tmp;
		tmp = table.top();
		table.pop();


		if(flags[tmp.y + 2][tmp.x] == false) {
			if(in[tmp.y + 1][tmp.x] == '0') {
				if(tmp.y + 2 == end_y && tmp.x == end_x) {
					return tmp.cost + 1;
				}
				table.push(hoge(tmp.x, tmp.y + 2, tmp.cost + 1));
				flags[tmp.y + 2][tmp.x] = true;
			}
		}
		if(flags[tmp.y - 2][tmp.x] == false) {
			if(in[tmp.y - 1][tmp.x] == '0') {
				if(tmp.y - 2 == end_y && tmp.x == end_x) {
					return tmp.cost + 1;
				}
				table.push(hoge(tmp.x, tmp.y - 2, tmp.cost + 1));
				flags[tmp.y - 2][tmp.x] = true;
			}
		}
		if(flags[tmp.y][tmp.x + 2] == false) {
			if(in[tmp.y][tmp.x + 1] == '0') {
				if(tmp.y == end_y && tmp.x + 2 == end_x) {
					return tmp.cost + 1;
				}
				table.push(hoge(tmp.x + 2, tmp.y, tmp.cost + 1));
				flags[tmp.y][tmp.x + 2] = true;
			}
		}
		if(flags[tmp.y][tmp.x - 2] == false) {
			if(in[tmp.y][tmp.x - 1] == '0') {
				if(tmp.y == end_y && tmp.x - 2 == end_x) {
					return tmp.cost + 1;
				}
				table.push(hoge(tmp.x - 2, tmp.y, tmp.cost + 1));
				flags[tmp.y][tmp.x - 2] = true;
			}
		}

	}

	return 0;
}

int main() {
	while(init(), input()) {
		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  vector<int>cnt(1e5+5);
  rep(i,n)cnt[a[i]]++;
  int ans=0;
  rep(i,1e5+1){
    int sum=0;
    if(i)sum+=cnt[i-1];
    sum+=cnt[i];
    sum+=cnt[i+1];
    chmax(ans,sum);
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int main() {
	int N,K;cin>>N>>K;
	map<int,int>mp;
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		mp[a]++;
	}
	vector<int>ns;
	for (auto m : mp) {
		ns.emplace_back(m.second);
	}
	sort(ns.begin(),ns.end());
	reverse(ns.begin(),ns.end());
	int ans=0;
	if (ns.size() <= K) {
		ans=0;
	}
	else {
		ans=N-accumulate(ns.begin(),ns.begin()+K,0);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10748