akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,a;
  cin>> n;
  map<int,int> m;
  for (int i=0; i<n; i++){
    cin>> a;
    m[a]=i+1;
  }
  for (auto i: m)
  cout<< i.second <<" ";
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, x);
  ll div = x / 11;
  x -= 11 * div;
  ll ans = div * 2;
  if (x > 0) {
    ans++;
    if (x > 6) {
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
/// I won't go back on my word, that's my ninja way!
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5 ;
int n ;
long long c ,sumClock[N] ,sumAnti[N] ,ans ,mxC2[N] ,mxA2[N] ,mxC[N] ,mxA[N] ;
pair<long long,long long> arr[N] ;
int main(){
    scanf("%d%lld",&n,&c);
    for(int i=1;i<=n;++i){
        scanf("%lld%lld",&arr[i].first,&arr[i].second);
        sumClock[i] = arr[i].second + sumClock[i-1] - arr[i].first + arr[i-1].first ;
        mxC[i] = max(mxC[i-1] ,sumClock[i]) ;
        mxC2[i] = max(mxC2[i-1] ,sumClock[i]-arr[i].first);
        ans = max(ans ,sumClock[i]);
    }
    for(int i=n;i>=1;--i){
        sumAnti[i] = arr[i].second + sumAnti[i+1] - (c - arr[i].first) ;
        if(i<n) sumAnti[i] += (c - arr[i+1].first) ;
        mxA[i] = max(mxA[i+1] ,sumAnti[i]) ;
        mxA2[i] = max(mxA2[i+1] ,sumAnti[i]-(c-arr[i].first));
        ans = max(ans ,sumAnti[i]);
    }
    for(int i=0;i<=n;++i){
        ans = max(ans ,mxC[i]+mxA2[i+1]);
        ans = max(ans ,mxC2[i]+mxA[i+1]);
    }
    printf("%lld",ans);
    return 0 ;
}


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

int main()
{
    int n,x,a[1000],i,ans;
    cin>>n>>x;
    ans=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a, a + n);
    for(i=0; i<x; i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i) for i in input().split(' ')]
result=min(r)-max(l)+1
result=result if result>0 else 0
print(result)

Measured memory_bytes: 10868
N = int(input())
A = list(map(int, input().split()))

L = {}
R_val = []
for i in range(N):
    if i+A[i] not in L:
        L[i+A[i]] = 0
    L[i+A[i]]+=1
    R_val.append(i-A[i])
    
ans = 0
for one in R_val:
    if one in L:
        ans+=L[one]
print(ans)

Measured memory_bytes: 124816
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 a, b, c;
  cin >> a >> b >> c;
  if ((a < c && c < b) || (b < c && c < a))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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


int main() {


	int n, m;

	cin >> n;
	int min = 10000000;
	int ans = 0;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (min > a) {
			min = a;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int n,k;
vector<int>d(k);

int dfs(vector<int>&d, vector<bool>&vec, int n){
    int tmp=n;
    bool flag=false;
    while(tmp!=0){
        for(int i=0;i<10;i++){
            if(vec.at(i)){
                if(tmp%10==i)dfs(d, vec, n+1);
            }
        }
        tmp/=10;
    }
    cout<<n<<endl;
    exit(0);
}


int main() {
    cin>>n>>k;
    vector<bool>vec(10, false);
    for(int i=0;i<k;i++){
        int x;
        cin>>x;
        vec.at(x)=true;
    }
    dfs(d, vec, n);



    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans=0;
	for(ll i=0;i<n-2;i++){
		for(ll j=i+1;j<n-1;j++){
			for(ll k=j+1;k<n;k++){
				if(a[k]<(a[i]+a[j])&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]) {
					//cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;

					ans+=1;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll count1;
ll i;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		ll k;cin>>k;ll sum1 = 0;
		for(ll i=1;i<=k;i++)
		{
			for(ll j=1;j<=k;j++)
			{
				for(ll h=1;h<=k;h++)
				{
					sum1 += __gcd(__gcd(i,j),h);
				}
			}
		}
		cout<<sum1<<endl;
}
int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}

Measured memory_bytes: 6000
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <chrono>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
int main() {
	ll N,M;
	cin>>N>>M;
	vpll V;
	for(int i=0;i<N;i++){
		ll a,b;
		cin>>a>>b;
		V.eb(a,b);
	}
	sort(V.begin(),V.end());
	ll num=0,ans=0;
	for(pll p:V){
		ans+=p.first*min(p.second,M-num);
		num+=p.second;
		if(num>=M)
			break;
	}
	cout<<ans<<endl;
    return 0;
}

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

//////全探索したいときに開けよ////////
/*vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}*/

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }
  queue<pair<pair<int,int>,int>> que;
  vector<vector<int>> mazecounter(h,vector<int>(w));
  rep(i,h){ //initialization
    rep(j,w){
      if(a.at(i).at(j) == '#'){
        mazecounter.at(i).at(j) = 0;
        que.push(pair<pair<int,int>,int>(pair<int,int>(i,j),0));
      }else{
        mazecounter.at(i).at(j) = -1;
      }
    }
  }
  int64_t maxdepth = 0;
  vector<vector<int>> dir = {{1,0},{-1,0},{0,1},{0,-1}};
  while(!que.empty()){
    int64_t y = que.front().first.first;
    int64_t x = que.front().first.second;
    int64_t depth =que.front().second;
    rep(i,4){
      int64_t alty = y + dir.at(i).at(0);
      int64_t altx = x + dir.at(i).at(1);     
      if(0 <= alty && alty <= h-1 && 0 <= altx && altx <= w-1
         && mazecounter.at(alty).at(altx) == -1){
        que.push(pair<pair<int,int>,int>(pair<int,int>(alty,altx),depth+1));
        mazecounter.at(alty).at(altx) = depth + 1;
        if(depth+1 > maxdepth){
          maxdepth = depth+1;
        }
      }
    }
    que.pop();
  }
  cout << maxdepth << endl;
}

Measured memory_bytes: 17424
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int A = cin.NextInt();
            int B = cin.NextInt();
            int C = cin.NextInt();
            int D = cin.NextInt();
            while (true)
            {
                C -=B;
                if (C<=0)
                {
                    Console.WriteLine("Yes");
                    break;
                }
                A -=D;
                if (A <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }

        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

bool is_even_string(string S)
{
    int len = S.size();
    if (len % 2 == 1)
        return false;
    REP(i, len / 2)
    {
        if (S[i + len / 2] != S[i])
        {
            return false;
        }
    }
    return true;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    REP(j, N)
    {
        S.erase(S.end() - 1);
        if (is_even_string(S))
        {
            cout << S.size() << "\n";
            exit(0);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <functional>

using namespace std;
using ll = long long;

int main() {
	string s, t;
	cin >> s >> t;
	bool ok = true;
	map<char, char>ma, ima;

	for (int i = 0; i < s.size(); i++) {
		char s_c = s[i], t_c = t[i];
		if (ma.count(s_c)) if (ma[s_c] != t_c) ok = false;
		if (ima.count(t_c)) if (ima[t_c] != s_c) ok = false;
		ma[s_c] = t_c;
		ima[t_c] = s_c;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 776
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    alice, bob = [0] * 2
    for i, v in enumerate(reversed(sorted(a))):
        if i % 2 == 0:
            alice += v 
        else:
            bob += v
    print(alice - bob)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

		for (int i = 0; i < N - 1; i++) {
			cout << A[i] << " ";
		}
		cout << A[N - 1] << endl;
	}
}

int main()
{
	const int MAX = 100;
	int A[MAX], N;

	cin >> N;

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

	for (int i = 0; i < N - 1; i++) {
			cout << A[i] << " ";
		}
	cout << A[N - 1] << endl;

	insertionSort(A, N);
}

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

//ユークリッドの互除法
int GCD(int x, int y){
    if( x % y == 0 ){
        return y;
    }
    return GCD( y , x % y );
}

int main() {
    using namespace std;
    //要素数の入力
    int N;
    cin >> N;
    //集合 A と、数の出てくる回数を管理する配列の準備
    vector<int> A(N);
    vector<int> count(1000001);
    int setwise_gcd;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        //pairwise判定の準備
        count[A[i]]++;
        //setwise判定(全てのgcdをここで計算する)
        setwise_gcd = ( i == 0 ? A[i] : GCD(A[i], setwise_gcd) );
    }
    if(setwise_gcd != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    //各数について倍数として出てくる数を確認する
    for(int i = 2; i < 1000001; i++){
        int divided_count = count[i];
        int now_number = 2*i;
        while( now_number < 1000001 ){
            divided_count+= count[now_number];
            now_number+= i;
        }
        if(divided_count >= 2){
            //A[x] % i == A[y] % i == 0 となるx, yが存在する
            cout << "setwise coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
    return 0;
}

Measured memory_bytes: 11136
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define MAX 100000
using namespace std;
int n;
int A[MAX+1],L[MAX];
int lis(){
    L[0]=A[0];
    int length=1;
    for(int i=1;i<n;i++){
        if(L[length-1]<A[i]){
            L[length++]=A[i];
        }else{
           *lower_bound(L,L+length,A[i])=A[i];//函数lower_bound()在first和last中的前?后?区??行二分?找，返回大于或等于val的第一个元素位置。如果所有元素都小于val，?返回last的位置
        }
    }
    return length;
}


int main(){
    cin>>n;
    for(int i=0;i<n;i++){

    cin>>A[i];
    }
    cout <<lis()<<endl;
return 0;
}

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

int main()
{
	string S,T;
	cin >> S >> T;
	int cnt = 0;
	if (S[0] == T[0]) cnt++;

	if (S[1] == T[1]) cnt++;

	if (S[2] == T[2]) cnt++;

	cout << cnt << endl;
	return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010, M = 20010;

int n, m;
int f[M];

int main()
{
	scanf("%d%d", &m, &n);
	memset(f, 0x3f, sizeof f);
	f[0] = 0;
	
	for (int i = 1; i <= n; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		
		for (int j = a; j <= m + a; j ++ )
			f[j] = min(f[j], f[j - a] + b);
	}

	int res = 0x3f3f3f3f;
	for (int i = m; i < M; i ++ ) res = min(res, f[i]);
	printf("%d\n", res);
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;

    while (n > 0) {
        ans += (n / 2) / 5;
        n /= 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)

Measured memory_bytes: 9068
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	
	long long int n, ans, num;
	
	cin >> n;
	
	cin >> num;
	ans += num - 1;
	
	long long int min = 1;
	
	for(int i = 1; i < n; i++){
		cin >> num;
		if(num == min + 1){
			min = num;
		}else{
			ans += (num - 1) / (min + 1);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair < int, int>
#define  pq         priority_queue
#define  pb         push_back
#define OK          pf("Yes\n")
#define _OK         pf("No\n")
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;
    return 0;
}
//https://github.com/me-shaon/bangla-programming-resources



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

using namespace std;

int main() {
    int n;  cin >> n;
    int *h = new int[n];
    int Mh = 0;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        Mh = max(h[i], Mh);
    }
    
    int ans = 0;
    while (1) {
        int i = 0;
        while (i < n && h[i] == 0)   i++;
        if (i == n)
            break;

        int k = i;
        while (k < n && h[k] > 0) {
            h[k]--;
            k++;
        }
        ans++;
    }

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

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<vector<ll>>> dp(M + 1, vector<vector<ll>> (N + 1, vector<ll> (N + 1, 0)));
  dp[0][1][1] = 1;
  REP(i,M)REP(j,N + 1)REP(k,N + 1) {
    if(j + 1 <= N) {
      dp[i + 1][j + 1][k] = (dp[i + 1][j + 1][k] + dp[i][j][k] * (N - j) % MOD) % MOD;
    }
    dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k] * (j - k) % MOD) % MOD;
    dp[i + 1][j][j] = (dp[i + 1][j][j] + dp[i][j][k] * k % MOD) % MOD;
  }
  cout << dp[M][N][N] << endl;
  return 0;
}



Measured memory_bytes: 216832
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=a;i<a+k;i++){
    if(i<=b) cout<<i<<endl;
  }
  for(int i=b-k+1;i<=b;i++){
    if(i>=a+k) cout<<i<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    char a;
    cin >> a;

    int s = a - 'a';
    string ans;
    if(s >= 0 && s <= 25)ans = "a";
    else ans = "A";

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
using ll = long long;

vector<vector<int>>vac;
ll dp[100010][3];


int main() {
	int n,a,b,c;
	cin >> n;
	vac.resize(n);
	rep(i, n) {
		cin >> a >> b >> c;
		vac[i].push_back(a);vac[i].push_back(b);vac[i].push_back(c);
	}
	for (int i = 0; i < n; i++) {
		//前日に行った活動以外の二種類での幸福度の総和が高いものとそれぞれの活動を足す
		//それを3つに場合分けしてあげて前日がa以外、b以外、c以外の3種類で行っていくといい

		//説明難しすぎるわ
		//分からんかったらみてこれ
		//https://yamakasa.net/atcoder-educational-dp-contest-c/

		//aという活動を行うためには、前日にbかcの活動を行っている必要がある
		//その二つのうち、高いほうを選択して実行する
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + vac[i][0];
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + vac[i][1];
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + vac[i][2];
	}
	cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,y;
    cin>>s;
    cin>>y;
    int cnt=0;
    for(int i=0;i<s.size();i++)
    {
        if(y[i]==s[i])
        {
            cnt++;
        }
    }
    if(cnt==s.size())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

    ll K;
    cin >> K;
    ll a = 0;
    FOR(i,0,K+3){
      a *= 10;
      a += 7;
      a %= K;
      if(a==0){
        cout << i+1 << endl;
        return 0;
      }
    }
    cout << -1 << endl;
}




Measured memory_bytes: 3552
#include "bits/stdc++.h"
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
 	
	long long A,B,K = 0;
	cin >> A;
	cin >> B;
	cin >> K;
	A = A - K;
	if(A<0){
		B = B + A;
		A=0;
	}
	if(B<0){
		B=0;
	}
	cout << A << " " << B;

}


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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  vector<long long> sum(n+1);
  for(int i=0;i<n;i++){
    sum[i+1] = sum[i] + a[i];
  }

  long long ret = 1e18;
  for(int i=1;i<n;i++){
    ret = min(ret, abs(sum[i] - (sum[n]-sum[i])));
    cerr << sum[n]-sum[i] << endl;
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 2560
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
                Sum=500*i+100*j+50*k
                if(Sum==X):
                    count+=1


print(count)







Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = 0;

		for (int i = 1; i <= a; i++) {

			b += i;

		}
		System.out.println(b);

	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main()
{
	int n;
	string s;
	cin >> n >> s;
	
	ll cnt = 0;
	vector<ll> rgb(3);
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			rgb[0]++;
		else if (s[i] == 'G')
			rgb[1]++;
		else
			rgb[2]++;
	}
	cnt = rgb[0] * rgb[1] * rgb[2];

	if (n > 2) {
		for (int d = 1; d < n; d++) {
			for (int i = 0; i < n; i++) {
				if (i + 2 * d >= n) {
					break;
				}
				else
				{
					if ((s[i] != s[i + d]) && (s[i + d] != s[i + 2 * d]) && (s[i + 2 * d] != s[i])) {
						cnt--;
					}
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3632
from collections import Counter
def main():
    n=int(input())
    s=input()
    d=Counter(s)
    a=d["R"]*d["G"]*d["B"]
    for i in range(n):
        t=min(n-i-1, i)
        for j in range(t+1):
            if s[i-j] != s[i] and s[i-j] != s[i+j] and s[i] != s[i+j]:
                a-=1
    print(a)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9392
from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
    if c[(i%2019)]==0:
        c[(i%2019)]+=1
        arr.append((i%2019))
        continue
    else:
        break
if c[0]!=0:
    print (0)
else:
    ans=99999999999
    for i in range(len(arr)):
        for j in range(i+1,len(arr)):
            ans=min(ans,(arr[i]*arr[j])%2019)
            if ans==0:
                break
        if ans==0:
            break
    print (ans)

Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    set<int> st;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        st.insert(a);
    }

    cout << (st.size() == 2 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n, t;
    cin >> n >> t;
    int ans = 1000;
    bool tle = true;
    while(n--){
        int c, x;
        cin >> c >> x;
        if(x <= t){
            tle = false;
            ans = min(ans, c);
        }
    }
    if(tle)
        cout << "TLE" << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
S = [''.join(sorted(input().rstrip())) for _ in range(N)]

from collections import Counter
counter = Counter(S)

answer = sum(x*(x-1)//2 for x in counter.values())
print(answer)


Measured memory_bytes: 19788
const main = (input) => {
  var N = input[0].split(" ")[0]-0;
  var Q = input[0].split(" ")[1]-0;

  var nodes = {};
  for(var i=1;i<=N;i++){
    nodes[i]={score:0, next:[]};
  }
  for(var i=1;i<N;i++){
    var a = input[i].split(" ")[0]-0;
    var b = input[i].split(" ")[1]-0;
    nodes[a].next.push(b);
  }
  for(var i=N;i<input.length;i++){
    var p = input[i].split(" ")[0]-0;
    var x = input[i].split(" ")[1]-0;
    nodes[p].score += x;
  }
  var stack = [nodes[1]];

  while(stack.length != 0){
    var now = stack.pop();
    for(var i=0;i<now.next.length;i++){
      var next = nodes[now.next[i]];
      next.score += now.score;
      stack.push(next);
    }
  }
  var ans = [];
  for(var i=1;i<=N;i++){
    ans.push(nodes[i].score);
  }
  console.log(ans.join(" "));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    double a, b, x;
    cin >> a >> b >> x;
    double y = 1.0*x/a;

    double res;
    if(y<=(1.0*a*b/2)){
    	double val = 1.0*b*b/(2.0*y);
    	//dump(val)
    	res = atan2(val, 1);
    }else{
    	double val = 2.0*(a*b-y)/(a*a);
    	res = atan2(val, 1);
    }
    printf("%.10f\n", (360*res/(2.0*M_PI)));
    return 0;
}

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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define debug(x) cerr<<#x<<"="<<x<<'\n'

int n,m;
vector <int> edge[55];
int dep[55],f[55];
pii res[22];
bool vis[55];

void dfs(int u,int lst) {
	f[u]=lst;
	dep[u]=dep[lst]+1;
	for (int i=0;i<SZ(edge[u]);i++) {
		int v=edge[u][i];
		if (v==lst) continue;
		dfs(v,u);
	}
	return;
}

ll ans=0ll;
int cnt;

void paint(int x,int y) {
	if (dep[x]<dep[y]) swap(x,y);
	while (dep[x]>dep[y]) {
		if (!vis[x]) vis[x]=true,cnt++;
		x=f[x];
	}
	while (x!=y) {
		if (!vis[x]) vis[x]=true,cnt++;
		if (!vis[y]) vis[y]=true,cnt++;
		x=f[x],y=f[y];
	}
	return;
}

ll solve(int mask) {
	memset(vis,0,sizeof(vis));
	cnt=0;
	for (int i=0;i<m;i++)
		if ((mask>>i)&1) paint(res[i].fi,res[i].se);
	return 1ll<<(ll)(n-1-cnt);
}

int main(){
	scanf("%d",&n);
	for (int i=0;i<n-1;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	scanf("%d",&m);
	for (int i=0;i<m;i++) scanf("%d%d",&res[i].fi,&res[i].se);
	dfs(1,0);
	for (int i=0;i<(1<<m);i++) 
		if (__builtin_popcount(i)%2==0) ans+=solve(i);
		else ans-=solve(i);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 384
"use strict";


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    // 差が2以上あると交互に並べられない
    if(Math.abs(N - M) > 1) {
        console.log(0);
        return;
    }
    
    const MOD = 1e9 + 7;
    let answer = 1;
    
    for(let i=1; i<=N; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    for(let i=1; i<=M; i++) {
        answer = (answer % MOD) * (i % MOD);
    }
    
    /* -----------------------------------------------------
       差が1のときは、組み合わせが2通り 例：犬猿犬猿, 猿犬猿犬
       差が0のときは、組み合わせが1通り 例：犬猿犬猿犬
       それによって答えを2倍にするかどうか分ける
    --------------------------------------------------------*/
    console.log(answer * ((N == M) + 1) % MOD);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

#ifdef Lin1043
    #define DEBUG(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__)
    #define massert(...) assert(...)
#else
    #define DEBUG(...)
    #define massert(...)
#endif

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

struct iopener
{
    iopener()
    {
#ifdef Lin1043
        freopen("./in" , "r" , stdin);
#endif
    }
} iop;

typedef long long LL;

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

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}

const int N = 4000 + 5;

int n , m , u , v;

struct Edge
{
    int to; Edge *nxt;
} E[N<<1] , *pre[N];

void addedge(int u , int v)
{
    static int tot = 0;
    E[++tot] = (Edge){v , pre[u]} , pre[u] = &E[tot];
    E[++tot] = (Edge){u , pre[v]} , pre[v] = &E[tot];
}

int dis[N] , sz[N] , k;
int dp[N][N] , f[N][N];

const int INF = 0x3f3f3f3f;

void dfs(int u , int fa)
{
    sz[u] = 1;
    for(Edge *i = pre[u] ; i ; i = i->nxt)
    {
        int v = i->to;
        if(v == fa) continue ;
        dfs(v , u);
        sz[u] += sz[v];
    }
    int U = 0 , S = 0;
    for(Edge *i = pre[u] ; i ; i = i->nxt)
    {
        int v = i->to;
        // if(v == fa) continue ;
        rep(j , 0 , m) f[U][j] = -INF;
        U++ , S += sz[v];
    }
    U = S = 0 , f[0][0] = 1;
    for(Edge *i = pre[u] ; i ; i = i->nxt)
    {
        int v = i->to;
        if(v == fa) continue ;
        rep(j , 0 , S)
        {
            chkmax(f[U + 1][j] , f[U][j]);
            rep(k , 0 , m - j - 1)
            {
                chkmax(f[U + 1][max(j , k + 1)] ,
                       f[U][j] + dp[v][k]);
            }
        }
        U++ , S += sz[v];
    }
    rep(i , 0 , m) dp[u][i] = f[U][i];
}

int main()
{
    read(n) , read(m);
    rep(i , 1 , n - 1)
    {
        read(u) , read(v) , addedge(u , v);
    }
    dfs(1 , 0);
    int Ans = 0;
    rep(i , 1 , n) rep(j , 0 , m)
        chkmax(Ans , dp[i][j]);
    return printf("%d\n" , n - Ans) , 0;
}



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

const int N = 805;
typedef pair<int,int> ii;

int n, m, k;
char a[N][N];
int sx, sy;

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

void from_border() {
	queue <ii> q;
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) d[i][j] = -1;
	for (int j = 2; j <= m - 1; ++j) d[1][j] = 1, q.push(ii(1, j));
	for (int j = 2; j <= m - 1; ++j) d[n][j] = 1, q.push(ii(n, j));
	for (int i = 1; i <= n; ++i) d[i][1] = 1, q.push(ii(i, 1));
	for (int i = 1; i <= n; ++i) d[i][m] = 1, q.push(ii(i, m));

	while(!q.empty()) {
		int x = q.front().first, y = q.front().second; q.pop();
		for (int dir = 0; dir < 4; ++dir) {
			int nx = x + dx[dir], ny = y + dy[dir];
			if (nx < 1 || nx > n || ny < 1 || ny > m || d[nx][ny] != -1) continue;
			d[nx][ny] = d[x][y] + 1;
			q.push(ii(nx, ny));
		}
	}
}

int frS[N][N];
void from_S() {
	queue <ii> q;
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) frS[i][j] = -1;
	frS[sx][sy] = 0; q.push(ii(sx, sy));
	while(!q.empty()) {
		int x = q.front().first, y = q.front().second; q.pop();
		for (int dir = 0; dir < 4; ++dir) {
			int nx = x + dx[dir], ny = y + dy[dir];
			if (nx < 1 || nx > n || ny < 1 || ny > m || frS[nx][ny] != -1 || a[nx][ny] == '#') continue;
			frS[nx][ny] = frS[x][y] + 1;
			q.push(ii(nx, ny));
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
		cin >> a[i][j]; if (a[i][j] == 'S') sx = i, sy = j;
	}
	from_border();
	from_S();

	int ans = 1e9;
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (frS[i][j] != -1 && frS[i][j] <= k) {
		if (i == 1 || i == n || j == 1 || j == m) ans = 1;
		for (int dir = 0; dir < 4; ++dir) {
			int nx = i + dx[dir], ny = j + dy[dir];
			if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
			int cur = d[nx][ny] / k + (d[nx][ny] % k != 0) + 1;
			ans = min(ans, cur);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 6016
N, M = map(int, input().split())
x = [0] * M
y = [0] * M
for i in range(M):
   x[i], y[i] = map(int, input().split())
   x[i]-=1
   y[i]-=1
isRed = [False] * N
isRed[0] = True
cnt = [1] * N
for i in range(M):
   cnt[y[i]]+=1
   if(isRed[x[i]]):
      isRed[y[i]] = True
   cnt[x[i]]-=1
   if(cnt[x[i]] == 0):
      isRed[x[i]] = False
ans = 0
for i in range(N):
   if(isRed[i]):
      ans+=1
print(ans)

Measured memory_bytes: 12404
A, B, M = map(int, input().split())
As = [i for i in map(int, input().split())]
Bs = [i for i in map(int, input().split())]
out = min(As) + min(Bs)
for _ in range(M):
  x, y, c = map(int, input().split())
  out = min(out, As[x-1]+Bs[y-1]-c)
print(out)

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

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int main() {
    int n;cin>>n;
    string a[n];
    int b[n];
    vector<string>c;

    
    string tmp;

    rep(i,n){
        cin>>a[i];
        c.push_back(a[i]);
        b[i]=a[i].size();
    }

    sort(c.begin(),c.end());
    
    rep(i,n-1){
        if(a[i+1][0]!=a[i][b[i]-1] ||c[i+1]==c[i]){
            cout<<"No"<<endl;
//          cout<<a[i+1][0]<<" "<<a[i][b[i]-1]<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
	/*for(int i=0;i<5;i++){
		int B[10];
		for(int i=0;i<10;i++){
			cin >> B[i];
			if(B[i] == 0){
				return 0; //プログラムの強制終了
			}
		}

		int sum = 0;

		for(int i=1;i<10;i++){
			sum += B[i];
		}

		cout << B[0] - sum << endl;
	}*/
	int s,h,o,p;
	cin >> s >> h >> o >> p;

	cout << (s+h+o+p)/60 << endl << (s+h+o+p)%60 << endl;


	return 0;

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;

const int N = 1e5 + 1;

int parent[N], sz[N];

void init() {
	for(int i = 1; i < N; ++i)
		parent[i] = i, sz[i] = 1;
}

int find(int node) {
	return parent[node] == node ? node : parent[node] = find(parent[node]);
}

ll join(int u, int v) {
	u = find(u);
	v = find(v);

	if(u == v)
		return 0;
	ll ret = sz[u] * sz[v];

	if(sz[u] > sz[v])
		swap(u, v);

	parent[v] = u;

	sz[u] += sz[v];

	return ret;
}

pair <int, int> arr[N];

ll ans[N];

int main() {
	Data_Nerd
	init();

	int n, m; scanf("%d%d", &n, &m);

	for(int i = 0; i < m; ++i) {
		scanf("%d%d", &arr[i].first, &arr[i].second);
	}

	for(int i = m - 1; i >= 0; --i) {
		ans[i] = join(arr[i].first, arr[i].second);
	}

	for(int i = 1; i < m; ++i)
		ans[i] += ans[i - 1];

	for(int i = 0; i < m; ++i) {
		printf("%lld\n", ans[i]);
	}
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long;
int main(){
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int count = 0;
    int x;

    for(int i=0;i<n;i++){
        x=0;
        for(int j=0;j<m;j++){
            x+=a[i][j]*b[j];

        }
        x+=c;
        if(x > 0)count++;
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    int N,max=0,x=0;
    cin >> N;
    vector<char> str(N);
    for(int i=0;i<N;i++){
        cin >> str.at(i);
    }
    for(int i=0;i<N;i++){
        if(str.at(i)=='I'){
            x++;
            if(x>max)max = x;
        }
        else if(str.at(i)=='D')x--;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


template<class T> class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<T> bit;
public:
    BIT(int n):bit(vector<T>(n+1, 0)), num(n) {}

    T sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, T x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }

    int lower_bound(T x) {
        T res=0;
        int N=1;
        while(N<num) N*=2;
        int i;
        for(i=N/2; i>0; i/=2) {
            if(res+i<num && bit[res+i]<x) {
                x = x - bit[res +i];
                res = res + i;
            }
        }
        return res + 1;
    }
};

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    ll ans=0;
    BIT<int> bit(n);
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(bit.sum(tmp)==0) ans++;
        bit.add(tmp,1);
    }
    printf("%lld\n", ans);

    return 0;
}


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


int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll ans;
    
    if(x/d>k)ans=x-d*k;
    else{
        ll e=x/d;
        k-=e;
        x-=e*d;
        if(k%2==1)x=abs(x-d);
        ans=x;
    }
        
        
    cout<<ans;
    
    }


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int ans[4];
int data[4];
int a[4];
int coin[4]={10,50,100,500};

int change(int n){
	int re=0;
	for(int i=3;i>=0;i--){
		re+=n/coin[i];n%=coin[i];
	}
	return re;
}

int main(){
	int n;
	int count=0;
	while(cin>>n && n){
		fill(ans,ans+4,0);
		fill(a,a+4,0);
		int s=0,mi=0;
		for(int i=0;i<4;i++){cin>>data[i];s+=data[i];}
		mi=s+10;
		for(a[0]=0;a[0]<=data[0];a[0]++){
			for(a[1]=0;a[1]<=data[1];a[1]++){
				for(a[2]=0;a[2]<=data[2];a[2]++){
					for(a[3]=0;a[3]<=data[3];a[3]++){
						int sum=0;
						for(int i=0;i<4;i++)sum+=a[i]*coin[i];
						if(sum<n)continue;
						int tmp=s+change(sum-n);
						for(int i=0;i<4;i++)tmp-=a[i];
						if(tmp<mi){
							mi=tmp;
							for(int i=0;i<4;i++)ans[i]=a[i];
						}
					}
				}
			}
		}
		if(count)cout<<endl;
		for(int i=0;i<4;i++){
			if(ans[i]>0)cout<<coin[i]<<" "<<ans[i]<<endl;
		}
		
		count++;
	}

}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;


int main(){
    
    int N,K;
    cin>>N>>K;
    int A[K][N]; // 1:お菓子の種類　2:人　持っていれば:1 持っていなければ0
    int count=0; //どれかもっているひと
                 // 初期値を0
    for(int i=0;i!=K;++i){
        for(int j=0;j!=N;++j){
            A[i][j]=0;
        }
    }
    
    
    for(int k=0;k!=K;++k){
        int d;   //k種類のおかしにd人います
        cin>>d;
        for(int i=0;i!=d;++i){
            int n;
            cin>>n;
            A[k][n-1]=1;
        }
    }
    
    for(int j=0;j!=N;++j){
          int sum=0;
          for(int i=0;i!=K;++i){
              sum+=A[i][j];
              if(sum>0){
                  ++count;
                  break;
              }
          }
      }
    cout<<N-count<<endl;
    
    
   
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

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

int main(){
    ll a, b;
    cin >> a >> b;
    cout << a / gcd(a, b) * b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
const int MAX_N  = 10000;

int n;
int a[MAX_N + 1];
 
int main() {
  int ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
eg = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    eg[a].append(b)
    eg[b].append(a)

ans = 0
for i in range(1, n + 1):
    high = True
    for t in eg[i]:
        if h[t] >= h[i]:
            high = False
            break
    if high:
        ans += 1
print(ans)


Measured memory_bytes: 95224