akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
vector<int> primep(int N){
    vector<int> prime;
    prime.push_back(2);
    bool flag = true;
    for (int i = 3;i<N+1;i++){
        flag = true;
        for (int j = 0;j<prime.size();j++){
            if(i % prime[j] == 0){
                flag = false;
                break;
            }
        }
        if(flag == true){
            prime.push_back(i);
        }
    }
    return prime;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
    long long n,m;
    cin >> n >> m;
    vector<int> prime = primep(int(sqrt(m))+2);
    int a[prime.size()+1] ={0};
    rep(i,prime.size()){
        while(m%prime[i] == 0){
            a[i]++;
            m/=prime[i];
        }
    }
    if(m!=1){
        a[prime.size()]++;
    }
    long long ans = 1;
    rep(i,prime.size()+1){
        for(int j = n+a[i]-1;j>=n;j--){
            ans*=j;
            ans%=MOD;
        }
        for(int j = a[i];j>=1;j--){
            ans*=modinv(j,MOD);
            ans%=MOD;
        }
    }
    cout << ans << endl;
}

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

	

int main() {
	
	int A, B, K;
	cin >>A >>B >>K;
	
	vector<int> As(0);
	
	for(int i=0; i<A; i++){
		
		if(A%(i+1)==0){
			
			As.push_back(i+1);
			
		}
		
	}
	
	vector<int> Bs(0);
	
	for(int i=0; i<B; i++){
		
		if(B%(i+1)==0){
			
			Bs.push_back(i+1);
			
		}
		
	}
	
	bool a=false;
	
	if(As.size()>=Bs.size()){
		
		a=true;
		
	}
	
	vector<int> Cs(0);
	vector<int> Ds(0);
	
	if(a){
		
		for(int i=0; i<As.size(); i++){
			
			Cs.push_back(As.at(i));
			
		}
		for(int i=0; i<Bs.size(); i++){
			
			Ds.push_back(Bs.at(i));
			
		}
		
	}
	else{
		
		for(int i=0; i<Bs.size(); i++){
			
			Cs.push_back(Bs.at(i));
			
		}
		for(int i=0; i<As.size(); i++){
			
			Ds.push_back(As.at(i));
			
		}
		
	}
	
	vector<int> Es(0);
	
	for(int i=0; i<Cs.size(); i++){
		
		for(int j=0; j<Ds.size(); j++){
			
			if(Cs.at(i)==Ds.at(j)){
				
				Es.push_back(Cs.at(i));
				
			}
			
		}
		
	}
	
	reverse(Es.begin(),Es.end());
	
	cout <<Es.at(K-1) <<endl;
	
}


Measured memory_bytes: 256
N = int(input())
C = sorted(list(map(int,input().split())),reverse=True)
L = 10**9 + 7


if N > 1:
    b = 2**(N-2) % (L)
    a = [C[i] * b * (2+i) % L for i in range(N)]
    print(sum(a)*b*2*2%L)
else:
    print(C[0]*2%L)

Measured memory_bytes: 31692
n = int(input())

n_max=100000

a1=[1]

a9=[]
for i in range(1, n+1):
	j=9**i
	if j<=n:
		a9.append(j)
	else:
		break

a6=[]
for i in range(1, n+1):
	j=6**i
	if j<=n:
		a6.append(j)
	else:
		break

#print(a9)
#print(a6)

k1=a1+a6+a9
kn=list(k1)
#print(k1)
#print(kn)


ans=1

while (1==1):
	if n in kn: break
	kn=[i+j for i in kn for j in k1 if i+j<=n]
	kn=list(set(kn))
	ans+=1
#	print(ans, kn)

print(ans)

exit(0)


Measured memory_bytes: 56680
import sys
s=input()
opt = ["+","-"]
for opt1 in opt:
    for opt2 in opt:
        for opt3 in opt:
            equation = s[0]+opt1+s[1]+opt2+s[2]+opt3+s[3]
            if  eval(equation) == 7:
                print(equation+"=7")
                sys.exit()
                

Measured memory_bytes: 2940
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int res = 0;
        int sum753 = 159;
        List<long> cur753 = new List<long>();
        cur753.Add(0);
        while (cur753.Count != 0)
        {
            List<long> new753 = new List<long>();
            foreach (var num in cur753)
            {
                if (num > n) continue;
                if (num.ToString().Distinct().Select(x => (int)x).Sum() == sum753) res++;
                new753.Add(num * 10 + 3);
                new753.Add(num * 10 + 5);
                new753.Add(num * 10 + 7);
            }
            cur753 = new753;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 19160
h,w = map(int,input().split())
a = [input() for i in range(h)]


count = 0
for i in range(h-1,-1,-1):
  if "#" not in a[i]:
    del a[i]
    count +=1
h -=count

tenti_a = list(map(list, zip(*a)))
count = 0
for i in range(w-1,-1,-1):
  if "#" not in tenti_a[i]:
    del tenti_a[i]
    count +=1
w -=count

tenti_tenti_a = list(map(list, zip(*tenti_a)))
for i in range(h):
  print(str(tenti_tenti_a[i]).replace("[","").replace("]","").replace(",","").replace("'","").replace(" ",""))

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vli;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define I cin
#define O cout
#define EN endl
#define ln cout<<endl
#define pb(a) push_back(a)
#define x first
#define y second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
  return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
  return a / gcd(a, b) * b;
}

int cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int a[10] = {};
  for(int i = 0; i < n; i++) {
    int m;
    I >> m;
    a[min(m / 400, 8)]++;
  }

  for(int i = 0; i < 8; i++) if(a[i]) cnt++;

  O << max(cnt, 1) << ' ' << cnt + a[8] << EN;
  
  return 0;
}


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

int main()
{
  int x,y;
  while(true){
    
    cin >> x >> y;

    if(x==0 && y==0) break;

    if(x>y){
      swap(x,y);
    }


  cout << x << " " << y << endl;
    

  }


  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

int main(){
  /*int s, w; cin >> s >> w;
  if(w>=s) cout << "unsafe" <<endl;
  else  cout << "safe" <<endl; */
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  a = (a+d-1)/d;
  c = (c+b-1)/b;
  if(a<c) cout << "No" << endl;
  else cout << "Yes" << endl;

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  string n;
  cin >> n;
  int m=0;
  for(auto &c: n){
    m += c - '0';
  }
  cout << (m%9==0 ? "Yes" : "No") << endl;
}



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

int main()
{
  int H, W, i, j;
  
  while(1)
    {
      cin >> H >> W;
      if(H==0 && W==0)
	break;
	
      for(i=0; i<H; i++)
	{
	  if(i==0 || i==H-1)
	    {
	      for(j=0; j<W; j++)
		cout << "#";
	      cout << endl;
	    }
	  else
	    {
	      for(j=0; j<W; j++)
		{
		  if(j==0 || j==W-1)
		    {
		      cout << "#";
		    }
		  else
		    {
		      cout << ".";
		    }
		}
	      cout << endl;
	    }
	}
      cout << endl;
    }
  return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s, t; std::cin >> s >> t;
  sort(rng(s)), sort(t.rbegin(), t.rend());
  std::cout << (s < t ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000

int main(){
  ll N;
  cin>>N;
  ll ans=0;
  for(ll i=1;i*i<=N-1;i++){
    if((N-1)%i==0){
      if(i==(N-1)/i){
        ans+=1;
      }else{
        ans+=2;
      }
    }
  }
  for(ll i=2;i*i<=N;i++){
    if(N%i==0){
      ll x=i;
      ll y=N/i;
      ll res=N;
      while(res%x==0){
        res/=x;
      }
      if(res%x==1){
        ans++;
      }
      if(x==y){
        continue;
      }
      res=N;
      while(res%y==0){
        res/=y;
      }
      if(res%y==1){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

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

		int max = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int answer = 0;
		for(int i = 1 ; i <= max ; i++ ) {
			String num = String.valueOf(i);
			String[] numArray = num.split("");
			//int[] keta = new int[numArray.length];
			int total = 0;
			for (int j = 0; j < numArray.length; j++) {
				total += Integer.parseInt(numArray[j]);
			}
			if(total >= a && total <= b) {
				answer += i;
			}

		}
		System.out.println(answer);

	}

}


Measured memory_bytes: 51204
N,M = map(int,input().split())

AB = []

for i in range(N):
    a,b = map(int,input().split())
    AB.append([a,b])


AB.sort(key=lambda x: x[0])

money = 0
goal = M

for i in range(10**5):
    if goal - AB[i][1] > 0:
        goal -= AB[i][1]
        money += AB[i][0] * AB[i][1]
    else:
        money += AB[i][0] * goal
        break

print(money)

Measured memory_bytes: 21212
# coding:utf-8
n, m = map(int, input().split())
ans = [0] * n

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

    ans[a] += 1
    ans[b] += 1

for i in ans:
    print(i)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define vec vector
#define mst(a,b) memset(a,b,sizeof(a))
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define all(v) v.begin(),v.end()
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
#define nnf LLONG_MIN
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=((res%mod)*(x%mod))%mod;
        }
        x=((x%mod)*(x%mod))%mod;
        y=y/2;
    }
    return res;
}
 
 struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(pair<uint64_t,uint64_t> x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};

void get_time(auto start,auto end){
    double time_taken =  
      chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
  
    time_taken *= 1e-9;
    cout<<"\n";
    cout<<"Time taken : "<<fixed<<time_taken<<setprecision(6);
}

  
int n,k,a[100],dp[100][1000002];

int main(){

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

  auto start = chrono::high_resolution_clock::now();

  
 

/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

  cin>>n>>k;

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

  for(int i=0;i<n;i++){
    dp[i][0]=1;
  }

  for(int i=0;i<=a[0];i++)dp[0][i]=1;

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

    vector<int>pre(k+1);

    pre[0]=dp[i-1][0];

    for(int j=1;j<=k;j++){
      pre[j]=(pre[j-1]+dp[i-1][j])%mod;
    }

    for(int j=1;j<=k;j++){

        if(a[i]<j)dp[i][j]=(pre[j]-pre[j-a[i]-1]+mod)%mod;
        else dp[i][j]=pre[j];
    }



  }
  cout<<dp[n-1][k];

   



   



  auto end = chrono::high_resolution_clock::now();

 /* #ifndef ONLINE_JUDGE

   get_time(start,end); 

  #endif*/

    return 0;
 }

Measured memory_bytes: 43396
import java.util.Scanner;

class Main{
	public static void main(String args[]){
	    final int INF = Integer.MAX_VALUE/2;
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		int cnt_zero = 0, cnt_two = 0, cnt_four = 0;
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if(a % 2 == 1) cnt_zero++;
			else if(a % 4 == 0) cnt_four++;
			else cnt_two++;
		}
		if(cnt_two > 0) {
			cnt_zero++;
		}
		System.out.println((cnt_zero - 1 <= cnt_four) ? "Yes" : "No");
	}
}

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

int main() {

    string S;

    cin >> S;

    string ans = "No";

    
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        ans = "Yes";
    }
    


    cout << ans << endl;


    
    return 0;
}

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

typedef struct rest {
    int id;
    string name;
    int rating;
} rest;

bool comp(rest r1, rest r2) {
    if(r1.name == r2.name) return r1.rating > r2.rating;
    return r1.name < r2.name;
}

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n;
    cin>>n;
    rest a[n];
    for(int i = 0;i < n;i++) {
        string name;
        int rating;
        cin>>name>>rating;
        a[i] = {i+1, name, rating};
    }

    sort(a,a+n, comp);

    for(int i = 0;i < n;i++) cout<<a[i].id<<endl;
    
}

Measured memory_bytes: 256
h, w = map(int,input().split())

dx = [1,1,1,0,-1,-1,-1,0]
dy = [0,1,-1,1,0,1,-1,-1]
ans = [[0] * (w + 2) for _ in range(h + 2)]

s = [input() for _ in range(h)]
for i in range(h):
    s[i] = '.' + s[i] + '.' 
s = ['.' * (w + 2)] + s + ['.' * (w + 2)] 

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '.':
            for A in range(8):
                if(s[i + dy[A]][j + dx[A]]=='#'):
                    ans[i][j] += 1
            

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '.':
            print(ans[i][j],end='')
        else:
            print('#',end='')
    print()

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

int main(){
    int x;
    cin >> x;
    if(x<=599){cout << 8 << endl;}
    else if(x<=799){cout << 7 << endl;}
    else if(x<=999){cout << 6 << endl;}
    else if(x<=1199){cout << 5 << endl;}
    else if(x<=1399){cout << 4 << endl;}
    else if(x<=1599){cout << 3 << endl;}
    else if(x<=1799){cout << 2 << endl;}
    else{cout << 1 << endl;}
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    REP(i,1,s.size()) if (s[i] != s[i-1]) ++ans;
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}


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

	int s = S[K];

	REP(i,N){
		if(S[i]!=S[K-1]){
			S[i] = '*';
		}
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        long a=in.nextLong();
        long b=in.nextLong();
        long x=in.nextLong();
        if (a % x == 0)
            System.out.println( (b / x) - (a / x) + 1);
        else
            System.out.println ((b / x) - (a / x));
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)  	
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const int maxn = 1e5+5;
const double pi = acos(-1.0);
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
ll read()     //输入外挂
{
    ll res = 0, ch, flag = 0;
    if ((ch = getchar()) == '-')
        flag = 1;
    else if (ch >= '0' && ch <= '9')
        res = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9')
        res = res * 10 + ch - '0';
    return flag ? -res : res;
}
int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int maxx,minn;
    maxx = h >= w ? h : w;
    minn = h < w ? h : w;
    if (n % maxx==0) cout << n / maxx << endl;
    else cout << n / maxx + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N,K;
    cin>>N>>K;
    int ans=0;
    REPF(b,K+1,N+1) {
        for(int k=0; b*k+K<=N; k++) {
            ans+=min((k+1)*b,N+1)-max(1LL,k*b+K);
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int a = Integer.parseInt(str);

        if(a >= 3){
            for(int loop = 1; loop <= a; loop++){
                if(loop % 3 == 0) System.out.print(" " + loop);
                else {
                    for(int x = loop; x > 0; x/=10){
                        if(x % 10 == 3) {
                            System.out.print(" " + loop);
                            break;
                        }
                    }
                }
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 28596
#include<stdio.h>
#include<string.h>
int main(){
  char str[1010];
  char word[1001][32],word2[32],maxw[32];
  int i,j,k,cnt,kazu[1001]={0},flg,l,max=-1,max2=0;
  fgets(str,1005,stdin);
  l=strlen(str);
  str[l-1]=' ';
  for(i=0,j=0,cnt=0;i<l;i++){
    if(str[i]==' '){
      for(k=0;j<i;j++,k++){
    word2[k]=str[j];
      }
      word2[k]='\0';
      for(k=0,flg=0;k<cnt;k++){
    if(strcmp(word[k],word2)==0){
      kazu[k]++;
      flg=1;
      break;
    }
      }
      if(flg==0){
    strcpy(word[cnt],word2);
    if(strlen(word2)>max2){
      max2=strlen(word2);
      strcpy(maxw,word2);
    }
    cnt++;
      }
      i++;
      j=i;
    }
  }
  for(i=0;i<cnt;i++){
    if( kazu[i]>max ){
      max=kazu[i];
    }
  }
  for(i=0;;i++){
    if(max==kazu[i]){
      printf("%s ",word[i]);
      break;
    }
  }
  printf("%s\n",maxw);
  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=2e5+7;
vector<int> G[maxn];
int n,k;
ll dfs(int u,int fa,int ye)
{
	ll res=1;
	if(ye<=0) ye++;
	if(G[u].size()==1&&fa!=-1)
	{
		return 1;
	}
	int sz=G[u].size();int cnt=0;
	for(int i=0;i<sz;i++)
	{
		int v=G[u][i];
		if(v==fa) continue;
		cnt++;
		res*=(((k-cnt-ye)%mod)*(dfs(v,u,ye)%mod))%mod;
		//cout<<"v: "<<v<<" times:"<<(k-cnt-ye)<<"cnt:"<<cnt<<endl;
		res%=mod;
	}
	return res;
}
int main()
{
	int x,y;
	cin>>n>>k;
	for(int i=1;i<=n-1;i++)
	{
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	ll ans=dfs(1,-1,-1);
	cout<<((ans%mod*k%mod)+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define MAXN 100005
using namespace std;
int n,m,dis[1005][1005];
char s[1005][1005];
bool vis[1005][1005];
queue<pii > Q;
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int main()
{
  cin>>n>>m;
  for(int i=1;i<=n;i++)
  {
    scanf("%s",s[i]+1);
    for(int j=1;j<=m;j++)
    {
      if(s[i][j]=='#')
      {
        Q.push(mp(i,j));
        vis[i][j]=1;
      }
    }
  }
  int ans=0;
  while(!Q.empty())
  {
    pii u=Q.front();
    Q.pop();
    ans=max(dis[u.fi][u.se],ans);
    for(int k=0;k<4;k++)
    {
      int tx=u.fi+dx[k],ty=u.se+dy[k];
      if(tx>=1&&tx<=n&&ty>=1&&ty<=m)
      {
        if(!vis[tx][ty])
          {
            vis[tx][ty]=1;
            dis[tx][ty]=dis[u.fi][u.se] + 1;
            Q.push(mp(tx,ty));
          }
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int N, t;
  N = B-A+1;
  t=0;
  for (int i=0; i< N;i++){
    int l, xi1, xi2, xi3,xi4, xi5;
    l= A+i;
    xi1= l%10;
    xi2 = (l/10)%10;
    xi3 = (l/100)%10;
    xi4 = (l/1000)%10;
    xi5 = l/10000;
    if ( xi1 == xi5 && xi2 == xi4)
      t++;
    else 
      continue;
  }
  cout << t << endl;
  
}
      
      
      


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

using namespace std;

int main() {
  int k, n;
  cin >> k >> n;
  int a[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = a[0] + k;
  int distancemax = 0;
  for(int i = 0; i < n; i++) {
    distancemax = max(distancemax, a[i + 1] - a[i]);
  }
  int ans = k - distancemax;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N,K;
	cin >> N>>K;
	ll an = 0;
	for (long long i = 1+K; i < N+1; i++) {
		an += ((N - N % i) / i) * (i-K);
		an += max(ll(0),( N % i) - K + 1);
		
	}
	if (K == 0) {
		an -= N;
	}
	cout << an << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
int a[100000];
int b[100000];

int main() {
    scanf(" %d %d", &n, &m);
    int cnt = m;
    int i = 1;
    int maxm = (n - 1) / 2;
    int mod = n % 2;
    while (cnt > 0) {
        printf("%d %d\n", i, maxm-i+2); cnt--;
        if (cnt==0) break;
        printf("%d %d\n", maxm+2+i-mod, n-i+1); cnt--;
        i++;
    }
}

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

int main(){
    int n;
    cin >> n;
    int ans=0;
    int a[n],b[n],c[n-1];
    for (int i=0;i<n;i++){
           cin >> a[i];
    }
    for (int i=0;i<n;i++){
           cin >> b[i];
    }
    for (int i=0;i<n-1;i++){
           cin >> c[i];
    }

    for (int i=0;i<n;i++){
            ans += b[i];
    }

    int m;
    for (int i=0;i<n-1;i++){
            if ((a[i]+1)==a[i+1]){
                    m=a[i]-1;
                    if ( m<n){
                            ans += c[m];
                    }
            }
    };

    cout << ans << endl;
}

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

int H,W;
int c[10][10];
int A[205][205];

int main(){
  cin>>H>>W;
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin>>c[i][j];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>A[i][j];
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        c[j][k] = min(c[j][k],c[j][i]+c[i][k]);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A[i][j] == -1) continue;
      ans += c[A[i][j]][1];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

ll A[200001];
ll s[200001];

int main() {
	int N; cin >> N;
	rep(i, N) {
		int tmp; cin >> tmp;
		A[i] = tmp;
		s[tmp]++;
	}
	ll a = 0;
	rep(i, N+1) {
		if (s[i] < 2) continue;
		a += s[i]*(s[i]-1)/2;
	}
	rep(i, N) {
		ll ans = a;
		if (s[A[i]] <= 1) {
			cout << ans << endl;
		} else if (s[A[i]] == 2) {
			cout << ans - 1 << endl;
		} else {
			ans -= s[A[i]]*(s[A[i]]-1)/2;
			ans += (s[A[i]]-1)*(s[A[i]]-2)/2;
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

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

  int n; cin >> n;
  map<char, int> mp;
  rep(i, n) {
    map<char, int> m;
    string s; cin >> s;
    for (char& c : s) {
      m[c]++;
    }
    if (i == 0) mp = m;
    for (char c = 'a'; c <= 'z'; c++) {
      chmin(mp[c], m[c]);
    }
  }

  for (char c = 'a'; c <= 'z'; c++) {
    rep(i, mp[c]) printf("%c", c);
  }
  printf("\n");

  return 0;
}


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

int main(){
  int a, b;

  while(cin >> a >> b){
    int a_lcm = a, b_lcm = b;
    while(a!=0 &&b!=0){
      if(a < b)
	swap(a,b);
      int tmp = b;
      b = a%b;
      a = tmp;
    }
    cout << a << " " << a_lcm/a*b_lcm << endl;

  }
  
  return 0;
}

Measured memory_bytes: 1160
n = int(input())
a = [list(map(int, input().split())) for i in range(2)]

res = 0

for i in range(n):
    tmp = 0
    for j in range(i + 1):
        tmp += a[0][j]
    for k in range(i, n):
        tmp += a[1][k]
    if res < tmp:
        res = tmp

print(res)


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

int main(){
    int N;
    cin >> N;
    vector<double> v(N);
    double ans = 0;
    double r = 0;
    for (int i = 0; i < N; i++){
        cin >> v[i];
    }
    
    sort(v.begin(),v.end());
    
    for(int i = 0; i < N - 1; i++){
        r = (v.at(0) + v.at(1))/2;
        v.erase(v.begin(),v.begin() + 2);
        v.insert(v.begin(),r);
    }
    cout << v.at(0) << 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 FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

const int N = 10001;

using P = pair<int, int>;

int n;

struct edge {
    int to;
    int cost;
};

vector<int> dist(N, Inf);
vector<edge> g[N];

void dijkstra(int s) {
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P> > pq;
    pq.push(P(0, s));

    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;

        rep (i, g[v].size()) {
            edge e = g[v][i];
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                pq.push(P(dist[e.to], e.to));
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n;
    rep (i, n) {
        int u, k;
        cin >> u >> k;
        rep (j, k) {
            int v, c;
            cin >> v >> c;
            edge e = {v, c};
            g[u].push_back(e);
        }
    }
    dijkstra(0);
    rep (i, n) {
        cout << i << " " << dist[i] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 8068
/**
 * Combinatorial - Coin Changing Problem
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int m = parseInt(line.substring(line.indexOf(' ') + 1));

			int[] ns = new int[n + 1];
			int[] cs = new int[m];

			for (int i = 1; i < n + 1; i++) ns[i] = Integer.MAX_VALUE;

			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int i = 0; i < m; i++) cs[i] = parseInt(st.nextToken());

			//solve
			for (int i = 0; i < m; i++) {
				for (int j = cs[i]; j < n + 1; j++) {
					ns[j] = Math.min(ns[j], ns[j - cs[i]] + 1);
				}
			}
			System.out.println(ns[n]);
		}//end while
	}//end main
}

Measured memory_bytes: 21844
# A - Limited Insertion

N,b = int(input()),list(map(int,input().split()))
a = list([])
judge = 1

for i in range(N):
    j = N-i
    while j>0 and b[j-1]!=j:
        j -= 1
    if j==0:
        judge = 0
        break
    else:
        b.pop(j-1)
        a.append(j)

if judge==0:
    print(-1)
else:
    for i in range(N):
        print(a[N-1-i])

Measured memory_bytes: 3064
n,m = map(int,input().split())
lr = [list(map(int,input().split())) for i in range(m)]

lp = 1
rp = n

for i in range(m):
    if lp < lr[i][0]:
        lp = lr[i][0]
    if rp > lr[i][1]:
        rp = lr[i][1]
else:
    if rp - lp < 0:
        ans = 0
    else:
        ans = rp-lp+1

print(ans)

Measured memory_bytes: 27340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef vector < vector<int> > vvi;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
#define deb(x) cout << #x << " : " << x << endl
#define debv(x) for(auto i=x.begin();i!=x.end();i++) cout<<*i<<' ';cout<<endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define s(n) cin >> n
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) ((b)+((a) - (b))/2)
#define INF (1e9 + 7)
#define endl '\n'

void solve() {
	int n,w;
	cin>>n>>w;
	vector<vector<ll>> dp(n,vll(w+1,-1));
  	ll mx=0;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		if(i==0){
			dp[i][0]=0;
			dp[i][a]=b;
          	mx=max(mx,b);
		}
		else{
			for(int j=0;j<w+1;j++){
				if(dp[i-1][j]!=-1){
					dp[i][j]=max(dp[i][j],dp[i-1][j]);
					if(j+a<=w){
						dp[i][j+a]=max(dp[i][j+a],dp[i-1][j]+b);
					}
				}
				mx=max(mx,dp[i][j]);
              	//deb(dp[i][j]);
			}
		}
	}
	cout<<mx;
}

int main() {
	csl;
	int testcase=1;
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 82132
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 05/07/2020

from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n = ii1()
count = ceil(n / 1000)
print(count * 1000 - n)



Measured memory_bytes: 9408
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b); 
   if(a==b)printf("%d",a*2);
   if(a>b)printf("%d",a*2-1);
   if(a<b)printf("%d",b*2-1);
    return 0;
}



Measured memory_bytes: 128
A,B,C,X,Y = map(int, input().split())
AB = 2 * C
mn = AB * max(X, Y)
for i in range(max(X, Y) + 1):
  mn = min(mn, A * max(0, X - i) + B * max(0, Y - i) + AB * i)
print(mn)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> n(4);
    rep(i, 4) cin >> n[i];
    sort(all(n));
    if(n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int N,d[300000];

bool can(){
	int l = d[0];
	for(int i = 1; i < N; i++){
		if(l < i*10){
			return false;
		}
		if(l < i*10+d[i]){
			l = i*10+d[i];
		}
	}
	return true;
}

int main(){
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d",&d[i]);
	}
	if(can()){
		reverse(d,d+N);
		if(can()){
			printf("yes\n");
			return 0;
		}
	}
	printf("no\n");

	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    int A,B;
    cin >> A >> B;
    if(A < B){
        cout << "0" << endl;
    }
    else{
        cout << "10" << endl;
    }
}

Measured memory_bytes: 256
<>;($x,$y,$~)=glob,$/=$_,printf"%f
",sort{$b<=>$a}0,map+(-$~+($~=$_))/$P-.5,(@b=sort{$a<=>$b}map{/ /*atan2$'-$y,$`-$x}grep$/ne$_,@a),"@b"+($P=6.2831853)for@a=<>

Measured memory_bytes: 5248
import heapq
A = []
data_i = []
while True:
    tmp = input()
    if tmp == 'end':
        break
    data_i.append(tmp)
#print(data_i)



for i in data_i:
    if i[0] == 'i':
        heapq.heappush(A, int(i[7:])*-1)
    else:
        print(heapq.heappop(A)*-1)
    '''
    print(i)
    print(A)
    '''


Measured memory_bytes: 184096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var N, sum, p int
	fmt.Scan(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, N+1)
	b := make([]int, N)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	for i := range b {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}
	for i := 0; i <= N; i++ {
		if p > a[i] {
			sum += a[i]
			a[i] = 0
		} else {
			sum += p
			a[i] -= p
		}
		p = 0
		if i >= N {
			break
		}
		if b[i] > a[i] {
			p = b[i] - a[i]
			sum += a[i]
		} else {
			sum += b[i]
		}
	}
	fmt.Println(sum)
}


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

cnt = 0

for i in range(0,A+1):
	for j in range(0,B+1):
		for k in range(0,C+1):
			#print(500*i + 100*j + 50*k)
			if 500*i + 100*j + 50*k == X:
				cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, k;
int a[100500];

void solve() {       
    int cnt = 0;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (a[i] >= k) {
            cnt++;
        }
    }

     cout << cnt;

}           
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans = "No";
    if ((a+d-1)/d >= (c+b-1)/b) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, p = -1;
	cin >> n;
	rep(i, n){
		int c; cin >> c;
		if(c < p){
			cout << "No" << endl;
			return 0;
		}
		p = max(p, c - 1);
	}
	cout << "Yes" << endl;
	return 0;
}

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

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

  ll N; cin >> N;
  ll xMAX = -1e18, xMIN = 1e18;
  ll yMAX = -1e18, yMIN = 1e18;

  for (ll i = 0; i < N; i++) {
    ll X; cin >> X;
    ll Y; cin >> Y;
    ll x = X + Y;
    ll y = X - Y;
    xMAX = max(xMAX, x);
    yMAX = max(yMAX, y);
    xMIN = min(xMIN, x);
    yMIN = min(yMIN, y);
  }
  ll ans = max(xMAX-xMIN, yMAX-yMIN);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3616
//
//AtCoder Beginner Contest 168
//B - ... (Triple Dots)
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int k;
    string s;

    cin >> k >> s; 

    if (s.size()<=k) cout << s << endl;
    else cout << s.substr(0, k) << "..." << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cassert>
#include<vector>
#include<deque>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> Pi;
int n,m,cnt;
int mincost[110][110];
bool visited[110][110];
int dx[2][6] = {{-1,+0,1,0,-1,-1},{+0,+1,1,1,0,-1}};
int dy[2][6] = {{-1,-1,0,1,+1,+0},{-1,-1,0,1,1,+0}};
 
void dfs(int x,int y)
{
 
  deque<Pi> deq;
  deq.push_back(Pi(P(x,y),0));
  mincost[y][x] = 0;
  visited[y][x] = true;
  cnt = 1;
  while(!deq.empty())
    {
      Pi pi = deq.front(); deq.pop_front();
 
      for(int i=0;i<6;i++)
    {
      int nx = pi.first.first + dx[pi.first.second%2][i];
      int ny = pi.first.second + dy[pi.first.second%2][i];
 
      if(!(0 <= nx && nx < m && 0 <= ny && ny < n))
        continue;
 
      if(mincost[ny][nx] > pi.second + 1)
        {
          if(!visited[ny][nx])
        cnt++;
          visited[ny][nx] = true;
          mincost[ny][nx] = pi.second + 1;
          deq.push_back(Pi(P(nx,ny),pi.second+1));
        }
    }
    }
}
 
int main()
{
  while(cin >> m >> n,m)
    {
      for(int i=0;i<n;i++) 
    for(int j=0;j<m;j++)
      mincost[i][j] = (1<<29);  
      
      int s,t,mex = 1;
      scanf("%d",&s);
      for(int i=0;i<s;i++)
    {
      int x,y;
      scanf("%d %d",&x,&y);
      x--,y--;
      mincost[y][x] = 0;
      dfs(x,y);
    }
      
      scanf("%d",&t);
      for(int i=0;i<t;i++)
    {   
      int pre_mincost[n][m];
      for(int j=0;j<n;j++)
        for(int k=0;k<m;k++)
          pre_mincost[j][k] = mincost[j][k],visited[j][k] = false;
      int p,q;
      scanf("%d %d",&p,&q);
      p--,q--;
      dfs(p,q);
       
      mex = max(mex,cnt);
      for(int j=0;j<n;j++)
        for(int k=0;k<m;k++)
          mincost[j][k] = pre_mincost[j][k];
    }
      cout << mex << endl;
    }
  return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>

int main(int argc, char **argv){
    int n, T, t[200000], ans=0;
    scanf("%d %d", &n, &T);
    for(int i=0; i<n; i++){
        scanf("%d", &t[i]);
    }
    ans += T;
    for(int i=1; i<n; i++){
        if(t[i]-t[i-1]>T){
            ans += T;
        }else{
            ans += t[i]-t[i-1];
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 896