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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  ll n,k,cnt=0;
  cin>>n>>k;
  rep(i,k+1,n+1){

    ll num2=max(n-(n/i)*i-k+1,0LL);
    ll cnt1=(n/i)*(i-k);
    cnt+= num2+cnt1;
    if(k==0) cnt--;
   }
  cout<<cnt<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: code-festival-2017-qual-b_c / Link: https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_c?lang=en  ----- */
/* ------問題------

りんごさんは N 頂点 の連結な無向グラフを持っています。 このグラフにはすでに M 本の辺があり、i 本目の辺は頂点 Ai と頂点 Bi を繋いでいます。
りんごさんは以下の操作を行うことで、辺を追加しようと思っています。
操作：頂点 u から辺をちょうど 3 本辿ることによって頂点 v に辿り着けるような u,v(u≠v) をとり、頂点 u と頂点 v の間に辺を追加する。ただし、すでに頂点 u と頂点 v の間に辺が存在する場合は辺を追加することはできない。
りんごさんが追加できる辺の本数の最大値を求めて下さい。

-----問題ここまで----- */
/* -----解説等-----

二部グラフとそうでないときを考える。
二部グラフでないときは最終的には完全グラフになるまで辺を追加することができる。
一方二部グラフのときは辺を追加しても二部グラフのままであるから、二部グラフの頂点の色の数に対応して
追加する辺の数を決めることができる。
これは先にカウントを行い、まわりの頂点の数を差し引けば良い。

----解説ここまで---- */

LL N, M;

LL ans = 0LL;
LL black = 0;
void dfs(int v, int p, VI &color, int c, VVI &G) {
	color[v] = c;
	if (c == 0)black++;
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i];
		if (color[nx] != -1) {
			if (color[nx] == c)ans = 0;
		}
		else {
			dfs(nx, v, color, !c, G);
		}
	}
}

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

	cin >> N >> M;
	VVI G(N);
	FOR(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	VI color(N, -1);
	ans = 1;
	dfs(0, -1, color, 0, G);
	if (ans) { // 二部グラフ
		ans = 0;
		// O(V+E)

		int white = N -  black;
		FOR(i, 0, N) {

			int ret = 0;
			if (color[i] == 1) {// white
				ans += black - SZ(G[i]);
			}
			else {
				ans += white - (SZ(G[i]));
			}
		}
		ans /= 2;

	}
	else {// ではない
		ans = 0;
		FOR(i, 0, N) {
			ans += (N - 1) - SZ(G[i]);
		}
		ans /= 2;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define vll vector<ll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio;
    ll i, j, k, n, m=0;
    string s,t;

    cin>>s>>t;

    n=s.size();

    for ( i = 0; i < n; i++)
    {
        if(s[i]!=t[i])
            m++;
    }
    
    cout<<m<<endl;


        
    return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    double l;
    cin >> l;

    double a = l/3;
    double v = a*a*a;

    cout << setprecision(10) << v << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
using P = pair<i64, i64>;
vector<vector<P>> g;
vector<bool> vis;
vector<i64> ds;

bool dfs(i64 u, i64 d) {
  if (vis[u]) return ds[u] == d;
  vis[u] = true;
  ds[u] = d;
  bool ok = true;
  for (auto p : g[u]) {
    i64 v, c;
    tie(v, c) = p;
    ok &= dfs(v, d + c);
  }
  return ok;
}

int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 l, r, d;
    cin >> l >> r >> d;
    g[l].emplace_back(r, d);
    g[r].emplace_back(l, -d);
  }
  init_n(vis, n + 1);
  init_n(ds, n + 1);
  bool ok = true;
  for (i64 u = 1; u <= n; ++u) {
    if (!vis[u]) ok &= dfs(u, 0);
  }
  cout << (ok ? "Yes" : "No") << '\n';
  return 0;
}



Measured memory_bytes: 16512
lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
H = array[1].split(" ").map(&:to_i)
INF = 10**9

def cost(hi, hj)
  #puts "|#{H[hi]}-#{H[hj]}|=#{(H[hi]-H[hj]).abs}"
  ans = (H[hi]-H[hj]).abs
  ans
end

dp = Array.new(N, INF)
dp[0] = 0

for j in 1...N
  dp[j] = [ dp[j-1] + cost(j-1, j), dp[j] ].min
  dp[j] = [ dp[j-2] + cost(j-2, j), dp[j] ].min if j>1
end

puts dp[N-1]


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

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
    int n, t, d=100000;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
		d*=1.05;
		t=d;
		t/=1000;
		t*=1000;
		if(d-t>0){
			d=t+1000;
		}
		//cout<<d<<endl;
		//cout<<d-t<<endl<<endl;
	}
	cout<<d<<endl;
	
	return 0;
}

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

int main()
{
    int D[4];
    for(int i = 0; i < 4; ++i) {
        D[i] = fgetc(stdin) - '0';
    }
    for(int i = 0; i < 8; ++i) {
        int tmp = D[0];
        for(int j = 0; j < 3; ++j) {
            if(i & (1<<j)) tmp += D[j+1];
            else tmp -= D[j+1];
        }
        if(tmp == 7) {
            cout << D[0];
            for(int j = 0; j < 3; ++j) {
                if(i & (1<<j)) cout << "+";
                else cout << "-";
                cout << D[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int r, d, x;

int main(){
    cin >> r >> d >> x;
    for(int i = 0; i < 10; i++){
        cout << r * x - d << endl;
        x = r*x-d;
    }


}


//g++ -std=c++14 comp.cpp; ./a.exe


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

const long long INF=9999999999;

int main(){
  int N; cin >> N;
  int h[N];
  for(int i=0; i<N; i++) cin >> h[i];
  
  int dp[N];
  for(int i=0; i<N; i++) dp[i]=INF;
  dp[0]=0;
  
  for(int i=1; i<N; i++){
    if(i==1) dp[i]=min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
    else dp[i]=min(dp[i], min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])));
  }
  
  cout << dp[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
ループをさがす
*/
int main(){
  ll N,K; cin>>N>>K;
  vector<ll> A(N+1,0),check(N+1,0);
  vector<bool> used(N+1,false);
  for(ll i=1; i<=N; i++) cin>>A[i];
  ll next=1,fin=0;
  for(ll i=1; i<=N+1; i++){
    if(K==0) break;
    if(used[next]){
      fin=i;
      break;
    }
    used[next]=true;
    check[next]=i;
    next=A[next];
    K--;
  }
  if(K==0){
    cout<<next<<endl;
    return 0;
  }
  ll roop=0,aft=0;
  roop=fin-check[next];
  aft=K%roop;
  for(ll i=1; i<=aft; i++) next=A[next];
  cout<<next<<endl;
}


Measured memory_bytes: 6424
import queue

def check(operator_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operator_list):
        if op == '+':
            res += num_list[i + 1]
        elif op == '-':
            res -= num_list[i + 1]

    return res == 7

def concat(operator_list, num_list):
    res = str(num_list[0])
    for op, num in zip(operator_list, num_list[1:]):
        res += op
        res += str(num)

    return res + "=7"

def solve():
    line = input()
    num_list = []
    for s in line:
        num_list.append(int(s))

    q = queue.Queue()
    q.put([])
    N = len(num_list)
    while not q.empty():
        operator_list = q.get()
        # print(operator_list)
        if len(operator_list) == N - 1:
            if check(operator_list, num_list):
                return concat(operator_list, num_list)

        else:
            q.put(operator_list + [ '+' ])
            q.put(operator_list + [ '-' ])

    return "No Answer"


print(solve())


Measured memory_bytes: 4208
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]

class WeightedUnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
        self.weight = [0] * N
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            pa = self.root(self.parent[a])
            self.weight[a] += self.weight[self.parent[a]]
            self.parent[a] = pa
            return pa
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b,w):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
            self.weight[ra] = w - self.weight[a] + self.weight[b]
        else:
            self.parent[rb] = ra
            self.weight[rb] = -w - self.weight[b] + self.weight[a]
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1
    def diff(self,a,b):
        return self.weight[a] - self.weight[b]

wuf = WeightedUnionFind(N)
for l,r,d in src:
    l,r = l-1, r-1
    if wuf.is_same(l,r):
        if d != wuf.diff(l,r):
            print('No')
            exit()
    else:
        wuf.unite(l,r,d)
print('Yes')

Measured memory_bytes: 40812
#include "stdio.h"
#include "string.h"
char s[100005];

int main(){
	scanf("%s",s);
	int len = strlen(s);
	if(len%2){
		if(s[0]==s[len-1]){
			printf("Second\n");
		}else{
			printf("First\n");
		}
	}else{
		if(s[0]!=s[len-1]){
			printf("Second\n");
		}else{
			printf("First\n");
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    rrep(i, n - 1) {
        ans += i;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
function MA(h,w){return Array(h).fill(0).map(a=>Array(w).fill(0));}
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9+7;

console.log(main());
function main(){
  var n = o.a();
  var h = o.a();
  var a = o.m(n);
  a.sort((a,b)=>b[1]-a[1]);
  var m = 0;
  for(var i = 0; i < n; i++){
    if(m < a[i][0])m = a[i][0];
  }
  var ans = 0;
  for(i = 0; i < n; i++){
    if(m > a[i][1])break;
    ans++;
    h -= a[i][1];
    if(h <= 0)return ans;
  }
  return ans + Math.ceil(h / m);
}

Measured memory_bytes: 65480
class UnionFind():
  def __init__(self,n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    
    if x == y :
      return 
    
    if self.parents[x] > self.parents[y]:
      x,y = y,x
      
    self.parents[x] += self.parents[y]
    
    self.parents[y] = x
    
  def root_len(self):
    count = 0
    for i in self.parents:
      if i < 0:
        count += 1
    
    return count
    
n,m = map(int,input().split())

uf = UnionFind(n)

for i in range(m):
  x,y,z = map(int,input().split())
  
  uf.union(x-1,y-1)
  
print(uf.root_len())

Measured memory_bytes: 5368
# -*- coding: utf-8 -*-
N = int(input())
an = list(map(int, input().split()))

ave = sum(an)/len(an)

an2 = {i:abs(a-ave) for i,a in enumerate(an)}

ans,val = sorted(an2.items(), key=lambda x: x[1])[0] 

print(ans)


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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll l,r,d;
        cin>>l>>r>>d;

        ll ans=0;

        for(ll i=l;i<=r;i++)
        {
            if(i%d==0)
            ans++;
        }

        cout<<ans;
    }
}

Measured memory_bytes: 3648
K = int(input())
g = [[0 for i in range(201)] for j in range(201)]


def gcd(x, y):
    if x*y == 0:
        return x+y
    if x == y:
        return x
    elif x > y:
        return gcd(y, x)
    else:
        return gcd(y%x, x)
    
for i in range(201):
    for j in range(201):
        g[i][j] = gcd(i, j)
    
s = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            s += g[a][g[b][c]]
print(s)

Measured memory_bytes: 9524
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (4 * i + 7 * j == n) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			Deque<Character> stack = new ArrayDeque<>();
			char[] s = in.nextString().toCharArray();
			int count = 0, len = s.length;

			for (int i = len - 1; i >= 0; i--) {
				if (s[i] == 'T') {
					stack.push(s[i]);
				} else {
					if (stack.isEmpty()) {
						count++;
					} else {
						stack.pop();
					}
				}
			}

			out.println(count+stack.size());

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 24532
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string s;

    if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))
        s = "Yes";
    else
        s = "No";
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int mod = 1e9 + 7;
struct MI{
	LL a;
	MI operator + (const MI & b) {
		MI res{a + b.a};
		if(res.a >= mod) res.a -= mod;
		return res;
	}
	MI operator - (const MI & b) {
		MI res{a - b.a};
		if(res.a <= 0) res.a += mod;
		return res;
	}
	MI operator * (const MI & b) {
		return MI{a * b.a % mod};
	}
	MI operator / (const MI & b) {
		return MI{a * fastpo(b.a, mod - 2, mod) % mod};
	}
	MI(LL x) {
		a = x;
	}
	MI() {
	}
};
const int N = 5555;
const int LOG = 20;
const int inf = 1e9 + 7;
MI dp[N][N];
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) {
		if(i == 1) {
			for(int j = 1; j <= m; j++) {
				dp[i][j] = j == 1 ? 2 : dp[i][j - 1] * MI(2);
			}
			continue;
		}
		dp[i][1] = MI(2) * dp[i - 1][1];
		MI tmp = 0;
		for(int j = 2; j <= m; j++) {
			tmp = tmp * MI(2) + MI(j - 1) * dp[i - 1][j - 1];
			dp[i][j] = tmp + MI(j + 1) * dp[i - 1][j];
		}
	}
	cout << dp[n][m].a << endl;
}






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

using namespace std;

const int inf = (int) 1e9;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int n = (int) a.size();
  int a_1s = 0, b_1s = 0;
  for (auto& c : a) {
    a_1s += c - '0';
  }
  for (auto& c : b) {
    b_1s += c - '0';
  }
  if (a_1s > 0 && b_1s == 0) {
    cout << "-1\n";
    return 0;
  }
  vector<int> f_right(n, inf);
  vector<int> f_left(n, inf);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (b[(i + j) % n] == '1') {
        f_right[i] = j;
        break;
      }
    }
    for (int j = 0; j < n; j++) {
      if (b[(i - j + n) % n] == '1') {
        f_left[i] = j;
        break;
      }
    }
  }
  int ans = inf;
  for (int j = 0; j <= n; j++) {
    int res = j;
    vector<pair<int, int>> pairs;
    for (int i = 0; i < n; i++) {
      if (a[(i + j) % n] != b[i]) {
        res++;
        if (j < f_right[i]) {
          pairs.emplace_back(f_left[i], f_right[(i + j) % n]);
        }
      }      
    }        
    sort(pairs.begin(), pairs.end()); 
    vector<int> max_second((int) pairs.size());
    for (int i = (int) pairs.size() - 1; i >= 0; i--) {
      max_second[i] = max(pairs[i].second, i + 1 < (int) pairs.size() ? max_second[i + 1] : 0);
    }
    int add = inf;
    for (int i = 0; i <= (int) pairs.size(); i++) {
      add = min(add, (i == 0 ? 0 : pairs[i - 1].first) + (i < (int) pairs.size() ? max_second[i] : 0));
    }
    res += 2 * add;
    ans = min(ans, res);
  }
  for (int j = 0; j <= n; j++) {
    int res = j;
    vector<pair<int, int>> pairs;
    for (int i = 0; i < n; i++) {
      if (a[(i - j + n) % n] != b[i]) {
        res++;
        if (j < f_left[i]) {
          pairs.emplace_back(f_left[(i - j + n) % n], f_right[i]);
        }
      }      
    }
    sort(pairs.begin(), pairs.end());
    vector<int> max_second((int) pairs.size());
    for (int i = (int) pairs.size() - 1; i >= 0; i--) {
      max_second[i] = max(pairs[i].second, i + 1 < (int) pairs.size() ? max_second[i + 1] : 0);
    }
    int add = inf;
    for (int i = 0; i <= (int) pairs.size(); i++) {
      add = min(add, (i == 0 ? 0 : pairs[i - 1].first) + (i < (int) pairs.size() ? max_second[i] : 0));
    }
    res += 2 * add;
    ans = min(ans, res);
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int cnt = 0;
  for(int i=0;i<n-2;i++){
    if(p[i+1] <= p[i] && p[i+1] >= p[i+2]){
      cnt++;
    }else if(p[i+1] >= p[i] && p[i+1] <= p[i+2]){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def main():
    d = defaultdict(int)
    for _ in range(3):
        a, b = list(map(int, input().split()))
        d[a] += 1
        d[b] += 1
    if sorted(d.values()) == [1, 1, 2, 2]:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9320
N = gets.chomp.to_i
ARY = gets.chomp.split.map(&:to_i)

count = 0
0.upto(N-3) do |i|
  a = ARY.slice(i, 3)
  count +=1 if a.sort.uniq.length > 2 && ARY[i+1] == a.sort.uniq[1]
end
puts count


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
using Graph = vector<vector<int>>;

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

	Graph G(n);

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			v--;
			G[u].push_back(v);
		}
	}

	vector<int> dist(n, -1);
	queue<int> q;
	q.push(0);
	dist[0] = 0;

	while (!q.empty()) {
		int v = q.front();
		q.pop();

		for (int nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			q.push(nv);
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << dist[i] << endl;
	}

	return 0;
}



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

long long N;

pair<vector<int>, int> construct(long long val) {
  if (val == 1) {
    return make_pair(vector<int>(), 0);
  }
  pair<vector<int>, int> res;
  if (val % 2 == 0) {
    res = construct(val / 2);
    ++res.second;
    res.first.push_back(res.second);
  } else {
    res = construct(val - 1);
    ++res.second;
    res.first.insert(res.first.begin(), res.second);
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;
  ++N;
  pair<vector<int>, int> res = construct(N);
  cout << res.first.size() * 2 << endl;
  for (int x : res.first) {
    cout << x << " ";
  }
  for (int i = 1; i <= res.first.size(); ++i) {
    cout << i << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
x = int(input())
*li, = list(map(int, input().split()))

ans = 0

for i in range(x):
    for j in range(x-1):
        if li[j] > li[j+1]:
            li[j], li[j+1] = li[j+1], li[j]
            ans += 1

print(*li)
print(ans)


Measured memory_bytes: 5608
N = int(input())
a = list(map(int, input().split()))
suma = sum(a)
sunuke = a[0]
arai = suma-a[0]
mi = abs(sunuke-arai)
for i in range(1,N-1):
    sunuke += a[i]
    arai -= a[i]
    mi = min(mi,abs(sunuke-arai))
print(mi)

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

int main(){
    string S;
    cin >> S;
    deque<char> dq;
    bool normal = true;
    for(auto & s : S){
        dq.push_back(s);
    }
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        int T;
        cin >> T;
        if (T==1){
            normal = !normal;
        }else{
            int F;
            cin >> F;
            char C;
            cin >> C;
            if(F == 1){
                if(normal) dq.push_front(C);
                else dq.push_back(C);
            }else{
                if(normal) dq.push_back(C);
                else dq.push_front(C);
            }
        }
    }
    if(!normal) reverse(dq.begin(), dq.end());
    for(auto it = dq.begin();it != dq.end();it++) cout << *it;
    cout << endl;
}

Measured memory_bytes: 896
N = int(input())
R = [int(input()) for i in range(N)]

maxv = R[1] - R[0]
minv = R[0]
for i in range(1,len(R)):
    maxv = max(maxv,R[i]-minv)
    minv = min(minv,R[i])

print (maxv)

Measured memory_bytes: 15580
#include <stdio.h>

int main(void)
{
	int a, b, c, re;
	
	scanf("%d %d %d", &a, &b, &c);
	re = 0;
	
	while (a <= b){
		if (c % a == 0){
			re++;
		}
		a++;
	}
	printf("%d\n", re);
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

signed main()
{
    fast;
    long long int n = 0;
    cin >> n;
    cout << n * (n - 1) / 2;
}


Measured memory_bytes: 256
// Created by AboAbdoMC
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int M,D;
    int ans = 0;
    cin >> M >> D;
    repA(i,1,M)
    {
    	repA(j,1,D)
    	{
    		int d1 = j%10;
    		int d2 = j/10;
    		if (d1 >= 2 && d2 >= 2 && d1*d2 == i) ans++;
    	}
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define whole(v) begin(v),end(v)
#define print(c,n) for(int i=0;i<n;i++) cout << c[i] << " ";
#define MOD 1000000007
#define INF 0x3f3f3f3f
int main()
{
	
   	std::ios::sync_with_stdio(false);
	cin.tie(0);
   	int n;
   	cin >> n;
   	int64_t sol[n],s=0,a[n];
   	for(int i=0;i<n;i++){
   		cin >> a[i];
   		if(i%2==0){
   			s-=(2*a[i]);
   		}
   		else s+=(2*a[i]);
   	}
   	sol[0] = (-s)/2;
   	for(int i=1;i<n;i++){
   		sol[i] = (2*a[i-1])-sol[i-1];
   	}
   	print(sol,n);
   	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
 int main()
 {
    int a,b,c;
    int i;
    int sum;
    sum = 0;
    scanf("%d %d %d",&a,&b,&c);

    for(i=a;i<=b;i++){
        if(c%i==0){
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
 }


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

int main() {
  int n,k,q; cin>>n>>k>>q;
  vector<int> l(n,0);
  for (int i=0; i<q; i++){
    int a; cin>>a;
    a-=1;
    l[a]+=1;
  }
  for (int j=0; j<n; j++){
    cout<<(k-q+l[j]>0 ? "Yes" : "No")<<endl;
  }
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, k;

struct edge{int to, cost;};

vector<ll> dijkstra(int s, int n, vector<vector<edge>>& g){
    priority_queue<plli, vector<plli>, greater<plli>> que;
    vector<ll> d(n, LLONG_MAX/10); d[s] = 0;
    que.push(plli(0, s));

    while (!que.empty()){
        plli p = que.top();que.pop();
        int fr = p.second;
        if (d[fr] < p.first) continue;
        for (edge e: g[fr]){
            if (d[e.to] > d[fr] + e.cost){
                d[e.to] = d[fr] + e.cost;
                que.push(plli(d[e.to], e.to));
            }
        }
    }
    return d;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        cin >> n >> k;
        if (n == 0) break;
        vector<vector<edge>> g(100 + 5);
        rep(i, k) {
            int  a, b, c, d, e, com;
            cin >> com;
            if (com == 0) {
                cin >> a >> b;
                a--; b--;
                vector<ll> dist = dijkstra(a, n, g);
                if (dist[b] == LLONG_MAX / 10) cout << -1 << endl;
                else cout << dist[b] << endl;
            }
            else {
                cin >> c >> d >> e;
                c--; d--;
                g[c].push_back(edge{d, e});
                g[d].push_back(edge{c, e});
            }
        }
    }
}

Measured memory_bytes: 3172
import sys
input=sys.stdin.readline
n,q=map(int,input().split())

def unite(x,y):
	rx=root(x);ry=root(y)
	if rank[rx]>rank[ry]:
		parent[ry]=rx
		size[rx]+=size[ry]
	else:
		parent[rx]=ry
		size[ry]+=size[rx]
		if rank[rx]==rank[ry]:
			rank[ry]+=1
def root(x):
	if x!=parent[x]:
		return root(parent[x])
	return x
def same(x,y):
	return root(x)==root(y)
parent=list(range(n))
rank=[0]*n
size=[1]*n

for i in range(q):
	t,a,b=map(int,input().split())
	if t==0:
		unite(a-1,b-1)
	else:
		print(int(same(a-1,b-1)))

Measured memory_bytes: 20060
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S,T;

  ll r= 0;
  REP(i, S.length()) {
    if (S[i] !=T[i]) r++;
  }

  return r;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3884
#include <stdio.h>

int main( void )
{
	int line_num, column_num, line_cou, column_cou;
	int matrix_A[100][100] = {};
	int matrix_B[100] = {};
	int product[100] = {};
	
	line_num = 0;
	column_num = 0;
	
	scanf( "%d %d", &line_num, &column_num );
	
	for( line_cou = 0; line_cou < line_num; line_cou++ )
	{
		for( column_cou = 0; column_cou < column_num; column_cou++ )
		{
			scanf( "%d", &matrix_A[line_cou][column_cou] );
		}
	}
	
	for( column_cou = 0; column_cou < column_num; column_cou++ )
	{
		scanf( "%d", &matrix_B[column_cou] );
	}
	
	for( line_cou = 0; line_cou < line_num; line_cou++ )
	{
		for( column_cou = 0; column_cou < column_num; column_cou++ )
		{
			product[line_cou] += matrix_A[line_cou][column_cou] * matrix_B[column_cou];
		}
	}
	
	for( line_cou = 0; line_cou < line_num; line_cou++ )
	{
		printf( "%d\n", product[line_cou] );
	}
	
	return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
int main(void){
	int a,counta,n[10000],p,o,t,min;
	double max, sum;
	scanf("%d", &a);
	for (counta = 1; counta <= a; counta++){
		scanf("%d", &n[counta]);
	}
	//min
	for (t = 0; a - t > 1; t++){
		if (n[a - (t + 1)] > n[a - t]){
			o = n[a - (t + 1)];
			p = n[a - t];
			n[a - (t + 1)] = p;
			n[a - t] = o;
		}
	}
	min = n[1];
	//max
	for (t = 0; a - t > 1; t++){
		if (n[a - (t + 1)] < n[a - t]){
			o = n[a - (t + 1)];
			p = n[a - t];
			n[a - (t + 1)] = p;
			n[a - t] = o;
		}
	}
	max = n[1];
	//sum
	counta = 0;
	sum = 0;
	for (counta = 1; counta <= a; counta++){
		sum = sum + n[counta];
	}
	printf("%d %.0f %.0f\n", min,max,sum);
return 0;
}

Measured memory_bytes: 672
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, K, C = [int(x) for x in input().strip().split()]
S = [i == 'o' for i in list(input().strip())]

a = [0] * K
b = [2 * 10 ** 5] * K
c = 0
k = 0
for i, s in enumerate(S, start=1):
    if c > 0:
        c -= 1
        continue
    if s:
        a[k] = i
        k += 1
        c = C
    if k == K:
        break

c = 0
k = 0
for i, s in enumerate(S[::-1], start=1):
    if c > 0:
        c -= 1
        continue
    if s:
        b[K-k-1] = N-i+1
        k += 1
        c = C
    if k == K:
        break

for aa, bb in zip(a, b):
    if aa == bb:
        print(aa)

Measured memory_bytes: 23252
import java.util.*;

public class Main{
  static int p = 1000000007;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int M = Integer.parseInt(S[1]);
    int n = 0;
    if(N == 1){
      n = 10;
    }else if(N == 2){
      n = 100;
    }else{
      n = 1000;
    }
    
    char[][] val = new char[M][2];
    for(int i = 0; i < M; i++){
      S = sc.nextLine().split(" ");
      val[i][0] = S[0].charAt(0);
      val[i][1] = S[1].charAt(0);
    }
    int st = n/10;
    if(st == 1) st = 0;
    for(int i = st; i < n; i++){
      String s = i+"";
      boolean f = true;
      for(int j = 0; j < M; j++){
        int m = val[j][0]- '0' - 1;
        if(m >= s.length()) continue;
        char c = s.charAt(m);
        if(c != val[j][1]){
          f = false;
          break;
        }
      }
      if(f){
        System.out.println(i);
        return;
      }
    }
    System.out.println(-1);
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int n, ans, G[300][300][4];
int mv[4][2] = { { -1,0 },{ 0,-1 },{ -1,-1 },{ -1,1 } };
signed main(void) {
	while (scanf("%d", &n) && n) {
		memset(G, 0, sizeof(G)), ans = 0; getchar();
		for (int i = 1; i <= n; i++, getchar())
			for (int j = 1; j <= n; j++) if (getchar()-'0')
				for (int k = 0; k < 4; k++)
					G[i][j][k] = G[i + mv[k][0]][j + mv[k][1]][k] + 1,
					ans = ans < G[i][j][k] ? G[i][j][k] : ans;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 2608
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

(|>) :: a -> (a -> b) -> b
infixl 1 |>
x |> f = f x

($>) :: (Functor m) => m a -> (a -> b) -> m b
infixl 1 $>
x $> f = fmap f x

bsToInt :: BC.ByteString -> Int
bsToInt bs = bs |> BC.readInt |> fromJust |> fst
 
getInt :: IO Int
getInt = BC.getLine $> bsToInt
 
getInts :: IO [Int]
getInts = BC.getLine $> BC.words $> map bsToInt

calc :: [Int] -> Int
calc xs
    | len >= num = len - num
    | otherwise  = len
    where len = length xs
          num = head xs
 
main = do
    getLine
    xs <- getInts
    xs |> sort |> group |> map calc |> sum |> print

    

Measured memory_bytes: 16764
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <algorithm>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
string s,t;
int a,b;
string u;
int main(){
	cin>>s>>t>>a>>b>>u;
	if(u==s)a--;
	if(u==t)b--;
	cout<<a<<' '<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let (n,s) : (i32,String)= {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().to_string()
        )
    };

    println!("{}", s.matches("ABC").collect::<Vec<&str>>().len());
}


Measured memory_bytes: 4476
#include<stdio.h>
int main(void){
    int a,b;
    char op;
    while(scanf("%d %c %d",&a,&op,&b)!=EOF){
        switch(op){
            case '?':{
            break;
            break;
            } 
            case '+':{
            printf("%d\n",a+b);
            break;
            }
            case '-':{
            printf("%d\n",a-b);
            break;
            }
            case '*':{
            printf("%d\n",a*b);
            break;
            }
            case '/':{
            printf("%d\n",a/b);
            break;
            }          
        }

    }
    return 0;
}


Measured memory_bytes: 2112
for _ in[0]*int(input()):
 a,b,c,d,e,f=map(float,input().split())
 s,t,u=a*a+b*b,c*c+d*d,e*e+f*f
 x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))
 y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))
 print(f'{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}')


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

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main()
{
	cin>>s>>t;
	if(s.size()+1!=t.size()) printf("No\n");
	else{
		bool q=true;
		for(int i=0;i<s.size();++i){
			if(s[i]!=t[i]){
				q=false;
				break;
			}
		}
		if(q) printf("Yes\n");
		else printf("No\n");
	}
}

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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

int priority[128];

long long number(string::const_iterator &it) {
	long long res = 0;
	while(isdigit(*it)) {
		res = res * 10 + (*it - '0');
		++it;
	}
	return res;
}

long long expr(string::const_iterator &it, int p = 3) {
	if(p == 0) {
		if(*it == '(') {
			++it;
			const long long res = expr(it);
			assert(*it == ')');
			++it;
			return res;
		}
		else {
			return number(it);
		}
	}
	else {
		long long res = expr(it, p - 1);

		while(priority[*it] == p) {
			const char c = *it;
			++it;
			const long long right = expr(it, p - 1);

			switch(c) {
			case '+': res += right; break;
			case '*': res *= right; break;
			case '-': res -= right; break;
			default:
				assert(false);
			}
		}

		return res;
	}
}


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

	string expression;
	cin >> expression;

	long long ans = LLONG_MIN;
	for(int &i = priority['+'] = 1; i <= 3; ++i) {
		for(int &j = priority['-'] = 1; j <= 3; ++j) {
			for(int &k = priority['*'] = 1; k <= 3; ++k) {
				auto it = expression.cbegin();
				chmax(ans, expr(it));
			}
		}
	}
	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1188
#include<iostream>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long a[n],i,c=0,mx=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++){
        if(a[i]>=a[i+1]) {
            c++;
        }
        else {
            if(c>mx)
                mx=c;
            c=0;
        }
    }
    cout<<mx;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(b-a==c-b){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
var a,b2: int64;
    b: string;

function todigit(c : char) : integer;
begin
    todigit := ord(c) - ord('0');
end;

begin
    read(a,b);
    b2 := todigit(b[2]) * 100 + todigit(b[4]) * 10 + todigit(b[5]);
    writeln((a * b2) div 100);
end.


Measured memory_bytes: 1388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n,X;
  cin >> n >> X;
  vector<int> x(n);
  rep(i,n) {
    int a;
    cin >> a;
    a = abs(a-X);
    x[i] = a;
  }
  int ans = x[0];
  rep(i,n) {
    ans = gcd(ans, x[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3724