akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define N 1000
 
int main() {
    int i, j, len, flag;
    char T[N], P[N];
 
    scanf("%s", T);
    scanf("%s", P);
 
    for (i = 0; i < strlen(T); i++) {
        flag = 0;
        if (T[i] == P[0]) {
            flag = 1;
            for (j = 0; j < strlen(P); j++) {
                if (T[i+j] != P[j]) {
                    flag = 0;
                    break;
                }
            }
        }
        if (flag == 1) printf("%d\n", i);
    }
 
    return 0;
}

Measured memory_bytes: 540
# 標準入力
a = input()
b, c = input().split()
#print(list)

flag = False

for num in range(int(b), int(c) + 1):
    #print(num)
    if num % int(a) == 0:
        flag = True

if flag == True:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9132
import math

N, D = [int(x) for x in input().split()]

Data = []
for i in range(N):
    Data.append([int(x) for x in input().split()])

dis = []
for i in range(0, N):
    for j in range(i + 1, N):
        tmp = 0

        for a in range(0, D):
            tmp = tmp + (Data[i][a] - Data[j][a]) ** 2
        tmp = math.sqrt(tmp)
        if tmp.is_integer():
            dis.append(tmp)

print(len(dis))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

int MOD;
int INF=100100100100100;

int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}
int a[3010];
int b[3010];
int powe[3010];

signed main(){
  cin>>MOD;
  rep(i,MOD)cin>>a[i];
  
  rep(ima,MOD){
    int p=MOD;
    if(a[ima]==0)continue;
    if(ima==0)b[p-1]=(b[p-1]+1)%p,b[0]=(b[0]+p-1)%p;
    else{
      rep(i,MOD){
        if(i==0)powe[0]=1;
        else powe[i]=prod(powe[i-1],ima);
      }
  
      for(int i=1;i<=p-1;i++){
        b[i]=add(b[i],powe[p-1-i]);
      }
    }
  }
  rep(i,MOD){
    cout<<(MOD-b[i])%MOD<<" ";
  }
  cout<<endl;
  return 0;
}


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

int main()
{
	double eye[ 2 ];
	int result[ 4 ][ 2 ];
	memset( result, 0, sizeof(result) );

	while( cin >> eye[ 0 ] >> eye[ 1 ] ){
		for( int i = 0; i < 2; ++i ){
			if( eye[ i ] >= 1.1 ){
				++result[ 0 ][ i ];
			}else if( eye[ i ] >= 0.6 ){
				++result[ 1 ][ i ];
			}else if( eye[ i ] >= 0.2 ){
				++result[ 2 ][ i ];
			}else{
				++result[ 3 ][ i ];
			}
		}
	}

	for( int i = 0; i < 4; ++i ){
		cout << result[ i ][ 0 ] << " " << result[ i ][ 1 ] << endl;
	}

	return 0;
}

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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;

lli upper, lower, mid, ans;


void binsearch(lli l, lli u)
{
	char deci;
	if( l == u)
	{
		ans = l;
		return;
	}
	lli mid = (l + u)/2;

	cout << "? "<< (mid*10) << "\n";
	fflush(stdout);

	cin >> deci;
	if( deci == 'Y')
	{
		binsearch(l, mid);
	}
	else
	{
		binsearch(mid+1, u);
	}
}
int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	char deci;
	lli x = 1, checker = 10000000000;
	cout << "? "<< checker <<"\n";
	fflush(stdout);

	cin >> deci;

	if( deci == 'Y')
	{
		while(checker)
		{
			cout << "? "<< (checker*2)<< "\n";
			fflush(stdout);
			cin >> deci;
			if(deci == 'N')
				break;
			checker /= 10;
		}
		if( checker)
			cout << "! "<< (checker*10)<< "\n";
		else
			cout << "! 1\n";
		fflush(stdout);
		return 0;
	}
	else
	{
		while(true)
		{
			cout << "? "<< x<< "\n";;
			fflush(stdout);
			cin >> deci;

			if( deci == 'N')
				break;
			x *= 10;
		}
		upper = x-1;
		lower = x/10+1;

		binsearch(lower, upper);
		cout << "! "<< ans << "\n";
		fflush(stdout);
		return 0;
	}
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;

#define M 2005
int n;
char a[M][M];
int f[M][M],l[M][M],r[M][M];

inline void max(int &x,int y) {if(x<y) x=y;}
inline void min(int &x,int y) {if(x>y) x=y;}

int main () {
	//freopen("a.in","r",stdin);
	scanf("%d",&n);
	for1(1,n,i) scanf("%s",a[i]+1);
	
	ll ans=0;
	FOR2(n,1,i) FOR2(n,1,j) 
		if(isdigit(a[i][j])) {
			bool t[2]={isdigit(a[i+1][j]),isdigit(a[i][j+1])};
			if(!t[0]&&!t[1]) {
				l[j][i]=r[j][i]=j;
				for1(i+1,n,k) l[j][k]=n+1,r[j][k]=0;
			}
			else if(!t[0]) {
				f[i][j]=f[i][j+1];
				l[j][i]=j,r[j][i]=r[j+1][i];
				for1(i+1,n,k) l[j][k]=l[j+1][k],r[j][k]=r[j+1][k];
			}
			else if(!t[1]) {
				f[i][j]=f[i+1][j];
				l[j][i]=r[j][i]=j;
			}
			else {
				int las=0;
				int tot=f[i+1][j]+f[i][j+1];
				l[j][i]=j,r[j][i]=r[j+1][i];
				
				for1(i+1,n,k) {
					if(l[j+1][k]<=r[j][k]&&l[j+1][k]>las) tot-=f[k][l[j+1][k]];
					max(las,r[j][k]);
					min(l[j][k],l[j+1][k]);
					max(r[j][k],r[j+1][k]); 
				}
				f[i][j]=tot;
			}
			ans+=f[i][j]*(a[i][j]-'0');
			f[i][j]+=a[i][j]-'0';
		}
		else l[j][i]=n+1,r[j][i]=0;
	cout<<ans<<endl;
}

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

bool operator<(const string &a, const string &b) {
  int n = min(a.size(), b.size());
  for (int i = 0; i < n; i++)
    if (a[i] < b[i])
      return true;
    else if (a[i] > b[i])
      return false;
  return a.size() < b.size();
}

int cnt[26];

int main() {
  string s;
  cin >> s;
  string mx = "zyxwvutsrqponmlkjihgfedcba";
  if (!(s < mx)) return puts("-1"), 0;
  string res = mx;
  for (int i = 25; i >= 0; i--) {
    string now="";
    now+=char('a'+i);
    if (s<now && now < res) res=now;
  }
  for (int i = 0, flag = 1; i < s.size(); i++) {
    auto &c = s[i];
    if (cnt[c - 'a']) break;
    cnt[c - 'a']++;
    int p = -1;
    string now = s.substr(0, i + 1);
    for (int j = 25; j >= 0; j--)
      if (!cnt[j] && s < string(now + char('a' + j))) p = j;
    if (~p) {
      now += char(p + 'a');
      if (now < res && s < now) res = now;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int N, M; string S, T;
	cin >> N >> M >> S >> T;
	int G = gcd(N, M);
	bool ok = true;
	for (int i = 0; i < G; ++i) {
		if (S[i * (N / G)] != T[i * (M / G)]) {
			ok = false;
		}
	}
	if (!ok) cout << -1 << endl;
	else cout << (long long)(N) * M / G << endl;
	return 0;
}

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

int main(){
    int k, l;
    char str[105];
    scanf("%d%s", &k, str);
    l = strlen(str);
    for (int i=0 ; i<k ; i++){
        if (str[i]=='\0'){
            break;
        }
        printf("%c", str[i]);
    }
    if (l>k){
        printf("...");
    }
    puts("");
    return 0;
}

Measured memory_bytes: 1708
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

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

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

void solve(int N, const std::vector<ll> &x, const std::vector<ll> &y) {

  vector<ll> vx(N), vy(N);
  REP(i, N) {
    vx[i] = x[i] - y[i];
    vy[i] = x[i] + y[i];
  }

  ll xmin = 1e14, xmax = -1e14;
  ll ymin = 1e14, ymax = 0;

  REP(i, N) {
    chmin(xmin, vx[i]);
    chmax(xmax, vx[i]);

    chmin(ymin, vy[i]);
    chmax(ymax, vy[i]);
  }
  cout << max(xmax - xmin, ymax - ymin) << endl;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int N;
  std::cin >> N;
  std::vector<ll> x(N), y(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> x[i] >> y[i];
  }
  solve(N, x, y);
  return 0;
}


Measured memory_bytes: 9584
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

bool a[27];
bool b[27];

void nextGeneration(vector<vector<vector<bool> > >& house) {
	vector<vector<vector<bool> > > tmp(7, vector<vector<bool> >(7, vector<bool>(7, false)));
	for(int i = 1; i <= 5; ++i) for(int j = 1; j <= 5; ++j) for(int k = 1; k <= 5; ++k) {
		int cnt = 0;
		for(int z = -1; z <= 1; ++z) for(int y = -1; y <= 1; ++y) for(int x = -1; x <= 1; ++x)  {
			if(z | y | x) {
				cnt += house[i + z][j + y][k + x];
			}
		}

		if(house[i][j][k])
			tmp[i][j][k] = b[cnt];
		else
			tmp[i][j][k] = a[cnt];
	}

	house.swap(tmp);
}

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

	vector<vector<vector<bool> > > house(7, vector<vector<bool> >(7, vector<bool>(7, false)));

	for(int t = 1;; ++t) {
		int n;
		cin >> n;

		if(!n)
			break;

		for(int i = 1; i <= 5; ++i) {
			for(int j = 1; j <= 5; ++j) {
				for(int k = 1; k <= 5; ++k) {
					char c;
					cin >> c;
					house[i][j][k] = c - '0';
				}
			}
		}

		memset(a, false, sizeof(a));
		memset(b, false, sizeof(b));

		int m;
		cin >> m;
		for(int i = 0; i < m; ++i) {
			int in;
			cin >> in;
			a[in] = true;
		}

		cin >> m;
		for(int i = 0; i < m; ++i) {
			int in;
			cin >> in;
			b[in] = true;
		}

		for(int i = 0; i < n; ++i)
			nextGeneration(house);

		if(t > 1)
			cout << endl;

		cout << "Case " << t << ":" << endl;
		for(int i = 1; i <= 5; ++i) {
			for(int j = 1; j <= 5; ++j) {
				for(int k = 1; k <= 5; ++k) {
					cout << house[i][j][k];
				}
				cout << endl;
			}
			if(i < 5)
				cout << endl;
		}
	}


	return EXIT_SUCCESS;
}

Measured memory_bytes: 1212
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/23/20 23:55:06
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  struct Trans {
    int t;
    ll s;
  };
  constexpr ll INF = 1e18;
  cerr<<INF<<endl;
  vector<Trans> graph[n];
  for (int i = 0; i < m; i++) {
    int u,v,s; cin>>u>>v>>s; u--; v--;
    graph[u].push_back({v,s});
    graph[v].push_back({u,s});
  }
  vector<pair<ll,ll>> ranges(n, {INF,INF});
  auto dfs = [&ranges, &graph](auto& f, int s, ll w, bool odd) {
    if (odd) {
      if (ranges[s].first != INF) {
        return ranges[s].first == w;
      } else {
        ranges[s].first = w;
      }
    } else {
      if (ranges[s].second != INF) {
        return ranges[s].second == w;
      } else {
        ranges[s].second = w;
      }
    }
    for (auto [t,ts]:graph[s]) {
      if (!f(f, t, ts-w, !odd)) return false;
    }
    return true;
  };
  if (dfs(dfs, 0, 0, true)) {
    ll inf=1, sup=INF;
    for (auto [l,h]:ranges) {
      if (l!=INF and h!=INF) {
        if ((h-l)%2==1) {
          inf = INF;
          sup = 0;
          break;
        } else {
          auto t = (h-l)/2;
          inf = max(inf, t);
          sup = min(sup, t);
        }
      }
      if (l!=INF) {
        inf = max(inf, 1-l);
      } else {
        sup = min(sup, h-1);
      }
    }
    cout << max(0ll, sup-inf+1) << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 18592
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1000000007;

ll n, k, c, a[200010], dp_not[200010], dp_take[200010];
string s;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) {
    dp_not[i] = -INF;
    dp_take[i] = -INF;
  }

  dp_not[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int j = (i - 1) / 2;
    dp_not[j + 1] = max(dp_not[j + 1], dp_take[j + 1]);
    dp_take[j + 1] = dp_not[j] + a[i - 1];

    dp_not[j] = max(dp_not[j], dp_take[j]);
    dp_take[j] = dp_not[j - 1] + a[i - 1];
  }
  cout << max(dp_not[n / 2], dp_take[n / 2]);
  return 0;
}



Measured memory_bytes: 8328
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	ll n,cnt=0,ans=0;
	cin >> n;
	ll a[n];
	rep(i,n) cin >> a[i];
	rep(i,n){
		cnt++;
		if(a[i]!=a[i+1] || i==n-1){
			ans+=cnt/2;
			cnt=0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int mx=0,mn=0x7FFFFFFF;
	for(int i=0,t;i<n;++i){
		cin>>t;
		mx=max(mx,t);
		mn=min(mn,t);
	}
	cout<<mx-mn<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int n, m;
  int sum = 0;
  cin >> n >> m;
  vector<int> a;
  rep(i, n)
  {
    int x;
    cin >> x;
    a.push_back(x);
    sum += x;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  rep(i, m)
  {
    if (a[i] * 4 * m < sum)
    {
      cout << "No" << endl;
      return 0;
    }
  }

    cout << "Yes" << endl;
  return 0;
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

int x[N]; ll f[N];

int main () {

	File();

	int n = read(), a = read(), b = read();

	x[1] = read();
	For (i, 2, n) {
		x[i] = read();
		f[i] = min(f[i - 1] + 1ll * a * (x[i] - x[i - 1]), f[i - 1] + b);
	}
	printf ("%lld\n", f[n]);

	return 0;

}

Measured memory_bytes: 1408
#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;
  string S;
  cin >> N >> S;
  vector<ll> memo_r(N);
  vector<ll> memo_l(N);
  ll l_cnt = 0, r_cnt = 0;
  for (int i = 0; i < N; i++) {
    memo_r[i] = r_cnt;
    if (S[i] == 'W') r_cnt++;
  }
  for (int i = N - 1; i >= 0; i--) {
    memo_l[i] = l_cnt;
    if (S[i] == 'E') l_cnt++;
  }
  ll ans = INF;
  for (int i = 0; i < N; i++) {
    ans = min(memo_r[i] + memo_l[i], ans);
  }
  cout << ans << endl;
  return 0;
}

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



class Main{

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] input = br.readLine().split(" ");
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = Integer.parseInt(input[i]);
		}
		int max = a[0];
		int min = a[0];
		for(int i = 1;i < n;i++){
			max = Math.max(max,a[i]);
			min = Math.min(min,a[i]);
		}
		System.out.println(max - min);
	}

}

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

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

    int n, k;
    cin >> n >> k;
    int ans = 0;
    while(n > 0) {
        n /= k;
        ans++;
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  int n; cin >> n;
  int ans = 0;
  REP(i, n) ans += i + 1;
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N, count = 1;
    cin >> N;
    int *a = new int[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i]==count){
            count++;
        }
    }
    if(count==1){
        cout << -1 << endl;
        return 0;
    }
    cout << N - count + 1 << endl; 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct union_find{
    VI par;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
    }

    int find(int x){
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    union_find uf;
    uf.init(n);
    REP(i,m){
        int u = in() - 1, v = in() -1 , z = in();
        uf.merge(u, v);
    }
    int ans = 0;
    REP(i,n) ans += (uf.find(i) == i);
    cout << ans << endl;
    return 0;
}


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

unsigned int countDigit(unsigned long long num){
  unsigned int digit=0;
  while(num!=0){
    num /= 10;
    digit++;
  }
  return digit;
}

int sentou(unsigned long long num){
  while(num>=10) num /= 10;
  return num;
}

int N;

signed main() {
  cin >> N;

  //int N_matsubi = N%10;
  int N_sentou  = sentou(N);
  int N_keta = countDigit(N);    

  if(N<10) {
    cout << N << endl;
    return 0;
  }

  int ans = 0;

  for(int A=1; A<=N; A++) {
    int A_matsubi = A%10;
    int A_sentou  = sentou(A);

    if(A_matsubi == 0) continue;

    {
      // keta == 1
      if(A_matsubi == A_sentou) ans++;
    }

    for(int keta=2; keta<N_keta; keta++) {
      int B_min = A_matsubi * (int)pow(10,keta-1) + A_sentou;
      if(B_min > N) continue;
      ans += (int)pow(10, keta-2);
    }

    {
      // keta == N_keta
      int B_min = A_matsubi * (int)pow(10,N_keta-1) + A_sentou;
      if(B_min <= N) {
        if(A_matsubi == N_sentou) {
          ans += ((N-B_min) / 10) + 1;
        }
        else {
          ans += (int)pow(10, N_keta-2);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	vector<int> cnt(3,0);
	rep(i,n){
		int p;
		cin>>p;
		if(p<=a) cnt[0]++;
		else if(a+1<=p && p<=b) cnt[1]++;
		else cnt[2]++;
	}
	cout<<*min_element(begin(cnt),end(cnt))<<endl;
}

Measured memory_bytes: 256
program a

integer :: i,j,k,l,m,n,basho,left,right,n_left,n_right,n_total=9999999
integer :: aaa(100000)

read(*,*) n,k
read(*,*) (aaa(i),i=1,n)

do i = 1,n
if(aaa(i) == 1) then
basho = i
endif
enddo


do j=0,k-1
left = max(0,basho-1-(k-j-1))
right = max(0,n-basho-j)
n_left = left / (k-1)
n_right = right / (k-1)
if(mod(left,k-1) /= 0)then
n_left = n_left + 1
endif
if(mod(right,k-1) /= 0)then
n_right = n_right + 1
endif
n_total = min(n_total,n_left+n_right+1)
enddo

write(*,*) n_total

end program

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
const int INF = 1145141919, MOD = 1e9 + 7;
const int64_t LINF = 8931145141919364364, LMOD = 998244353;
// const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
// const int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

int main() {
    int64_t n; cin>>n;
    pair<int64_t,int64_t> xy[n];
    rep(i,n){
        int64_t x,y; cin>>x>>y;
        xy[i]={x,y};
    }
    sort(xy,xy+n);
    int64_t ans=INF;
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    for(int64_t i=0;i<n;i++){
        for(int64_t j=0;j!=i&&j<n;j++){
            int64_t p = xy[j].first-xy[i].first;
            int64_t q = xy[j].second-xy[i].second;
            // cerr<<p<<" "<<q<<endl;
            int64_t cost=0;
            for(int64_t k=0;k<n;k++){
                cost++;
                for(int64_t l=0;l<n;l++){
                    if(xy[k].first-p==xy[l].first){
                        if(xy[k].second-q==xy[l].second){
                            cost--;
                            break;
                        }
                    }
                }
            }
            ans=min(ans,cost);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int x;
    cin >> x;
    if(x >= 30)cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

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


int main(){
    int n;cin >> n;
    if(!n){cout << 0 << endl; return 0;}
    vector<int>v;
    v.clear();
    while(n){
        int t;
        if(n & 1)t = 1;
        else t = 0;
        v.push_back(t);
        n-=t;
        n/=-2;
    }
    reverse(v.begin(), v.end());
    for(int i = 0; i < v.size(); ++i)cout << v[i];
    cout << endl;
    //cout << n/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
  long double a,b,c,d;
  scanf("%Lf %Lf %Lf",&a,&b,&c);
  d=c-a-b; //展開は誤差の元　項が増える
  if(d*d>4.0L*a*b && d>0) //d<0 でも成立してしまう 2sqrt(ab)>0よりd>0
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
const int MAX = 1000;
long long n,m;
vector<vector<int> > dp(MAX+1,vector<int>(MAX+1,-1));
vector<vector<char> > v(1000+1,vector<char> (1000+1));
long long ways(long r,long c){
    if(r==n&&c==m){
        return dp[r][c]=1;
    }
    if(dp[r][c]!=-1){
        return dp[r][c]%mod;
    }else{
        long long val1=0,val2=0;
        if(c+1<=m&&v[r][c+1]!='#'){
            val1=ways(r,c+1);
        }
        if(r+1<=n&&v[r+1][c]!='#'){
            val2=ways(r+1,c);
        }
        return dp[r][c]=((val1)%mod+(val2)%mod)%mod;
    }
}
int main() {
	
	cin>>n>>m;
	
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=m;j++){
	        cin>>v[i][j];
	    }
	}
    long long ans=ways(1,1);
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int>wtf(N);
for(int i=0; i<N; i++){
cin>>wtf.at(i);
}
int count=0;
for(int i=0; i<N; i++){
for(int j=0; j<i; j++){
count+=wtf.at(i)*wtf.at(j); 
}
}
cout<<count<<endl;
}

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

int main(void) {
  long long a[6], n, ans;

  if(scanf("%lld %lld %lld %lld %lld %lld", &n, &a[0], &a[1], &a[2], &a[3], &a[4]) == 1);

  for(int i = 0; i < 5; i++) {
    for(int j = i; j < 5; j++) {
      if(a[i] > a[j]) {
        ans = a[i];
        a[i] = a[j];
        a[j] = ans;
      }
    }
  }

  if(n % a[0] != 0) {
    ans = n / a[0] + 5;
  } else {
    ans = n / a[0] + 4;
  }

  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int main(){
    int ans=0;
    ll n,d;
    cin >> n >> d;
    for(int i=0; i<n; i++){
        ll x,y;
        cin >> x >> y;
        if(d*d >= x*x+y*y){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	string a,t;
	cin>>a>>t;
	if(a=="H"&&t=="H"){
		cout<<"H"<<endl;
		}
	if(a=="D"&&t=="H"){
		cout<<"D"<<endl;
	}
	if(a=="H"&&t=="D"){
	cout<<"D"<<endl;
	}
	if(a=="D"&&t=="D"){
	cout<<"H"<<endl;
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d.at(i);
    }
    
    sort(d.begin(),d.end());

    cout << d.at(n/2) - d.at(n/2 - 1) << endl;

    return 0;
}

Measured memory_bytes: 640
import itertools

if __name__ == '__main__':
    n = int(input())
    s1 = [int(i) for i in input().split()]
    s2 = [int(i) for i in input().split()]
    l = []
    for i in range(n):
        l.append(i+1)
    g = []

    for v in itertools.permutations(l, n):
        h = ""
        for i in v:
            h=h+str(i)
        g.append(h)
    g.sort()

    index1 = ""
    index2 = ""
    for i in s1:
        index1 = index1 +str(i)
    for i in s2:
        index2 = index2 +str(i)

    print(abs(g.index(index1) - g.index(index2)))


Measured memory_bytes: 6064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    int m[] = {-1,31,28,31,30,31,30,31,31,30,31,30,31};
    Cout(m[a] == m[b] ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
  int n;
  cin>>n;
  long long a[n];
  bool zflag=0;
  int minusctr=0;
  rep(i,n){
    cin>>a[i];
    if(a[i]==0)zflag=1;
    if(a[i]<0)minusctr++;
  }
  long long ans=0;
  if(zflag){
    rep(i,n){
      ans+=abs(a[i]);
    }
  }
  else if(minusctr%2){
    rep(i,n){
      if(a[i]<0)a[i]*=-1;
    }
    sort(a,a+n);
    a[0]*=-1;
    rep(i,n-1)a[i+1]+=a[i];
    ans=a[n-1];
  }
  else rep(i,n) ans+=abs(a[i]);
  cout<<ans<<endl;
}
  

Measured memory_bytes: 1024
import numpy as np
h, w = map(int, input().split())
s = [input() for _ in range(h)]

dp = np.zeros(h * w).reshape(h, w)

if s[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0
    
for i in range(h - 1):
    if s[i + 1][0] == "." or s[i][0] == s[i + 1][0]:
        dp[i + 1][0] = dp[i][0]
    else:
        dp[i + 1][0] = dp[i][0] + 1
for j in range(w - 1):
    if s[0][j + 1] == "." or s[0][j] == s[0][j + 1]:
        dp[0][j + 1] = dp[0][j]
    else:
        dp[0][j + 1] = dp[0][j] + 1

for i in range(h - 1):
    for j in range(w - 1):
        if s[i + 1][j + 1] == "." or (s[i][j + 1] == s[i + 1][j + 1] and s[i + 1][j + 1] == s[i + 1][j]):
            dp[i + 1][j + 1] = min(dp[i][j + 1], dp[i + 1][j])
        elif s[i][j + 1] == s[i + 1][j + 1] and s[i + 1][j + 1] != s[i + 1][j]:
            dp[i + 1][j + 1] = min(dp[i][j + 1], dp[i + 1][j] + 1)
        elif s[i][j + 1] != s[i + 1][j + 1] and s[i + 1][j + 1] == s[i + 1][j]:
            dp[i + 1][j + 1] = min(dp[i][j + 1] + 1, dp[i + 1][j])
        else:
            dp[i + 1][j + 1] = min(dp[i][j + 1] + 1, dp[i + 1][j] + 1)
  
# if h == 1 and w == 1:
#     if s[0][0] == "#":
#         dp[0][0] == 1
#     else:
#         dp[0][0] == 0
# elif h == 1:
#     if s[h - 1][w - 1] == "#" and (s[0][0] == "#" and dp[h - 1][w - 2] != 1):
#         dp[h- 1][w - 1] += 1
# elif w == 1:
#     if s[h - 1][w - 1] == "#" and (s[0][0] == "#" and dp[h - 2][w - 1] != 1):
#         dp[h- 1][w - 1] += 1
# else:
#     if s[h - 1][w - 1] == "#" and (s[0][0] == "#" and (dp[h - 2][w - 1] != 1 and dp[h - 1][w - 2] != 1)):
#         dp[h- 1][w - 1] += 1
        
# for i in range(w):
#     print(dp[0][i])

print(int(dp[h - 1][w - 1]))

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
bitset<4000001> can;
int x[2000];

int main () {
	scanf ("%d", &n);
	int s = 0;
	for (int i = 0; i < n; i++) {
		scanf ("%d", &x[i]);
		s += x[i];
	}	
	can[0] = 1;
	for (int i = 0; i < n; i++)
		can |= can << x[i];
	for (int i = s / 2; i >= 0; i--)
		if (can[i]) {
			printf ("%d\n", s - i);
			re 0;
		}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  int ans=1;
  
    if(x==1){
        cout << ans << endl;
        return 0;
    }
  for(int b=2;b<=x;b++){
      for(int p=2;p<=x;p++){
          if(pow(b, p)<=x) ans=max(ans, (int)pow(b, p));
          else break;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
W, H, x, y, r= map(int, input().split())
edge_left = x - r
edge_right = x + r
edge_top = y + r
edge_bottom = y - r
if (edge_left < 0) | (edge_right > W):
    answer = "No"
elif (edge_top > H) | (edge_bottom < 0):
    answer = "No"
else:
    answer = "Yes"

print(answer)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
inline int sqr(int x){return x*x%mod;}
int pow(int a,int n)
{
	if(!n)return 1;
	if(n&1)return sqr(pow(a,n/2))*a%mod;
	return sqr(pow(a,n/2));
}
inline int inv(int x){return pow(x,mod-2);}
int n,a[200001],invn[200001],co[200001],h[200001];
main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",a+i);
	for(int i=1;i<=n;i++)invn[i]=inv(i);
	h[2]=invn[2];
	for(int i=3;i<=n;i++)h[i]=(h[i-1]+invn[i])%mod;
	co[1]=1;
	for(int i=2;i<=n;i++)co[i]=co[1]=(co[1]+invn[i])%mod;
	for(int i=2;i<n;i++)co[i]=(co[i]+h[n+1-i])%mod;
	int ans=0,r=1;
	for(int i=1;i<=n;i++)ans+=a[i]*co[i]%mod,r=r*i%mod;
	printf("%lld\n",ans%mod*r%mod);
}


Measured memory_bytes: 5632
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL a,b,ans=1e18;

int main()
{
	cin>>a>>b;
	if(b-a+1>=2019)
	{
		cout<<0<<endl;
		rt0;
	}
	for(LL i=a;i<b;i++) for(LL j=i+1;j<=b;j++) ans=min(ans,i*j%2019);
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
    int a[101][101] = {0};
    int b[101][101] = {0};
    long long c[101][101] = {0};
    int l,m,n;
    cin >> n >> m >> l;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j ++){
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= l; j ++){
            cin >> b[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= l; j ++){
            for(int k = 1; k <= m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= l; j ++){
            if(j == 1){
                cout << c[i][j];
            }else {
                cout << " " << c[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3268
#include<iostream>
 
using namespace std;
 
int main()
{
  int w, h, x, y, r;
 
  cin >> w >> h >> x >> y >> r;
  
  if ((r <= x) && (x <= w - r) && (r <= y) && (y <= h - r))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long arr[N] = {};
int n;
long long k;
bool chack(int x) {
    long long cnt = 0;
    for (int i = 1; i <= n; i++)
        cnt += (arr[i] - 1) / x;
    return cnt <= k;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    int l = 1, r = 1e9 + 5, mid;
    while (l <= r) {
        mid = (l + r) >> 1;
        if (chack(mid))
            r = mid - 1;
        else l = mid + 1;
    }
    cout << l << '\n';
    return 0;
}

Measured memory_bytes: 5196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
    public void exec() throws IOException {
        InputUtil input = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
            int H = input.nextInt();
            int W = input.nextInt();
            if(H==0 && W==0) break;
            for(int y=0; y<H; y++) {
            	char[] cbuf = new char[W];
            	if(y==0 || y==H-1){
                	Arrays.fill(cbuf, '#');
            	}else{
            		cbuf[0]=cbuf[W-1]='#';
            		Arrays.fill(cbuf, 1, W-1, '.');
            	}
            	out.println(cbuf);
            }
            out.println("");
        }
        out.flush();
        input.close();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }

}
 
/**
 * --------------------------------------------------
 * Input Utility
 * --------------------------------------------------
 */
class InputUtil {
    //Static Fields
    private static final int BUFSIZ = 2100005;
     
    //Fields
    protected InputStream in;
    private char[] buf = null;
    private int ptr = 0;
    private int max = -1;
    private BufferedReader br = null;
     
    //Constructors
    public InputUtil() {this(System.in,BUFSIZ);}
    public InputUtil(int bufsiz) {this(System.in,bufsiz);}
    public InputUtil(InputStream in) {this(in,BUFSIZ);}
    public InputUtil(InputStream in, int bufsiz) {
        initBuf(bufsiz);
        initIn(in);
    }
     
    //Methods
    //Initializer
    protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
    protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
     
    //String Input Reader/Parser
    private void readBuf() throws IOException {
        if(ptr >= max && br.ready()) {
            max = br.read(buf);
            ptr = 0;
        }
    }
     
    public BufferedReader getReader() {return br;}
     
    //Number Input Reader/Parser
    private boolean isNum(char b) {return '0' <= b && b <= '9'; }
    private boolean isMinus(char b) {return b=='-'; }
    private void next() throws IOException {ptr++; readBuf();}
 
 
    public int nextInt() throws IOException {return nextInt(new int[1])[0];}
    public int[] nextInt(int[] result) throws IOException {
        readBuf();
        for(int i=0; i<result.length; i++) {
            int sign = 1;
            int res = 0;
            char c;
            while (!isNum(c=buf[ptr]) && !isMinus(c)) 
                next();
            if (isMinus(buf[ptr])) {
                sign = -1;
                next();
            }
            while (isNum(c=buf[ptr])) {
                res *= 10;
                res += c - '0' ;
                next();
            }
            next();
            result[i] = sign * res;
        }
        return result;
    }
     
    //Close 
    public void close() throws IOException {
        if(!this.in.equals(System.in)) 
            this.in.close();
    }
 
}

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

int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>> C(1,vector<char>(W));
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            cin>>C[0][j];
        }
        for(int j=0;j<W;++j) cout<<C[0][j];
        cout<<endl;
        for(int j=0;j<W;++j) cout<<C[0][j];
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
 int K,N;
  cin >> K >> N ;
 vector<int>A(N);
  vector<int>B(N);
  int maxB;
for(int i=0; i<N; i++){
  cin >> A[i];
 }
  for(int i=0; i<N-1; i++){
    B[i] = A[i+1]-A[i];
  }
  B[N-1] = A[0]+K-A[N-1];
  maxB = B[0];
  for(int i=0; i<N; i++){
    if(maxB < B[i]){
      maxB = B[i];
    }
  }
  cout << K-maxB;
  
    
   return 0;
}

Measured memory_bytes: 4848
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
let arr2 = Arr[3].split(" ").map(Number);

const binarySearch = (key) => {
  let mid;
  let left = 0;
  let right = N1;
  if (key < arr1[0] || arr1[N1-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr1[mid]) right = mid;
    else if (key > arr1[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}

console.log(arr2.map(binarySearch).reduce((a, b) => a + b, 0));




Measured memory_bytes: 34936
#include<stdio.h>
#include<vector>
#include<iostream>
#include<functional>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,k,x;
    vector<ll> list;
    cin >> n >> k;
    REP(i,n){
        cin >> x;
        list.push_back(x-1);
    }
    ll l=0, r=0;
    ll ans = 1<<30;
    std::vector<ll> stat; stat.assign(k, 0);
    ll sum=0;
    for(l=0; l<n; l++){
        if(l!=0)if(list[l-1]<k){
            if(stat[list[l-1]]==1) sum--;
            stat[list[l-1]]--;
        }
        if(r<l){ r=l; stat.clear(); sum=0; }
        while(sum < k && r<n){
            if(list[r]<k){
                if(stat[list[r]]==0) sum++;
                stat[list[r]]++;
            }
            r++;
        }
        /*
        cout << "###" << l << " " << r;
        REP(i,k) cout << ":" << stat[k];
        cout << " " << ans << endl;*/
        if(sum >= k)if(ans > r-l) ans = r-l;
    }
    if(ans == 1<<30) cout << "0" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 4668
N, K = map(int, input().split())
W = []

for i in range(N):
    W.append(int(input()))

def f(N, K, W, p):
    cnt = 0
    k = 1
    c_k = 0
    for w in W:
        if c_k + w <= p:
            c_k = c_k + w
            cnt = cnt + 1
        elif k < K and w <= p:
            k = k + 1
            c_k = w
            cnt = cnt + 1
        elif k < K and w > p:
            pass
        else:
            break
    return cnt

start = 0
end = 1000000000
while start != end:
    center = (start + end)//2
    if f(N, K, W, center) < N:
        start = center + 1
    else:
        end = center

print(start)


Measured memory_bytes: 9560
#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 ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define maxn 100001
vector<vector<ll>>v(maxn);
vector<ll>par(maxn);
void dfs(ll x,ll p)
{
    par[x]=p;
    for(auto itr:v[x])
    {
        if(itr==p)
        {
            continue;
        }
        dfs(itr,x);
    }
}
int main()
{
    ll n;
    cin>>n;
    ll x,y,val,val1,val2;
    map<pair<ll,ll>,ll>m;   
    vector<ll>ans(n-1,-1);
    for(int i=0;i<n-1;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        m[{x,y}]=i;
        m[{y,x}]=i;
    }
    y=0;
    for(int i=1;i<=n;i++)
    {
        y=max((ll)v[i].size(),y);
    }
    dfs(1,-1);
    queue<ll>q;
    q.push(1);
    vector<ll>visit(n+1);
    visit[1]=1;
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        val=1;
        if(par[x]!=-1)
        {
            val1=m[{x,par[x]}];
            val2=ans[val1];
        }
        for(auto itr:v[x])
        {
            if(visit[itr]==0)
            {
                val1=m[{x,itr}];
                if(val==val2)
                {
                    val++;
                }
                ans[val1]=val++;
                q.push(itr);
                visit[itr]=1;
            }
        }
    }
    cout<<y<<endl;
    for(auto itr:ans)
    {
        cout<<itr<<endl;
    }
}

Measured memory_bytes: 24268
#include <stdio.h>

#define MAX 100000

int parent(int i) {
  return i / 2;
}

int left(int i) {
  return 2 * i;
}

int right(int i) {
  return 2 * i + 1;
}

int main() {
  int H, i, A[MAX + 1];

  scanf("%d\n", &H);
  for(i = 1; i <= H; i++) {
    scanf("%d", &A[i]);
  }

  for(i = 1; i <= H; i++) {
    printf("node %d: key = %d, ", i, A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i) <= H) printf("left key = %d, ", A[left(i)]);
    if(right(i) <= H) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2056
n, k = map(int, input().split())
d = list(map(int, input().split()))
for i in range(n, 10 * n + 1):
    flag = True
    q = str(i)
    for j in range(len(q)):
        if int(q[j]) in d:
            flag = False
            break
    if flag:
        print(i)
        break


Measured memory_bytes: 2940