akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
#define int long long
#define MAXN 200006
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
int n , m , q;

int fa[MAXN];
int find( int x ) {
	return x == fa[x] ? x : fa[x] = find( fa[x] );
}
struct dl{
	int u , v;
} d[MAXN] ;
int cnt , c;

signed main( ) {
	cin >> n >> m >> q;
	for( int i = 1 ; i <= n ; ++ i ) fa[i] = i;
	for( int i = 1 , u , v , c ; i <= q ; ++ i ) {
		scanf("%lld%lld%lld",&u,&v,&c);
		++ u , ++ v;
		if( !c ) {
			fa[find( u )] = find( v );
		} else {
			d[++ cnt] = (dl) { u , v };
		}
	}
	for( int i = 1 , u , v ; i <= cnt ; ++ i ) {
		if( find( d[i].u ) == find( d[i].v ) )
			return puts("No") , 0;
	}
	for( int i = 1 ; i <= n ; ++ i ) if( fa[i] == i )
		++ c;
	int ed = m - n + c;
	if( !cnt ) return puts( ( ed >= c - 1 && ed <= c * ( c - 1 ) / 2 ) ? "Yes" : "No" ) , 0;
	else return puts( ( ed >= c && ed <= c * ( c - 1 ) / 2 ) ? "Yes" : "No" ) , 0;
}

Measured memory_bytes: 3840
/*
   THE DARK NIGHT RISES
I LOVE YOU 72 AND WILL FOREVER DO SO
Patience, Persistence, Perseverance, Passion, Purpose
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int N = 2e5 + 20 ;
#define F first
#define S second
# define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mk make_pair
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x)       (int)x.size()
const long long int mod=1e9 + 7;
const long double EPS=1e-12;
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )
 
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 

 
int solve()
{
 	ll n ;
 	cin >> n ;
 	string s ;
 	cin >> s ;
 	if(n%2) return cout << "No\n",0;
 	int i = 0, j = n/2 ;
 	while(j < n)
 	{
 		if(s[i]!=s[j])return cout << "No\n",0;
 		i++,j++;
 	}
 	cout << "Yes\n";
	
}
int main()
{
	fast;
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
 
	return 0;
}
// Patience, Persistence, Perseverance, Passion, Purpose
// I LOVE YOU 72 AND WILL FOREVER DO SO.

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

#define NDEBUG
#ifdef DEBUG
#include "cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}

int solve(int N, vi& a) {
    map<int,int> m;
    for(int ai:a) {
        ++m[ai];
    }
    int cnt = 0;
    for(auto p:m){
        int x = p.first;
        if (p.second >= x) cnt += (p.second - x);
        else cnt += p.second;
    }
    return cnt;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N, a) << endl;
    return 0;
}


Measured memory_bytes: 6016
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, u, v, m;
	cin >> n >> u >> v >> m;
	map<int, pair<int, int>> bingo_u;
	map<int, pair<int, int>> bingo_v;
	REP(i,n)
		REP(j, n){
		int num;
		cin >> num;
		bingo_u[num] = pair<int, int>(i,j);
	}
	REP(i, n)
		REP(j, n){
		int num;
		cin >> num;
		bingo_v[num] = pair<int, int>(i, j);
	}
	queue<int> tyusen;
	REP(i, m){
		int num;
		cin >> num;
		tyusen.push(num);
	}
	vector<int> usa_h(n,0);
	vector<int> usa_v(n,0);
	int usa_naname[2] = {0};
	vector<int> nek_h(n,0);
	vector<int> nek_v(n,0);
	int nek_naname[2] = {0};

	while (!tyusen.empty()){
		int q = tyusen.front(); tyusen.pop();
		if (bingo_u.find(q) != bingo_u.end()){
			if (n == 1)
				u--;
			else{
				usa_h[bingo_u[q].first]++;
				if (usa_h[bingo_u[q].first] == n)
					u--;
				usa_v[bingo_u[q].second]++;
				if (usa_v[bingo_u[q].second] == n)
					u--;
				if (bingo_u[q].first == bingo_u[q].second){
					usa_naname[0]++;
					if (usa_naname[0] == n)
						u--;
				}
				if (bingo_u[q].first + bingo_u[q].second == n - 1){
					usa_naname[1]++;
					if (usa_naname[1] == n)
						u--;
				}
			}
		}
		if (bingo_v.find(q) != bingo_v.end()){
			if (n == 1)
				v--;
			else{
				nek_h[bingo_v[q].first]++;
				if (nek_h[bingo_v[q].first] == n)
					v--;
				nek_v[bingo_v[q].second]++;
				if (nek_v[bingo_v[q].second] == n)
					v--;
				if (bingo_v[q].first == bingo_v[q].second){
					nek_naname[0]++;
					if (nek_naname[0] == n)
						v--;
				}
				if (bingo_v[q].first + bingo_v[q].second == n - 1){
					nek_naname[1]++;
					if (nek_naname[1] == n)
						v--;
				}
			}
		}
		if (u <= 0 && v <= 0){
			cout << "DRAW" << endl;
			return 0;
		}
		else if (u <= 0){
			cout << "USAGI" << endl;
			return 0;
		}
		else if (v<=0){
			cout << "NEKO" << endl;
			return 0;
		}
	}
	cout << "DRAW" << endl;
}

Measured memory_bytes: 21236
from itertools import takewhile

# 入力
H, W = map(int, input().split())
S = [input() for _ in range(H)]

# 各マスについて、横方向に照らすマスの数と縦方向に照らすマスの数を求める
x = [[0 for _ in range(W)] for _ in range(H)]
y = [[0 for _ in range(W)] for _ in range(H)]

for i, j in ((i, j) for i in range(H) for j in range(W) if S[i][j] == '.'):
    if x[i][j] == 0:
        w = len(list(takewhile(lambda k: S[i][k] == '.', range(j, W))))
        for k in range(j, j + w):
            x[i][k] = w
    if y[i][j] == 0:
        h = len(list(takewhile(lambda k: S[k][j] == '.', range(i, H))))
        for l in range(i, i + h):
            y[l][j] = h

ans = max(
    x[i][j] + y[i][j] - 1
    for i in range(H)
    for j in range(W)
)
# 出力
print(ans)


Measured memory_bytes: 126424
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

double abs_d(double x){
    return x < 0 ? -x : x;
}

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double dirA, dirB;
    dirA = (h / 12.0 + m / 720.0) * 2.0 * M_PI;
    dirB = (m / 60.0) * 2.0 * M_PI;
    double ans = sqrt(a*a + b*b - 2.0*a*b*cos(abs_d(dirA - dirB)));
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int N;
map<int, vector<int>> A;
map<int, int> memo;
int f(int p) {
	auto it = A.lower_bound(p);
	if (it == A.end()) return 0;
	int q = it->first;
	if (memo.count(q)) return memo[q];
	int r = 0;
	for (int x : it->second) {
		r = max(r, f(x) + 1);
	}
	++ it;
	if (it != A.end()) r = max(r, f(it->first));
	return memo[q] = r;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++ i) {
		int x, l;
		cin >> x >> l;
		A[x-l].push_back(x+l);
	}
	cout << f(A.begin()->first) << endl;
}


Measured memory_bytes: 23680
N,M=map(int,input().split())
e=[[] for i in range(N)]
tester=[None]*M
for i in range(M):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  e[a].append(b)
  e[b].append(a)
  tester[i]=set([a,b])
  
ans=0
for test in tester:
  stack=[]
  stack.append([0,-1])
  seen=[0 for i in range(N)]
  while stack:
    node=stack.pop()
    v=node[0]
    parent=node[1]
    if seen[v]==1:
      continue
    seen[v]=1
    childs=e[v]
    for child in childs:
      if child==parent:
        continue
      if test==set([v,child]):
        continue
      stack.append([child,v])
      
  if sum(seen)!=N:
    ans+=1
print(ans)

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class BIT:

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

    def bisearch_left(self, l, r, x):
        """ 区間[l,r]で左からx番目の値がある位置 """
        l_sm = self.sum(l-1)
        ok = r + 1
        ng = l - 1
        while ng+1 < ok:
            mid = (ok+ng) // 2
            if self.sum(mid) - l_sm >= x:
                ok = mid
            else:
                ng = mid
        if ok != r + 1:
            return ok
        else:
            return -1

    def bisearch_right(self, l, r, x):
        """ 区間[l,r]で右からx番目の値がある位置 """
        r_sm = self.sum(r)
        ok = l - 1
        ng = r + 1
        while ok+1 < ng:
            mid = (ok+ng) // 2
            if r_sm - self.sum(mid-1) >= x:
                ok = mid
            else:
                ng = mid
        if ok != l - 1:
            return ok
        else:
            return -1

N = INT()
A = LIST()
# aの昇順に処理できるようにindexで並べておく
idxs = [0] * (N+1)
for i, a in enumerate(A):
    idxs[a] = i + 1

bit = BIT(N+2)
# 先頭と末尾に番兵を仕込む
bit.add(0, 2)
bit.add(N+1, 2)
ans = [0] * (N+1)
# 大きいaから見ていく
for a in range(N, 0, -1):
    # a(N~1)が格納されているindex
    idx = idxs[a]
    # 自分より小さいindexで2回目に自分より大きい値がある直前の場所
    p = bit.bisearch_right(0, idx, 2) + 1
    # 自分より小さいindexで最初に自分より大きい値がある直前の場所
    q = bit.bisearch_right(0, idx, 1) + 1
    # 自分より大きいindexで最初に自分より大きい値がある直前の場所
    r = bit.bisearch_left(idx, N+1, 1) - 1
    # 自分より大きいindexで2回目に自分より大きい値がある直前の場所
    s = bit.bisearch_left(idx, N+1, 2) - 1
    # aを使う回数 * a = (左に自分より大きい値がある時の通り数 + 右に自分より大きい値がある時の通り数) * a
    ans[a] = ((q-p)*(r-idx+1) + (idx-q+1)*(s-r)) * a
    # aを出現済とする
    bit.add(idx, 1)
# 全てのaについての合計
print(sum(ans))


Measured memory_bytes: 60876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define INF (1LL << 31)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b; --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            // dist[nv] = dist[v] + 1;
            dist[nv] = v;
            que.push(nv);
        }
    }
    bool f = true;
    rep(i, N) if (dist[i] == -1) f = false;
    if (f) {
        cout << "Yes" << endl;
        FOR(v, 1, N) {
            ++dist[v]; 
            cout << dist[v] << endl;
        }
    }else{
        cout << "No" << endl;
    }
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



// // 二分探索(最小値を出す問題は疑う)
// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < N; ++i){
// 		res += max(0ll, A[i]-x/F[i]);
//     }
//     return res <= K;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }

int main(){
int A, B, C;
cin >> A >> B >> C;
int ans = 0;
while(true){
  if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1) break;
  if(A == B && A == C) {
    ans = -1;
    break;
  }

  int a = (B / 2) + (C / 2);
  int b = (A / 2) + (C / 2);
  int c = (A / 2) + (B / 2);
  A = a;
  B = b;
  C = c;
  ans++;
}

print(ans);

}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val ab = Array(n+1){ mutableListOf<Int>()}
    repeat(m){
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        ab[a].add(b)
        ab[b].add(a)
    }
    fun dfs(d: Int, v :Int): Boolean{
        return if(d == 2){
            v == n
        }else {
            ab[v].map {
                dfs(d + 1, it)
            }.contains(true)
        }
    }
    dfs(0, 1).let { if(it) println("POSSIBLE") else println("IMPOSSIBLE") }
}

Measured memory_bytes: 106088
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str,s;
  int cnt=0;
  cin >> s;
  for(int i=0,l=s.size();i<l;i++)
    if(s[i]>='A'&&s[i]<='Z')s[i]+=('a'-'A');
  while(cin >> str){
    if(str=="END_OF_TEXT")break;
    for(int i=0,l=str.size();i<l;i++)
      if(str[i]>='A'&&str[i]<='Z') str[i]+=('a'-'A');
    if(s==str) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1192
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  h,w,i,j,count,x,y,sw,m,n:Integer;
  a,b:array of string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(n);
    Readln(m);
    SetLength(a,n+1);
    SetLength(b,m+1);

    for i := 1 to n do
      Readln(a[i]);
    for i := 1 to m do
      Readln(b[i]);

    tf:=false;
    for j := 1 to n-m+1 do
      for i := 1 to n-m+1 do
        for y := 1 to m do begin
          for x := 1 to m do begin
            if b[y][x]<>a[j+y-1][i+x-1] then begin
              tf:=true;
              break;
            end;
            if (x=m)and(y=m) then begin
              Writeln('Yes');
              Readln;
              exit;
            end;
          end;
          if tf then begin
            tf:=false;
            break;
          end;
        end;

    Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <stdio.h>
#include <vector>
using namespace std;
#define dout if (debug) cout
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPI;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define db(x) cerr << #x << " = " << x << endl
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
const int inf = 1000000404;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 1000000000000000404ll;
const ld EPS = 1e-9;
template <typename t1, typename t2> inline void upmax(t1 &a, t2 b) { a = max(a, (t1)b); }
template <typename t1, typename t2> inline void upmin(t1 &a, t2 b) { a = min(a, (t1)b); }
template <typename T>inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T>inline T lcm(T a, T b) { return a*(b / gcd(a, b)); }
template <typename T>inline T sqr(T a) { return a*a; }
inline bool pal(string &x) { int n = (int)x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }
template <typename T>inline void rev(T &x) { int n = SZ(x); REP(i, 0, n / 2) swap(x[i], x[n - i - 1]); }
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
class compare{
public:
	bool operator()(const int a, const int b) const {

		return 1;
	}
};
int SQ = 400;

#define debug 1
#define N 111111
int m[N];
void solve()
{
	int n;
	cin >> n;
	
	REP(i, 0, n) {
		int x;
		cin >> x;
		m[x - 1]++;
		m[x]++;
		m[x + 1]++;
	}
	int ans = 0;
	REP(i, 0, N) {
		upmax(ans, m[i]);
	}
	cout << ans;

}

int main()
{
	//freopen("codeforces.in", "r", stdin);
	//freopen("codeforces.out", "w", stdout);
	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;
	//cin>>t;

	while (t--) {
		solve();
	};


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;

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

long long max(long long a,long long b){
	return (a>b)? a:b;
}
int j_k_bit_1or0(int j,int k){

}

int main (){
	long long NNN,MMM,maxx=0,p=0,sum=0;
	cin >> NNN >> MMM;
	long long a[3][NNN];
	rep(i,NNN){rep(j,3){scanf("%lld",&a[j][i]);}}
	vector <long long> temp[8];
	rep(i,8){
		rep(j,NNN){
			rep(k,3)(i & (1 << k))? p += a[k][j]:p -= a[k][j];
			temp[i].push_back(p);
			p=0;
		}
		sort(temp[i].rbegin(),temp[i].rend());
		sum=0;
		rep(k,MMM)sum += temp[i][k];
		maxx = max(sum,maxx);
	}
	printf("%lld",maxx);

	return 0;
}


Measured memory_bytes: 384
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M

main = do
    (n:m:_)<-map read.words<$>getLine::IO[Int]
    pys<-replicateM m $ unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[[Int]]

    let mp = foldl' (\m ((p:y:_),n)->M.alter (f (y,n)) p m) M.empty $ zip pys [1..]
    --
    let ns = sort $ concatMap (\(p, m)-> (map (\((_,c),n)->(c, (p,n)) ) $ zip (M.toAscList m) [1..])) $ M.toAscList mp
    putStr $ unlines $ map g ns
--
f (y,n) Nothing = Just (M.singleton y n)
f (y,n) (Just m) = Just (M.insert y n m)
--
g (_,(p,x)) = drop (length $ show p) ("000000"++show p) ++ drop (length $ show x) ("000000"++show x)

Measured memory_bytes: 46588
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect

while(True):
    score = [0, 0]
    cards = []
    n = int(input())
    if n == 0:
        break

    for i in range(n):
        cards.append(list(map(int, input().split())))

    for i in range(n):
        if cards[i][0] > cards[i][1]:
            score[0] += sum(cards[i])
        elif cards[i][0] < cards[i][1]:
            score[1] += sum(cards[i])
        else:
            score[0] += cards[i][0]
            score[1] += cards[i][1]
    print(str(score[0]) + " " + str(score[1]))

Measured memory_bytes: 15080
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int H, W;
    cin >> H >> W;
    int sh, sw;
    cin >> sh >> sw;
    sh--, sw--;
    int gh, gw;
    cin >> gh >> gw;
    gh--, gw--;

    vector<vector<char>> G(H, vector<char>(W));
    rep(i, H) {
        rep(j, W) { cin >> G[i][j]; }
    }

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

    queue<pll> que;
    vector<vector<int>> dist(H,
                             vector<int>(W, -1)); // 全頂点を「未訪問」に初期化
    que.push({sh, sw});
    dist[sh][sw] = 0;

    while (1) {
        queue<pll> q;

        q = que;

        if (que.empty())
            break;

        while (!que.empty()) {
            pll v = que.front();
            que.pop();

            for (int i = 0; i < 4; i++) {
                pll nv = {v.first + dx[i], v.second + dy[i]};

                if (nv.first < 0 || nv.second < 0 || nv.first >= H ||
                    nv.second >= W)
                    continue;
                if (G[nv.first][nv.second] == '#' ||
                    dist[nv.first][nv.second] != -1)
                    continue;
                dist[nv.first][nv.second] = cost;
                que.push({nv.first, nv.second});
                q.push({nv.first, nv.second});
            }
        }

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

            for (int i = -2; i <= 2; i++) {
                for (int j = -2; j <= 2; j++) {
                    int nh = v.first + i;
                    int nw = v.second + j;
                    if (nh < 0 || nw < 0 || nh >= H || nw >= W)
                        continue;
                    if (G[nh][nw] == '#' || dist[nh][nw] != -1)
                        continue;
                    que.push({nh, nw}), dist[nh][nw] = cost + 1;
                }
            }
        }

        cost++;
    }

    cout << dist[gh][gw] << endl;
}

Measured memory_bytes: 8724
#harshad number 
n = int(input()) 
flag = 0 
n_str = str(n) 
n_len = len(n_str) 
n_digit = 0 
for i in range(n_len):
    n_digit += int(n_str[i]) 

if n % n_digit == 0: 
    flag = 1



if flag:
    print('Yes') 
else:
    print('No')


Measured memory_bytes: 9116
#include <cstdio>

int main(){
    char C1[4], C2[4];
    scanf("%s %s", C1, C2);
    if(C1[0]==C2[2] && C1[1]==C2[1] && C1[2]==C2[0]) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
using ll = long long;
using str = string;
constexpr long long INF = (1LL<<60);
constexpr long long MOD = (1e9+7);
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}

main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);
  
  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  vector<pair<ll,ll>> b;
  rep(i,n)b.emplace_back(a[i],i+1);
  sort(b.begin(),b.end(),greater<>());
  multiset<ll> st={0,0,b[0].second,n+1,n+1};
  ll ans=0;
  reps(i,n-1){
    auto itr=st.insert(b[i].second);
    auto LL=itr,L=itr,R=itr,RR=itr;
    LL--;LL--;L--;
    RR++;RR++;R++;
    // LL L bi.sec R RR
    ll w=*LL,e=*L,r=b[i].second,t=*R,y=*RR;
    // w e r t y
    if(w==0&&e==0&&t!=n+1&&y==n+1){
      // use r-t
      ans+=(y-t)*(r-e)*b[i].first;
    }
    else if(w==0&&e!=0&&t==n+1&&y==n+1){
      //use e-r
      ans+=(t-r)*(e-w)*b[i].first;
    }
    else if(w==0&&e!=0&&t!=n+1&&y==n+1){
      // use r-t
      ans+=(y-t)*(r-e)*b[i].first;
      // use e-r
      ans+=(t-r)*(e-w)*b[i].first;
    }
    else if(w==0&&e==0&&t!=n+1&&y!=n+1){
      // use r-t
      ans+=(r-e)*(y-t)*b[i].first;
    }
    else if(w!=0&&e!=0&&t==n+1&&y==n+1){
      // use e-r
      ans+=(t-r)*(e-w)*b[i].first;
    }
    else if(w==0){
      // use r-t
      ans+=(y-t)*(r-e)*b[i].first;
      // use e-r
      ans+=(t-r)*e*b[i].first;
    }
    else if(y==n+1){
      // use r-t
      ans+=(y-t)*(r-e)*b[i].first;
      // use e-r
      ans+=(t-r)*(e-w)*b[i].first;
    }
    else{
      // use r-t
      ans+=(y-t)*(r-e)*b[i].first;
      // use e-r
      ans+=(t-r)*(e-w)*b[i].first;
    }
  }
  cout<<(ans)<<endl;
  


}


Measured memory_bytes: 7280
#include <iostream>
#include <algorithm>
#include <vector>

using ll = long long;
using namespace std;
static const int INF = 1000000007;
using P = pair<int, int>;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};



int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> m(52, vector<int> (52, INF));
    for (int i = 1; i <= h; ++i) {
        string s;
        cin >> s;
        for (int j = 1; j <= w; ++j) {
            if(s[j-1] == '#') m[i][j] = 1;
            else m[i][j] = 2;
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(m[i][j] <= 1){
                for (int k = 0; k < 4; ++k) {
                    if(m[i+dx[k]][j+dy[k]] <= 1){
                        m[i][j] = 0; m[i+dx[k]][j+dy[k]] = 0;
                    }
                }
            }
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if(m[i][j] == 1) {
                cout << "No" << "\n";
                return 0;
            }
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  string a[100],b[100];
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  int cnt=0;
  bool flag;
  for(int i=0;i<m;i++){
    flag=false;
    for(int j=0;j<a[i].size();j++){
      if(flag){
	break;
      }
      if(a[i][j]==b[i][0]){
	for(int k=0;k<b[i].size();k++){
	  if(a[i][j+k]!=b[i][k]){
	    break;
	  }
	  if(k==b[i].size()-1){
	    cnt++;
	    flag=true;
	  }
	}
      }
    }
  }
  if(cnt==m){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
      
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a[m];
    cin(i,a);
    intl cnt = 0;
    rep(i,m)cnt += a[i];
    cout << max(-1,n - cnt) << endl;
    return 0;
}

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

using namespace std;

int main(){

  int N, K ;
  cin >> N >> K;

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

  for(int i = 0;i < N ; i++){
    int max = i;
    for(int j = i+1;j < N;j++){
      if(array[max] < array[j]){
	max = j;

      }

    }
          swap(array[i],array[max]);
  }
  /*for (int i = 0; i < N ;i++){
    cout <<array[i];
    } */
  
  int sum = 0;
  for(int i = 0;i < K;i++){

    sum += array[i];
  }
  
  cout << sum << endl;
    
  return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
const int N = 1e5+1;
signed main()
{
    fast;
    int x;
    cin>>x;
    for(int i=0;i*100<=x;i++)
        for(int j=0;j*101<=x-i*100;j++)
            for(int k=0;102*k<=x-i*100-j*101;k++)
                for(int l=0;103*l<=x-i*100-j*101-k*102;l++)
                    for(int m=0;104*m<=x-i*100-j*101-k*102-l*103;m++)
                        for(int n=0;105*n<=x-i*100-j*101-k*102-l*103-m*104;n++)
                            if(i*100+j*101+k*102+l*103+m*104+n*105 == x)
                            {
                                cout<<1;
                                return 0;
                            }
    cout<<0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	int N;
	vector<long long> A, a;

	cin >> N;
	for(int i=0; i<N; i++){
		long long v;
		cin >> v;
		A.push_back(v);
		a.push_back(v - (i + 1));
	}

	//ソートしておく
	sort(a.begin(), a.end());

	//bがb->b+1に変化するとき、悲しさは以下の通り変化する。
	// (b以下の個数) - (b+1以上の個数)
	// 全部でN個なので、(b以下の個数) - (N - b以下の個数)変化する。
	//　b以下の個数がN/2以下の場合は減り続け、b以下の個数がN/2を超えると増える。
	long long ans = 0, ans1 = 0, ans2=0, ans3=0;
	for(int i=0; i<N; i++){
		ans1 += abs(a[i] - a[N/2]);
	}
	for(int i=0; i<N; i++){
		ans2 += abs(a[i] - a[(N/2)]+1);
	}
	for(int i=0; i<N; i++){
		ans3 += abs(a[i] - a[(N/2)]-1);
	}
	ans = min(ans1, min(ans2, ans3));
	cout << ans << endl;
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var first = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var second = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var H = first[0];
            var W = first[1];
            var h = second[0];
            var w = second[1];

            var result = H * W - (h * W + (H - h) * w);

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    ll a,b,c,k; cin>>a>>b>>c>>k;
    ll res=k;
    ll ans=0;
    if(res<=a){
        cout<<res<<endl;
        return 0;
    }else{
        ans+=a;
        res-=a;
    }

    if(res<=b){
        cout<<ans<<endl;
        return 0;
    }else{
        res-=b;
    }

    cout<<ans-res<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
/*********ANISH***********ANISH*************ANISH***********ANISH******/
#define pb push_back
#define ll long long
#define ff first
#define ss second
ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
ll min(ll a,ll b)
{
    if(a<b) return a;
    return b;
}
/********ANISH************ANISH*************ANISH**********ANISH*********/
const int mod=1e9+7;
int h,w;
char arr[1001][1001];
ll dp[1001][1001];
int main()
{
    int t;
    t=1;
    while(t--)
    {
        cin>>h>>w;
        for(int i=0;i<h;++i)
        {
            for(int j=0;j<w;++j)
                cin>>arr[i][j];
        }
        dp[0][0]=1;
        for(int i=1;i<h;++i)
        {
            if(arr[i][0]=='#') dp[i][0]=0;
            else dp[i][0]=dp[i-1][0];
        }
        for(int i=1;i<w;++i)
        {
            if(arr[0][i]=='#') dp[0][i]=0;
            else dp[0][i]=dp[0][i-1];
        }
        for(int i=1;i<h;++i)
        {
            for(int j=1;j<w;++j)
            {
                if(arr[i][j]=='.')
                 dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
                else dp[i][j]=0;
            }
        }
        cout<<dp[h-1][w-1];
    }
}


Measured memory_bytes: 9088
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	w := getNextInt(scanner)

	vw := make([][2]int, n)

	for i := 0; i < n; i++ {
		vw[i][0] = getNextInt(scanner)
		vw[i][1] = getNextInt(scanner)
	}

	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, w+1)
		for ii := 1; ii <= w; ii++ {
			if i == 0 {
				if ii-vw[i][1] >= 0 {
					dp[i][ii] = vw[i][0]
				}
				continue
			}
			dp[i][ii] = dp[i-1][ii]
			if ii-vw[i][1] < 0 {
				continue
			}
			if dp[i-1][ii-vw[i][1]]+vw[i][0] > dp[i][ii] {
				dp[i][ii] = dp[i-1][ii-vw[i][1]] + vw[i][0]
			}
		}
	}

	fmt.Fprintln(writer, dp[n-1][w])
	writer.Flush()
}



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

 
int main(){

  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end(),greater<int>());

  int ans = 0;
  
  rep(i,n-2){
    int lmax = l[i];
    for(int j = i+1; j < n-1; j++){
      int dif = lmax - l[j];
      for(int k = j+1; k<n; ++k){
        if(l[k] <= dif) break;
        ++ans;
      }
    }
  }

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

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

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

ll N, D[101010][2];
ll i, j, k;

int main(){
    scanf("%lld", &N);
    ll mx=0;
    j = 0;
    rep(i,0,N){
        scanf("%lld%lld", &D[i][0], &D[i][1]);
        if(D[i][0]==D[i][1]){
            ++j;
            mx = max(mx, j);
        }else{
            j = 0;
        }
    }
    if(mx>=3){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define reg register

using namespace std;

const int mod = 1e9 + 7;
long long A, B;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline long long ksm(long long base, int mi) {
	long long res = 1;
	while(mi) {
		if(mi & 1) (res *= base) %= mod;
		(base *= base) %= mod, mi >>= 1;
	}
	return res;
}

int main() {
	cin >> A >> B;
	cout << max(A + B, max(A - B, A * B)) << endl;
	return 0;
}


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


A.sort()
A.append(N + 1)
ans = [0] * (N+1)
count = [0, 0]

for i in range(N):
    if count[0] == A[i]:
        count[1] += 1
    else:
        ans[count[0]] = count[1]
        count[0] = A[i]
        count[1] = 1

for j in range(1, N+1):
    print(ans[j])

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
  int n; cin >> n;
  int a[n-1]; rep(i,n-1) cin >> a[i];

  map<int, int> m;
  rep(i,n-1){
    m[a[i]]++;
  }

  rep(i,n){
    cout << m[i+1] << endl;
  }
}

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

int cnt_digits(ll N){
	int digits=0;
	
	while(N>0){
		N/=10;
		digits++;
	}
	
	return digits;
}

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

	int ans=cnt_digits(N); // 1*N=N max(cnt_digits(1),cnt_digits(N))=cnt_digits(N)

	for(ll A=1LL;A*A<=N;++A){
		if(N%A!=0) continue;
		const ll B=N/A;
		
		const int cur=max(cnt_digits(A),cnt_digits(B));

		if(ans>cur){
			ans=cur;
		}
	}

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

Measured memory_bytes: 256
def main():
    N, X, Y = map( int, input().split())
    K = [0]*N
    X -= 1
    Y -= 1
    for i in range(N-1):
        for j in range(i+1,N):
            if i <= X:
                if j <= X:
                    K[j-i] += 1
                elif X <= j <= Y:
                    if (X-i) + 1 + (Y-j) <= j-i:
                        K[(X-i) + 1 + (Y-j)] += 1
                    else:
                        K[j-i] += 1
                else:
                    K[(X-i) + 1 + (j-Y)] += 1
            elif i <= Y:
                if j <= Y:
                    if (i-X) + 1 + (Y-j) <= j-i:
                        K[(i-X) + 1 + (Y-j)] += 1
                    else:
                        K[j-i] += 1
                else:
                    if (i-X) + 1 + (j-Y) <= j-i:
                        K[(i-X) + 1 + (j-Y)] += 1
                    else:
                        K[j-i] += 1
            else:
                K[j-i] += 1

    print( "\n".join( map( str, K[1:])))
if __name__ == '__main__':
    main()


Measured memory_bytes: 41912
N, K = map(int, input().split())
mod = 998244353

L = []
for _ in range(K):
    a, b = map(int, input().split())
    b += 1
    L.append([a, b])

ruiwa = [0] * (N + 1)
dp = [0] * (N + 1)
dp[1] = 1
ruiwa[1] = 1
for i in range(2, N + 1):
    for l, r in L:
        l = i - l
        r = i - r
        l, r = r, l
        if r < 0:
            continue
        elif l >= 0:
            # print(ruiwa, r, l)
            dp[i] += (ruiwa[r] - ruiwa[l]) % mod
        else:
            dp[i] += ruiwa[r] % mod
    ruiwa[i] = (ruiwa[i - 1] + dp[i]) % mod

print(dp[-1] % mod)


Measured memory_bytes: 26988
#include <stdio.h>
#define N 101
#define null (-1)
#define INF (1 << 21)
#define WHITE 0
#define BLACK 1;
#define GRAY 2

void BFS(int);
void Enqueue(int);
int Dequeue();
int G[N][N];
int vertex[N];
int color[N];
int d[N];
int queue[N];
int n;
int head, tail;
int e[N];

int main(void){

  int i, j;
  scanf("%d",&n);
  
  for(i = 1;i <= n;i++){
    scanf("%d", &vertex[i]);
    scanf("%d", &e[vertex[i]]);
    
    for(j = 1;j <= e[vertex[i]];j++)
      scanf("%d", &G[i][j]);
  }

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

void BFS(int s){
  
  int i, u, v;
  int next;
  int empty;
 
  for(u = 1; u <= n;u++){
    color[u] = WHITE;
    d[u] = INF;
  }

  color[s] = GRAY;
  d[s] = 0;
  empty = 0;

  //最初はsをキューに入れる。
  Enqueue(s);
  empty++;

  //空じゃなかったら
  while(empty != 0 ){    
    u = Dequeue();
    empty--;

    //取り出したキューがエッジを持つなら、訪問する。
    for(v = 1;v <= e[u];v++){
      next = G[u][v];
      if(next && (color[next] == WHITE)){
	color[next] = GRAY;
	d[next] = d[u] + 1;
	Enqueue(next);
	empty++;
      }
    }
    
    //訪問した場所は黒くする。
    color[u] = BLACK;
  }

  for(i = 1;i <= n;i++){
    if(color[i] == WHITE)
      d[i] = null;
  }
}

void Enqueue(int v){

  if(tail == N)
    tail = 0;
  queue[tail++] = v;
}

int Dequeue(){

  if(head == N)
    head = 0;
  return queue[head++];
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    long h,w ;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << 1 << endl;
    }else{
       if((h*w)%2 == 0){
            cout << (h*w)/2 << endl;
        }else{
            cout << (h*w)/2 + 1 << endl;
        }
    }
 
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
typedef pair<int,int> P;
int main(){
    string s;cin>>s;
    ll k;cin>>k;
    char c;
    ll id=INF;
    for(int i=0;i<s.length();i++){
        if(s[i]!='1'){
            c=s[i];
            id=i;
            break;
        }
    }
    if(id>=k||id==INF){
        cout<<1<<endl;
    }else{
        cout<<c<<endl;
    }
}   


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	bool b;
	int n, i, j, t, c[2];
	char s[201];
	cin >> n;
	for (i = 0; i < n; i++)
	{
		b = true;
		cin >> s;
		if (s[0] == '>')
		{
			if (s[1] == '\'')
			{
				for (j = 2, t = c[0] = c[1] = 0; j < strlen(s)-1; j++)
				{
					if (s[j] == '=')
						c[t]++;
					else if (t == 0 && s[j] == '#')
						t++;
					else
					{
						b = false;
						break;
					}
				}
				if (b && c[0] > 0 && c[0] == c[1] && s[strlen(s)-1] == '~')
					cout << "A" << endl;
				else
					cout << "NA" << endl;
				continue;
			}
			else if (s[1] == '^')
			{
				for (j = 2, c[0] = 0; j < strlen(s)-2; j+=2)
				{
					if (s[j] != 'Q' || s[j+1] != '=')
					{
						b = false;
						break;
					}
					else
						c[0]++;
				}
				if (b && c[0] > 0 && s[strlen(s)-2] == '~' && s[strlen(s)-1] == '~')
					cout << "B" << endl;
				else
					cout << "NA" << endl;
				continue;
			}
			else
				b = false;
		}
		else
			b = false;
		if (!b)
			cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int n;
vector<pair<int, int>> a[20];
int best = 0;

void solve(int pos, vi& s) {
	if(pos == n) {
		int ret = 0;
		rep(i,0,n) {
			if(!s[i]) continue;
			ret++;
			vector<pii>& b = a[i];
			rep(j,0,sz(b)) {
				int k = b[j].F;
				int y = b[j].S;
				if(s[k] != y) {
					return;
				}
			}
		}
		best = max(best, ret);
		return;
	}

	s[pos] = 0;
	solve(pos+1, s);
	s[pos] = 1;
	solve(pos+1, s);
}

int main(void) {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    cin >> n;
    rep(i,0,n) {
    	int t;
    	cin >> t;
    	rep(j,0,t) {
    		int x, y;
    		cin >> x >> y;
    		x--;
    		a[i].pb(mp(x,y));
    	}
    }

    vi status(n, 2);
    solve(0, status);
    cout << best << endl;
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    string s;
    cin >> s;
    Int n = s.length();
    Int x = 0;
    for (Int i = 0; i < n; i++) {
        x += s[i] - '0';
    }
    Int y = (n - 1) * 9 + (s.front() - '1');
    dump(max(x, y));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1e9;
const long double EPS = 1e-10;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;
  char s[h][w];
  rep(i, h) {
    rep(j, w) {
      cin >> s[i][j];
    }
  }

  int d[h][w];
  rep(i, h) {
    rep(j, w) {
      d[i][j] = INF;
    }
  }
  d[0][0] = 1;
  
  bool flag = true;
  while (flag) {
    flag = false;
    rep(i, h) {
      rep(j, w) {
        if (s[i][j] == '#') continue;
        rep(k, 4) {
          if (i + dy[k] < 0) continue;
          if (i + dy[k] >= h) continue;
          if (j + dx[k] < 0) continue;
          if (j + dx[k] >= w) continue;
          if (d[i + dy[k]][j + dx[k]] == INF) continue;
          if (d[i][j] > d[i + dy[k]][j + dx[k]] + 1) {
            d[i][j] = d[i + dy[k]][j + dx[k]] + 1;
            flag = true;
          }
        }
      }
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') ans++;
    }
  }
  ans -= d[h - 1][w - 1];
  cout << (ans < 0 ? -1 : ans) << endl;
  





  
  return 0;
}

Measured memory_bytes: 256