akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <deque>

using namespace std;
typedef long long LL;
deque<LL>de;
LL number[200005];
int fun(LL d,int flag)
{
    if(d==1)
    {
        de.push_back(number[0]);
        de.push_back(number[1]);
    }
    else if(d==2)
    {
        de.push_back(number[1]);
        de.push_back(number[0]);
    }
    else
        {

            fun(d-2,1);
            de.push_front(number[d-1]);
            if(d%2==0)
                de.push_back(number[d-2]);
            else
                de.push_back(number[d]);




        }

}
int main()
{
    LL n,i;
    cin>>n;

    for( i=0;i<n;i++)
    {
        cin>>number[i];
    }
    fun(i,0);
    for(LL k=0;k<n;k++)
    {
        LL temp=de.front();
        de.pop_front();
        cout<<temp<<" ";
    }

    return 0;
}


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

#define M_PI 3.14159265358979 

void koch( int n, double ax, double ay, double bx, double by) {
  double sx, sy, tx, ty, ux, uy;
  double th = M_PI * 60.0 / 180.0; 

  if ( n == 0 ){
    return;
  }
  
  sx = (2.0 * ax + 1.0 * bx) / 3.0;
  sy = (2.0 * ay + 1.0 * by) / 3.0;
  tx = (1.0 * ax + 2.0 * bx) / 3.0;
  ty = (1.0 * ay + 2.0 * by) / 3.0;
  ux = (tx - sx) * cos(th) - (ty - sy) * sin(th) + sx;
  uy = (tx - sx) * sin(th) + (ty - sy) * cos(th) + sy;
  
  koch(n - 1, ax, ay, sx, sy);
  printf("%.8f %.8f\n", sx, sy);
  koch(n - 1, sx, sy, ux, uy);
  printf("%.8f %.8f\n", ux, uy);
  koch(n - 1, ux, uy, tx, ty);
  printf("%.8f %.8f\n", tx, ty);
  koch(n - 1, tx, ty, bx, by);
}

int main(){
  double ax, ay, bx, by;
  int n;
  
  scanf("%d", &n);
  
  ax = 0;
  ay = 0;
  bx = 100;
  by = 0;
  
  printf("%.8f %.8f\n", ax, ay);
  koch(n, ax, ay, bx, by);
  printf("%.8f %.8f\n", bx, by);
  
  return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

const ll MOD = 1e9 + 7;

vector<int> G[101010];
ll memo[101010][2];
int visited[101010];

ll dp(int v, int c){
    if(~memo[v][c])return memo[v][c];
    ll sum = 1;
    visited[v] = 1;
    if(c){
        for(auto adj : G[v])if(!visited[adj])sum *= dp(adj, 0), sum%= MOD;
    }
    else for(auto adj : G[v])if(!visited[adj])sum *= (dp(adj, 0) + dp(adj, 1)), sum %= MOD;
    visited[v] = 0;
    return memo[v][c] = sum;
}

void solve(){
    int N;
    cin >> N;
    for (int j = 0; j < 101010; ++j) {
        for (int i = 0; i < 2; ++i) {
            memo[j][i] = -1;
        }
    }
    for (int i = 0; i < N-1; ++i) {
        int x,y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    G[0].push_back(1);
//    int sum1 = dp(1,0);
//    for (int l = 0; l < 101010; ++l) {
//        visited[l] = 0;
//    }
//    for (int j = 0; j < 101010; ++j) {
//        for (int i = 0; i < 2; ++i) {
//            memo[i][j] = -1;
//        }
//    }
    cout << dp(0,0) << endl;



}

#undef int
int main() {

#ifdef debug
    freopen("../in","r",stdin);
    freopen("../out","w",stdout);
#endif

    solve();
    return 0;
}


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

#define endl '\n'

int main() {
    ios::sync_with_stdio(0);

    string s;
    cin >> s;
    for(int i = 0; i < 4; i++) {
        if(s[i] == 'A' && s[i + 1] == 'C') {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    cin >> s;
    int i, n = s.size();
    REP (i,n) {
        if (i < n-1 && s[i] == s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        if (i < n-2 && s[i] == s[i+2]) {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


Measured memory_bytes: 512
import java.lang.Math

fun main(args: Array<String>)
{
    val MOD: Long = 1000000007L // (1e+9)+7

    val s = readLine()!!
    when (s) {
        "SUN" -> {println(7)}
        "MON" -> {println(6)}
        "TUE" -> {println(5)}
        "WED" -> {println(4)}
        "THU" -> {println(3)}
        "FRI" -> {println(2)}
        "SAT" -> {println(1)}
    }
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector< vector<int> > g(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') {
        g[i].push_back(j);
      }
    }
  }

  int ans = -1;
  for (int i = 0; i < n; i++) {
    vector<int> v(n, -1);
    v[i] = 0;
    bool ok = true;
    int num = 0;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (v[k] == j) {
          for (auto u : g[k]) {
            if (v[u] == -1) {
              v[u] = num = j + 1;
            } else if (abs(v[u] - j) != 1) {
              ok = false;
            }
          }
        }
      }
    }
    // for (auto x : v) {
    //   cout << x << ' ';
    // }
    // cout << '\n';
    if (ok) ans = max(ans, num + 1);
  }
  cout << ans << '\n';

  return 0;
}

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


int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    while(true){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a<b&&b<c){
		    System.out.println("Yes");
		}else{
		    System.out.println("No");
		}
	}
    
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, K;
    double maxi = 0;
    vector<double> kitai;
    cin >> N >> K;
    kitai.resize(N);
    for(ll i = 0;i < N;i++) {
        double p;
        cin >> p;
        kitai[i] = (i == 0 ? 0 : kitai[i - 1]) + p * (p + 1) / 2 / p;
    }
    for(ll i = K - 1;i < N;i++) {
        double current = kitai[i] - (i == K - 1 ? 0 : kitai[i - K]);
        maxi = max(current, maxi);
    }
    cout << fixed << setprecision(6) << maxi << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
#define x real()
#define y imag()

string ccw(P a,P b,P c){
  P ab=b-a;
  P ac=c-a;
  P k=ac*conj(ab);
  if( k.y > 0 ){
    return "COUNTER_CLOCKWISE";
  }
  if( k.y < 0 ){
    return "CLOCKWISE";
  }
  if( k.x < 0 ){
    return "ONLINE_BACK";
  }  
  if( abs(ab) < abs(ac) ){
    return "ONLINE_FRONT";
  }
  return "ON_SEGMENT";
}

int main(){
  double x0,y0,x1,y1,x2,y2;
  cin>>x0>>y0>>x1>>y1;
  P a(x0,y0);
  P b(x1,y1);
  int n;
  cin>>n;
  while(n--){
    cin>>x2>>y2;
    P c(x2,y2);
    cout<< ccw(a,b,c) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
N=int(input())
task=[]
for _ in range(N):
    task.append([int(i) for i in input().split()])

task=sorted(task, key=lambda x: x[1])

spent_time1=0
ans='Yes'

for i in range(N):
    spent_time1+=task[i][0]
    deadline1=task[i][1]
    if deadline1<spent_time1:
        ans='No'
        break

print(ans)

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c,d;cin >> a >> b >> c >> d;
    int cnt = 0;
    while(a > 0 && c > 0){
        if(cnt%2 == 0)c -= b;
        else a -= d;
        cnt++;
    }
    if(a<=0)cout << "No" << endl;
    else if(c<=0) cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3640
n, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
c = 0
for i in range(1, len(a)):
	b = a[i - 1] + a[i]
	d = b - x
	if d > 0:
		c += d
		e = min(a[i], d)
		a[i] -= e
		d -= e
		if d > 0:
			a[i - 1] -= d
print(c)

Measured memory_bytes: 14592
n, m = map(int, input().split())
h = list(map(int, input().split()))
t = [set() for i in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1

    t[a].add(b)
    t[b].add(a)

ans = 0
for i in range(n):
    tmp = 1
    for v in t[i]:
        if h[i] <= h[v]:
            tmp = 0
            False

    ans += tmp

print(ans)


Measured memory_bytes: 45336
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll kam = x / d, to = x % d;
    if(kam % 2 != k % 2){
        kam++;
        to = to - d;
    }
    if(kam <= k){
        cout << abs(to);
        return 0;
    }
    cout << x - (k * d);

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

const long double EPS = 1e-30; //要検証
long double add(long double x, long double y){
    if(abs(x + y) < EPS * (abs(x) + abs(y)) ) return 0;
    return x + y;
}
struct PL{
    long double x, y;
    PL() {}
    PL(long double x, long double y) : x(x), y(y) {
    }
    PL operator + (PL p){
        return PL(add(x, p.x), add(y, p.y));
    }
    PL operator - (PL p){
        return PL(add(x, -p.x), add(y, -p.y));
    }
    PL operator * (long double d){
        return PL(x * d, y * d);
    }
    long double dot(PL p){
        return add(x * p.x, y * p.y);
    }
    long double det(PL p){
        return add(x * p.y, -y * p.x);
    }
    long double norm(){
        return sqrt(add(x * x, y * y));
    }
};
/*bool cmp_x(const PL &p, const PL &q){
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}*/

vector<PL> plot(50);
long double dot(int i, int j, int k){return (plot[i] - plot[k]).dot(plot[j] - plot[k]);}

long double tlen(int i, int j, int k){
    if(dot(i,j,k) < 0 || dot(j,k,i)<0||dot(k,i,j)<0) return 0;
    PL p(plot[i] - plot[k]), q(plot[j] - plot[k]), r(plot[i] - plot[j]);
    long double a = r.norm();
    return (a / 2.0) / (abs(p.det(q)) / (p.norm() * q.norm()));
}

int main(){
    cin>>N;
    rep(i,N) cin>>plot[i].x>>plot[i].y;
    long double ans = 0;
    rep(i,N){
        rep(j,i){
            rep(k,j){
                ans = max(ans, tlen(i, j, k));
            }
        }
    }
    rep(i,N){
        rep(j,i){
            ans = max(ans, (plot[i] - plot[j]).norm() / 2.0);
        }
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
*A, = map(int, input().split())

l = [0]*n
for i in range(n):
    if l[i] == 0:
        s = set()
        p = i
        can = 1
        while p not in s:
            if l[p] == 1:
                can = 0
                break
            s.add(p)
            l[p] = 1
            p = (p + A[p]) % n
        if can:
            while l[p] == 1:
                l[p] = 2
                p = (p + A[p]) % n
print(sum(e == 2 for e in l))

Measured memory_bytes: 21824
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  vector<ll> p(70);
  rep(i,n){
    ll x;
    cin>>x;
    int cnt=0;
    while(x>0){
      p[cnt]+=x%2;
      x/=2;
      cnt++;
    }
  }
  
  ll ans=0;
  rep(i,70){
    ll x=jou(2,i);
    x*=p[i];
    if(x>mod) x%=mod;
    x*=n-p[i];
    if(x>mod) x%=mod;
    ans+=x;
    if(ans>mod) ans%=mod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int a;

	std::cin >> a;

	if (a==7 || a==5 || a==3) {
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


struct Node{
    string s;
    ll p;
    ll i;
    bool operator< (const Node &r) const{
        if(s != r.s) return s < r.s;
        return p > r.p;
    }
};

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

  vector<Node> v;
  rep(i, n) v.push_back({s[i], p[i], i+1});

  sort(all(v));

  rep(i, n) cout << v[i].i << endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		
		// Populate matrix with 0s first
		for(int r = 0; r < totalVertex; r++) {
			for (int c = 0; c < totalVertex; c++) {
				adjMatrix[r][c] = 0;
			}
		}
		
		// For each LinkedList in adjList, if it contains values, set
		//  adjMatrix in that position to 1
		for (int i = 0; i < totalVertex ; i++) {
			LinkedList<Integer> adj = adjList.pop();
			if(adj != null) {
				int s = adj.size();
				for(int j = 0; j < s; j++) {
					int x = adj.pop();
					adjMatrix[i][x] = 1;
				}
			}
			
			// Print row
			for(int k = 0; k < totalVertex - 1; k++) {
				System.out.print(adjMatrix[i][k] + " ");
			}
			System.out.print(adjMatrix[i][totalVertex - 1]);
			System.out.println();
		}

        }
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


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

int main() {
  int n,i;
  cin>>n;
  long long int a[n],cnt=0;
  bool even=true;
  
  for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2!=0)
      even=false;
  }
  
  if(even){
  for(i=1;i>0;i++){
    for(int j=0;j<n;j++){
      a[j]=a[j]/2;
      if(a[j]%2!=0)
        even=false;
    }
    cnt++;
    if(even==false)
      break;
  }
  }
      
    cout<<cnt;
    
  
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    rep(i, n) rep(j, 3) cin >> a[i][j];

    vector<vector<int>> dp(n + 1, vector<int>(3));
    rep(i, n){
        rep(j, 3){
            rep(k, 3){
                if(j == k){
                    continue;
                }
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    int ans = 0;
    rep(i, 3){
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

  int64_t result = 0;
  for (int b = K + 1; b <= N; b++) {
    result += (N / b) * (b - K) + max(N % b - K + 1, 0);
    if (K == 0) result--;  // do not include a=0.
  }
  printf("%ld\n", result);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  string S,T;
  cin>>S>>T;
  string ans;
  rep(i,60) ans+='z';
  if(S.size()<T.size()) cout<<"UNRESTORABLE"<<endl;
  else{
    rep(i,S.size()-T.size()+1){
      string X;
      int F=1;
      rep(j,i){
        if(S[j]=='?') X+='a';
        else X+=S[j];
      }
      rep(j,T.size()){
        if(S[i+j]=='?'){
          X+=T[j];
        }else if(S[i+j]==T[j]){
          X+=S[i+j];
        }else{
          F=0;
          break;
        }
      }
      rep(j,S.size()-T.size()-i){
        if(S[i+T.size()+j]=='?') X+='a';
        else X+=S[i+T.size()+j];
      }
      if(F) ans=min(ans,X);
    }
    if(ans.size()==S.size()) cout<<ans<<endl;
  else cout<<"UNRESTORABLE"<<endl;
  }
}

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

int main() {
  string A, B;
  int aa[5], bb[5];
  int ab, ac, ss, bc, bd, ee, count;
  cin >> A >> B;
  for(int i = 0; i < 5; i++) {
    aa[i] = A[4 - i] - '0';
    bb[i] = B[4 - i] - '0';
  }
  ab = 10 * aa[3] + aa[4];
  ac = 10 * aa[1] + aa[0];
  ss = 100 * aa[4] + 10 * aa[3] + aa[2];
  if(ab < ac) {
      ss = min(ss + 1, 999);
  }
  bc = 10 * bb[3] + bb[4];
  bd = 10 * bb[1] + bb[0];
  ee = 100 * bb[4] + 10 * bb[3] + bb[2];
  if(bc > bd) {
      ee = max(ee - 1, 100);
  }
  cout << (ee - ss + 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
typedef long long ll;
ll a[N],sum[N];
int main() {
	int n;
	scanf("%d",&n);
	sum[0]=0;
	for(int i=1;i<=n;++i) {
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	ll ans=1e18+7;
    for(int i=1;i<=n-1;++i) {
        ans=min(ans,abs(sum[i]-sum[n]+sum[i]));
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int n;
  cin>>n;
  int num;
  map<int,int> mp;
  rep(i,n){
    cin>>num;
    mp[num]++;
  }
  
  bool flag=true;
  for(const auto& x: mp){
    if(x.second>1){
      flag=false;
    } 
  }
  if(flag) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N;
    cin >> K;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        if (h >= K) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF 1000000000000LL
using namespace std;
typedef long long ll;

ll N, M;
ll A[3000], B[3000], C[3000];
ll dist1[3000], dist2[3000];

int main(void) {
  cin >> N >> M;
  REP(i, 0, M) cin >> A[i] >> B[i] >> C[i], A[i]--, B[i]--, C[i] *= -1;

  REP(i, 0, N) dist1[i] = dist2[i] = INF;
  dist1[0] = dist2[0] = 0;

  REP(i, 0, N - 1) {
    bool f = false;
    REP(j, 0, M) {
      if(dist1[A[j]] != INF && dist1[B[j]] > dist1[A[j]] + C[j]) {
        dist1[B[j]] = dist1[A[j]] + C[j];
        f = true;
      }
    }
    if(!f) break;
  }
  REP(i, 0, N) {
    bool f = false;
    REP(j, 0, M) {
      if(dist2[A[j]] != INF && dist2[B[j]] > dist2[A[j]] + C[j]) {
        dist2[B[j]] = dist2[A[j]] + C[j];
        f = true;
      }
    }
    if(!f) break;
  }
  if(dist1[N - 1] != dist2[N - 1]) cout << "inf" << endl;
  else cout << -dist1[N - 1] << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder bu = new StringBuilder();
		int h=sc.nextInt();
			for(int i=1;i<=h;i++){
				int x=i;
					if(x%3==0){
						bu.append(" ").append(i);
					}else{
						while(x!=0){
							if(x%10==3){
								bu.append(" ").append(i);
								break;
							}else{
								x/=10;
							}
						}
					}
			}
		System.out.println(bu);
	}
}

Measured memory_bytes: 27224
s = gets.chomp.split('')

start_zero = 0
start_one = 0
s.size.times do |i|
  if i%2 == 0
    start_zero += 1 if s[i] != '0'
    start_one += 1 if s[i] != '1'
  else
    start_zero += 1 if s[i] != '1'
    start_one += 1 if s[i] != '0'
  end
end

puts([start_zero, start_one].min)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define len length()
int main()
{
string a,b;
  cin>>a>>b;
  ll n=a.len;ll m=b.len;
  ll dp[a.len+10][b.len+10];
//   memset(dp,0,sizeof dp);
  for(int i=0;i<n+1;i++)
  {
       for(int j=0;j<m+1;j++)
       {
           if(i==0||j==0){dp[i][j]=0;}

       else if(a[i-1]==b[j-1])
       {
       dp[i][j]=1+dp[i-1][j-1];
       }
         else
         {
         dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
         }
       }
  }
  ll i=a.len;ll j=b.len;string s="";
  while(i>=1&&j>=1){
    if(a[i-1]==b[j-1])
    {
        s.push_back(a[i-1]);i--;j--;
    }
    else
    {
        if(dp[i-1][j]>dp[i][j-1])
        {i--;}
        else
        {
            j--;
        }
        
    }
    
}
reverse(s.begin(),s.end());
   cout<<s<<endl;
  
 
  
return 0;}

Measured memory_bytes: 70784
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e6+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
char ch[MAXN];
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==0){
        cout<<0<<endl;
        return 0;
    }
    ll p=n/(a+b);
    ll ans=p*a+min((n-p*(a+b)),a);
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 500005
//<<fixed << setprecision(9)

int arr[space];
int cnt[space];
int distinct;

const int block_size=700;

struct Query
{
    int l, r, idx;
    bool operator<(const Query& other) const
    {
        if(l/block_size != other.l/block_size) return l<other.l;
        return ((l/block_size)&1) ? r<other.r : r>other.r ;
    }
};

void add(int x)
{
    cnt[arr[x]]++;
    if(cnt[arr[x]]==1) distinct++;
}
void remove(int x)
{
    cnt[arr[x]]--;
    if(cnt[arr[x]]==0) distinct--;
}

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>t;

    rep(i,1,n+1) cin>>arr[i];

    Query Q[t];
    int ans[t];
    rep(i,0,t)
    {
        int l,r;
        cin>>l>>r;
        Q[i]={l,r,i};
    }
    sort(Q,Q+t);

    int cur_l = 1;
    int cur_r = 0;
    
    for (Query q : Q)
    {
        while (cur_l > q.l) {
            cur_l--;
            add(cur_l);
        }
        while (cur_r < q.r) {
            cur_r++;
            add(cur_r);
        }
        while (cur_l < q.l) {
            remove(cur_l);
            cur_l++;
        }
        while (cur_r > q.r) {
            remove(cur_r);
            cur_r--;
        }
        ans[q.idx] = distinct;
    }

    rep(i,0,t)cout<<ans[i]<<'\n';

    return 0;
}

Measured memory_bytes: 15488
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod (1e9+7)

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

ll kill(ll x){
    if(x==1)return 1;
    return kill(x/2)*2+1;
}

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    ll H;
    cin >> H;

    //-----------------------------------

    cout << kill(H) <<endl;


    return (0);
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
h = 0
ans = 0
for i in a:
    if (h + i > s / 2):
        ans = min(int(abs(h - s / 2) / 0.5), int(abs((h + i) - s / 2) / 0.5))
        break
    h += i
print(ans)



Measured memory_bytes: 26396
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 606, mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, A, B, col[maxn][maxn], f[maxn][maxn];
vpi sols;
void dfs(int x, int y) {
	for(auto &i : sols) {
		int tx = x + i.first, ty = y + i.second;
		if(tx < 0 || tx >= 2*n || ty < 0 || ty >= 2*n || col[tx][ty] || f[tx][ty]) continue;
		col[tx][ty] = 3^col[x][y];
		dfs(tx, ty);
	}
}
void solve(vpi &a, int d) {
	memset(col, 0, sizeof col);
	memset(f, 0x69, sizeof f);
	sols.clear();
	for(int i = 0; i < 1000; i++)
		for(int j = 0; j < 1000; j++) {
			if(i*i + j*j == d) {
				sols.pb({i, j});
				sols.pb({-i, j});
				sols.pb({i, -j});
				sols.pb({-i, -j});
			}
		}
	for(auto i : a) f[i.first][i.second] = 0;
	vpi l, r;
	
	for(auto t : a) {
		int i = t.first, j = t.second;
		if(!col[i][j]) {
			col[i][j] = 1;
			dfs(i, j);
		}
		(col[i][j] == 1 ? l : r).pb({i, j});
	}
	
	if(l.size() >= r.size())
		a = l;
	else
		a = r;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> A >> B;
	vpi ans;
	for(int i = 0; i < 2*n; i++)
		for(int j = 0; j < 2*n; j++)
			ans.pb({i, j});
	solve(ans, A);
	solve(ans, B);
	for(int i = 0; i < n*n; i++) cout << ans[i].first << " " << ans[i].second << '\n';
}


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



int main (void){
    ll i=2,j=2, x,flag[100005]={}, f,n=100003;

    cin >> x;

    while(i<n){
        j=2;
        f=j*i;
        while(f<n){
            flag[f]-=1;
            f=j*i;
            j++;
            }
        f=0;
        i++;
        while(flag[i]!=0){
                i++;
                }
    }
    
    i=x;
    while(i<100005){
        if(flag[i]==0){
            cout << i << endl;
            return 0;
        }
        i++;
    }
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll dp[5][3010][3010];
ll tbl[3010][3010];

void init() {
    rep(k, 0, 5) rep(i, 0, 3010) rep(j, 0, 3010) {
        dp[k][i][j] = 0;
    }
    rep(i, 0, 3010) rep(j, 0, 3010) tbl[i][j] = 0;
}


int main(){

    init();

    // input
    ll R, C, K;
    cin >> R >> C >> K;
    VL r(K), c(K), v(K);
    rep(i, 0, K){
        cin >> r[i] >> c[i] >> v[i];
        tbl[r[i]-1][c[i]-1] = v[i];
    }

   
    rep(i, 0, R+1){
        rep(j, 0, C+1) {
            // (i, j) -> (i+1, j)
            if(i < R){
                // i, j で取らない
                rep(k, 0, 4) dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j]);
                // i, j で取る
                rep(k, 0, 3) dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j] + tbl[i][j]);
            }
            // (i, j) -> (i, j+1)
            if(j < C){
                // i, jで取らない
                rep(k, 0, 4) dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j]);
                // i, jで取る 
                rep(k, 0, 3) dp[k+1][i][j+1] = max(dp[k+1][i][j+1], dp[k][i][j] + tbl[i][j]);
            }
        }
    }
    
    ll ans = 0;
    rep(i, 0, 4) ans = max(dp[i][R][C], ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 432776
from typing import Optional


class Node:
    def __init__(self, arg_parent: Optional["Node"], arg_key: int,
                 arg_left: Optional["Node"], arg_right: Optional["Node"]):
        self.parent = arg_parent
        self.key = arg_key
        self.left = arg_left
        self.right = arg_right


def print_preorder(node: Node) -> None:
    print(f" {node.key}", end="")
    if node.left is not None:
        print_preorder(node.left)
    if node.right is not None:
        print_preorder(node.right)


def print_inorder(node: Node) -> None:
    if node.left is not None:
        print_inorder(node.left)
    print(f" {node.key}", end="")
    if node.right is not None:
        print_inorder(node.right)


def insert(root: Optional[Node], node: Node) -> Node:
    y: Optional[Node] = None
    x = root

    while x is not None:
        y = x
        if node.key < x.key:
            x = x.left
        else:
            x = x.right
    node.parent = y

    if y is None:
        root = node
    elif node.key < y.key:
        y.left = node
    else:
        y.right = node

    assert root is not None
    return root


if __name__ == "__main__":
    root: Optional[Node] = None
    node_num = int(input())
    for _ in range(node_num):
        command, *value = input().split()
        if "insert" == command:
            root = insert(root, Node(None, int(value[0]), None, None))
        elif "print" == command:
            assert root is not None
            print_inorder(root)
            print()
            print_preorder(root)
            print()
        else:
            pass



Measured memory_bytes: 107000
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define pi 3.141592653589793238
const int N = 1e5 + 10;
vector<vector<int>> adj(N);
vector<bool> vis(N);
void dfs(ll u)
{
    vis[u]=true;
    for(auto v:adj[u])
        if(!vis[v])
            dfs(v);
}
int main(){
    FAST;
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n,m,ans=0;
        cin>>n>>m;
        map<ll,ll> mp;
        for(ll i=0;i<m;i++)
        {
            ll x,y;
            cin>>x>>y;
            mp[x]++,mp[y]++;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        for(ll i=1;i<=n;i++)
        {
            if(mp.find(i)==mp.end())
            {
                ans++;
                continue;
            }
            if(!vis[i])
                ans++,dfs(i);
        }
        cout<<ans-1;
    }
    return 0;
}


Measured memory_bytes: 14536
<?php
fscanf(STDIN, "%d %d", $monster_count, $critical);
$monster_s = fgets(STDIN);
$exploded_monster_s = explode(' ', trim($monster_s));
rsort($exploded_monster_s);
array_splice($exploded_monster_s, 0, $critical);
echo array_sum($exploded_monster_s);

Measured memory_bytes: 33436
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	int a, b, product=1;

	cin >> a >> b;

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

}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
ll _accumulate(const VL &v) { return accumulate(ALL(v), (ll)0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	ll A;
	string B;
	cin >> A >> B;
	ll seisu = (B[0] - '0') * 100;
	seisu += (B[2] - '0') * 10;
	seisu += (B[3] - '0') * 1;
	ll ans = seisu * A / 100;
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3656
import bisect

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

min_A = min(A); max_A = max(A)
A.extend([-100, int(1e6)])
A.sort()

ans = 0
for i in range(min_A, max_A+1):
  lower = bisect.bisect_left(A, i-1) - 1
  upper = bisect.bisect_right(A, i+1) - 1
  ans = max(ans, upper - lower)
  
print(ans)



Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e18)
#define MOD (1e9+7)

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

void Main(){
  ll N; cin >> N;
  vector<ll> A(N);
  rep(i, 0, N) cin >> A[i];

  ll res = INF;
  ll sum, tmp;
  sum = tmp = 0;
  rep(i, 0, N){
    sum += A[i];
    if(i % 2){
      if(sum >= 0){
        tmp += abs(sum) + 1;
        sum = -1;
      }
    }else{
      if(sum <= 0){
        tmp += abs(sum) + 1;
        sum = 1;
      }
    }
  }
  if(tmp < res) res = tmp;
  
  sum = tmp = 0;
  rep(i, 0, N){
    sum += A[i];
    if(i % 2){
      if(sum <= 0){
        tmp += abs(sum) + 1;
        sum = 1;
      }
    }else{
      if(sum >= 0){
        tmp += abs(sum) + 1;
        sum = -1;
      }
    }
  }
  if(tmp < res) res = tmp;

  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 1152
#!/usr/bin/env ruby

n = gets.to_i
nums = gets.split(' ').map &:to_i

l_gcd_cache = []
r_gcd_cache = []

l_gcd_cache[0] = 0
1.upto(n-1).each do |i|
  l_gcd_cache[i] = l_gcd_cache[i-1].gcd(nums[i-1])
end

r_gcd_cache[n-1] = 0
(n-2).downto(0).each do |i|
  r_gcd_cache[i] =  r_gcd_cache[i+1].gcd(nums[i+1])
end

puts 0.upto(n-1).map{|i| l_gcd_cache[i].gcd(r_gcd_cache[i]) }.max


Measured memory_bytes: 11084
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << a.end() - lower_bound(a.begin(), a.end(), k) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES":"NO");}
void Yn(bool z){cout<<(z?"Yes":"No");}
void yn(bool z){cout<<(z?"yes":"no");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  Yn(a+b >= c);
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cis(s);
    map<string, int> mp;
    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;
    auto ans = mp[s];
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

map<pii, vector<pair<pii, int>>> G;
map<pii, int> d;
set<int> company[100100];//company[i]:=駅iを通る会社
int N, M;

void dijkstra() {
    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> que;
    d[pii(0, -1)] = 0;
    que.push(make_pair(0, pii(0, -1)));
    while (!que.empty()) {
        pair<int, pii> p = que.top();
        que.pop();
        pii v = p.second;
        if (d.count(v) && d[v] < p.first)continue;

        rep(i, G[v].size()) {
            pair<pii, int> edge = G[v][i];
            if (!d.count(edge.first) || d[edge.first] > d[v] + edge.second) {
                d[edge.first] = d[v] + edge.second;
                que.push(make_pair(d[edge.first], edge.first));
            }
        }
    }
}

signed main() {
    cin >> N >> M;
    rep(i, M) {
        int p, q, c;
        cin >> p >> q >> c;
        p--;
        q--;
        G[pii(p, c)].push_back(make_pair(pii(q, c), 0));
        G[pii(q, c)].push_back(make_pair(pii(p, c), 0));
        company[p].insert(c);
        company[q].insert(c);
    }
    rep(i, N) {
        for (int c:company[i]) {
            G[pii(i, c)].push_back(make_pair(pii(i, -1), 0));
            G[pii(i, -1)].push_back(make_pair(pii(i, c), 1));
        }
    }

    dijkstra();
    if (d.count(pii(N - 1, -1)))
        cout << d[pii(N - 1, -1)] << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 147376