akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>	
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
	
signed main(){
	int a,b; cin>>a>>b;
	cout<<a+b/2<<en;
}
	
	
	
	
	

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=tnn(n)
  let mmove=0,move=0,height=ar[0]
  for(let i=1;i<n;i++){
    if(ar[i]<=height)move++
    else{
      if(mmove<move)mmove=move
      move=0
    }
    height=ar[i]
  }
  if(mmove<move)mmove=move
  to(mmove)
}
main()


Measured memory_bytes: 26700
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	double a,b,c,d;
	double X,Y;
	cin >> a >> b >> c >> d;
	X=(a-c)*(a-c);
	Y=(b-d)*(b-d);
	printf("%.7f\n",sqrt(X+Y));
	return 0;
}

Measured memory_bytes: 1236
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#define ll long long
#define fi first
#define se second
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
const int INF=0x7fffffff;
const double EPS=1e-6;
const int MAX_N=1000000+5;
string s;
int main (void)
{
    cin>>s;
    int i;
    int flag=0;
    if((s!="AAA")&&(s!="BBB"))
        flag=1;
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,c;
  cin>>n>>c;
  vector<Int> x(n),v(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>v[i];

  Int ans=0;
  for(Int uku=0;uku<2;uku++){
    vector<Int> s(n+1,0);
    for(Int i=0;i<n;i++) s[i+1]=s[i]+v[i];
    for(Int i=0;i<n;i++) chmax(ans,s[i+1]-x[i]);

    auto calc=[&](Int i){
      return (s[n]-s[i]-(c-x[i])*2);
    };
    
    Int res=calc(n-1);
    for(Int j=n-2;j>=0;j--){
      chmax(res,calc(j+1));
      chmax(ans,res+(s[j+1]-s[0]-x[j]));
    }
    for(Int i=0;i<n;i++) x[i]=c-x[i];
    reverse(x.begin(),x.end());
    reverse(v.begin(),v.end());
  }

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


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll L=c-a-b;
    ll R=4*a*b;
    if(L<0) cout<<"No\n";
    else {
        L=L*L;
        if(L>R) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

int main() {
	char S[101];
	cin >> S;

	int len = strlen(S);
	int ans = 0;
	for (int i = 0; i < len / 2; i++) {
		if (S[i] != S[len - 1 - i]) {
			ans += 1;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
unittest
{
	assert( [ "4", "0", "1", "1", "2" ].parse.expand.solve == 3 );
	assert( [ "3", "1", "2", "1" ].parse.expand.solve == -1 );
	assert( [ "9", "0", "1", "1", "0", "1", "2", "2", "1", "2" ].parse.expand.solve == 8 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto m = 0L;
	foreach_reverse( i, a; as )
	{
		if( i < a || a < m ) return -1;
		if( m < a ) ans += a;
		m = a - 1;
	}
	return ans;
}


Measured memory_bytes: 4860
import sys
input=lambda: sys.stdin.readline().rstrip()
k=int(input())
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[k-1])


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

int main()
{
 int X,Y,Z,t1,t2,t3;
 cin>>X>>Y>>Z;
 t1=X;
 t2=Y;
 t3=Z;
 Z=t2;
 X=t3;
 Y=t1;
 cout<<X<<" "<<Y<<" "<<Z;

    return 0;
}


Measured memory_bytes: 256
loop do
    h, w = gets.split.map(&:to_i)
    break if h == 0
    input = (1..h).map { gets.chomp.split("") }
    next_mark_pos = Array.new(h).map { Array.new(w) }

    (0..h-1).each do |i|
        (w-1).downto(0) do |j|
            if input[i][j] == ?*
                next_mark_pos[i][j] = j
            elsif j == w - 1
                next_mark_pos[i][j] = w
            else
                next_mark_pos[i][j] = next_mark_pos[i][j+1]
            end
        end
    end

    m = 0

    (0..h-1).each do |i|
        (0..w-1).each do |j|
            next if input[i][j] == ?*
            l = w - 1
            (i..h-1).each do |k|
                l = [l, next_mark_pos[k][j] - 1].min
                break if l <= j
                s = (k - i + 1) * (l - j + 1)
                m = s if s > m
            end
        end
    end

    p m
end



Measured memory_bytes: 29316
/*
Stay innocent, be naive. 
But still dream big. 
Dream big to the point that it is beyond your ability and endeavour to achieve it. 
So dream big and don’t lose your innocence.
*/
import java.util.*;
import java.io.*;

   public class Main
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
          int N = Integer.parseInt(st.nextToken());
         String input = infile.readLine();
         if(N < 3200)
           	System.out.println("red");
        else
          	System.out.println(input);
      }
   }

Measured memory_bytes: 20308
from math import ceil, floor

while 1:
    x,y,s = map(int,input().split())
    if x==0: break
    a = []
    for i in range(1, s):
        p1 = ceil(i/(1+x/100)-0.00001)
        if floor(p1*(1+x/100)+0.00001) != i:
            continue
        p2 = ceil((s-i) / (1 + x / 100) - 0.00001)
        if floor(p2 * (1 + x / 100)+0.00001) != (s-i):
            continue
        a.append(floor(p1*(1+y/100)+0.00001) + floor(p2*(1+y/100)+0.00001))
    print(max(a))


Measured memory_bytes: 5684
<?php
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}

array_splice($tmp, 0, 1);

$array = $tmp;
$maxs = array_keys($array, max($array));
array_splice($array, $maxs[0], 1);
$second = max($array);

foreach ($tmp as $key => $value) {

    if($key == $maxs[0]){
        echo $second . "\n";
    }else{
        echo $tmp[$maxs[0]]. "\n";
    }
}


Measured memory_bytes: 43500
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  rep(i,n-1){
    if(s[i]==s[i+1]){
      cout << i+1 << " " << i+1+1 << endl;
      return 0;
    }
  }
  rep(i,n-2){
    if(s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]){
      cout << i+1 << " " << i+2+1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1;
  cout << endl;
  return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int INF = 1e9;

int main() {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  vi dp(h+1, INF);
  dp[0] = 0;
  rep(i, n){
    rep(j, h+1){
      int magic = b[i];
      if (j >= a[i]){
        magic += dp[j-a[i]];
      }
      dp[j] = min(magic, dp[j]);
    }
  }
  cout << dp[h] << endl;
  return 0;
}

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

const string Alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    int h, w;
    cin >> h >> w;
    string S;
    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> S;
            if(S == "snuke"){
                cout << Alph[j] << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
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: 22228
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>
#include <complex>
#include <iostream>
#include <iomanip>

using namespace std;

typedef long double D;
typedef complex<D> P,Vec;

#define X real()
#define Y imag()

template<typename D> D EPS(){return 1e-9;}

struct L : public vector<P> {
  Vec vec;
  L(const P &a, const P &b):vec(b-a) {
	push_back(a); push_back(b);
  }
};

int sig(D a, D b=0){return a<b-EPS<D>()?-1:a>b+EPS<D>()?1:0;}
D norm(D a) {return a*a;}

istream& operator >> (istream& is, complex<D>& p) {
  D x,y; is >> x >> y;p=P(x,y); return is;
}
bool eq(const P& a, const P& b) {return sig(a.real(), b.real())== 0 && sig(a.imag(), b.imag())==0;}
bool compY (const P& a, const P& b) {return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;}
bool compX (const P& a, const P& b) {return a.X != b.X ? a.X < b.X : a.Y < b.Y;}

D dot(const Vec& a, const Vec& b) { return real(conj(a)*b);}

bool isIntersectSP(const L &s, const P &p) {
  return sig(abs(s[0]-p)+ abs(s[1]-p), abs(s[1]-s[0])) <= 0;
}

P projection(const L &l, const P &p) {
  D t = dot(p-l[0], l.vec) / norm(l.vec);
  return l[0] + t * l.vec;
}

D distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (isIntersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

int main() {
  int n1;
  cin >> n1;
  D x1[n1+2], y1[n1+2];
  x1[0] = 0.0; y1[0] = 0.0;
  for (int i = 1; i <= n1; i++) {
	cin >> x1[i] >> y1[i];
  }
  x1[n1+1] = 1000.0; y1[n1+1] = 0.0;
  int n2;
  cin >> n2;
  D x2[n2+2], y2[n2+2];
  x2[0] = 0.0; y2[0] = 1000.0;
  for (int i = 1; i <= n2; i++) {
	cin >> x2[i] >> y2[i];
  }
  x2[n2+1] = 1000.0; y2[n2+1] = 1000.0;
  n1 += 2; n2 += 2;
  D res = 1e9;
  for (int i = 0; i < n1; i++) {
	for (int j = 0; j < n2-1; j++) {
	  res = min(res, distanceSP(L(P(x2[j],y2[j]), P(x2[j+1],y2[j+1])), P(x1[i],y1[i])));
	}
  }
  for (int i = 0; i < n2; i++) {
	for (int j = 0; j < n1-1; j++) {
	  res = min(res, distanceSP(L(P(x1[j],y1[j]),P(x1[j+1],y1[j+1])), P(x2[i],y2[i])));
	}
  }
  cout << fixed << setprecision(20) << res <<endl;
  //  printf("%.10lf\n", res);
}

Measured memory_bytes: 1320
n = gets.chomp.to_i
a = gets.chomp.split(' ').map{|i| i.to_i}
n.times do |i|
        a[i] = a[i] - i - 1
end
a.sort!
b = a[n / 2]
sum = 0
n.times do |i|
        sum += (a[i] - b).abs
end
puts sum

Measured memory_bytes: 19456
N, Y = map(int, input().split())

k = Y / 1000

ans_a, ans_b, ans_c = -1, -1, -1
for a in range(N+1):
    for b in range(N+1-a):
        if 9*a + 4*b == k - N:
            ans_a, ans_b = a, b

if ans_a != -1:
    ans_c = N - ans_a - ans_b

print(ans_a, ans_b, ans_c)

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

const int MAX_N = 1e5;
vector<vector<int> > G(3*(MAX_N+10));

int main() {
    ll N, M; cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int u, v; cin >> u >> v;
        G[u*3].push_back(v*3+1);
        G[u*3+1].push_back(v*3+2);
        G[u*3+2].push_back(v*3);
    }
    ll S, T; cin >> S >> T;
    vector<bool> visited(3*(N+10), false);
    queue<pair<int, int>> q;
    visited[S*3] = true;
    q.push({S*3, 0});
    while (!q.empty()) {
        pair<int, int> obj = q.front();
        q.pop();
        if (obj.first == T*3) {
            cout << obj.second / 3 << endl;
            return 0;
        }
        for (int x : G[obj.first]) {
            if (!visited[x]) {
                visited[x] = true;
                q.push({x, obj.second + 1});
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 16640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


int popcount32(unsigned int x) {
	x = x - ((x >> 1) & 0x55555555);
	x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
	x = (x + (x >> 4)) & 0x0F0F0F0F;
	x = x + (x >> 8);
	x = x + (x >> 16);
	return x & 0x0000003F;
}

long long pow_mod(long long x, long long y, int mod) {
	int res = 1;
	while (y) {
		if (y & 1)res = (res * x) % mod;
		y >>= 1;
		x = (x * x) % mod;
	}
	return res;
}


int dp[200000];


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

	int n;
	string x;
	cin >> n >> x;

	for (int i = 1; i < 200000; i++) {
		dp[i] = dp[i % popcount32(i)] + 1;
	}

	int one = count(all(x), '1');
	if (one == 0) {
		rep(i, n)cout << 1 << endl;
		return 0;
	}

	int modm = 0;
	int modp = 0;
	rep(i, n) {
		if (one > 1) {
			modm = modm * 2;
			modm += x[i] - '0';
			modm %= one - 1;
		}
		modp = modp * 2;
		modp += x[i] - '0';
		modp %= one + 1;
	}

	rep(i, n) {
		if(x[i]=='0'){
			int mod = (one + 1);
			int p = pow_mod(2, n - 1 - i, mod);
			cout << dp[(modp + p) % mod] + 1 << endl;
		}
		else {
			int mod = (one - 1);
			if (mod == 0) {
				cout << 0 << endl;
				continue;
			}
			int p = pow_mod(2, n - 1 - i, mod);
			cout << dp[(modm - p + mod) % mod] + 1 << endl;
		}
	}



	return 0;
}


Measured memory_bytes: 4544
n = int(input())
x = input()
x_popcnt = x.count('1')
one_popcnt = x_popcnt - 1
zero_popcnt = x_popcnt + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_popcnt != 0:
        one_mod = (one_mod*2 + int(b)) % one_popcnt
    zero_mod = (zero_mod*2 + int(b)) % zero_popcnt

f = [0]*220000
popcnt = [0]*220000
for i in range(1, 220000):
    popcnt[i] = popcnt[i//2] + i % 2
    f[i] = f[i % popcnt[i]] + 1

for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_popcnt != 0:
            nxt = one_mod
            nxt -= pow(2, i, one_popcnt)
            nxt %= one_popcnt
            print(f[nxt]+1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += pow(2, i, zero_popcnt)
        nxt %= zero_popcnt
        print(f[nxt]+1)


Measured memory_bytes: 12824
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1; i<=b; i++){
        if((a*i)%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = INF + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin >> n ;
	string a,b;
	cin >> a >> b;
	for(int i=0 ; i<n ; i++)
		cout << a[i] << b[i] ;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic={}
for i in range(len(a)):
    if a[i] in dic:
        q = q
    dic.setdefault(a[i],0)
    dic[a[i]]+=1
answer=sum(a)
for i in range(q):
    b,c=map(int,input().split())
    if b not in dic:
        answer = answer
    if c not in dic:
        answer = answer
    dic.setdefault(b,0)
    dic.setdefault(c,0)
    dic[c]+=dic[b]
    answer=answer+dic[b]*c-dic[b]*b
    dic[b] = 0
    print(answer)

Measured memory_bytes: 23824
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	string s;
	cin>>s;
	if(s[s.length()-1]!='s')
	{
		cout<<s<<"s"<<endl;
	}
	else
	{
		for(i=0;i<s.length();i++)
			cout<<s[i];
		cout<<"es"<<endl;
	}
	
	


	
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  int ans = 0;
  for(int i = 1;i < N;i++) {
    int n = N-i;
    int num = 0;
    for(int j = 1;j*j <= n;j++) {
      if(n % j != 0) continue;
      if(j*j == n) num++;
      else num += 2;
    }
    ans += num;
  }

  cout << ans << endl;

}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[100100];
li d[100100];

int main() {
    li n;
    cin >> n;
    li sum = 0;
    rin{
        cin >> a[i];
        sum += a[i];
    }
    li base = n * (n + 1) / 2;
    if (sum % base > 0) {
        puts("NO");
        return 0;
    }
    li k = sum / base;
    rin{
        d[i] = a[(i + 1) % n] - a[i] - k;
    }
    //dump(d, n);
    li tmp = 0;
    rin{
        if (d[i] > 0) {
            puts("NO");
            return 0;
        }
        if (-d[i] % n > 0) {
            puts("NO");
            return 0;
        }
        tmp += -d[i] / n;
    }
    cout << (tmp == k ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc160
{
    class Program
    {
        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc160C();
        }
        public static void solve_abc160C()
        {
            int[] kn = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int k = kn[0];
            int n = kn[1];
            int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int max = 0;
            int prev = 0;
            for (int i = 0; i < n; i++)
            {
                max = Math.Max(max, Math.Abs(prev - a[i]));
                prev = a[i];
            }
            max = Math.Max(max, k - a[n - 1] + a[0]);
            Console.WriteLine(k - max);
        }

        public static void solve_abc160B()
        {
            int x = Convert.ToInt32(Console.ReadLine());
            int a = x / 500;
            int r = x % 500;
            int b = r / 5;
            Console.WriteLine(a * 1000 + b * 5);
        }

        public static void solve_abc160A()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 34268
import bisect

n = int(input())
ListL = [int(i) for i in input().split()]

ListL.sort()
ans = 0

for i in reversed(range(2, n)):
	a = ListL[i]
	for j in reversed(range(1, i)):
		b = ListL[j]
		index = bisect.bisect_right(ListL, a-b)
		#print(a, b)
		if (index >= j):
			break
		else:
			ans += j - index

print(ans)

Measured memory_bytes: 3316
import scala.io.StdIn

object Main {

  case class Point(x: Double = 0, y: Double = 0) {

    def +(p: Point): Point = Point(this.x + p.x, this.y + p.y)

    def -(p: Point): Point = Point(this.x - p.x, this.y - p.y)

    def *(a: Double): Point = Point(this.x * a, this.y * a)

    def /(a: Double): Point = {
      assert(a == 0)
      Point(this.x / a, this.y / a)
    }

    def norm(): Double = this.x * this.x + this.y * this.y

    def abs(): Double = scala.math.sqrt(norm())

    def <(p: Point): Boolean = this.x < p.x && this.y < p.y

    private val EPS = 1 ^ (-10)

    def ==(p: Point): Boolean = scala.math.abs(this.x - p.x) < EPS && scala.math.abs(this.y - p.y) < EPS


  }

  case class Segment(p1: Point, p2: Point)

  type GeoVector = Point

  object Cgl0A {

    // 内積
    def dot(a: Point, b: Point): Double = a.x * b.x + a.y * b.y

    def isOrthogonal(a: GeoVector, b: GeoVector): Boolean = dot(a, b) == 0.0

    def isOrthogonal(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {
      isOrthogonal(a1 - a2, b1 - b2)
    }

    def isOrthogonal(s1: Segment, s2: Segment): Boolean = {
      dot(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0
    }

    // 外積
    def cross(a: Point, b: Point): Double = a.x * b.y - a.y * b.x

    def isParallel(a: GeoVector, b: GeoVector): Boolean = cross(a, b) == 0.0

    def isParallel(a1: Point, a2: Point, b1: Point, b2: Point): Boolean = {
      isParallel(a1 - a2, b1 - b2)
    }

    def isParallel(s1: Segment, s2: Segment): Boolean = {
      cross(s1.p2 - s1.p1, s2.p2 - s2.p1) == 0.0
    }

    def project(s: Segment, p: Point): Point = {
      val base: GeoVector = s.p2 - s.p1
      val r: Double = Cgl0A.dot(p - s.p1, base) / base.norm()
      s.p1 + base * r
    }
    
    def reflect(s: Segment, p: Point) = {
      p + (project(s, p) - p) * 2.0
    }
    
  }


  def main(args: Array[String]): Unit = {
    val a = StdIn.readLine().split(' ').map(_.toDouble)
    val p1 = Point(a(0), a(1))
    val p2 = Point(a(2), a(3))
    val base = Segment(p1, p2)

    val q = StdIn.readLine().toInt
    (0 until q).foreach { i =>
      val ai = StdIn.readLine().split(' ').map(_.toDouble)
      val qi = Point(ai(0), ai(1))

      val r = Cgl0A.reflect(base, qi)
      println(f"${r.x}%.8f  ${r.y}%.8f")

    }

  }

}



Measured memory_bytes: 55016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    for (int i = 1, j = m+1; i < j; i++, j--) cout << i << ' ' << j << endl;
    for (int i = m+2, j = 2*m+1; i < j; i++, j--) cout << i << ' ' << j << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << endl
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[300000];

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

    int n;
    cin >> n;
    for (int i = 0; i < 3 * n; ++i)
        cin >> a[i];

    multiset<int> s3, s4;
    priority_queue<int, vector<int>, greater<int>> s1;
    ll lsum = 0, rsum = 0;
    for (int i = 0; i < n; ++i)
    {
        lsum += a[i];
        s1.push(a[i]);
    }

    for (int i = n; i < 3 * n; ++i)
    {
        if (s3.size() < n)
        {
            rsum += a[i];
            s3.insert(a[i]);
        }
        else if (a[i] < *s3.rbegin())
        {
            int x = *s3.rbegin();
            s3.erase(s3.find(x));
            s4.insert(x);
            s3.insert(a[i]);
            rsum -= x;
            rsum += a[i];
        }
        else
        {
            s4.insert(a[i]);
        }
    }
    ll sol = lsum - rsum;
    for (int i = n; i < 2 * n; ++i)
    {
        if (a[i] > s1.top())
        {
            lsum -= s1.top();
            s1.pop();
            s1.push(a[i]);
            lsum += a[i];
        }
        auto it = s3.find(a[i]);
        if (it != s3.end())
        {
            s3.erase(it);
            rsum -= a[i];
            rsum += *s4.begin();
            s3.insert(*s4.begin());
            s4.erase(s4.begin());
        }
        else
            s4.erase(s4.find(a[i]));

        sol = max(sol, lsum - rsum);
    }
    cout << sol;
}


Measured memory_bytes: 11256
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n , k;
    long long ans=0 , mod=1000000007 , sma , lar;
    cin >> n >> k;
    
    sma = lar = 0;
    for(int i=0;i<k;i++){
        sma += i , lar += n-i;
    }
    
    for(int i=k;i<=n+1;i++){
        if(lar >= mod && sma >= mod){
            lar = lar - mod , sma = sma - mod;
        }
        ans += lar - sma + 1;
        ans = ans % mod;
        sma += i , lar += n-i;
    }
    cout << ans << endl;
    return(0);
}


Measured memory_bytes: 3596
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N, X, Y = map(int, read().split())

dist = []
for i in range(1, N):
    x = np.arange(i + 1, N + 1)
    # 直接
    d1 = np.abs(x - i)
    # i -> X -> Y -> x
    d2 = np.abs(i - X) + np.abs(Y - x) + 1
    # i -> Y -> X -> x
    d3 = np.abs(i - Y) + np.abs(X - x) + 1
    d = np.minimum(np.minimum(d1, d2), d3)
    dist.append(d)

dist = np.concatenate(dist)
count = np.bincount(dist, minlength=N)
print('\n'.join(count[1:].astype(str)))


Measured memory_bytes: 43896
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var ans = 0L;
        for (int i=0;i<N;++i)
        {
            ans += A[i] - 1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;




long POW (long N, int middle) {
	for (int i = 0; i < middle; i++) {
		N *= 1.01;
	}
	return N;
}
int  main(int argc, char *argv[]) {
	
	long N; cin >> N;
	
	long left = 1;
	long middle =  2000;
	long right = 4000;
	long num = 100;
	while(left != middle) {
		if (POW(num,middle) <= N) {
			left = middle;
			middle = (left + right) / 2;
		}else {
			right = middle;	
			middle = (left + right) / 2;
		}
	}

	if (POW(100,left) >= N) {
		cout << left << endl;	
	}else if (POW(100,middle) >= N) {
		cout << middle << endl;	
	}else {
		cout << right << endl;	
	}

	return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str_as = br.readLine().split(" ");
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = Integer.parseInt(str_as[i]);
        }
        
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (as[i] % 2 == 1) count++;
        }
        
        System.out.println(count%2==0?"YES":"NO");
    }
}


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

namespace AtTest.ABC_135
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] ps = ReadInts();
            int[] sorted = new int[n];
            for (int i = 0; i < n; i++) sorted[i] = ps[i];
            Array.Sort(sorted);
            for(int i = 0; i < n; i++)
            {
                for(int j = i; j < n; j++)
                {
                    int tmp = ps[i];
                    ps[i] = ps[j];
                    ps[j] = tmp;
                    int cnt = 0;
                    for(int k = 0; k < n; k++)
                    {
                        if (ps[k] == sorted[k]) cnt++;
                    }
                    if (cnt == n)
                    {
                        WriteLine("YES");
                        return;
                    }
                    ps[j] = ps[i];
                    ps[i] = tmp;
                }
            }

            WriteLine("NO");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#define DEBUG

int main(void){
    int N;
    scanf("%d", &N);
    int num = 3,top = 1, pri[55555], flag = 1, i;
    pri[0] = 2;
    printf("2 ");
    while(1){
        //printf("%d\n", num);
        for(int i = 0; i < top; i++){
            if(num % pri[i] == 0)
                goto a;
        }
       pri[top] = num;
        top++;
       if(num % 5 == 2){
                if(flag == N - 1){
                    printf("%d\n", num);
                    return 0;
                }
                printf("%d ", num);
                flag++;
        }
    a:num++;
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n, m, l;
    cin >> n >> m >> l;
    int A[n][m];
    int B[m][l];
    long ans[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> B[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            ans[i][j] = 0;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            for(int k = 0; k < m; k++){
                ans[i][j] += A[i][k] * B[k][j];
            }
            cout << ans[i][j];
            if(j != l - 1) cout << " ";
        } cout << endl;
    }
    return 0;
}
    

Measured memory_bytes: 3212
#include <iostream>
#include <cstring>

int main()
{
	char* A = new char[11];
	char* B = new char[11];;
	char* C = new char[11];;

	std::cin >> A;
	std::cin >> B;
	std::cin >> C;

	if (A[std::strlen(A) - 1] == B[0] &&
		B[std::strlen(B) - 1] == C[0]) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

    return 0;
}



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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

    vector<int> s(m);
    vector<int> c(m);

    for(int i=0;i<m;i++){
        cin >> s[i] >> c[i];
    }

    int num = 0;
    int min_n = pow(10,n-1);
    int max_n = pow(10,n) - 1;

    // cout << min_n << " " << max_n << endl;

    std::string str;

    if(n==1){
        bool flag = true;
        for(int j=0;j<m;j++){
            if(c[j]!=0){
                flag = false;
            }
        }
        if(flag){
            cout << 0 << endl;
            return 0;
        }
    }

    for(int i=min_n;i<=max_n;i++){
        str = to_string(i);
        bool flag = true;
        for(int j=0;j<m;j++){
            int tmp = ctoi(str[s[j]-1]);
            if(tmp!=c[j]){
                flag = false;
            }
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    } 
    
    cout << -1 << endl;
}


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

using namespace std;

long long cnt;
vector<int> G;
int A[1000000];

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int i = 1; i <= n; i = i * 3 + 1) {
        G.push_back(i);
    }

    int size = (int)G.size();

    for (auto itr = rbegin(G); itr != rend(G); ++itr) {
        insertionSort(A, n, *itr);
    }
}

int main()
{
    int N;    

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

    cnt = 0;

    shellSort(A, N);

    cout << (int)G.size() << endl;

    int n = 0;
    for (auto itr = rbegin(G); itr != rend(G); ++itr) {
        if (n != 0) printf(" ");
        printf("%d", *itr);
        n++;
    }
    printf("\n");

    printf("%lld\n", cnt);

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


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD = 1e9 + 7;

void add(int &a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
}

int ADD(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

vi mult(vi &a, vi &b)
{
	vi c(a.size(),0);
	assert(a.size()==b.size());
	for(int i=0;i<a.size();i++)
	{
		for(int j=0;j+i<b.size();j++)
		{
			add(c[i+j],mult(a[i],b[j]));
		}
	}
	return c;
}

int f[5001][5001];
int g[5001][5001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n; string s; cin>>s;
	n-=s.length();
	if(n<0)
	{
		cout<<0<<'\n';
		return 0;
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j>0) add(f[i][j],ADD(f[i-1][j-1],f[i-1][j-1]));
			if(j==0) add(f[i][j],f[i-1][j]);
			if(j+1<=n) add(f[i][j],f[i-1][j+1]);
		}
	}
	g[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			if(j>0) add(g[i][j],ADD(g[i-1][j-1],g[i-1][j-1]));
			if(j+1<=n) add(g[i][j],g[i-1][j+1]);
		}
	}
	vi base(n+1);
	for(int i=0;i<=n;i++)
	{
		base[i]=g[i][0];
	}
	vi res = base;
	vi dig;
	int tmp=s.length();
	while(tmp)
	{
		dig.pb(tmp&1);
		tmp>>=1;
	}
	if(!dig.empty()) dig.pop_back();
	reverse(dig.begin(),dig.end());
	for(int i=0;i<dig.size();i++)
	{
		res=mult(res,res);
		if(dig[i]) res=mult(res,base);
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		add(ans,mult(f[i][0], res[n-i]));
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 194048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << "debug: " << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  vector<string> ans(h);
  rep(i, h) rep(j, w) ans[i].push_back('#');
  rep(i, h) cin >> v[i];
  rep(i, h) {
    rep(j, w) {
      int cta = 0;
      if (v[i][j] == '#') continue;
      rep2(k, max(0, i - 1), min(i + 2, h)) {
        rep2(l, max(0, j - 1), min(j + 2, w)) {
          if (k == i && l == j) continue;
          if (v[k][l] == '#') cta++;
        }
      }
      ans[i][j] = '0' + cta;
    }
  }
  rep(i, h) out(ans[i]);
}
int main(void) { solve(); }

Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n);
	double sum = 0;
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		
		sum += a[i];
	}
	sum /= n;
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(std::abs(a[i] - sum) < std::abs(a[ans] - sum)) {
			ans = i;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int isprime(int);

int main(){
  int i,num,num2,sum=0,x;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&num2);
      x=isprime(num2);
      if(x==1)sum+=1;
    }
      printf("%d\n",sum);

  return 0;
}



int isprime(int x){
int i =3;
    if (x == 2){
      return 1;
}

    if (x < 2 || x%2==0){
      return 0;
    }

    while (i <= sqrt(x)){
      if (x%i==0)return 0;

      i = i + 2;
}
   return 1;
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
  int p=i*1.08;
  if(p==N){
    cout<<i<<endl;
    return 0;
  }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, 0, n - 1)cin >> a[i];
	sort(all(a),greater<ll>());
	ll line1 = 0, line2 = 0;
	vector<bool> ok(1e9 + 1, 0);
	rep(i, 0, n - 1)
	{
		if (line1 > 0)
		{
			if (ok[a[i]])
			{
				line2 = a[i];
				break;
			}
			else
			{
				ok[a[i]] = true;
			}
		}
		else
		{
			if (ok[a[i]])
			{
				line1 = a[i];
				ok[a[i]] = false;
			}
			else ok[a[i]] = true;
		}
	}
	cout << line1 * line2 << endl;
}

Measured memory_bytes: 123136
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
lli n;
cin>>n;
lli i,j;
lli mini=inf;
for(i=1;i*i<=n;i++){
    if(n%i==0){
        mini=min(mini,i+n/i-2);
    }
}
cout<<mini<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5+5;
const int INF = 0x3f3f3f3f;

int a[N];
bool vis[N];

int main()
{
    int n,m,pos,val;
	scanf("%d%d",&n,&m);
	
	bool f = 0;
	for(int i = 1;i <= m;++i){
		scanf("%d%d",&pos,&val);
		if(vis[pos]){
			if(val != a[pos]) f = 1;
			continue;
		}
		vis[pos] = 1;
		a[pos] = val;
	}
	if(f) printf("-1\n");
	else{
		if(n == 1) printf("%d",a[1]);
		else{
			if(!vis[1]) a[1] = 1;
			if(!a[1]) printf("-1\n");
			else{
				for(int i = 1;i <= n;++i) printf("%d",a[i]);
			}
		}
	}
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a)
c=b.most_common()
ans=0
for i in range(len(c)):
  if c[i][0]>c[i][1]:
    ans+=c[i][1]
  else:
    ans+=c[i][1]-c[i][0]
print(ans)


Measured memory_bytes: 21232
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s.size() % 2 == 1) {
        char center = s[s.size() / 2];
        int k1 = 0;
        reprev (i, 1, s.size() / 2 + 1) {
            if (s[i] == s[i - 1]) k1++;
            else break;
        }
        int k2 = 0;
        rep (i, s.size() / 2, s.size() - 1) {
            if (s[i] == s[i + 1]) k2++;
            else break;
        }
        eprintf("%d %d\n", k1, k2);
        cout << s.size() / 2 + min(k1, k2) + 1 << "\n";
    } else {
        int k1 = 0;
        reprev (i, 1, s.size() / 2 + 1) {
            if (s[i] == s[i - 1]) k1++;
            else break;
        }
        int k2 = 0;
        rep (i, s.size() / 2 - 1, s.size() - 1) {
            if (s[i] == s[i + 1]) k2++;
            else break;
        }
        eprintf("%d %d\n", k1, k2);
        cout << s.size() / 2 + min(k1, k2) << "\n";
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 20 + 5;
int a[N],b[N],c[N];

int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
	}
	a[0] = -1;
	for(int i = 1;i <= n;i++){
		scanf("%d",&b[i]);
	}
	for(int i = 1;i < n;i++){
		scanf("%d",&c[i]);
	}
	int sum = 0;
	for(int i = 1;i <= n;i++){
		if(a[i] == (a[i-1]+1)){
			sum += (b[a[i]]+c[a[i]-1]);
		}
		else sum += b[a[i]];
//		cout << sum << endl;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256