akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int X = input[1];
            int[] m = new int[N];
            long sum = 0;
            for(var i = 0; i < N; i++)
            {
                m[i] = int.Parse(Console.ReadLine());
                X -= m[i];
            }

            long ans = N;
            ans += X / m.Min();
            Console.WriteLine(ans);


            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 13396
#include <stdio.h>
int main(void)
{
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a / b;
	r = a%b;
	f =(double)(a) /(double)(b);
	printf("%d %d %f\n", d, r, f);
	return 0;
}

Measured memory_bytes: 1844
#include <stdio.h>

int main(void){
  int i,sum;
  char num[1001]; //NULLが入る

  for(;;){
    scanf("%s", &num);
    if(num[0] == '0') break;
    
    sum = 0;
    for(i=0;num[i]!='\0';i++) //‘\0’ char
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
  
  return 0;
}
//これ、データセットじゃないのか




Measured memory_bytes: 2048
#include <stdio.h>

int main(void){
  double x, y, a, b, c, d, e, f;

  /* ??£???????¨????????§£??? */
  while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF){
    y = (c*d - f*a) / (b*d - e*a);
    x = (c - b*y) / a;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 652
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, P[200001], i, min, ans=0;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> P[i];
    }

    min = P[1];

    for(i=1; i<=N; i++){
        if(P[i] <= min){
            ans++;

            min = P[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

int N, M;
vector<bool> issafe; // issafe[v] := v が壊れていないかどうか

int main() {
    cin >> N >> M;
    issafe.assign(N+1, true);
    for (int i = 0; i < M; ++i) {
        int a; cin >> a;
        issafe[a] = false; // a 段目は壊れてる
    }

    // DP テーブル
    vector<int> dp(N+1, 0); // 各段について 0 で初期化しておく

    // 初期条件
    dp[0] = 1;
    if (issafe[1]) dp[1] = 1;

    // ループ
    for (int n = 2; n <= N; ++n) {
        if (issafe[n-1]) dp[n] += dp[n-1]; // n-1 段目が安全なら
        if (issafe[n-2]) dp[n] += dp[n-2]; // n-2 段目が安全なら
        dp[n] %= MOD; // 1000000007 で割る
    }
    cout << dp[N] << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 2);
  for(int i = 0; i < n; i++){
    cin >> a.at(i + 1);
  }
  a.at(0) = 0;
  a.at(n + 1) = 0;
  vector<int> b(n + 1);
  for(int i = 0; i < n + 1; i++){
    b.at(i) = a.at(i + 1) - a.at(i);
    if(b.at(i) < 0) b.at(i) = -b.at(i);
  }
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    c.at(i) = a.at(i + 2) - a.at(i);
    if(c.at(i) < 0) c.at(i) = -c.at(i);
  }
  long int sum = 0;
  for(int i = 0; i < n + 1; i++){
    sum += b.at(i);
  }
  for(int i = 0; i < n; i++){
    cout << sum - b.at(i) - b.at(i + 1) + c.at(i) << endl;
  }
}

Measured memory_bytes: 2432
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,m=MI()
ans=0
vote=[0 for i in range(m)]
likes=[]
for i in range(n):
    likes.append(LI())
#print(likes)
for j in range(len(likes)):
    for k in range(1,len(likes[j])):
        #print(likes[j][k])
        vote[likes[j][k]-1]+=1
#print(vote)
for v in vote:
    if v==n:
        ans+=1
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

bool is_square(int64_t n){
    if ((int64_t)sqrt(n) * (int64_t)sqrt(n) == n) return true;
    else return false;
}

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

int N; cin >> N;

// 1+8N は奇。奇＝奇×奇。
// 1+8N が平方数であるならyes
if (is_square(1 + 8*N)){
    cout << "Yes\n";
    int w = (sqrt(1 + 8*N) + 1) / 2;
    cout << w << "\n";
    VVI ans(w, VI(w-1));
    for(int i = 0, a = 1; i < w-1; ++i){
        rep(j, i, w-1){
            ans[i][j] = a;
            ans[j+1][i] = a;
            ++a;
        }
    }
    rep(i, 0, w){
        cout << w-1 << ' ';
        rep(j, 0, w-1) cout << ans[i][j] << ' ';
        cout << "\n";
    }
}
else {
    cout << "No\n";
}


return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2944
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

N = read_a_int()
A = read_ints()
Q = read_a_int()
B, C = read_col(Q)

# 各数が何回登場するかカウントすれば良い
cnt = Counter(A)
ans = []
tmp = sum(A)
for b, c in zip(B, C):
    # 値がBであるものの個数の取得と0に書き換え
    n = cnt[b]
    cnt[b] = 0
    # 値cへの加算
    cnt[c] += n
    tmp -= n * b
    tmp += n * c
    ans.append(tmp)


# ans = 0
# for k, v in cnt.items():
#     ans += k * v
print(*ans, sep='\n')


Measured memory_bytes: 117264
#include<vector>
#include<iostream>
#include<string>
#include <iostream>
#include <algorithm>
#include <queue>

#define INF 100000000000000
using namespace std;
//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す
//int strlen(char[] str)	文字列 str の長さを返す
//char[] strcpy(char[] s1, char[] s2)	文字列 s1 に文字列 s2 をコピーする
//char[] strcat(char[] s1, char[] s2)	文字列 s1 に文字列 s2 を連結する
//char[] strstr(char[] s1, char[] s2)	文字列 s1 から文字列 s2 を探す：
//見つかったときその位置のアドレスを返す
//見つからなかったとき NULL を返す
//int strcmp(char[] s1, char[] s2)	文字列 s1 と文字列 s2 を比較する：
//s1 = s2 のとき 0 を返す
//s1 < s2（s1 の方が辞書順で前）のとき '負' を返す
//s1 > s2（s2 の方が辞書順で前）のとき '正' を返す

//与えられた文字列にアルファベットが存在した場合全て小文字にする
//queue
//queue<型> 変数名;
//変数.push(値)
//変数.front()
//変数.pop()先頭の要素を削除
//変数.size() 要素数の取得
string all_lower(string S){
    for(int i=0;  i<S.size(); i++){
        if(isalpha(S.at(i))==false){
            continue;
        }
        if(isupper(S.at(i))){
            S.at(i) = tolower(S.at(i));
        }
    }
    return S;
}

typedef struct _ProcInfo{
    string name;
    long long time;
    long long elapsed_time;
}ProcInfo;

int main() {
    queue<ProcInfo> fifo;
    long long n,q;
    string name;
    long long time;
    ProcInfo proc;
    long long elapsed_time=0;
    cin >> n >> q;
    for(int i=0; i<n; i++){
        cin >> name >> time;
        proc.name = name;
        proc.time = time;
        proc.elapsed_time = 0;
        fifo.push(proc);
    }
    while(fifo.size()!=0){
        proc = fifo.front();
        fifo.pop();
        elapsed_time = elapsed_time + min(proc.time, q);
        
        proc.time = proc.time - q;
        if(proc.time<=0){
            cout << proc.name << " " << elapsed_time << endl;
        }else{
            fifo.push(proc);
        }
    }

}


Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=2e5+10,MAXM=1e6+10;
const int MOD=1e9+7,INF=~(1<<31);
const ll llINF=((1ll<<61));

ll a[MAXN];

int main()
{
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    ll maxn=llINF,tmp=0;
    for(int i=1;i<n;i++)
    {
        tmp+=a[i];
        maxn=min(maxn,abs(sum-tmp*2));
    }
    cout<<maxn;
    return 0;
}


Measured memory_bytes: 1792
require 'set'; require 'prime'
INF=Float::INFINITY
n,k,s = gets.chomp.split.map(&:to_i)

ar = []
if s != 10**9
  k.times do |i|
    ar.push s
  end

  (n-k).times do |i|
    ar.push s+1
  end
else
  k.times do |i|
    ar.push s
  end

  (n-k).times do |i|
    ar.push 1
  end
end

puts ar.join(' ')

Measured memory_bytes: 5368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

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

  std::sort(A.begin(), A.end());

  for (int i = 1; i < N; i++)
  {
    A[i] %= A[0];
  }

  bool changed = true;
  while (changed)
  {
    std::sort(A.begin(), A.end());

    changed = false;
    int mn = 0;
    for (int i = 0; i < N; i++)
    {
      if (A[i] == 0)
        continue;

      if (mn == 0)
      {
        mn = A[i];
        continue;
      }

      int tmp = A[i];
      A[i] %= mn;
      if (tmp != A[i])
        changed = true;
    }
  }

  rep(i, N)
  {
    if (A[i] != 0)
    {
      cout << A[i] << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
import math

def solve(N, S, Q, queries):
    def update(i, c):
        values[i] = c
        s = (i // sN) * sN
        buckets[i//sN] = 0
        for v in values[s:min(s+sN, len(values))]:
            buckets[i//sN] |= 1 << v

    def count(l, r):
        res = 0
        for i in range(sN):
            ll = i * sN
            rr = ll + sN
            if r <= ll or rr <= l:
                continue
            if l <= ll and rr <= r:
                res |= buckets[i]
            else:
                for j in range(max(l, ll), min(r, rr)):
                    res |= 1 << values[j]
        return sum(b == '1' for b in bin(res))
        
    sN = math.ceil(N ** 0.5)
    values = [ord(c)-ord('a') for c in S]
    buckets = [0] * sN
    for i, v in enumerate(values):
        buckets[i//sN] |= 1 << v
    for t, x, y in queries:
        if t == 1:
            update(int(x)-1, ord(y)-ord('a'))
        else:
            yield count(int(x)-1, int(y))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    S = next(tokens)
    Q = int(next(tokens))
    queries = [(int(next(tokens)), next(tokens), next(tokens)) for _ in range(Q)]
    for result in solve(N, S, Q, queries):
        print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 81756
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def resolve():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input().rstrip())

    if w >= v:
        print("NO")
        exit()

    dis = b - a
    dis = abs(dis)
    v_sub = v - w

    limit_dis = v_sub * t

    if dis <= limit_dis:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 61880
#include<stdio.h>
#define N 8
#define FALSE 0
#define TRUE 1
#define FREE -1
#define NFREE 1

int M[N][N],row[N],col[N],dpo[2*N-1],dne[2*N-1];

void ini();
void Print();
void Queen(int);

int main(){
  int i,k,j,x,y;

  ini();

  for(i=0;i<N;i++){
    for(j=0;j<N;j++)M[i][j] = FALSE;
  }

  scanf("%d",&k);

  for(i=0;i<k;i++){
    scanf("%d%d",&x,&y);
    M[x][y] = TRUE;
  }

  Queen(0);

  return 0;
}

void ini(){
  int i;
  for(i=0;i<N;i++) row[i] = col[i] = FREE;
  for(i=0;i<2*N-1;i++)dne[i] = dpo[i] = FREE;
}

void Queen(int i){
  int j;

  if(i == N) {
    Print();
    return;
  }

  for(j=0;j<N;j++){
    if(col[j] ==  NFREE || dpo[i+j] == NFREE || dne[i-j+N-1] == NFREE)continue;

    row[i] = j;
    col[j] = dpo[i+j] = dne[i-j+N-1] = NFREE;
    Queen(i+1);
    row[i] = col[j] = dpo[i+j] = dne[i-j+N-1] = FREE;
  }

}

void Print(){
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(M[i][j]){
        if(row[i]!= j)return;
      }
    }
  }


  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



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

typedef long long int ll;

using namespace std;

int main() {
    ll N, h;
    cin >> N;
    ll dp[N+4], H[N+4];
    for (ll i=1; i<=N; i++){
        cin >> h;
        H[i] = h;
    }

    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(H[2]-H[1]);

    for (ll i=3; i<=N; i++){
        dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]),
                    dp[i-2] + abs(H[i] - H[i-2]));
    }

    // for (ll i=0; i<=N; i++){
    //     cout << "i = " << i << " " << dp[i] << endl;
    // }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
// 型に合わせた値 2倍してもオーバーフローしないようにする
// const int INF = 1e9;
const LL INF = 1e17;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    vector<LL> v(N+1, 0);    // 累積和
    for(int i=0; i<N; i++) v[i+1] = v[i]+a[i];
    vector<LL> w(N+1, 0);    // 正の値のみの累積和
    for(int i=0; i<N; i++) w[i+1] = w[i]+max(a[i], 0);

    LL ans = -INF;
    for(int i=0; i+K<=N; i++){
        LL tmp = w[N];
        // Kマスを白or黒に塗る
        tmp += max(v[i+K]-v[i], 0LL);
        tmp -= w[i+K]-w[i];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
//
// Created by yamunaku on 2019/07/14.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> f(h);
    rep(i,h) cin >> f[i];
    int mil=100000,mal=-100000,mir=100000,mar=-100000;
    rep(i,h){
        rep(j,w){
            if(f[i][j]=='B'){
                mil=min(mil,i+j);
                mal=max(mal,i+j);
                mir=min(mir,i-j);
                mar=max(mar,i-j);
            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(f[i][j]=='B'){
                ans=max(ans,abs(i+j-mil));
                ans=max(ans,abs(i+j-mal));
                ans=max(ans,abs(i-j-mir));
                ans=max(ans,abs(i-j-mar));
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3244
import Control.Applicative

main :: IO ()
main = do
    [w,h,x,y,r] <- map read . words <$> getLine
    putStrLn $ if (x,y,r) `isInside` (w,h) then "Yes" else "No"

isInside :: (Int, Int, Int) -> (Int, Int) -> Bool
isInside (x,y,r) (w,h) = r <= x && x+r <= w && r <= y && y+r <= h


Measured memory_bytes: 3644
#include<stdio.h>
int main ()
{
  long int x[1000][2];
  long int n, h, w;
  int count = 0;
  scanf("%ld %ld %ld", &n, &h, &w);
  for (int i = 0; i < n; i++) {
    scanf("%ld %ld", &x[i][0], &x[i][1]);
  }
  for (int i = 0; i < n; i++) {
    if (x[i][0] >= h && x[i][1] >= w) count++;
  }
  printf("%d", count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;

int main() {
  for (int i = 1; i <= 5; i++) {
    int x;
    cin >> x;
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
import math
text=input().split()
for i,v in enumerate(text):
    text[i]=int(v)
while text[0] or text[1]:
    for i in range(text[0]):
        if i%2==0:
            print('#.'*(text[1]//2)+'#'*(text[1]%2))
        else:
            print('.#'*(text[1]//2)+'.'*(text[1]%2))
    text=input().split()
    print()
    for i,v in enumerate(text):
        text[i]=int(v)



Measured memory_bytes: 5668
import sys
input = sys.stdin.readline

def same_tree(node_a, node_b):
    if node_a.root() == node_b.root():
        return True

def unite(node_a, node_b):
    root_a = node_a.root()
    root_b = node_b.root()
    if root_a == root_b:
        return
    if root_b.depth > root_a.depth:
        root_a, root_b = root_b, root_a
    root_b.is_root = False
    root_b.parent = root_a
    root_a.depth = max(root_a.depth, root_b.depth+1)

class Node:
    def __init__(self):
        self.is_root = True
        self.parent = None
        self.depth = 1
    
    def root(self):
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    N, M = map(int, input().split())
    kl = [list(map(int, input().split())) for i in range(N)]

    nodes = [Node() for i in range(M)]
    peaple = [Node() for i in range(N)]

    for i in range(N):
        l = kl[i][1:]
        peaple[i].is_root = False
        peaple[i].parent = nodes[l[0]-1]
        for j in range(1, len(l)):
            unite(nodes[l[j]-1], nodes[l[j-1]-1])
    
    ok = True
    for i in range(1, N):
        if not same_tree(peaple[0], peaple[i]):
            ok = False
    
    if ok:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Measured memory_bytes: 54348
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#include <random>
#include <ctime>
#include <chrono>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long

using namespace std;
const int N = 1e6 + 1e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

//long long arr[N];


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

    char ch;cin >> ch;
    if(isupper(ch)) cout << 'A' << endl;
    else cout << 'a' << endl;

    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> updown(n);
    for (ll i = 0; i < n - 1; i++) {
        if (a[i + 1] > a[i]) updown[i] = 1;
        else if (a[i + 1] == a[i]) updown[i] = 0;
        else updown[i] = -1;
    }
    updown[n - 1] = -1;

    ll ans = 1000;
    ll stock = 0;
    rep(i, n) {
        if (updown[i] == 1) {
            ll num = ans / a[i];
            ans -= a[i] * num;
            stock += num;
        }
        else if (updown[i] == -1) {
            ans += stock * a[i];
            stock = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int sum[] = new int[n+1];
		for(int i=0;i<n;i++)sum[i+1] = ( sum[i] + a[i] )% k;
		for(int i=0;i<n+1;i++) {
			sum[i] = (sum[i] - i)%k;
			if(sum[i]<0)sum[i]+=k;
		}
		Map<Integer,Integer> map = new HashMap<>();
		Queue<Integer> q = new ArrayDeque<>();
		long ans = 0;
		for(int i=0;i<n+1;i++) {
			int now = sum[i];
			int num = map.getOrDefault(now,0);
			ans += num;
			map.put(now, num+1);
			q.offer(now);
			while(q.size()>=k) {
				int rm = q.poll();
				map.put(rm, map.get(rm)-1);
			}
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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

Measured memory_bytes: 64144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N=0, Y=0;
  cin >> N >> Y;
  int total=0;
  bool flg=false;
  bool finished=false;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
        int k=N-i-j;
        total=10000*i+5000*j+1000*k;
        if(i+j+k==N && total==Y && k>=0){
          cout << i<< " " << j << " " << k << endl;
          flg=true;
          finished=true;
          break;
        }
      }
      if(finished){
        break;
      }
    }
 
  
  if(!flg){
    cout << "-1 -1 -1" << endl;
  }
  
  
}

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

int main(){
 	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	int t,s;
	for(int i = 0; i < m; i++) {
		cin >> t >> s;
      t--;s--;
		a[t]++;
		a[s]++;
	}
	for(int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
//#define S second
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif
int n,k;
cin>>n>>k;
int arr[n];
rep(i,n){
	cin>>arr[i];
}
int dp[k+1];
memset(dp,0,sizeof(dp));
for(int i = 1;i<=k;i++){
	for(int j = 0;j<n;j++){
		if(arr[j]<=i && !dp[i])
			dp[i] = 1-dp[i-arr[j]];
		if(dp[i])
			break;
	}

}
string s = dp[k]?"First":"Second";
cout<<s;






#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    string s="";
    cin >> s;
    int a[4];
    rep(i,4){
        a[i] = s[i] - '0';
    }
    if(a[0]-a[1]-a[2]-a[3] == 7){
        cout << a[0] << '-' << a[1] << '-' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]-a[1]-a[2]+a[3] == 7){
        cout << a[0] << '-' << a[1] << '-' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]-a[1]+a[2]-a[3] == 7){
        cout << a[0] << '-' << a[1] << '+' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]-a[1]+a[2]+a[3] == 7){
        cout << a[0] << '-' << a[1] << '+' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]+a[1]-a[2]-a[3] == 7){
        cout << a[0] << '+' << a[1] << '-' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]+a[1]-a[2]+a[3] == 7){
        cout << a[0] << '+' << a[1] << '-' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]+a[1]+a[2]-a[3] == 7){
        cout << a[0] << '+' << a[1] << '+' << a[2] << '-' << a[3] << '=' << '7' << endl;
        return 0;
    }
    if(a[0]+a[1]+a[2]+a[3] == 7){
        cout << a[0] << '+' << a[1] << '+' << a[2] << '+' << a[3] << '=' << '7' << endl;
        return 0;
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const ld PIE = atan2(0, -1);

void solve() {
	ld r;
	cin >> r;
	ld ans = 2.00 * PIE * r;
	cout.precision(100);
	cout << ans << "\n";
}

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

Measured memory_bytes: 3764
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
// vector<vector<int>> dir = {{1, 0}, {-1, 0}, {0, 1}, {0, -1},{1,1},{1,-1},{-1,1},{-1,-1}};
vector<vector<int>> v;

double pi = 3.1415926535;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b;
    int h,m;
    cin>> a >> b >> h >> m;
    int tm = h * 60 + m;
    double am = ((2 * pi) / 60) * m;
    double hm = ((2 * pi) / 720) * tm;
    double angle = abs(am - hm);
    double dis = a * a + b * b - 2 * a * b * cos(angle);
    dis = sqrt(dis);
    cout << fixed << setprecision(15) << dis;





}
    

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
  string str,str2;
  cin>>str>>str2;
   if(str.length()>str2.length())
    cout<<"GREATER";
   else if(str.length()<str2.length())
    cout<<"LESS";
  else
  {     int i;
       for( i=0;i<str.length();i++)
       {
        if(str[i]>str2[i])
        {
            cout<<"GREATER";
            break;
        }
        else if(str[i]<str2[i])
        {
            cout<<"LESS";
            break;
        }
       }
       if(i==str.length())
        cout<<"EQUAL";
  }

    return 0;
}








Measured memory_bytes: 3580
// https://atcoder.jp/contests/abc098/tasks/arc098_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = INF;
    string s;
    cin >> n;
    cin >> s;

    int sumW = 0, sumE = 0;
    // 残りの文字の出現回数を計算するため、最初に総数を数える
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            sumW++;
        } else {
            sumE++;
        }
    }
    int nowW = 0, nowE = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            nowW++;
        } else {
            nowE++;
        }
        // (現在より左にあるWの数) + (現在より右にあるEの数) を変更
        if (s[i] == 'W') {
            ans = min(ans, nowW - 1 + (sumE - nowE));
        } else {
            ans = min(ans, nowW + (sumE - nowE));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#include <functional>

#define SIZE 300005
#define INF 1000000000
#define FD(d) fixed << setprecision(d)
#define MOD 1000000007
#define ll long long

using namespace std;

typedef pair<ll, ll> P;


int main()
{
	int a, b;
	int tmp = 1;
	string res;

	cin >> a >> b;

	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
		return (0);
	}
	if (a > 0) {
		cout << "Positive" << endl;
		return (0);
	}
	if ((b - a) % 2 == 0) {
		cout << "Negative" << endl;
		return (0);
	}
	else {
		cout << "Positive" << endl;
		return (0);
	}


}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

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

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_n = 1e3;

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

  int H, W;
  cin >> H >> W;
  int a[H][W];
  REP(i, H) REP(j, W)
    cin >> a[i][j];

  vector<pair<int, int> > vs;
  REP(i, H)
  {
    REP(j, W-1)
    {
      if (a[i][j] % 2 == 1)
      {
	vs.push_back(make_pair(i, j));
	a[i][j]--;
	a[i][j+1]++;
      }
    }
  }
  REP(i, H-1)
  {
    if (a[i][W-1] % 2 == 1)
    {
      vs.push_back(make_pair(i, W-1));
      a[i][W-1]--;
      a[i+1][W-1]++;
    }
  }

  cout << vs.size() << "\n";
  for (vector<pair<int, int> >::iterator i = vs.begin();i != vs.end();i++)
  {
    int y = (*i).first, x = (*i).second;
    if (x != W-1)
    {
      cout << y + 1 << " " << x + 1 << " " << y + 1 << " " << x + 2 << "\n";
    }
    else
    {
      cout << y + 1 << " " << W << " " << y + 2 << " " << W << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 4212
#include<stdio.h>
 
 
int main()
{
  int res,alt,i,j,po=0,f,g,h;
  scanf("%d",&res);
  int x[res];
  char c[12];
  for(i=0;i<res;i++){
    scanf("%s %d",c,&alt);
    if(c[0]=='i'){
      x[i]=alt;
    }
    else if(c[6]=='F'){
      i-=2;
      res-=2;
    }
    else if(c[6]=='L'){
      i--;
      res--;
      po++;
    }
    else{
      i--;
      res--;
      f=0;
      for(j=i;j>=0;j--){
	if(f>0)
	  break;
	if(alt==x[j]){
	  h=0;
	  g=i-j;
	  f++;
	  while(g!=h++)
	    x[j+h-1]=x[j+1+h-1];
	  i--;res--;
	}
      }
    }
  }
  for(i=0;i<res-po;i++){
    if(i==res-po-1)
      printf("%d\n",x[res-1-i]);
    else printf("%d ",x[res-1-i]);
  }
  return 0;
}

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

using namespace std;

int n,m,i,j,a[5005],b[5005][205];
vector <pair<int, int> > c[205];
long long s[5005],sum[5005];

void add(int l, int r, int val){
	s[l] += val;
	s[r + 1] -= val;
}

long long f(int l, int r){
	return sum[r] - sum[l];
}

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 1; i < n; i++)
	scanf("%d", &a[i]);
	
	for(i = 1; i < n; i++)
	sum[i] = sum[i - 1] + a[i];
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++)
		scanf("%d", &b[i][j]);
	}
	
	long long res = 0;
	
	for(i = 0; i < n; i++){
		
		for(j = 0; j < m; j++){
			
			while(c[j].size() && c[j].back().first < b[i][j]){
				pair <int, int> tmp = c[j].back();
				c[j].pop_back();
				
				if(c[j].size())
				add(c[j].back().second + 1, tmp.second, -tmp.first);
				else
				add(0, tmp.second, -tmp.first);
			}
		
			if(c[j].size())
			add(c[j].back().second + 1, i, b[i][j]);
			else
			add(0, i, b[i][j]);
			
			c[j].push_back({b[i][j], i});
		}
		
		long long tot = 0;
		
		for(j = 0; j <= i; j++){
			tot += s[j];
			res = max(res, tot - f(j, i));
		}
		
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 4480
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, m, t, a[SIZE];

  scanf("%d%d%d", &n, &m, &t);

  for(int i=1;i<=n;i++){
    scanf("%d", a+i);
  }
  a[0] = -m;
  a[n+1] = t + m;

  int ans = 0;
  
  for(int i=1;i<=n+1;i++){
    ans += max(0, (a[i]-a[i-1]) - 2*m);
  }

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



Measured memory_bytes: 3244
#line 1 "abc159_d.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
using P = std::pair<int, int>;
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vi a(n);
  REP(i, n) { cin >> a[i]; }
  vl count(n + 1);
  REP(i, n) { count[a[i]]++; }
  ll tmpans = 0;
  REP(i, n + 1) {
    if (count[i] >= 2) {
      tmpans += count[i] * (count[i] - 1) / 2;
    }
  }

  REP(i, n) {
    ll ans = tmpans;
    if (count[a[i]] >= 2) {
      ans -= count[a[i]] * (count[a[i]] - 1) / 2;
      ans += (count[a[i]] - 1) * (count[a[i]] - 2) / 2;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int32_t main(){
    fast;
    int n,d;
    cin>>n>>d;
    int count=0;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        int D=ceil(sqrt(x*x+y*y));
        if(D<=d)
            count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3760
#!/usr/bin/env python
import math

N = int(input())
d = 0
A = [int(i) for i in input().split()]
B = []
for i in range(N):
    B.append(A[i] - (i+1))
b = sorted(B)[N//2]

f = [abs(i-b) for i in B]
print(sum(f))


Measured memory_bytes: 28500
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif
#define MAXN 100005

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int a[MAXN];
int seen[MAXN];

pair<int,int> find_duplicates(int n)
{
    ms(seen,-1);
    for0(i,n+1) {
        if (seen[a[i]] != -1)
            return mp(seen[a[i]],i);
        seen[a[i]] = i;
    }
}

long long fact[MAXN], fact_inv[MAXN];

void compute_factorials(int maxn)
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for (long long i=2; i<=maxn; i++){
        fact[i] = (i*fact[i-1]) %MOD;
        fact_inv[i] = ((-(MOD/i) * fact_inv[MOD%i] % MOD) + MOD) % MOD;
    }
    for (long long i=2; i<=maxn; i++){
        fact_inv[i] = fact_inv[i-1] * fact_inv[i] % MOD;
        #ifdef DEBUG
        assert((fact[i]*fact_inv[i])%MOD == 1);
        #endif
    }
}

long long C(int n, int r)
{
    if (n < 0 || r < 0 || r > n)
        return 0;
    long long P = (fact[n]*fact_inv[r]) %MOD;
    return (P*fact_inv[n-r]) %MOD;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n; read(n);
    for0(i,n+1) {
        read(a[i]);
    }
    pair<int,int> dup = find_duplicates(n);
    int i1 = dup.first;
    int i2 = dup.second;
    //prl(i1) prl(i2);

    compute_factorials(n+1);
    for (int k=1; k<=n+1; k++) {
        ll ans = (C(n+1,k) - C(n-i2+i1,k-1)) %MOD;
        ans = (ans + MOD) %MOD;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int x, a;
	cin >> x >> a;
	cout << (x<a?0:10) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    string s;
    cin>>s;
    int n=s.length();
    bool ans = true;
    if(s[0]!='A'){
        ans = false;
    }
    if(isupper(s[1])||isupper(s[n-1])){
        ans = false;
    }
    int Ccnt=0;
    for(int i=2;i<=n-2;i++){
        if(s[i]=='C'){
            Ccnt++;
        }
        if(isupper(s[i])){
            if(s[i]!='C' || Ccnt>=2){
                ans = false;
            }
        }
    }
    if(Ccnt!=1){
        ans = false;
    }
    if(ans){
        cout<<"AC"<<endl;
    }
    else{
        cout<<"WA"<<endl;
    }
}

Measured memory_bytes: 256
while true do
  n, m = gets.split.map {|x| x.to_i }
  break if n == 0 && m == 0
  lucky_nums = Array.new
  n.times do
    num, money = gets.split
    money = money.to_i
    num = Regexp.new( num.gsub('*', '\d') )
    lucky_nums << { num: num, money: money }
  end

  sum = 0
  m.times do
    have_num = gets.chomp
    lucky_nums.each do |lucky_num|
      if have_num =~ lucky_num[:num]
        sum += lucky_num[:money]
      end
    end
  end
  puts sum
end

Measured memory_bytes: 6644
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int d, t, s;
    cin >> d >> t >> s;
    cout << (s * t >= d ? "Yes" : "No");
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s, t, ans = "Yes";
  int  n;
  cin >> s >>t;
  n = s.size();
  for(int i=0;i<n;i++){
    if(s[i]!=t[i]){
      ans = "No";
      break;
    }
  }
  
  
  cout << ans <<endl;
}

Measured memory_bytes: 3624