akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

const int L_MAX = 10005;
const int INF = 100000000;

struct edge{
    int to, cap, rev;
    edge(int t, int c, int r): to(t), cap(c), rev(r){}
};

vector<edge> G[L_MAX];
bool used[L_MAX];

void add_edge(int from, int to, int cap){
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, 0, G[from].size() - 1);
}

int dfs(int v, int t, int f){
    if (v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

const int H_MAX = 105;
const int W_MAX = 105;
char leaf[H_MAX][W_MAX];
int s, t;

int main(){
    int H, W;
    cin >> H >> W;
    int sorce = 0;
    int sink = H + W + 1;
    pair<int, int> S, T;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            char here;
            cin >> here;
            leaf[i][j] = here;
            if (here == 'S'){
                add_edge(sorce, W + i, INF);
                add_edge(sorce, j, INF);
                S = make_pair(i, j);
            } 
            if (here == 'T'){
                add_edge(W+i, sink, INF);
                add_edge(j, sink, INF);
                T = make_pair(i, j);
            }
            if (here != '.'){
                add_edge(W + i, j, 1);
                add_edge(j, W + i, 1);
            }
        }
    }

    if (S.first == T.first || S.second == T.second)cout << "-1" << endl;
    else cout << max_flow(sorce, sink) << endl;
    return 0;
}

Measured memory_bytes: 1152
from fractions import gcd
#from math import gcd
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
ans = 0

L = [0]*(N+1)
R = [0]*(N+1)
for i in range(0,N):
    L[i+1] = gcd(L[i],A[i])
for i in range(N-1,-1,-1):
    R[i] = gcd(R[i+1],A[i])

M = [0]*N
for i in range(N):
    M[i] = gcd(L[i],R[i+1])
print(max(M))


Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  string s,sf,sb;
  cin >> s;
  string sr(s);
  reverse(all(sr));
  if(s == sr){
    sf = s.substr(0,(s.length()-1) /2);
    string sfr(sf);
    reverse(all(sfr));
    if(sf == sfr){
      sb = s.substr((s.length()+3)/2-1,s.length());
      string sbr(sb);
      reverse(all(sbr));
      if(sb == sbr){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

main(){
  int st = 0;
  int b;
  for ( int i = 0; i < 3; i++ ){
    cin >> b;
    if ( b == 1 ) st += (1<<i);
  }
  if ( st >= 3 ) cout << "Open" << endl;
  else cout << "Close" << endl;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, a, b, c, d;
  cin >> N;
  a = N/1000; b = N/100 - a*10;
  c = N/10 - N/100*10; d = N - a*1000 - b*100 - c*10;
  if (a == b && b == c) cout << "Yes" << endl;
  else if (b == c && c == d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, m;
    cin >> n >> m;
    long long res = (n == 1 || m == 1) ? 1 : 1ll * m / 2 * n + (m % 2 ? (n + 1) / 2: 0);
    cout << res << "\n";
}


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

int main() {
    int N; cin >> N;
    vector<P> B(N);
    rep(i, N){
        int x, y; cin >> x >> y;
        B[i] = make_pair(x, y);
    }

    map<P, int> m;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if(i == j)continue;
            int a = B[i].first - B[j].first;
            int b = B[i].second - B[j].second;
            P p = make_pair(a, b);
            m[p]++;
        }
    }

    int ma = 0;
    for(auto p : m){
        auto value = p.second;
        ma = max(ma, value);
    }

    cout << N - ma << endl;

    return 0;
}

Measured memory_bytes: 3576
S = input()
T = input()
dic1 = {}
dic2 = {}
flag = True
for i , j in zip(S, T):
    if i in dic1:
        if dic1[i] != j:
            flag = False
            break
    dic1[i] = j
    if j in dic2:
        if dic2[j] != i:
            flag = False
            break
    dic2[j] = i
if flag:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 3632
import re

ptn_A = r'>\'(=+)#(=+)~'
ptn_B = r'>\^(Q=)+~~'

for i in range(int(raw_input())):
    snake = raw_input()
    matchA = re.search(ptn_A, snake)
    matchB = re.search(ptn_B, snake)
    if matchA and matchA.group(1) == matchA.group(2):
        print 'A'
    elif matchB:
        print 'B'
    else:
        print 'NA'

Measured memory_bytes: 4252
while True :
    try :
        a, b, c, d, e, f = map(float, input().split())
        
        x = (c * e - b * f) / (a * e - b * d)
        y = (c * d - a * f) / (b * d - a * e)
        
        if x == -0 :
            x = 0
        if y == -0 :
            y = 0
            
        print(f"{x:.3f} {y:.3f}")
        
    except :
        break



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


int n;
int bd[601][601];

void do_ban(int x){
    int m = 1;
    while(x % 4 == 0){
        m *= 2;
        x /= 4;
    }
    if(x % 4 == 3) return;
    if(x % 4 == 1){
        for(int i=0;i<2*n;i++){
            for(int j=0;j<2*n;j++){
                if((i % (2 * m) >= m) ^ (j % (2 * m) >= m)){
                    bd[i][j] = 0;
                }
            }
        }
    }else if(x % 4 == 2){
        for(int i=0;i<2*n;i++){
            for(int j=0;j<2*n;j++){
                if(i % (2 * m) >= m){
                    bd[i][j] = 0;
                }
            }
        }
    }
}

int main(){
    int d1, d2;
    scanf("%d%d%d",&n,&d1,&d2);
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            bd[i][j] = 1;
        }
    }
    do_ban(d1);
    do_ban(d2);
    int cnt = 0;
    for(int i=0;i<2*n;i++){
        for(int j=0;j<2*n;j++){
            if(cnt == n*n) continue;
            if(bd[i][j]){
                printf("%d %d\n", i, j);
                cnt++;
            }
        }
    }
}


Measured memory_bytes: 2304
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {
 void run(){
  Scanner sc = new Scanner(System.in);
  while(sc.hasNext()) {
   int n =sc.nextInt();
   int min, max;
   for(max=n-1;!isP(max);max--);
   for(min=n+1;!isP(min);min++);
   System.out.println(max + " " + min);
  }
 }
 boolean isP(int p) {
  for(int i=2;i*i<=p;i++) if(p%i == 0)
   return false;
  return true;
 }
 public static void main (String[] args ) {
  new Main().run();
 }
}

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

int main() {
  int N;
  cin >> N;
  
  vector<tuple<string, int, int>> v(N);
  for (int i = 0, z = 0; i < N; i++) {
    cin >> get<0>(v.at(i)) >> get<1>(v.at(i));
    get<2>(v.at(i)) = i + 1;
    get<1>(v.at(i)) *= -1;
  }
  
  sort(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    cout << get<2>(v.at(i)) << endl;
  }
}

Measured memory_bytes: 256
import sys

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())

branch = [[] for _ in range(N)] # [[]]*N だと参照渡しになってしまう
X = [0,]*N
root = [None]*N
t = 0

for _ in range(N - 1):
    a, b = map(int, input().split())
    branch[a-1].append(b)
    branch[b-1].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x


def search(p):
    global t
    root[p-1] = t
    t += 1
    for q in branch[p-1]:
        if root[q-1] != None:
            continue
        X[q - 1] += X[p - 1]
        search(q)
    t -= 1



search(1)
print(*X)

Measured memory_bytes: 238844
/// sultanov

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char& c : s) {
        c = (c - 'A' + n + 26) % 26 + 'A';
    }    
    cout << s;

    return 0;
}

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


int main()
{
  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  rep(i, n)
    cin >> w[i] >> v[i];
  vector<ll> dp(W + 1, 0);
  rep(i, n)
    for (int j = W; j >= w[i]; j--)
      dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
  cout << dp[W] << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
ab = [tuple(map(int, readline().split())) for _ in range(m)]
ab.sort(key=lambda x: x[1])
cnt = 0
check = -1
for a, b in ab:
    if a <= check < b:
        continue
    check = b - 1
    cnt += 1
print(cnt)


Measured memory_bytes: 18172
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
LL A[MAX], B[MAX];
int idx[MAX];

int main(void) {
    scanf("%d", &N);
    REP(i, N) {
        scanf("%lld%lld", A + i, B + i);
        idx[i] = i;
    }
    sort(idx, idx + N, [&](const int &l, const int &r) {
        if (B[l] == B[r]) return A[l] < A[r];
        else return B[l] < B[r];
    });

    LL cur_time = 0;
    REP(i, N) {
        cur_time += A[idx[i]];
        if (cur_time > B[idx[i]]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
	double l,r;
	int al=0,bl=0,cl=0,dl=0,ar=0,br=0,cr=0,dr=0;
	while(scanf("%lf%lf",&l,&r)!=EOF){
		if(l>=1.1){
			al++;
		}else if(l>=0.6){
			bl++;
		}else if(l>=0.2){
			cl++;
		}else{
			dl++;
		}
		if(r>=1.1){
			ar++;
		}else if(r>=0.6){
			br++;
		}else if(r>=0.2){
			cr++;
		}else{
			dr++;
		}
	}
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",al,ar,bl,br,cl,cr,dl,dr);
	return 0;
}

Measured memory_bytes: 2600
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int N;
    cin >> N;
    
    queue<int> que;
    int count=0;
    for(int i=0; i<N; i++) {
        int h;
        cin >> h;
        while(que.size()<h) {
            que.push(1);
        }
        while(que.size()>h) {
            que.pop();
            count++;
        }
    }

    while(que.size()>0) {
        que.pop();
        count++;
    }
    
    cout << count << endl;

    return 0;
    
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    Map<Integer, Integer> count = new HashMap<>();
    long sum;
    void solve(Scanner sc, PrintWriter pw) {
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            int data = sc.nextInt();
            count.put(data, count.getOrDefault(data, 0) + 1);
            sum += data;
        }
        int Q = sc.nextInt();
        long result = sum;
        for (int i = 0; i < Q; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            result += (c - b) * count.getOrDefault(b, 0);
            count.put(c, count.getOrDefault(b, 0) + count.getOrDefault(c, 0));
            count.remove(b);
            pw.println(result);
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


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

vector<int> a;

struct UF{
   vector<int> par;
   vector<int> sz;
   vector<priority_queue<int, vector<int>, greater<int> > > q;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       rep(i, 0, n) par[i] = i;
       q.resize(n, priority_queue<int, vector<int>, greater<int> >());
       rep(i, 0, n) q[i].push(a[i]);
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        while(q[y].size()){
            int tmp = q[y].top(); q[y].pop();
            q[x].push(tmp);
        }
        sz[x] += sz[y];
        par[y] = x;
    }
    int getmin(int x){
        x = find(x);
        if(q[x].empty()) return INF;
        int res = q[x].top(); q[x].pop();
        return res;
    }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    a.resize(n);
    vector<int> d;
    rep(i, 0, n){
        cin >> a[i];
    } 
    UF uf(n);
    rep(i, 0, m){
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    int cnt = 0;
    int ans = 0;    
    rep(i, 0, n){
        if(uf.find(i) == i){
            cnt++;
            int tmp = uf.getmin(i);
            ans += tmp;
            while(1){
                tmp = uf.getmin(i);
                if(tmp >= INF) break;
                d.push_back(tmp);
            }
        }
    }
    if((cnt - 1) * 2 > n){
        cout << "Impossible" << endl;
        return 0;
    }
    if(cnt == 1){
        cout << 0 << endl;
        return 0;
    }
    sort(all(d));
    rep(i, 0, cnt - 2){
        ans += d[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 12532
s=gets.chop
k=gets.to_i
res=''
i=0
s.bytes{|b|
    x=b-97
    if x>0 and k>=26-x
        res<<?a
        k-=26-x
    else
        res<<s[i]
    end
    i+=1
}
res[-1]=((res[-1].ord-97+k%26)+97).chr
puts res


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

namespace CC {
	class Program {
		static void Main(string[] args) {
			int n = int.Parse(Console.ReadLine());
			var p = Console.ReadLine().Split(' ').Select(pp => int.Parse(pp)).ToArray();

			int min = p[0];
			int cnt = 1;
			for(int i = 1; i < p.Length; ++i) {
				if(min > p[i]) {
					cnt += 1;
					min = p[i];
				}
			}
			Console.WriteLine(cnt);
		}
	}
}


Measured memory_bytes: 33628
import sys, collections

def dfs(i, c, col, edge):
    col[i] = c
    for next_node in edge[i]:
        if col[next_node] == c: return False
        if col[next_node] == 0 and dfs(next_node, -c, col, edge) == False: return False

    return True

def solve():
    N = int(input())
    edge = dict()
    col = dict()
    for i in range(N): 
        edge[i] = set()
        col[i] = 0
        s = input()
        for j in range(N):
            if s[j] == "1": edge[i] |= {j}

    is_bipartite = dfs(0, 1, col, edge)
    if not is_bipartite: print(-1)
    else:
        INF = 10 ** 15
        dist = [[INF for j in range(N)] for i in range(N)]
        for i in range(N):
            for j in range(N):
                if i == j: dist[i][j] = 0
                elif j in edge[i]: dist[i][j] = 1

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

        ans = -1
        for i in range(N):
            for j in range(N):
                if dist[i][j] < INF: ans = max(ans, dist[i][j])
        print(ans + 1)

    

    return 0

if __name__ == "__main__":
    solve()


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

int main(){
  int k,x;
  cin>>k>>x;
  //引いたやつから足したやつまで出力
  int ans=x-k+1;
  for(int i=0;i<2*k-1;i++){
    
  cout<<ans++<<" ";
  }
  
  
  

}

  
    
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
    string n;
    int ans=7;
    cin >>n;
    if(n=="AAA" or n=="BBB"){
        ans=0;
    }
    solve(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
using namespace std;

ll n;

ll add(ll a, ll b) {
	ll ret = a + b;
	if (ret > MOD) ret -= MOD;
	return ret;
}

ll mul(ll a, ll b) {
	ll ret = (a * b) % MOD;
	return ret;
}

struct Mat {
	ll m[50][50] = { { 0 } };

	Mat(bool id) {
		if (id) {
			for (int i = 0; i < 50; i++) {
				m[i][i] = 1;
			}
		} 
	}

	friend Mat operator*(Mat& mat1, Mat& mat2) {
		Mat ret(0);

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++) {
					ll tmp = mul(mat1.m[i][k], mat2.m[k][j]);
					ret.m[i][j] = add(ret.m[i][j], tmp);
				}
		
		return ret;
	}
};

Mat matpow(Mat mat, ll k) {
	Mat ans(1);

	while (k) {
		if (k & 1) ans = ans * mat;
		
		mat = mat * mat;
		k >>= 1;
	}

	return ans;
}

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

	Mat mat(0);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) cin >> mat.m[i][j];

	ll ans = 0;

	Mat matans = matpow(mat, k);

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) ans = add(ans, matans.m[i][j]);

	cout << ans;

	return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

struct BIT {
    int n;
    vector<int> bit; // 1-indexd

    BIT(int sz) {
        bit.resize(sz + 1);
        n = sz;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

class DSwapAndFlip {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N), B(N);
        REP(i, N) cin >> A[i];
        REP(i, N) cin >> B[i];

        vector<vector<int>> dp(1LL << N, vector<int>(51, INF));
        dp[0][0] = 0;
        REP(i, N) {
            REP(s, 1LL << N) {
                int b = 0;
                REP(j, N) {
                    if (s >> j & 1) b++;
                }
                if (b != i) continue;
                REP(j, N) {
                    if (s >> j & 1) continue;
                    int val = 0;
                    FOR(jj, j + 1, N - 1) {
                        if (s >> jj & 1) val++;
                    }
                    int dis = abs(i - j) % 2;
                    int v = dis % 2 == 0 ? A[j] : B[j];
                    REP(k, 51) {
                        if (dp[s][k] == INF) continue;
                        if (v < k) continue;
                        dp[s | (1LL << j)][v] = min(dp[s | (1LL << j)][v], dp[s][k] + val);
                    }
                }
            }
        }
        int res = INF;
        REP(j, 51) {
            res = min(res, dp[(1LL << N) - 1][j]);
        }
        if (res == INF) res = -1;
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DSwapAndFlip solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 114944
K,N = (int(x) for x in input().split())
A   = [int(x) for x in input().split()]

MaxD = (K-A[N-1])+A[0]
for T in range(0,N-1):
    Dist = A[T+1]-A[T]
    MaxD = max(MaxD,Dist)
print(K-MaxD)

Measured memory_bytes: 24908
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iomanip>
using namespace std;

int main() {
	int a, b;
	cin >> a;
	cin >> b;
	cout << a / b << endl;
	cout << a % b << endl;
	cout << fixed << setprecision(8) << (double)a / b << endl;
	
	return 0;
}

Measured memory_bytes: 3236
#include<cstdio>

int x,y,z;

int main(){
	scanf("%d %d %d",&x,&y,&z);
	for (int i=0;i<=1000;i++)
	if (i*x%y==z)
	{
		printf("YES");
		return 0;
	}
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String arare[]=new String[100];
		for(int i=0;i<n;i++) {
			arare[i]=sc.next();
			if(arare[i].equals("Y")) {
				System.out.println("Four");
				break;
			}else if(i==n-1){
				System.out.println("Three");
				break;
			}
		}
		
	}

}

Measured memory_bytes: 21332
N = int(input())
def n_ary(l,d): # リストl中の文字でd桁までを全列挙
    if d == 1:
        return(l)
    n = len(l)
    ll = n_ary(l,d-1)
    lll = []
    for i in l:
        for j in ll[n*(n**(d-2)-1)//(n-1):]:
            lll.append(i+j)
    return(ll+lll)
k = [i.replace('0','3').replace('1', '5').replace('2','7') for i in n_ary(['0','1','2'],9)]
#print(n_ary(['0','1','2'],3))
print(len([int(i) for i in k if '3' in i and '5' in i and '7' in i and int(i) <= N]))



Measured memory_bytes: 7304
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int[] W = cin.ReadIntArray(N);
            int min = 10000;
            for(int i = 1; i < N; i++)
            {
                int A = 0;
                int B = 0;
                for(int j = 0; j < i; j++)
                {
                    A += W[j];
                }
                for(int k = i; k < N; k++)
                {
                    B += W[k];
                }
                if(Abs(A - B) < min)
                {
                    min = Abs(A - B);
                }
            }
            Console.WriteLine(min);
            
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int l, r;
    cin >> l >> r;
    constexpr int div = 2019;
    vec candi;
    if (r - l >= 2019) {
        rep (i, 2019) { candi.pb(i); }
    } else {
        l %= div;
        r %= div;
        while (true) {
            candi.pb(l);
            l++;
            if (l == r + 1) break;
            l %= div;
        }
    }

    int len = candi.size();
    int mi = INF;
    rep (i, len) {
        rep (j, len) {
            if (i >= j) continue;
            mi = min((candi[i] * candi[j]) % div, mi);
        }
    }
    print(mi);
    return 0;
}


Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
vector<ll>fact;
ll ncr(ll n,ll r)
{
    if(r==0ll)
    {
        return 1ll;
    }
    if(n==r)
    {
        return 1ll;
    }
    if(n<r)
    {
        return 0ll;
    }
    ll ans=1;
    for(ll i=0;i<r;i++)
    {
        ans=(ans*(n-i))%mod;
    }
    ll y=power(fact[r],mod-2);
    ans=(ans*y)%mod;
    return ans;
}
int main()
{
fast;
fact.pb(1);
for(ll i=1;i<=2e5+1;i++)
{
   ll y=(fact[i-1]*i)%mod;
   fact.pb(y);
}
ll n;
cin>>n;
ll a,b;
cin>>a>>b;
ll ans=power(2,n);
ans=(ans-1ll+mod)%mod;
ll x=ncr(n,a);
ll y=ncr(n,b);
ans=(ans-x+mod)%mod;
ans=(ans-y+mod)%mod;
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//author TRdsbf
int N;
int A[20];
int x[20][20];
int y[20][20];
 
int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(ll a, ll b, ll c, ll d) {
	if (a < b || b > d) {
		return false;
	}

	if (c >= b) {
		return true;
	}

	ll g = gcd(b, d);
	return b - g + (a % g) <= c;
}

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

	int t;
	cin >> t;

	for (int i = 0; i < t; i++) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;

		cout << (solve(a, b, c, d) ? "Yes" : "No") << endl;
	}
	return 0;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

int a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b;
	cout << (3 * a + b) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
z = [i for i in range(x+1,y+1)]
x_p = max(list(map(int,input().split())))
y_p = min(list(map(int,input().split())))

z = list(filter(lambda x: x>x_p,z))
z = list(filter(lambda x: x<=y_p,z))
print('War' if z == [] else 'No War')

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

int main() {
  string a;
  cin>>a;
  if(a=="A"){
    cout<<"T"<<endl;
  }
  else if(a=="T"){
    cout<<"A"<<endl;
  }
  else if(a=="G"){
    cout<<"C"<<endl;
  }
  else{
    cout <<"G"<<endl;
  }
}

Measured memory_bytes: 256
<?php
list($n, $d) = ints();
echo ceil($n/($d*2+1));
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const ll INF = 1LL<<60;
using T = tuple<ll, int, int>;

struct edge { int to, cost, t;};
vector<vector<edge>> G;
vll rate, c_time;
vvll dp;
ll mx;

// 時間が小さい順に回る
// 両替するか、移動するかの二択
// 所持金mxなら両替しなくて良い

void dijkstra(int s, int x) {
    priority_queue<T, vector<T>, greater<T>> q;
    dp[s][x] = 0;
    q.push(T(0, s, x));

    while (!q.empty()) {
        T p = q.top();
        q.pop();
        ll t = get<0>(p);
        int v = get<1>(p);
        int money = get<2>(p);
        if (dp[v][money] < t) continue;
        if (money < mx) {
            for (int i = 1; ; ++i) {
                if (chmin(dp[v][min(mx, money + rate[v] * i)], t + c_time[v] * i)) {
                    q.push(T(t + c_time[v] * i, v, min(mx, money + rate[v] * i)));
                }
                if (money + rate[v] * i >= mx) break;
            }
        }
        for (edge e : G[v]) {
            if (money - e.cost >= 0 && chmin(dp[e.to][money - e.cost], t + e.t)) {
                q.push(T(t + e.t, e.to, money - e.cost));
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, s;
    cin >> n >> m >> s;
    G.resize(n);
    int max_a = 0;
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        chmax(max_a, a);
        u--; v--;
        G[u].pb(edge{v, a, b});
        G[v].pb(edge{u, a, b});
    }
    rate.resize(n);
    c_time.resize(n);
    rep(i, n) cin >> rate[i] >> c_time[i];

    mx = max_a * (n-1);
    dp.resize(n, vll(mx + 1, INF));
    dijkstra(0, min(mx, (ll)s));

    for (int i = 1; i < n; ++i) {
        ll ans = INF;
        rep(j, mx+1) {
            chmin(ans, dp[i][j]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 37120
#include <cstdio>
#include <iostream>
#include <vector>


using namespace std;

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

typedef vector<int> vi;


int main(void){
	int N;
	while(cin>>N,N){
		vi block;
		rep(i,N){
			int v;
			cin >> v;
			block.push_back(v);
		}
		
		int ans=0;
		while(ans<=10000){
			bool flg=true;
			rep(i,block.size()){
				if(block[i]!=(i+1)){
					flg=false;
					break;
				}
			}
			if(flg){
				break;
			}


			int cou=0;
			rep(i,block.size()){
				block[i]--;
				cou++;
			}

			vi b;
			rep(i,block.size()){
				if(block[i]>0){
					b.push_back(block[i]);
				}
			}
			b.push_back(cou);
			block = b;
			ans++;
		}
		if(ans<=10000){
			cout << ans << endl;
		}else{
			puts("-1");
		}
	}
}

Measured memory_bytes: 1248
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    ab = LIR(n)
    ans = 0
    for a, b in ab:
        if k & a == a:
            ans += b
    for i in range(31):
        if k & (1 << i):
            res = 0
            K = (k | ((1 << i) - 1)) ^ (1 << i)
            for a, b in ab:
                if K & a == a:
                    res += b
            if ans < res:
                ans = res
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 58844
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    map<LL, int> cnt;
    LL a;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        cnt[a]++;
    }
    int max=0;
    int tmp;
    for(auto x : cnt){
        tmp=cnt[x.first];
        if(cnt.find(x.first-1)!=cnt.end()){
            tmp+=cnt[x.first-1];
        }
        if(cnt.find(x.first+1)!=cnt.end()){
            tmp+=cnt[x.first+1];
        }
        if(tmp>max){
            max=tmp;
        }
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 4224
from collections import Counter

h, w, n = [int(x) for x in input().split()]
cnt = Counter()

for _ in range(n):
    y, x = [int(x) for x in input().split()]
    for dx in [-1, 0, 1]:
        for dy in [-1, 0, 1]:
            if 2 <= x + dx < w and 2 <= y + dy < h:
                cnt[x + dx, y + dy] += 1

cnt2 = Counter(cnt.values())
print((h - 2) * (w - 2) - sum(cnt2.values()))
for c in range(1, 10):
    print(cnt2[c])


Measured memory_bytes: 140452
// بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيم
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define el cout << '\n';
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

const int mx = (int)(1e5) + 5;

ll n, cap;

ll w[mx], val[mx], dp[100][mx];

ll solve(ll i, ll weight)
{

    if (i == n || weight > cap)
        return 0;

    if (dp[i][weight] != -1)
        return dp[i][weight];

    ll a = 0, b = 0;

    if (weight + w[i] <= cap)
        a = val[i] + solve(i + 1, weight + w[i]);

    b = solve(i + 1, weight);

    return dp[i][weight] = max(a, b);
}

int main()
{
    IOS

        memset(dp, -1, sizeof dp);

    cin >> n >> cap;

    for (size_t i = 0; i < n; i++)
    {
        cin >> w[i] >> val[i];
    }

    cout << solve(0, 0);

    el
}

Measured memory_bytes: 81712
while True:

    input_list = [int(item) for item in input().split(" ")]

    if input_list[0] == 0:
        break

    total = 0
    count = 0

    for num in input_list:
        if 10 < num:
            num = 10
        elif num == 1:
            count += 1

        total += num

        if 21 < total:
            break

    if total <= 21:

        while total + 10 <= 21 and 0 < count:
            total += 10
            count -= 1

        print(total)
    else:
        print(0)



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

long long N;

void Input(){
	cin>>N;
}

void Solve(){
	long long total=0;
	for(long long i=1; i<N; i++){
		long long j=1;
		while(i*j<N){
			j++; total++;
		}
	}
	cout<<total<<'\n';
}

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

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

int main() {
	ll a, b; cin >> a >> b;
	ll ans = 0;

	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	else if (a > 0) {
		cout << "Positive" << endl;
		return 0;
	}
	else {
		if (b > 0) {
			cout << ((a & 1) ? "Negative" : "Positive") << endl;
		}
		else {
			cout << (((b - a + 1) & 1) ? "Negative" : "Positive") << endl;
		}
	}

	return 0;
}

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

ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}
//aのｂ乗をｃで割った余り
const int MAX = 510000;
const int MOD = 998244353;

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

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

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

int main(){
  string s,t;
  cin>>s>>t;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3632
use std::cmp::max;
use std::io;
fn main() {
    let mut buft = String::new();
    io::stdin().read_line(&mut buft).unwrap();
    let n: usize = buft.trim().parse().unwrap();
    
    let mut Aij : Vec<Vec<usize>> = Vec::new();
    for _ in 0..n{
        buft.clear();
        io::stdin().read_line(&mut buft).unwrap();
        let tmp : Vec<usize> = buft.trim().split_whitespace().map(|x| x.parse::<usize>().unwrap()).collect();
        Aij.push(tmp);
    }
    let mut state = vec![0usize; n];

    let mut days = 0i32;
    let mut cnt = n * (n-1)/2;
    while cnt > 0{
        let mut flag = false;
        let mut pos = vec![true; n];
        for i in 0..n{
            if state[i] >= n-1{
                continue;
            }
            let j = Aij[i][state[i]]-1;
            if j < i || state[j] >= n-1 || !pos[i] || !pos[j]{
                continue;
            }
            if Aij[j][state[j]] == i + 1{
                flag = true;
                state[i]+=1;
                state[j]+=1;
                pos[i] = false;
                pos[j] = false;
                cnt -= 1;
                // println!("{} {} {}", days, i,j);
            }
        }
        if !flag{
            days = -1;
            break;
        }
        days+=1;
    }
    println!("{}", days);
}


Measured memory_bytes: 12540