akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            for (int i = 1; i < 10; i++) 
            {
                for (int j = 1; j < 10; j++)
                {
                    if (N / i == j && N % i == 0)  
                    {
                        Console.WriteLine("Yes");
                        j = 9;
                        i = 9;
                        break;
                    }
                    if (i == 9 && j == 9) 
                    {
                        Console.WriteLine("No");
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13140
import math
n = int(input())
xy_ls = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans += math.sqrt((xy_ls[i][0]-xy_ls[j][0])**2 + (xy_ls[i][1]-xy_ls[j][1])**2)
        # print(math.sqrt((xy_ls[i][0]-xy_ls[j][0])**2 + (xy_ls[i][1]-xy_ls[j][1])**2))
print(ans / ((n-1)*(n)//2 )*(n-1) )

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

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

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

int gcd3(int a, int b, int c)
{
    return gcd(gcd(a,b),c);
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int k;
    cin>>k;
    ll answer=0;
    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c=1; c<=k; c++){
                answer+=gcd3(a,b,c);
            }
        }
    }
    cout<<answer;

    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,r,t;
    cin >>n >>r >>t;
    vector<int> p(n);
    rep(i,n) scanf(" %d", &p[i]);

    //?????¨????????????
    vector<int> pos(n,0);
    //??????????????¨?????¬??°
    vector<int> av(r,0);
    int ans=0;

    //?????????1?§?????§??????????????????????
    rep(T,t)
    {
        //?§????
        rep(i,n) pos[i]=(pos[i]+p[i])%r;

        //??????
        rep(i,n)
        {
            if(av[pos[i]]==0) ++ans;
            else --av[pos[i]];
        }

        //??????
        if(T)
        {
            rep(i,n) ++av[pos[i]];
        }
    }

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

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

using namespace std;

int main () {
	int a[4];
	for (int i=1;i<=3;i++) cin >> a[i];
	bool y=1;
	sort (a+1,a+4);
	if (a[1]=5&&a[2]==5&&a[3]==7) cout << "YES" << endl; else cout << "NO" << endl;
	return 0;
}

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

#define readv(v) for(auto& pepito : v) cin >> pepito;
#define printv(v) for (int pepo = 0; pepo < v.size(); pepo++) cout << (pepo==0?: ) << v[pepo]; cout << endl;
#define queries(maria) int maria; cin >> maria; while (maria--) 
//for (int i = 0; i < n; i++) 

using ll = long long int;
using vi = vector<ll>;
using vvi = vector<vi>;

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    if (n % max(h, w) == 0) cout << n/max(h,w) << endl;
    else cout << n/max(h,w)+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int x = 0; char c;
  rep(i,s.size()){
    if(x==0){
      c = s[i];
    }
    if(s[i]==c){
      ++x;
    }else{
      ans += 2;
      --x;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
ll K;
vector<ll> A,F;

bool judge(ll lim){
  ll res=0;
  for(int i=0;i<N;i++){
    ll z=lim/F[i];
    if(z>=A[i]) continue;
    res+=(A[i]-z);
    if(res>K) return false; 
  }
  return true;
}

int main(){
  cin>>N>>K;
  A.resize(N);
  F.resize(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>F[i];

  sort(A.begin(),A.end());
  sort(F.begin(),F.end());
  reverse(F.begin(),F.end());

  ll ok=1e15,ng=-1;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    if(judge(mid)) ok=mid;
    else ng=mid;
  }

  cout<<ok<<endl;

  return 0;
}


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

const int Mod = 1e9 + 7;

int N, x, y, z, haiku, Lim;
long long ans = 1, f[45][132000];

int main() {
	cin >> N >> x >> y >> z;
	haiku = (1 << (x - 1)) | (1 << (x + y - 1)) | (1 << (x + y + z - 1));
	Lim = (1 << (x + y + z)) - 1;
	for (int i = 0; i < N; i++)
		ans = ans * 10 % Mod;
	f[0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int now = 0; now <= Lim; now++) {
			for (int k = 1; k <= 10; k++) {
				int nxt = (now << k) | (1 << (k - 1));
				nxt &= Lim;
				if ((nxt & haiku) != haiku)
					f[i + 1][nxt] = (f[i + 1][nxt] + f[i][now]) % Mod;
			}
		}
	}
	for (int i = 0; i <= Lim; i++)
		ans = (ans - f[N][i]) % Mod;
	if (ans < 0) ans += Mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 42240
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *A,*B;

    int C[VMAX+1];
    int n,i,j;
    scanf("%d",&n);
    A=malloc(sizeof(short)*n+1);//分配动态存储空间
    B=malloc(sizeof(short)*n+1);

    for(i=0;i<=VMAX;i++) C[i] =0;
    for(i=0;i<n;i++){
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }
    for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];

    for(j=1;j<=n;j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for(i=1;i<=n;i++){
        if(i>1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");

    return 0;

}


Measured memory_bytes: 9596
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        List<State> stateList = new LinkedList<>();
        State firstState = new State();
        stateList.add(firstState);
        for (int i = 0; i < n; i++) {
            int l = sc.nextInt();

            List<State> newStateList = new LinkedList<>();
            for (State state : stateList) {
                State stateA = new State(state);
                stateA.cost += (stateA.a == 0) ? 0 : 10;
                stateA.a += l;
                newStateList.add(stateA);

                State stateB = new State(state);
                stateB.cost += (stateB.b == 0) ? 0 : 10;
                stateB.b += l;
                newStateList.add(stateB);

                State stateC = new State(state);
                stateC.cost += (stateC.c == 0) ? 0 : 10;
                stateC.c += l;
                newStateList.add(stateC);

                newStateList.add(state);
            }
            stateList = newStateList;
        }

        int ans = Integer.MAX_VALUE;
        for (State s : stateList) {
            ans = Math.min(ans, s.requiredMP(a, b, c));
        }
        System.out.println(ans);
    }
}

class State {
    int a;
    int b;
    int c;
    int cost;

    State() {
        this.a = 0;
        this.b = 0;
        this.c = 0;
        this.cost = 0;
    }

    State(State state) {
        this.a = state.a;
        this.b = state.b;
        this.c = state.c;
        this.cost = state.cost;
    }

    int requiredMP(int a, int b, int c) {
        if (this.a == 0 || this.b == 0 || this.c == 0) {
            return Integer.MAX_VALUE;
        }

        int mp = this.cost + Math.abs(this.a - a) + Math.abs(this.b - b) + Math.abs(this.c - c);
        return mp;
    }
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;

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

    if (N <= 1){
        cout << 0 << "\n";
        return 0;
    }

    /*
    vector<int> dp(N);

    dp[0] = 0, dp[1] = abs(vi[1] - vi[0]);

    for(int i = 2; i < N ; ++i){

        dp[i] = min (abs(vi[i] - vi[i-1]) +  dp[i-1], abs(vi[i] - vi[i-2])+ dp[i-2]);
    }

    */

   /*
    int d1 = 0, d2 = abs(vi[1] - vi[0]), d3 = 0;

    for(int i = 2; i < N;  ++i){
        d3 = min (abs(vi[i] - vi[i-1]) + d2 , abs(vi[i] - vi[i-2]) + d1);
        d1 = d2 ;
        d2 = d3;
    }

    cout << d3 << "\n";

    */

    vector<int> dp(3,0);

    dp[0] = 0 , dp[1] = abs(vi[1] - vi[0]);

    for(int i = 2; i < N; ++i){
        dp[i % 3] = min(abs (vi[i] - vi[i-1]) + dp[(i-1) % 3] , abs(vi[i] - vi[i-2]) + dp [(i-2) %3]); 
        // cout << "dp of i = " << i << " and " << i % 3 << "  became " << dp[i %3 ] << "\n";
    }

    cout << dp[(N-1) % 3] << "\n";
    /*
    for(int i : dp){
        cout << i << " ";
    }
    cout << "\n";
    */
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    if(S[0]==S[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


def rle(list):
    dict = {}
    for i in list:
        if i in dict.keys():
            dict[i] += 1
        else:
            dict[i] = 1
    return dict


n = int(input())
a = list(map(int, input().split()))
minus = rle([i-a[i] for i in range(n)])
plus = rle([i+a[i] for i in range(n)])

cnt = 0
for i in minus:
    if i in plus:
        cnt += minus[i] * plus[i]
print(cnt)


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; ++i){
    if (ans + K > ans * 2){
      ans = ans * 2;
    }else{
      ans += K;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
//list($A,$B,$C,$D,$E,$F) = explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
if (strncmp($N,"YAKI",4)===0) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 3828
#include <stdio.h>
 
#define Max 1000000

void pA(int A[Max], int N);

int insertion(int A[Max], int N, int g);

void shell(int A[Max], int N);

 

 
int main( ) {
  int N,i,j,A[Max];
 
    scanf("%d",&N);
 
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
 
    shell(A, N);
 
    return 0;
}

void pA(int A[Max], int N) {
    int i;
 
    for (i = 0; i < N - 1; i++)
        printf("%d ", A[i]);
    printf("%d\n", A[i]);
}

int insertion(int A[Max], int N, int g) {
    int i, j, v;
    int cnt = 0;
 
    for (i = g; i < N; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
 
    return cnt;
}

void shell(int A[Max], int N) {
    int i = 0;
    int cnt = 0;
    int m = 0;
    int box[20];
    int G[Max];
 
 
    box[0] = 1;
    for (i = 1; i < 20; i++) box[i] = 3 * box[i - 1] + 1;
 
    for (i = 20 - 1; i >= 0; i--) {
        if (box[i] <= N) G[m++] = box[i];
    }
 
    printf("%d\n", m);
 
    pA(G, m);
 
    for (i = 0; i < m; i++) cnt += insertion(A, N, G[i]);
 
    printf("%d\n", cnt);
 
    for (i = 0; i < N; i++) printf("%d\n", A[i]);
}



Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  
 
    if( s.at(1) != s.at(2)){
     
  cout << "No" << endl;
    }
   else if(s.at(0) == s.at(1) || s.at(2) == s.at(3)){
     cout << "Yes" << endl;
   }
  else{ cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
using namespace std;
typedef long long ll;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const int MAX_N = 100010;
ll A[MAX_N];
ll fac[MAX_N];
ll finv[MAX_N];
ll inv[MAX_N];

ll comb(int n, int k) {
    return ((fac[n] * finv[k])%MOD) * finv[n-k] %MOD;
}

int main() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    repi(i,2,MAX_N) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
    int N, K;
    cin >> N >> K;
    rep(i,N) cin >> A[i];
    sort(A, A+N);
    ll ans = 0;
    rep(i,N-K+1) {
        (ans += MOD - (A[i]*comb(N-i-1,K-1))%MOD) %= MOD;
    }
    repi(i,K-1,N) {
        (ans += A[i]*comb(i,K-1)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	string s;
	string t;

	cin >> s;
	cin >> t;

	int changes = s.size() + 1;


	for (int indS = 0; indS < s.size(); indS++) {
		int auxChanges = 0;
		for (int i = 0; i < t.size(); i++) {
			if (i + indS >= s.size()) {
				cout << changes;
				return 0;
			}

			if (t[i] != s[indS + i]) {
				auxChanges++;
			}
		}

		if (auxChanges < changes) changes = auxChanges;
		if (changes == 0) {
			cout << changes;
			return 0;
		}
	}
	cout << changes;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    int N, M, X[100001], deltaX[100001], ans=0;
    cin >> N >> M;
    for (int i=0; i<M; i++) scanf("%d", &X[i]);

    sort(X, X+M);
    for (int i=0; i<M-1; i++) deltaX[i] = X[i+1] - X[i];
    sort(deltaX, deltaX+(M-1), greater<int>());

    for (int i=N; i<M; i++) ans += deltaX[i-1];

    cout << ans << endl;

    return 0;

}


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

using namespace std;
#define PI 3.1415926535897932384626
#define ll long long
#define ull unsigned long long

#define all(x) x.begin(), x.end()
#define fo(i, n) for (i = 0; i < n; i++)
#define sortall(x) sort(all(x))

#define vi vector<int>
#define vs vector<string>
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, int> pii;
typedef vector<psi> vpsi;
typedef vector<psi> vpci;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
//=======================

const int MOD = 1'000'000'007;
const int N = 2e6 + 13;

//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================

void solve()
{
    cin >> n;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    if (t < 30)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 50488
N, X, Y = map( int, input().split(" "))

ans = [0]*N
for i in range(1,N+1):
  for j in range(i,N+1):
    dis = min( abs(j-i), abs(X-i) +1+abs(j-Y), abs(Y-i) +1+abs(j-X) )
    ans[dis]+=1
    
for i in range(1,N):
  print( ans[i] )

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

using namespace std;

typedef long long ll;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<pair<string, string>, int> number;
  function<void(int, string, string)> dfs = [&](int x, string red, string blue) {
    if (x == n) {
      ++number[make_pair(red, blue)];
      return;
    }
    dfs(x + 1, red + s[x], blue);
    dfs(x + 1, red, s[x] + blue);
  };
  dfs(0, "", "");
  reverse(s.begin(), s.end());
  ll answer = 0;
  function<void(int, string, string)> rec = [&](int x, string red, string blue) {
    if (x == n) {
      answer += number[make_pair(red, blue)];
      return;
    }
    rec(x + 1, red + s[x], blue);
    rec(x + 1, red, s[x] + blue);
  };
  rec(0, "", "");
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 84992
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int k=a*b;
    int j=a+b;
    if(k==15){
        printf("*\n");
    }
    else if(j==15){
        printf("+\n");
    }
    else{
        printf("x\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int x;
	cin >> x;
	
	int i, j;
	for (i = x; ; i++) {
		for (j = 2; j < i; j++) {
			if (i % j == 0) break;
		}
		if (j == i) { cout << i << endl; return 0; }
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 100005
#define MAXM 100005
#define MAXV 1000000009

map<int, int> mp;
int n, a[MAXN], ma, ans;

int main()
{
    cin >> n;
    REP(i, 0, n){
        cin >> a[i];
        mp[a[i]]++;
        mp[a[i] - 1]++;
        mp[a[i] + 1]++;
    }
    map<int, int> :: iterator ite;
    for(ite = mp.begin(); ite != mp.end(); ++ite){
        if(ma < ite->se){
            ans = ite->fi;
            ma = ite->se;
            //printf("%d %d\n", ite->fi, ite->se);
        }
    }
    cout << ma << endl;


    return 0;
}
/*

bcdea
4

*/















Measured memory_bytes: 5120
#include<stdio.h>
#include<math.h>
int main() {
	long long int n,a,b,d1,d2,p,i,sum;
	long long num[100100];
	scanf("%lld %lld %lld",&n,&a,&b);
	for(i=0; i<n; i++) {
		scanf("%lld",&num[i]);
	}
	sum=0;
	for(i=0; i<n-1; i++) {
		d1=abs(num[i]-num[i+1])*a;
		d2=b;
		if(d1<d2) {
			sum=sum+d1;
		} else {
			sum=sum+d2;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C + D))
  {
    cout << "Left" << endl;
  }
  else if ((A + B) == (C + D))
  {
    cout << "Balanced" << endl;
  }
  else
  {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
int main() {
  ll N;
  cin >> N;
  vector<ll> C(N), S(N), F(N);
  vector<vector<ll>> dist_time(N);
  ll sum_s = 0;
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i] >> S[i] >> F[i];
    sum_s += S[i] + C[i];
  }
  for (int i = 0; i < N - 1; i++) {
    ll t = S[i] + C[i];
    for (int j = i + 1; j < N - 1; j++) {
      ll start = (t % F[j] == 0) ? t : F[j] * (t / F[j] + 1);
      start = max(S[j], start);
      // cout << i + 1 << "," << j + 1 << "," << start << endl;
      t = start + C[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    int a, b; cin >> a >> b;
    int cnt = 0;

    for(int i = a; i <= b; i++) {
        int v = i % 10;
        int w = (i - v) % 100 / 10;
        int x = i / 1000 % 10;
        int y = i / 10000;
        if(v == y && w == x) cnt++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  string s = "";


  while(n){
    n--;
    s += (char)('a' + (n % 26));
    n /= 26;
  }
  reverse(ALL(s));
  cout << s << endl;
  // count /= 26;
  // rem += count;
  //
  //
  // for(int i = 0; i < mozi; i++){
  //   cout << s[rem % 26];
  //   rem /= 26;
  // }
  // cout << endl;

}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int num=0;
  for(int i=1;i<=b;i++){
    num+=a;
    if(num%b==c){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.HashMap;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SevenFiveSix solver = new SevenFiveSix();
        solver.solve(1, in, out);
        out.close();
    }

    static class SevenFiveSix {
        HashMap<Long, Long> map;
        long result = 0;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            map = new HashMap<>();

            for (int i = 2; i <= n; i++) {
                HashMap<Long, Long> p = primeFactorize(i);
                for (long key : p.keySet()) {
                    map.put(key, map.getOrDefault(key, 1L) + p.get(key));
                }
            }


            dfs(new ArrayList<>(map.keySet()), 0, 75);
            out.println(result);

        }

        public void dfs(List<Long> list, int index, int target) {

            if (list.size() == index) {
                if (target == 1) {
                    result++;
                }
                return;
            }

            int limit = map.get(list.get(index)).intValue();
            for (int i = 1; i <= limit; i++) {
                if (target % i != 0) {
                    continue;
                }
                dfs(list, index + 1, target / i);
            }
        }

        static HashMap<Long, Long> primeFactorize(long x) {
            HashMap<Long, Long> result = new HashMap<>();
            for (long i = 2; i * i <= x; i++) {
                if (x % i != 0) {
                    continue;
                }
                long ex = 0;
                while (x % i == 0) {
                    ex++;
                    x /= i;
                }
                result.put(i, ex);
            }
            if (x != 1) {
                result.put(x, 1L);
            }
            return result;
        }

    }
}



Measured memory_bytes: 38064
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct Mod {
    static constexpr auto kMod = 1000000007L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

main() {
    int64_t x, y;
    cin >> x >> y;

    if ((x + y) % 3 > 0) {
        cout << 0 << endl;
        return 0;
    }

    int64_t n = (x + y) / 3;
    if (x < n || y < n) {
        cout << 0 << endl;
        return 0;
    }

    auto dx = x - n, dy = y - n;
    assert(dx + dy == n);

    constexpr auto M = 1000000007L;

    Mod c(1);
    for (auto i : irange(n - dx + 1, n + 1)) {
        c *= i;
    }
    for (auto i : irange(1L, dx + 1)) {
        c /= i;
    }

    cout << c.n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1e9+7;
using namespace std;
typedef pair<long long,long long> pii;
int main(){
    int n;
    cin >> n;
    pii arr[n];
    rep(i,n) cin >> arr[i].first >> arr[i].second;
    sort(arr,arr+n);
    long long cnt = 0;
    long long right = arr[0].first+arr[0].second;
    for(int i = 1;i<n;i++){
        if((arr[i].first-arr[i].second)>=right) right = arr[i].first+arr[i].second;
        else{
            cnt++;
            right = min(arr[i].first+arr[i].second,right);
        }
    }
    cout << n- cnt << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n,y;cin>>n>>y;
    ll mx = y / 10000;
    REP(i, mx+1){
        ll n2 = n;
        ll y2 = y;
        n2 -= i;
        y2 -= 10000 * i;
        ll mx2 = y2 / 5000;
        REP(j, mx2+1){
            ll n3 = n2;
            ll y3 = y2;
            n3 -= j;
            y3 -= 5000 * j;
            if (n3 * 1000 == y3) {
                cout<<i <<' '<<j<<' '<<n3<<endl;
                return 0;
            }
        }   
    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
    return 0;
}


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

int main() {
   string S;
   cin >> S;
   string T = S.substr(2, S.size()-3);
   int count = 0;
   rep(i, T.size()) if( T[i] == 'C' ) count++;
   int o = 0;
   rep(i, S.size()) if( S[i] < 'a' || S[i] > 'z' ) o++;
   if( S.substr(0,1) == "A" && count == 1 && o == 2 ) cout << "AC" << endl;
   else cout << "WA" << endl;
}

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

typedef long long int ll;

int main()
{
    ll x, y;
    cin >> x >> y;

    for(ll i = 0;i <= x;i++){
        if(i * 2 + (x - i) * 4 == y){
            cout << "Yes";

            return 0;
        }
    }

    cout << "No";

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using namespace std;
using ii = long long;
const ii inf = 1e17;
int main()
{
    int n;
    ii w;
    cin >> n >> w;
    vector<ii> dp(n * 1000 + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        for (int j = n * 1000 - b + 1; j >= 0; --j) {
            dp[j + b] = min(dp[j + b], dp[j] + a);
        }
    }
    for (int j = n * 1000; j >= 0; --j) {
        if (dp[j] <= w) {
            cout << j << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
  cout << n/3 << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
C = list(map(str,input().split()))
data = [[] for i in range(9)]
for i in C:
    data[int(i[1])-1].append(i[0])
D = [s for s in C]
#print(data)
for i in range(n):
    for j in range(n-1,i,-1):
        if int(C[j][1]) < int(C[j-1][1]):
            C[j],C[j-1] = C[j-1],C[j]
print(" ".join(C))
flag = True
for i in range(9):
    if len(data[i]) >= 2:
        for j in range(len(data[i])-1):
            if C.index(data[i][j]+"{}".format(i+1)) > C.index(data[i][j+1]+"{}".format(i+1)):
                print("Not stable")
                flag = False
                break
        if not flag:
            break
else:
    print("Stable")
for i in range(n):
    minj = i
    for j in range(i,n):
        if int(D[j][1]) < int(D[minj][1]):
            minj = j
    else:
        D[i],D[minj] = D[minj],D[i]
print(" ".join(D))
flag = True
for i in range(9):
    if len(data[i]) >= 2:
        for j in range(len(data[i])-1):
            if D.index(data[i][j]+"{}".format(i+1)) > D.index(data[i][j+1]+"{}".format(i+1)):
                print("Not stable")
                flag = False
                break
        if not flag:
            break
else:
    print("Stable")


Measured memory_bytes: 5628
from heapq import*

def Dijkstra(G: list, source=0):
	INF = float("inf")
	V = len(G)
	D = [INF] * V
	D[source] = 0
	vis = [False] * V
	H = [(0, source)]
	while H:
		dist, cur = heappop(H)
		if vis[cur]:
			continue
		vis[cur] = True
		for nxt, cost in G[cur]:
			t = dist + cost
			if D[nxt] > t:
				D[nxt] = t
				heappush(H, (t, nxt))
	return D

import sys
input = sys.stdin.buffer.readline
from math import hypot
sx,sy,gx,gy=map(int,input().split())
n=int(input())
v=[(sx,sy,0),(gx,gy,0)]
for _ in range(n):
	v.append(tuple(map(int,input().split())))
con=[[] for _ in range(n+2)]
for i,p1 in enumerate(v):
	for j,p2 in enumerate(v[i+1:]):
		t=max(0,hypot(p1[0]-p2[0],p1[1]-p2[1])-p1[2]-p2[2])
		con[i].append((i+j+1,t))
		con[i+j+1].append((i,t))
print(Dijkstra(con)[1])


Measured memory_bytes: 126216
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
	int n,q,c,t,time=0;
	string name;
	cin>>n>>q;
	queue<pair<string,int> > Q;
	while(n--){
		cin>>name>>t;
		Q.push(make_pair(name,t));
	}
	
	pair<string,int> u;
	while(!Q.empty()){
		u = Q.front();Q.pop();
		c = min(u.second,q);
		u.second -= c;
		time += c;
		if(u.second) Q.push(make_pair(u.first,u.second));
		else cout<<u.first<<" "<<time<<endl;
	}
	return 0;
}


Measured memory_bytes: 6252
A,B,M=map(int,input().split())
l_a=list(map(int,input().split()))
l_b=list(map(int,input().split()))
ans=[min(l_a)+min(l_b)]
for i in range(M):
  xi,yi,ci=map(int,input().split())
  ans.append(l_a[xi-1]+l_b[yi-1]-ci)
print(min(ans))

Measured memory_bytes: 97312
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

int d[2010][2010];

signed main(){
	int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 1e15;
    rep(i, 0, n){
        d[i][0] = a[i];
        rep(j, 1, n){
            int p = (i - j + n) % n;
            d[i][j] = min(d[i][j - 1], a[p]);
        }
    }
    rep(i, 0, n){
        int tmp = 0;
        rep(j, 0, n){
            tmp += d[j][i];
        }
        ans = min(ans, tmp + i * x);
    }
    cout << ans << endl;
}

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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/* func */

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

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

//#define int ll
//#define int long long

int fwa(int j){
int sum = 0;
  	while (j) {
		sum += j % 10;
		j /= 10;
	}
	return sum;
}

signed main()
{
  int n; cin >> n;
  int ans = 0;


  if(n == 10 || n == 100 || n == 1000 || n == 10000 || n == 100000){
    cout << 10;
    return 0;
  }
  
  while(n){
   ans += n%10;
   n/=10;
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

offset = 1 << 18
D = Array.new(offset, 0)
BT = Array.new(offset * 2, 0)
class << BT
  def update(x)
    offset = size / 2
    self[offset + x] = D[x] * x
    k = (offset + x) / 2
    while k > 0
      self[k] = self[2 * k] + self[2 * k + 1]
      k /= 2
    end
  end
end
A.each do |v| 
  D[v] += 1
  BT.update(v)
end

Q = gets.to_i
Q.times do
  b,c = gets.split.map(&:to_i)
  D[c] += D[b]
  D[b] = 0
  BT.update(b)
  BT.update(c)
  puts BT[1]
end



Measured memory_bytes: 27508
#include<stdio.h>
#include<string.h>

char last_char(char *str){
  int i=0;

  do{
  }while(str[++i]!='\0');

  char chr=str[i-1];
  
  return chr;
}

int main(){
  int n;
  char w[100][11];
  char last;

  scanf("%d", &n);

  for(int i=0;i<n;i++)
    scanf("%s", w[i]);

  last = last_char(w[0]);

  for(int i=1;i<n;i++){
    if(last!=w[i][0]){
      printf("No\n");
      return 0;
    }
    for(int j=0;j<i;j++){
      if(strcmp(w[i], w[j])==0){
        printf("No\n");
        return 0;
      }
    }
    last = last_char(w[i]);
  }

  printf("Yes\n");

  return 0;
}


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

int main()
{
	int N,K,i,h[1000000],m;
	while(cin>>N>>K)
	{
		for(i=0,m=0;i<N;i++)
		{
			cin>>h[i];
			if(h[i]>=K){
				m=m+1;
			}
		}
		cout<<m<<endl;
	}
}

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

int main(void){
  bool ishammingNumber[1000001] = {false, true, true, true, true, true};
  for(int i = 6; i <= 1000000; i++){
    if((i % 2 == 0 && ishammingNumber[i/2]) || (i % 3 == 0 && ishammingNumber[i/3]) || (i % 5 == 0 && ishammingNumber[i/5])) ishammingNumber[i] = true;
    else ishammingNumber[i] = false;
  }
  int m, n, cnt;
  while(cin >> m && m != 0 && cin >> n){
    cnt = 0;
    for(int i = m; i <= n; i++) if(ishammingNumber[i]) cnt++;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 2140
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int h, w;
  scanf("%d%d", &h, &w);
  char s[h+2][w+5];
  for (int i=0; i<w; i++) {
    s[0][i] = '.';
    s[h+1][i] = '.';
  }
  for (int i=0; i<h; i++)
    scanf("%s", s[i+1]);
  for (int i=0; i<h+2; i++)
    s[i][w] = '.';
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s[i+1][j] == '#')
        continue;
      int cnt = 0;
      if (j != 0) {
        if (s[i][j-1] == '#')
          cnt++;
        if (s[i+1][j-1] == '#')
          cnt++;
        if (s[i+2][j-1] == '#')
          cnt++;
      }
      if (s[i][j] == '#')
        cnt++;
      if (s[i][j+1] == '#')
        cnt++;
      if (s[i+1][j+1] == '#')
        cnt++;
      if (s[i+2][j] == '#')
        cnt++;
      if (s[i+2][j+1] == '#')
        cnt++;
      s[i+1][j] = cnt+'0';
    }
  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++)
      printf("%c", s[i+1][j]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 128
// E - Max GCD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A[500];
int rem[500];
ll cum_L[500];
ll cum_R[500];

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

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

	// Aの和の約数が答えの候補
	set<int> candidates;
	for (int i=1; i*i<=A_sum; i++) {
		if (A_sum % i == 0) {
			candidates.insert(i);
			candidates.insert(A_sum / i);
		}
	}

	// 候補のそれぞれについて、K以下の操作でAの全ての要素を割り切れるようにできるか判定し、
	// 割り切れるようにできたものの最大値が答え
	int ans = 0;
	for (int X : candidates) {
		ll need = INF; // 全ての要素を割り切れるようにするのに必要な回数

		ll rem_sum = 0;
		for (int i=0; i<N; i++) {
			rem[i] = A[i] % X;
			rem_sum += rem[i];
		}

		sort(rem, rem+N);

		// rem[i] までを減らす操作、rem[i+1]以降を増やす操作に割り当てる

		// cum_L[i]: rem[i]までを減らすときの減らす操作の合計
		cum_L[0] = rem[0];
		for (int i=1; i<N; i++) {
			cum_L[i] = cum_L[i-1] + rem[i];
		}

		// cum_R[i]: rem[i]までを減らすときの増やす操作の合計
		cum_R[N-1] = 0;
		for (int i=N-2; i>=0; i--) {
			cum_R[i] = cum_R[i+1] + (X - rem[i+1]);
		}

		for (int i=0; i<N; i++) {
			if (cum_L[i] == cum_R[i]) {
				need = min(need, cum_L[i]);
			}
		}

		if (need <= K) {
			ans = max(ans, X);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/trie_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7;
constexpr int mod2 = 998244353;
 
template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}
 
    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};
 
template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
template <class T> using Set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class K, class V> using Umap = gp_hash_table<K, V>;
using Trie = trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update>;
 
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    vector<int> d1(n), d2(n);

    rep(i,n){
        cin >> d1[i] >> d2[i];
    }

    rep(i,n - 2){
        bool flg = true;
        for(int j = i; j < i + 3; ++j){
            flg &= (d1[j] == d2[j]);
        }
        if(flg){
            return cout << "Yes\n", 0;
        }
    }

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>

using namespace std;
static const int MAX=200000;

int main()
{
    int n,R[MAX];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>R[i];
    int maxv =-2000000000;
    int minv=R[0];
    for(int j=1;j<n;j++)
    {
        maxv=max(maxv,R[j]-minv);
        minv=min(minv,R[j]);
    }

    cout<<maxv<<endl;
    return 0;
}

Measured memory_bytes: 3880
import os
import sys

# import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    :return:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret


def mod_invs(max, mod):
    """
    逆元のリスト 0 から max まで
    :param int max:
    :param int mod:
    """
    invs = [1] * (max + 1)
    for x in range(2, max + 1):
        invs[x] = (-(mod // x) * invs[mod % x]) % mod
    return invs


def factorial_invs(max, mod):
    """
    階乗 0!, 1!, 2!, ..., max! の逆元
    :param int max:
    :param int mod:
    """
    ret = []
    r = 1
    for inv in mod_invs(max, mod):
        r = r * inv % mod
        ret.append(r)
    return ret


class Combination:
    def __init__(self, max, mod):
        """
        :param int max:
        :param int mod: 3 以上の素数であること
        """
        self._factorials = get_factorials(max, mod)
        self._finvs = factorial_invs(max, mod)
        self._mod = mod

    # @debug
    def ncr(self, n, r):
        """
        :param int n:
        :param int r:
        :rtype: int
        """
        if n < r:
            return 0
        return self._factorials[n] * self._finvs[r] % self._mod * self._finvs[n - r] % self._mod


N, A, B, C, D = list(map(int, sys.stdin.buffer.readline().split()))

comb = Combination(max=N + 1, mod=MOD)
# dp[u][i]: u 人のグループまでみて、合計 i 人のグループ分けをする方法の数
dp = [[0] * (N + 1) for _ in range(N + 1)]
for u in range(N + 1):
    dp[u][0] = 1
for unit in range(A, B + 1):
    for j in reversed(range(N + 1)):
        dp[unit][j] = dp[unit - 1][j]
        for cnt in range(C, D + 1):
            if j + unit * cnt > N:
                break
            # ((N-j)! / (N-j-unit*cnt)! / (unit!)^cnt) / cnt!
            ncr = comb._factorials[N - j] * comb._finvs[N - j - unit * cnt] % MOD * \
                  pow(comb._finvs[unit], cnt, MOD) % MOD * comb._finvs[cnt] % MOD
            dp[unit][j + unit * cnt] += dp[unit - 1][j] * ncr % MOD
            dp[unit][j + unit * cnt] %= MOD
# print(dp)
print(dp[B][N])


Measured memory_bytes: 51548
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,6)if(s[i] == '1')ans++;
  cout << ans << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 256