akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

# A - Sorted Arrays
import copy

N = int(input())
A = list(map(int, input().split()))

arr = []
ans = []
# 0: どっちの可能性もある
# 1: 単調非減少(増加)
# 2: 単調非増加(減少)
status = 0

for i in range(N):
  if status == 0:
    if len(arr) > 0:
      if A[i] > arr[-1]:
        status = 1
      elif A[i] < arr[-1]:
        status = 2

    arr.append(A[i])
  elif status == 1 and A[i] >= arr[-1]:
    arr.append(A[i])
  elif status == 2 and A[i] <= arr[-1]:
    arr.append(A[i])
  else:
    ans.append(copy.copy(arr))
    arr = [A[i]]
    status = 0

if len(arr) > 0:
  ans.append(arr)

print(len(ans))

'''
for a in ans:
  print(a)
'''

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

std::string s;

int main() {
    std::cin >> s;
    if ((s[0] == s[1]) && (s[1] == s[2]) || (s[1] == s[2]) && (s[2] == s[3])) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
<?php
$line = fgets(STDIN);
$line = fgets(STDIN);
$line = rtrim($line, "\r\n");
$aa_list = explode(" ", $line);
$nn = count($aa_list);

$sum = 0;
foreach ($aa_list as $aa) {
  $sum += $aa;
}

$kk = $nn * ($nn + 1) / 2;
if ($sum % $kk != 0) { print 'NO'; exit; }
$div = $sum / $kk;

for ($ii = 1; $ii < $nn; $ii++) {
  $dd = $aa_list[$ii] - $aa_list[$ii - 1] - $div;
  if ($dd > 0) { print 'NO'; exit; }
  if ($dd < 0) {
    if ($dd % $nn != 0) { print 'NO'; exit; }
  }
}
print 'YES';
exit;


Measured memory_bytes: 22084
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,s,d,f,g,h,c=0;;
    cin>>a>>s>>d>>f>>g>>h;
    if((a+s*5+d*10+f*50+g*100+h*500)/1000)c++;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#include<math.h>
#include<string.h>
int main()
{
    unsigned ll a,b,c,d,test,i,j,k,l,m,o,p;
    cin>>a;
    ll s=0;
    if(a%2==1)printf("0\n");
    else
    {
        for(i=10; i<=a; i=i*5)
        {
            s=a/i+s;
        }
        cout<<s<<endl;
    }
    return 0;
}

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


void mn(ll& a, ll b) {
	a = min(a, b);
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n, W;
	cin >> n >> W;

	const int N = (int) 1e5 + 5;
	const ll INF = (ll) 1e18;

	vector<ll> dp(N, INF);
	dp[0] = 0;

	for (int i = 0; i < n; ++i) {
		int w, v;
		cin >> w >> v;

		for (int j = N - 1 - v; j >= 0; --j) {
			mn(dp[j + v], dp[j] + w);
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (dp[i] <= W) {
			ans = i;
		}
	} 

	cout << ans << "\n";

}



Measured memory_bytes: 1024
n = gets.chomp.to_i

max_v = 0
max_a = n + 1

n.times.each do
  a, v = gets.chomp.split(" ").map{|s| s.to_i}

  if max_v < v
    max_v = v
    max_a = a
  elsif max_v == v && max_a > a
    max_a = a
  end
end

puts [max_a, max_v].join(" ")

Measured memory_bytes: 6112
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

/**
 * 最大値のインデックスを保持しておく
 * 準最大値の値を保持しておく
 */
int main()
{
    int N; cin >> N;
    vector<int> A, CP_A;
    rep (i, 0, N) {
        int a; cin >> a;
        A.push_back(a);
    }

    copy(A.begin(), A.end(), back_inserter(CP_A));

    auto max_iter = max_element(A.begin(), A.end());
    int max_idx = distance(A.begin(), max_iter);
    int max_val = A[max_idx];
    A.erase(max_iter);
    auto pre_max_iter = max_element(A.begin(), A.end());
    int pre_max_idx = distance(A.begin(), pre_max_iter);
    int pre_max_val = A[pre_max_idx];

    rep (i, 0, CP_A.size()) {
        if (max_idx != i) cout << max_val << endl;
        else cout << pre_max_val << endl;
    }

    return 0;
}

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

int main(){
    
    int A , B; cin >> A >> B;
    
    int hangaku = B / 2;
    
    if(A >= 13){
        cout << B << endl;
    }else if(A >= 6 && A <= 12){
        cout << hangaku << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define mod 1000000007


int main()
{
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll p=0;
    for(ll i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            p=1;break;
        }
    }
    if(p)
    cout<<"NO"<<"\n";
    else
    cout<<"YES"<<"\n";
}

Measured memory_bytes: 5188
package main

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

func main() {
	X := nextInt()
	N := nextInt()
	P := make([]int, N)
	s := false
	for i := 0; i < N; i++ {
		v := nextInt()
		P[i] = v
		if v == X {
			s = true
		}
	}
	if !s {
		fmt.Println(X)
		return
	}
	sort.Ints(P)
	base := 0
	for i, v := range P {
		if v == X {
			base = i
		}
	}
	big := X
	current := base
	for {
		if P[current] != big {
			break
		}
		current++
		big++
		if current > N-1 {
			break
		}
	}
	small := X
	current = base
	for {
		if P[current] != small {
			break
		}
		current--
		small--
		if current < 0 {
			break
		}
	}
	if Abs(big-X) < Abs(small-X) {
		fmt.Println(big)
		return
	}
	fmt.Println(small)
	return
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

int main() {
  int n;cin>>n;
  int cnt=0;
  map<string,int> mp;
  rep(i,n){
    string s;cin>>s;
    mp[s]++;
    cnt=max(cnt,mp[s]);
  }
  for(auto tmp:mp){
    if(tmp.second==cnt)cout<<tmp.first<<endl;
  }
}

Measured memory_bytes: 19244
ans=[11,
 31,
 41,
 61,
 71,
 101,
 131,
 151,
 181,
 191,
 211,
 241,
 251,
 271,
 281,
 311,
 331,
 401,
 421,
 431,
 461,
 491,
 521,
 541,
 571,
 601,
 631,
 641,
 661,
 691,
 701,
 751,
 761,
 811,
 821,
 881,
 911,
 941,
 971,
 991,
 1021,
 1031,
 1051,
 1061,
 1091,
 1151,
 1171,
 1181,
 1201,
 1231,
 1291,
 1301,
 1321,
 1361,
 1381]

N=int(input())

print(*ans[:N])

Measured memory_bytes: 3064
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    ll n,k; cin >> n >> k;
    vector<pair<ll,ll>> v;
    rep(i,n){
        ll a,b; cin >> a >> b;
        v.pb({a,b});
    }
    sort(ALL(v));
    rep(i,n){
        k-=v[i].se;
        if(k<=0){
            cout << v[i].fi << endl;
            return 0;
        }
    }
}


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

c = [2,5,5,4,5,6,3,7,6]

dp = [[-1 for n in range(N+1)] for m in range(M+1)]
dp[0][0] = 0
#keta
dp_r = [[-1 for n in range(N+1)] for m in range(M+1)]
#m

d = {}
for a in A:
    d[a] = c[a-1]
#print(d)

inv_d = {}
for k,v in d.items():
    if v in inv_d:
        if k > inv_d[v]:
            inv_d[v] = k
    else:
        inv_d[v] = k
#print(inv_d)

s_A = sorted(inv_d.items(), key=lambda x:x[0],reverse=True)
#print(s_A)
A = [a[1] for a in s_A]
M = len(A)

for m in range(1,M+1):
    for n in range(N+1):
        #dp[m][n] = max(dp[m-1][n],
        #dp[m][n-c[A[m-1]-1]] + 1 if (n-c[A[m-1]-1])>=0 and dp[m][n-c[A[m-1]-1]] != -1 else -1)
        if n-c[A[m-1]-1] >= 0 and dp[m][n-c[A[m-1]-1]] != -1:
            if dp[m-1][n] < (dp[m][n-c[A[m-1]-1]] + 1):
                dp[m][n] = dp[m][n-c[A[m-1]-1]] + 1
                dp_r[m][n] = 1
            elif dp[m-1][n] == (dp[m][n-c[A[m-1]-1]] + 1):
                dp[m][n] = dp[m][n-c[A[m-1]-1]] + 1
                dp_r[m][n] = 2
            else:
                dp[m][n] = dp[m-1][n]
                dp_r[m][n] = 0
        else:
            dp[m][n] = dp[m-1][n]
            dp_r[m][n] = 0


#import pprint
#pprint.pprint(dp,width=100)
#pprint.pprint(dp_r,width=100)

def trace(dp,m,n):
    r=[[]]
    for _ in range(N+M+2):
        if m==0 and n==0:
            return r
        elif dp_r[m][n] == 0:
            m = m-1
        elif dp_r[m][n] == 1:
            r = [r_+[m] for r_ in r]
            n = n-c[A[m-1]-1]
        elif dp_r[m][n] == 2:
            r_1 = trace(dp,m-1,n)
            r_2 = trace(dp,m,n-c[A[m-1]-1])
            return [r[0]+r_ for r_ in r_1] + [r[0]+r_+[m] for r_ in r_2]

tm = trace(dp,M,N)

ans = []
for tm_ in tm:
    ans_ = [inv_d[c[A[m-1]-1]] for m in tm_]
    ans_.sort(reverse=True)
    ans += [ans_]

ans.sort(reverse=True)
#print(ans)
for ans_ in ans[0]:
    print(ans_,sep='',end='')
print()

Measured memory_bytes: 7124
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define   sz(x)  (int)x.size()
#define   ff first
#define   ss second
#define   pii  pair<int,int> 
#define   pb  push_back
#define   eb  emplace_back
#define   lcm(a,b)  (a*b)/gcd(a,b)
using namespace std;

const int inf=10000000;
signed main(){
	int n,m;
	cin>>n>>m;
	int a[1000],b[1000],c[1000],dist[1000][1000];	
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--,b[i]--;
	}
	for(int i=0;i<n;++i){
		for(int j=0;j<n;++j){
			if(i==j) dist[i][j]=0;
			else dist[i][j]=inf;
		}
	}
	for(int i=0;i<m;++i){
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);			dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
	}
	for(int k=0;k<n;++k){
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans=m;
	for(int i=0;i<m;++i){
		bool shortest=false;
		for(int j=0;j<n;++j)
			if(dist[j][a[i]]+c[i]==dist[j][b[i]])
				shortest=true;										if(shortest==true){
			ans--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    auto mp = make_v(h, w, '.');
    REP(i, 0, h) {
        REP(j, 0, w) {
            cin >> mp[i][j];
        }
    }
    auto dp = make_v(h, w, 0);
    int cnt = 0;
    REP(i, 0, h) {
        int last = cnt;
        bool update = false;
        REP(j, 0, w) {
            if (mp[i][j] == '#') {
                last = ++cnt;
                update = true;
            }
            if (update) {
                dp[i][j] = last;
            }
        }
        last = cnt;
        if (update) {
            for (int j = w - 1; j >= 0; j--) {
                if (dp[i][j] == 0) {
                    dp[i][j] = last;
                }
                last = dp[i][j];
            }
        }
    }
    REP(i, 1, h) {
        if (dp[i][0] == 0) {
            REP(j, 0, w) {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    for (int i = h - 2; i >= 0; i--) {
        if (dp[i][0] == 0) {
            REP(j, 0, w) {
                dp[i][j] = dp[i + 1][j];
            }
        }
    }
    REP(i, 0, h) {
        REP(j, 0, w) {
            cout << dp[i][j] << " \n"[j + 1 == w];
        }
    }

    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int A = ri();
		Console.WriteLine(A + A * A + A * A * A);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17628
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
const int INF = 1001001001;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define re0 return 0
#include<string.h>
int npr(int n , int r){//nPr
    r = n - r;
    int sum = 1;
    int i;
    for (i=n;i>=r+1;i--)sum*=i;
    return sum;
}
int gcd(int a, int b) {//最大公約数
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
    return a * b / gcd(a, b);
}
int digsum(int n) {//桁和
    int res = 0;
    while(n > 0) {
        //res += n%10;
        //　↑をres++;にすれば桁数
         res++;
        n /= 10;
    }
    return res;
}
bool isPrime(int x){//素数判定
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
/*bit全探索
for (int bit = 0; bit < (1<<N); ++bit) {
}
if (bit & (1 << i)) {
}
*/


int main(void){
    string s;
    cin >> s;
    if(s=="RRR"){
        cout << 3 <<endl;
    }else if(s=="RRS"){
        cout << 2 <<endl;
    }else if(s=="SRR"){
        cout << 2 <<endl;
    }else if(s=="RSR" || s=="RSS" || s=="SRS" || s=="SSR"){
        cout << 1 <<endl;
    }else{
        cout << 0 <<endl;
    }
    return 0;
}




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

using namespace std;


int main() {
    vector<int> tens;
    vector<pair<int,int>> P;
    for(int i = 0; i < 5; i++) {
        int a;
        cin >> a;
        if(a % 10 == 0) {
            tens.push_back(a);
        } else {
            P.push_back(make_pair(a % 10, a));
        }
    }
    sort(P.begin(),P.end());
    int ans = 0;
    for(int i = 0; i < tens.size(); i++) {
        ans += tens[i];
    }
    for(int i = 0; i < P.size(); i++) {
        if(i == 0) {
            ans += P[i].second;
        } else {
            int d = P[i].second / 10;
            d++;
            ans += d * 10;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
n = int(input())
s = input()

ans = ''

abc =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(len(s)):
    for j in range(len(abc)):
        if s[i] == abc[j]:
            ans += abc[j + n]
            break
        
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    rep(i, h) rep(j, w) {
        cin >> a[i][j];
    }
    set<int> row, column;

    rep(i, h) {
        bool ok = true;
        rep(j, w) {
            if (a[i][j] == '#') ok = false;
        }
        if (ok) row.insert(i);
    }
    rep(j, w) {
        bool ok = true;
        rep(i, h) {
            if (a[i][j] == '#') ok = false;
        }
        if (ok) column.insert(j);
    }

    rep(i, h) {
        if (row.find(i) != row.end()) continue;
        rep(j, w) {
            if (column.find(j) != column.end()) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
}


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

ans=0
for h in range(1<<H):
    for w in range(1<<W):
        count=0
        for i in range(H):
            for j in range(W):
                if (h>>i)&1 and (w>>j)&1:
                    if c[i][j]=='#':count+=1
        if count==K:ans+=1
print(ans)

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

signed main(){
    string s,t;
    while(cin >> s){
        cin >> t;
        auto dp = vector<vector<int>>(s.size() + 1, vector<int>(t.size() + 1,0LL));
        for(int i = 0; i < s.size(); ++i){
            for(int j =0; j < t.size();++j){
                if(s[i] == t[j])
                    dp[i + 1][j + 1] =  dp[i][j] + 1;
            }
        }
        int maxi = -1;
        for(auto u : dp)
            for(auto e : u)
                cmax(maxi,e);
        cout << maxi << endl;
    }
}



Measured memory_bytes: 127904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<string> v;
    int n,ar[200],ar1[200],first=-1,second=-1,ar3[207];
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>ar[i];
    for(int i=1; i<=n; i++)
        cin>>ar1[i];
    for(int i=1; i<=n; i++)
        ar3[i]=i;
    int cnt=1,flag=0;
    for(int i=1; i<=n; i++)
        if(ar[i]!=ar1[i])
            flag=1;
    if(flag==0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    int flag1=0,flag2=0;
    for(int i=1; i<=n; i++)
    {
        if(ar[i]!=ar3[i])
            flag1=1;
        if(ar1[i]!=ar3[i])
            flag2=1;
    }
    if(flag1==0)
        first=1;
    if(flag2==0)
        second=1;
    while(next_permutation(ar3+1,ar3+n+1))
    {
        cnt++;
        int flag=0;
        for(int i=1; i<=n; i++)
        {
            if(ar3[i]!=ar[i])
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
            first=cnt;
        flag=0;
        for(int i=1; i<=n; i++)
        {
            if(ar3[i]!=ar1[i])
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
            second=cnt;
        if(first!=-1&&second!=-1)
        {
            cout<<abs(first-second)<<endl;
            return 0;
        }
    }
    // cout<<abs(first-second)<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int n,k;
  cin>>n>>k;
  V<int> h(n);
  fo(i,n){
    cin>>h[i];
  }
  Sort(h);
  rev(h);
  int ans=0;
  for(int i=k; i<n; i++){
    ans+=h[i];

  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="Y"){
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
  return 0;
}

Measured memory_bytes: 3608
X=int(input())
import math
Xroot=math.ceil(math.sqrt(X))
ans=1
for b in range(2,Xroot+1):
  p=2
  while b**p<=X:
    p+=1
  if p!=2 and b**(p-1)>ans:
    ans=b**(p-1)
print(ans)

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

using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back
const double PI  =3.141592653589793238463;
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    double r;
    cin >> r;
    cout << setprecision(10) << fixed;
    cout << 2 * PI * r;
    return 0;
}



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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 1; i <= n; ++i) cin >> a[i];
	int cnt = 0, curr = 1;
	while(curr != 2) {
		if(cnt == n) {
			cnt = -1;
			break;
		}
		curr = a[curr];
		++cnt;
	}
	cout << cnt;

	return 0;
}


Measured memory_bytes: 4408
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main() {
  int32_t A, B;
  cin >> A >> B;
  if ((A + B) & 0x01) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (A + B) / 2 << endl;
  }

  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.math.BigInteger;
import java.util.Arrays;
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 MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

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

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);
			int sum = Arrays.stream(a).sum();

			BigInteger now = BigInteger.ONE;
			now = now.or(BigInteger.ONE.shiftLeft(a[0]));
			for (int i = 1; i < n; i++) {
				now = now.or(now.shiftLeft(a[i]));
			}

			for (int i = sum/2 + (sum & 1); i <= sum; i++) {
				if (!BigInteger.ONE.shiftLeft(i).and(now).equals(BigInteger.ZERO)) {
					out.println(i);
					return;
				}
			}

		}
	}

	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: 346836
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    for (int i = 1; i <= B; i++) {
        if (A*i % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            if (a < b)
            {
                if (b < c)
                {
                    Console.WriteLine("Yes");
                }
            }
            else
            {
                Console.WriteLine("No");

            }
            if (a < b)
            {
                if (b > c)
                {
                    Console.WriteLine("No");

                }
            }
        }
    }
}

Measured memory_bytes: 8900
#include <bits/stdc++.h>
using namespace std;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=15,S=1<<N,mod=1e9+7;
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
int n,m;
int g[N][N],pw[N*N],cnte[N][S],dp[S];
int DP(int S){
	int &v=dp[S];
	if (~v)
		return v;
	if (!S)
		return v=1;
	int d[N],t=0;
	for (int i=0;i<n;i++)
		if (S>>i&1)
			d[t++]=i;
	v=0;
	for (int k=1;k<(1<<t);k++){
		int i=0;
		for (int j=0;j<t;j++)
			if (k>>j&1)
				i|=1<<d[j];
		if ((i&3)==1||(i&3)==2)
			continue;
		int j=S^i,now=1;
		// i -> i  no Edges
		// j -> i  at least one per node
		for (int x=0;now&&x<n;x++)
			if (j>>x&1)
				now=1LL*now*(pw[cnte[x][i]]-1)%mod;
		if (!now)
			continue;
		// i -> j  all
		for (int x=0;x<n;x++)
			if (i>>x&1)
				now=1LL*now*pw[cnte[x][j]]%mod;
		// j -> j  DP(j)
		now=1LL*now*DP(j)%mod;
		Add(v,now);
	}
	return v;
}
int main(){
	for (int i=pw[0]=1;i<N*N;i++)
		pw[i]=2*pw[i-1]%mod;
	n=read(),m=read();
	memset(g,0,sizeof g);
	for (int i=1;i<=m;i++){
		int a=read()-1,b=read()-1;
		g[a][b]=1;
	}
	for (int x=0;x<n;x++)
		for (int i=0;i<(1<<n);i++)
			for (int y=0;y<n;y++)
				if (g[x][y]&&(i>>y&1))
					cnte[x][i]++;
	memset(dp,-1,sizeof dp);
	cout << (pw[m]-DP((1<<n)-1)+mod)%mod << endl;
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

int main(void) {
    ll i, j, N;
    ll c[500], s[500], f[500];
    cin >> N;
    for(i=1; i<N; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    ll t;
    ll k;
    for(i=1; i<N; i++) {
        t=s[i]+c[i];
        for(j=i+1; j<N; j++) {
            if(t<s[j]) {
                t=s[j];
            }else {
                k=(t-s[j])/f[j]+((t-s[j])%f[j]==0 ? 0 : 1);
                t+=s[j]+f[j]*k-t;
            }
            t+=c[j];
        }
        
        cout << t << endl;
    }
    cout << 0 << endl;
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) cin >> H.at(i); 
    sort(H.rbegin(), H.rend());

    vector<ll> ans(0);
    for (int i = 0; i < N; i++) {
        if (N > i+K-1) {
            ans.push_back(H.at(i) - H.at(i+K-1));
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans.at(0) << endl;
}

Measured memory_bytes: 2168
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	string s;
	ll ans = 0;
	cin >> s;
	repi(i, 0, 4) {
		if (s[i] == '+') ans++;
		else ans--;
	}
	wrln(ans);
	return 0;
}


Measured memory_bytes: 256
n, x = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)

a = (xs + [x]).sort
diff = []
(a.size - 1).times do |i|
  diff.push(a[i + 1] - a[i])
end
if n > 1
g = diff[0].gcd(diff[1])
  (2..n-2).each do |i|
    g = g.gcd(diff[i])
  end
  puts g
else
  puts diff[0]
end


Measured memory_bytes: 11632
def isAble(a, r, c):
    lastC = 1
    for i in xrange(r):
        lowbit = a[i]&-a[i]
        if popcount(a[i]+lowbit)!=1:
            return False
        if lowbit!=lastC:
            return False
        lastC = (a[i]+lowbit)>>1
    if lastC!=(1<<(c-1)):
        return False
    return True

def popcount(x):
    x = (x & 0x55555555) + ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f)
    x = (x & 0x00ff00ff) + ((x >> 8) & 0x00ff00ff)
    x = (x & 0x0000ffff) + ((x >> 16) & 0x0000ffff)
    return x

def main():
    r, c = [int(x) for x in raw_input().strip().split()]
    a = []
    for i in xrange(r):
        row = raw_input().strip()
        foo = 0
        for j in xrange(c):
            if row[j]=='#':
                foo |= 1<<j
        a.append(foo)
    if isAble(a, r, c):
        print 'Possible'
    else:
        print 'Impossible'

if __name__ == '__main__':
    main()

Measured memory_bytes: 2824
# coding: utf-8

(row_count, col_count) = [int(i) for i in input().rstrip().split(" ")]

def shrink_col(map):
    new_map = [[] for i in range(len(map))]
    for i in range(col_count):
        all_space = True
        for j in range(len(map)):
            if map[j][i] == '#':
                all_space = False
                break
        if not all_space:
            for j in range(len(map)):
                new_map[j].append(map[j][i])
    return new_map

def shrink_row(map):
    new_map = []
    for i in range(row_count):
        if len([j for j in map[i] if j == "#"]) > 0:
            new_map.append(map[i])
    return new_map


map = [input().rstrip() for i in range(row_count)]
map = shrink_row(map)
map = shrink_col(map)

for row in map:
    print("".join(row))


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int N = int.Parse(input[0]);
    int T = int.Parse(input[1]);
    var input2 = Console.ReadLine().Split();
    int[] t = new int[N];
    for(int i=0; i<N; i++){
      t[i] = int.Parse(input2[i]);
    }
    int[] t2 = new int[N];
    t2[0] = t[0];
    for(int i=1; i<N; i++){
      t2[i] = t[i]-t[i-1];
    }
    
    long total = 0;
    for(int i=0; i<N; i++){
      if(t2[i] > T){
        total += T;
      }
      else{
        total += t2[i];
      }
    }
    total += T;
    Console.WriteLine(total);
    }
}

Measured memory_bytes: 26208
def Labeling(terrain):

    label = terrain

    offset = [[-1, 0], [0, -1], [1, 0], [0, 1]]
    signs = ["@", "#", "*"]
    rowLength, colLength = len(label) - 1, len(label[0]) - 1

    step = 0

    for row in range(1, rowLength):
        for col in range(1, colLength):
            mark = label[row][col]

            if mark in signs:
                pointStack = [[row, col]]
                label[row][col] = step

                while 0 < len(pointStack):
                    rowIndex, colIndex = pointStack.pop()

                    for x, y in offset:
                        offsetRow, offsetCol = rowIndex + x, colIndex + y

                        if label[offsetRow][offsetCol] == mark:
                            pointStack.append([offsetRow, offsetCol])
                            label[offsetRow][offsetCol] = step

                step += 1

    return step


Sentinel = "1"

while True:
    col, row = [int(item) for item in input().split()]

    if row == 0 and col == 0:
        break

    land = []
    land.append([item for item in Sentinel * row + Sentinel * 2])

    for lp in range(col):
        part = [item for item in input()]
        land.append([])
        land[-1].extend([Sentinel])
        land[-1].extend(part)
        land[-1].extend([Sentinel])

    land.append([item for item in Sentinel * row + Sentinel * 2])

    result = Labeling(land)

    print(result)



Measured memory_bytes: 5992
#include <stdio.h>
 #include <math.h>

 #define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
 scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *b) * cosl(rad);
 printf("%20.20Lf\n", sqrtl(rsq));
 return 0;
 }

Measured memory_bytes: 2580
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := nextInt()
	y := nextInt()
	g := make(map[int][]int, n)
	for i := 0; i < n; i++ {
		g[i] = []int{}
		if i != 0 {
			g[i] = append(g[i], i-1)
		}
		if i != n-1 {
			g[i] = append(g[i], i+1)
		}
		if i == x-1 {
			g[i] = append(g[i], y-1)
		}
		if i == y-1 {
			g[i] = append(g[i], x-1)
		}
	}
	ans := make([]int, n-1)
	for i := 0; i < n; i++ {
		q := make([]int, 0)
		q = append(q, i)
		c := make(map[int]int, n)
		c[q[0]] = 0
		for len(q) > 0 {
			current := c[q[0]]
			for _, next := range g[q[0]] {
				_, exist := c[next]
				if !exist {
					c[next] = current + 1
					ans[current]++
					q = append(q, next)
				}
			}
			q = q[1:]
		}
	}
	anss := make([]string, n-1)
	for k := 0; k < n-1; k++ {
		anss[k] = strconv.Itoa((ans[k] / 2))
	}
	fmt.Println(strings.Join(anss, "\n"))
}


Measured memory_bytes: 5376
from collections import Counter

N = int(input())
A = map(int, input().split())
# N = 5
# A = [2, 4, 4, 0, 2]
mod = 10 ** 9 + 7

cnt = Counter(A)
if N % 2 == 0:
    if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:
        print(0)
    else:
        print((2 ** (N // 2)) % mod)
else:
    if cnt[0] != 1:
        print(0)
    else:
        cnt.pop(0)
        if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:
            print(0)
        else:
            print((2 ** (N // 2)) % mod)


Measured memory_bytes: 16620
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
struct RollingHash2D{
  struct RollingHash{
    string S;
    ull B;
    vector<ull> hash,p;
    int len;
    RollingHash(){}
    RollingHash(string S,ull B=1000000007LL):S(S),B(B){init();};
    void init(){
      len=S.length();
      hash.resize(len+1);
      p.resize(len+1);
      hash[0]=0;p[0]=1;
      for(int i=0;i<len;i++){
	hash[i+1]=hash[i]*B+S[i];
	p[i+1]=p[i]*B;
      }
    }
  //S[l,r)
    ull find(int l,int r){
      return hash[r]-hash[l]*p[r-l];
    }
  };
  vector<string> S;
  vector<RollingHash> rh;
  vector<vector<ull> > hash;
  vector<ull> p;
  int h,w,r,c;
  ull B;
  RollingHash2D(){}
  RollingHash2D(vector<string> S,int r,int c,ull B=1000000009LL):S(S),r(r),c(c),B(B){init();};
  void init(){
    h=S.size();
    w=S[0].size();
    hash.resize(h+1,vector<ull>(w-c+1,0));
    rh.resize(h);
    for(int i=0;i<h;i++) rh[i]=RollingHash(S[i]);
    p.resize(h+1);
    p[0]=1;
    for(int i=0;i<h;i++) p[i+1]=p[i]*B;
    for(int j=0;j<w-c+1;j++){
      hash[0][j]=0;		    
      for(int i=0;i<h;i++)
	hash[i+1][j]=hash[i][j]*B+rh[i].find(j,j+c);
    }
  }
  //S[l,r)
  ull find(int i,int j){
    return hash[i+r][j]-hash[i][j]*p[r];
  }
};
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];
  int r,c;
  cin>>r>>c;
  vector<string> t(r);
  for(int i=0;i<r;i++) cin>>t[i];
  RollingHash2D srh(s,r,c);
  RollingHash2D trh(t,r,c);
  for(int i=0;i<h-r+1;i++){
    for(int j=0;j<w-c+1;j++){
      if(srh.find(i,j)==trh.find(0,0)) cout<<i<<" "<<j<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 38392
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int A[3];
	int ans = 0;

	cin >> A[0] >> A[1] >> A[2];

	sort(A, A + 3);

	ans = abs(A[2] - A[1]) + abs(A[1] - A[0]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> vec(N,vector<int>(3));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  vector<int> query(Q+2,-1e9);
  for(int i=1; i<=Q; i++){
    cin >> query.at(i);
  }
  query.at(Q+1) = 1e9+10;
  vector<vector<int>> in(Q+2,vector<int>(0));
  vector<vector<int>> out(Q+2,vector<int>(0)); 
  
  vector<int>::iterator pos;
  int idx;
  for(int i=0; i<N; i++){
    int s = vec.at(i).at(0);
    int e = vec.at(i).at(1);
    int p = vec.at(i).at(2);
    pos = lower_bound(query.begin(),query.end(),s-p);
    idx = distance(query.begin(),pos);
    in.at(idx).push_back(p);
    pos = lower_bound(query.begin(),query.end(),e-p);
    idx = distance(query.begin(),pos);
    //cout << idx << endl;
    out.at(idx).push_back(p);
  }
  
  /*for(int i=0; i<Q+2; i++){
    for(int j=0; j<out.at(i).size(); j++){
      cout << out.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
  
  map<int,int> mp;
  mp[1e9+10] = 1;
  for(int i=0; i<Q+1; i++){
    for(int j=0; j<in.at(i).size(); j++){
      if(mp.count(in.at(i).at(j))){
        mp[in.at(i).at(j)]++;
      }
      else{
        mp[in.at(i).at(j)] = 1;
      }
    }
    for(int j=0; j<out.at(i).size(); j++){
      mp[out.at(i).at(j)]--;
      if(mp[out.at(i).at(j)] == 0){
        mp.erase(out.at(i).at(j));
      }
    }
    if(i != 0){
      int x = mp.begin()->first;
      if(x == 1e9+10){
        cout << -1 << endl;
      }
      else{
        cout << x << endl;
      }
    }
  }
}

Measured memory_bytes: 38772
h, w = (int(i) for i in input().split())
s = [input() for i in range(h)]
ans = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        cnt = 0
        if s[i][j] == "#":
            ans[i][j] = "#"
            continue
        for k in range(-1,2):
            for l in range(-1,2):
                if 0 <= i+k <= h-1 and 0 <= j+l <= w-1 and s[i+k][j+l] == "#":
                    cnt += 1
        ans[i][j] = cnt

for i in ans:
    print(*i,sep="")

Measured memory_bytes: 45936
#include <iostream>
#include <math.h>

using namespace std;

const int MAXN = 101;
int x[MAXN], y[MAXN], h[MAXN];

int check(int n, int a, int b, int cur) {
  int ans_h = -1, max_h = (int)1e9;
  for (int i = 0; i < n; ++i) {
    int tmp = abs(a - x[i]) + abs(b - y[i]);
    if (max(cur - tmp, 0) != h[i])
      return false;
  }
  return true;
}

void solve(int n) {
  int pos = -1;
  for (int i = 0; i < n; ++i) {
    if (h[i] != 0) {
      pos = i;
      break;
    }
  }
  for (int a = 0, cur; a <= 100; ++a) {
    for (int b = 0; b <= 100; ++b) {
      if (pos == -1) 
        cur = 1;
      else
        cur = abs(a - x[pos]) + abs(b - y[pos]) + h[pos];
      if (check(n, a, b, cur)) {
        printf("%d %d %d\n", a, b, cur);
        return ;
      }
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d %d", x + i, y + i, h + i);
  }
  solve(n);
  return 0;
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if((a*100+b*10+c) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256