akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    cout << (n-2)*180 << endl;
    return 0;
}


Measured memory_bytes: 3532
h,w=map(int,input().split())
A=[list(input()) for _ in range(h)]
cnt=0
for i in range(h):
    for j in range(w):
        if A[i][j]=='#':
            cnt+=1
if cnt==h+w-1:
    print('Possible')
else:
    print('Impossible')


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

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

    int a[100][100];
    for(int i=0;i<n;i++)
       for(int j =0;j<m;j++) cin >> a[i][j];

    int b[100][100];
    for(int i =0;i<m;i++)
       for(int j =0;j<l;j++) cin >>b[i][j];

     long long c[100][100] ={};
     for (int i=0;i<n;i++)
         for(int j =0;j<l;j++)
             for(int k =0;k<m;k++) c[i][j]+=a[i][k]*b[k][j];

     for(int i=0;i<n;i++){
         for(int j =0;j<l;j++){
          if(j) cout<<" ";
          cout <<c[i][j];
         }
      cout <<endl;  
    }
    
    
         return 0;
}


Measured memory_bytes: 3244
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	int count4 = 0;
	int count2 = 0;
	int count = 0;
	rep(i, n) {
		int a;
		scanf("%d",&a);
		if (a % 4 == 0) {
			count4++;
		}
		else if (a % 2 == 0) {
			count2++;
		}
		else {
			count++;
		}
	}
	bool flag = true;
	count4++;
	if( (count > count4)or
		(count2 > 0&&count == count4) ){
		flag = false;
	}
	
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    let s: usize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let mut a: Vec<usize> = vec![];
    let mut now = s;
    let mut n;
    loop {
        a.push(now);
        let next = {
            if a.last().unwrap() % 2 == 0 {
                a.last().unwrap() / 2
            } else {
                a.last().unwrap() * 3 + 1
            }
        };
        if a.contains(&next) {
            n = a.len() + 1;
            break;
        }
        now = next;
    }
    println!("{}", n);
}


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

int main(){
    int N; cin >> N;
    vector<int> U(N), V(N);
    for(int i=0; i<N; i++){
        int X, Y;  cin >> X >> Y;
        U[i] = X + Y;
        V[i] = X - Y;
    }
    for(int i=1; i<N; i++){
        if(abs(U[i])%2 != abs(U[0])%2){
            cout << -1 << endl;
            return 0;
        }
    }

    int m = 31 + 1 - abs(U[0])%2;
    vector<int> d(m);
    for(int i=0; i<=30; i++) d[30-i] = pow(2,i);
    if(m==32) d[31] = 1;

    cout << m << endl;
    for(int i=0; i<m-1; i++) cout << d[i] << " ";
    cout << d[m-1] << endl;

    for(int i=0; i<N; i++){
        string mode = "";
        int u = 0, v = 0;
        for(int j=0; j<m; j++){
            //cerr << U[i] << " " << V[i] << " : " << u << " " << v << "  -- > ";
            if(u < U[i] && v < V[i]){
                u += d[j];  v += d[j];
                mode += "R";
            }else if(u >= U[i] && v < V[i]){
                u -= d[j];  v += d[j];
                mode += "D";
            }else if(u < U[i] && v >= V[i]){
                u += d[j];  v -= d[j];
                mode += "U";
            }else if(u >= U[i] && v >= V[i]){
                u -= d[j];  v -= d[j];
                mode += "L";
            }
            //cerr << u << " " << v << endl;
        }
        cout << mode << endl;
    }
}


Measured memory_bytes: 384
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    vector<ll>b;
    for(ll i=n-1;i>=0;i-=2)
        b.pb(a[i]);
    ll m=0;
    if(n%2==0)
        m=0;
    else m=1;
    for(ll i=m;i<n-1;i+=2)
        b.pb(a[i]);
    for(ll i=0;i<siz(b);i++)
        cout<<b[i]<<" ";
    cout<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector<int> fact;
vector<int> fact_inv;

int powm(int n, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) {
      res = (res * 1ll * n) % mod;
    }
    p >>= 1;
    n = (n * 1ll * n) % mod;
  }
  return res;
}

int inv(int n) { return powm(n, mod - 2) % mod; }

void precalc_fact(int n) {
  fact.resize(n + 1);
  fact_inv.resize(n + 1);
  fact[0] = 1;
  fact_inv[0] = 1;
  rep(i, 1, n) { 
    fact[i] = (fact[i - 1] * 1ll * i) % mod; 
    fact_inv[i] = (fact_inv[i - 1] * 1ll * inv(i)) % mod;
  }
}

int choose(int n, int r) {
  int inv_fact = ((fact_inv[r] * 1ll * fact_inv[n - r]) % mod);
  return (fact[n] * 1ll * inv_fact) % mod;
}

int calc_ways(int x1, int y1, int x2, int y2) {
  int h_steps = x2 - x1;
  int v_steps = y2 - y1;
  return choose(h_steps + v_steps, v_steps);
}

void solve() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  precalc_fact(h + w - 2);
  int res = 0;

  rep(i, b, w - 1) {
    int combs1 = calc_ways(0, 0, h - a - 1, i);
    int combs2 = calc_ways(h - a, i, h - 1, w - 1);
    int combs = (combs1 * 1ll * combs2) % mod;
    res = (res * 1ll + combs) % mod;
  }

  cout << res;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

Measured memory_bytes: 4756
#include <stdio.h>
#include <string.h>
#define N 1001

void Ics(char *X, char *Y)
{
   int c[N][N];
   int m, n, i, j;

   m = strlen(X);
   n = strlen(Y);

   for ( i = 0; i <= m; i++ ) {
      c[i][0] = 0;
   }
   for ( j = 1; j <= n; j++ ) {
      c[0][j] =0;
   }

   for ( i = 1; i <= m; i++ ) {
      for ( j = 1; j <=n; j++ ) {
         if ( X[ i - 1 ] == Y[ j - 1] ) {
            c[ i ][ j ] = c[ i - 1 ][ j - 1 ] + 1;
         } else if ( c[ i - 1 ][ j ] >= c[ i ][ j - 1 ] ){
            c[ i ][ j ] = c[ i - 1 ][ j ];
         } else {
            c[ i ][ j ] = c[ i ][ j - 1 ];
         }
      }
   }
   printf("%d\n", c[ m ][ n ]);
}
     
int main()
{
   int n, i;
   char X[N], Y[N];

   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) {
      scanf("%s%s", X, Y);
      Ics(X, Y);
   }
   return 0;
}

Measured memory_bytes: 5636
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	string s;
	set<string> items;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		items.insert(s);
	}

	cout << items.size() << "\n";

	return 0;

}

Measured memory_bytes: 19204
#include<bits/stdc++.h>
using namespace std ;
int main () {
  string a ;
  cin >> a ;
  int ans = 0 ;
  string b ;
  while(cin >> b){
    for(int i = 0; i< b.size() ; i++) b[i] = tolower(b[i]) ;
    if(a==b)ans++ ;
  }
  cout << ans << endl ;
}


Measured memory_bytes: 3156
n = input()
s = input()
count = 0
countl = 0
for c in s:
    if c=='(':
        count += 1
    else:
        count -= 1
    if count < 0:
        countl += 1
        count = 0
count = 0
countr = 0
for c in s[::-1]:
    if c=='(':
        count -= 1
    else:
        count += 1
    if count < 0:
        countr += 1  
        count = 0
print('('*countl + s + ')'*countr)



Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int x,y,z;cin>>x>>y>>z;

  for(int i=0;;i++){
    if((i+1)*z+y*i>x){
      out(i-1);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int l, r, d;
	cin >> l >> r >> d;
	int cnt = 0;
	rep_lr(i, l, r + 1)if (i % d == 0)cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
void printfloor(int b[])
{
	for(int i = 0 ; i < 10 ; i ++){
		std::cout << " " << b[i];
	}
	std::cout << std::endl;
	return;
}
void printdom(int (*bs)[10])
{
	for(int i = 0 ; i < 3 ; i ++){
		printfloor(bs[i]);
	}
	return;
}
void printall(int (*data)[3][10])
{
	std::string delim(20,'#');
	for(int i = 0; i < 4 ; i ++){
		printdom(data[i]);
		if(i < 3) std::cout << delim << std::endl;
	}
//	std::cout << std::endl;
	return;
}
int main(int argc, char const *argv[])
{
	int (*data)[3][10] = new int[4][3][10];
	//initialize
	for(int i = 0 ; i < 4 ; i ++){
		for(int j = 0 ; j < 3 ; j ++){
			for(int k = 0 ; k < 10 ; k ++){
				data[i][j][k] = 0;
			}
		}
	}

	int n ;//number of information
	std::cin >> n;
	for(int i = 0 ; i < n ; i ++){
		int b,f,r,v;
		std::cin >> b >> f >> r >> v;
		data[b-1][f-1][r-1] += v;
	}
	printall(data);
	delete[] data;
	return 0;
}

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

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    string S;
    cin >> S;

    int cnt1 = 0;
    int cnt2 = 0;
    int cnt3 = 0;
    int cnt4 = 0;
    rep(i,4){
        if(S[0]==S[i]){cnt1++;}
        if(S[1]==S[i]){cnt2++;}
        if(S[2]==S[i]){cnt3++;}
        if(S[3]==S[i]){cnt4++;}
    }
    
    if(cnt1 == 2 && cnt2 == 2 && cnt3 == 2 && cnt4 == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();

        int a = cin.nextInt();
        int b = cin.nextInt();

        int k = (a + b) / 2;

        if (Math.Abs(a - k) == Math.Abs(b - k)) Console.WriteLine(k);
        else Console.WriteLine("IMPOSSIBLE");
    }
}


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: 13268
n,t = map(int, input().split())
ct = [ list(map(int,input().split(" "))) for i in range(n)]
ct.sort()
ans = 0
for i in range(n):
    if ct[i][1] <= t:
        ans = ct[i][0]
        break
if ans > 0:
    print(ans)
else:
    print('TLE')


Measured memory_bytes: 9028
#define ll long long
#include<bits/stdc++.h>
#define mp(a, b) make_pair(a, b)
using namespace std;
ll p, q, tt;
ll gcd(ll a, ll b){
	return a == 0 ? b : gcd(b % a, a);
}
set<pair<ll, ll> > ss;
bool isValid(ll k){
	for(ll m = 0; m * m < k; m++){
		ll n = sqrt(k - m * m);
		pair<ll, ll> pp = mp(m, n);
		if(n * n == k - m * m && ss.find(pp) == ss.end() && abs(m * p + n * q) % k == 0 && abs(m * q - n * p) % k == 0){
			//cout << m << " " << n << endl;
			return true;
		}
		pp = mp(m, -n); n = -n;
		if(n * n == k - m * m && ss.find(pp) == ss.end() && abs(m * p + n * q) % k == 0 && abs(m * q - n * p) % k == 0){
			//cout << m << " " << n << endl;
			return true;
		}
		n = -n;
		pp = mp(-m, -n); m = -m; n = -n;
		if(n * n == k - m * m && ss.find(pp) == ss.end() && abs(m * p + n * q) % k == 0 && abs(m * q - n * p) % k == 0){
			return true;
		}
		m = -m; n = -n;
		pp = mp(-m, n); m = -m;
		if(n * n == k - m * m && ss.find(pp) == ss.end() && abs(m * p + n * q) % k == 0 && abs(m * q - n * p) % k == 0){
			return true;
		}
		m = -m;
	}
	return false;
}
void solve(){
	cin >> p >> q;
	tt = p * p + q * q;
	ss.clear(); 
	ss.insert(mp(0, 1)); ss.insert(mp(1, 0)); ss.insert(mp(0, -1)); ss.insert(mp(-1, 0));
	ss.insert(mp(p, q)); ss.insert(mp(-q, p)); ss.insert(mp(-p, -q)); ss.insert(mp(q, -p));
	if(tt <= 1){
		cout << "P" << endl;
		return;
	}
	bool flag = false;
	for(ll k1 = 2; k1 <= tt; k1++){
		ll k2 = tt / k1;
		if(k1 > 1 && k2 > 1 && tt % k1 == 0){
			if(isValid(k1) && isValid(k2)){
				cout << "C" << endl;
				return;
			}
		}
	}
	cout << "P" << endl;
}
int main(void){
	int t; cin >> t;
	while(t--) solve();
	return 0;
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main(){
  ll sum[200000];
  ll n,a;
  cin>>n>>a;
  sum[0]=a;
  for(int i=1;i<n;i++){
    cin>>a;
    sum[i]=sum[i-1]+a;
  }
  ll ans=abs(sum[n-1]-sum[0]*2);
  for(int i=1;i<n-1;i++){
    ans=min(ans,abs(sum[n-1]-2*sum[i]));
  }

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


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

int main() {
  long a = 0, b = 0;
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'B') a++;
    else b += a; 
  }
  cout << b << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
set <int> st;
int n,p,odd=0,even=0;
vi a(105);
bool change=false;
int main(int argc,char const* argv[])
{
  cin >> n >> p;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
      if(a[i]%2!=0) odd++;
      else even++;
    }
  if(odd==0)
    {
      if(p==1) 
	{
	  cout << 0 << endl;
	  return 0;
	}
      else
	{
	  cout << (ll)pow(2,n) << endl;
	  return 0;
	}
    }
  else
    {
      cout << (ll)pow(2,n-1) << endl;
    }
 
  return 0;
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int cmpAsc(const void* a, const void* b){
    char x = *(char*)a, y = *(char*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int cmpDsc(const void* a, const void* b){
    char x = *(char*)a, y = *(char*)b;
    if(x < y){
        return 1;
    }
    if(x > y){
        return -1;
    }
    return 0;
}

int main(){
    char s[101], t[101];
    scanf("%s %s", s, t);
    int s_len = strlen(s), t_len = strlen(t);
    qsort(s, s_len, sizeof(char), cmpAsc);
    qsort(t, t_len, sizeof(char), cmpDsc);
    if(strcmp(s, t) < 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

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

int main() {
    // ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,k,q;
    cin >> n >> k >> q;
    vector <int> v(n,0);
    for (int i=0; i<q; i++)
    {
        int a;
        cin >> a;
        v[a-1]++;
        // cout << v[a-1] << endl;
    }
    for (int j=0; j<n; j++)
    {
        if (k>q-v[j])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
namespace NTT {
	const int MOD = 998244353;  // to be set appropriately
	const long long PR = 3;     // to be set appropriately

	void trans(vector<long long> &v, bool inv = false) {
		int n = (int)v.size();
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (i > j) swap(v[i], v[j]);
		}
		for (int t = 2; t <= n; t <<= 1) {
			long long bw = modpow(PR, (MOD - 1) / t, MOD);
			if (inv) bw = modinv(bw, MOD);
			for (int i = 0; i < n; i += t) {
				long long w = 1;
				for (int j = 0; j < t / 2; ++j) {
					int j1 = i + j, j2 = i + j + t / 2;
					long long c1 = v[j1], c2 = v[j2] * w % MOD;
					v[j1] = c1 + c2;
					v[j2] = c1 - c2 + MOD;
					while (v[j1] >= MOD) v[j1] -= MOD;
					while (v[j2] >= MOD) v[j2] -= MOD;
					w = w * bw % MOD;
				}
			}
		}
		if (inv) {
			long long inv_n = modinv(n, MOD);
			for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD;
		}
	}

	// C is A*B
	vector<long long> mult(vector<long long> A, vector<long long> B) {
		int size_a = 1; while (size_a < A.size()) size_a <<= 1;
		int size_b = 1; while (size_b < B.size()) size_b <<= 1;
		int size_fft = max(size_a, size_b) << 1;

		vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
		for (int i = 0; i < A.size(); ++i) cA[i] = A[i];
		for (int i = 0; i < B.size(); ++i) cB[i] = B[i];

		trans(cA); trans(cB);
		for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD;
		trans(cC, true);

		vector<long long> res((int)A.size() + (int)B.size() - 1);
		for (int i = 0; i < res.size(); ++i) res[i] = cC[i];
		return res;
	}
};

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[303][303];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	long long ans = 0;
	int judge = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			judge = 0;
			for (int k = 0; k < n; k++) {
				if (i == k || j == k)continue;
				if (a[i][j] == a[i][k] + a[k][j])judge = 1;
				if (a[i][j]>a[i][k] + a[k][j]) {
					judge = 2; goto owari;
				}
			}
			if (judge == 0)ans += a[i][j];
		}
	}
owari:
	if (judge == 2)cout << -1;
	else cout << ans;
}

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

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

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

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	int ans=k;
	rep(i,n-1) ans*=k-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const long long inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x)
{
	cout << s << " = " << x << "\n";
}
template<typename T, typename... Args> void debug(string s, T x, Args... args)
{
	cout << s.substr(0, s.find(',')) << " = " << x << " | ";
	debug(s.substr(s.find(',') + 2), args...);
}
template<class T> void print_container(T &container)
{
	for (auto &t : container)
	{
		cout << t << " ";
	}
	cout << endl;
}
template<class T> void print_pair_container(T &container)
{
	for (auto &t : container)
	{
		cout << t.first << " " << t.second << endl;
	}
	cout << endl;
}
template<class T> void printArr(T &a, int n)
{
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}
typedef long long ll;
typedef pair<int, int> pii;

//Template Ends
int n, m;
bool visited[N];
vector<int> adj[N];
ll ans = 0;

int dfs(int x) {
	visited[x] = 1;
	int kids = 1;
	for (int u : adj[x]) {
		if (!visited[u]) {
			kids += dfs(u);
		}
	}

	ans = max(ans, kids);
	return kids;
}

void solve()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	for (int i = 1; i <= n; i++) {
		if (!visited[i]) {
			dfs(i);
		}
	}

	cout << ans << endl;
}

int32_t main()
{
	IOS;

	solve();

	return 0;
}




Measured memory_bytes: 42900
#include <bits/stdc++.h>
#define X first
#define Y second
#define LL long long
#define MP make_pair
#define PB push_back
#define SZ(a) (LL)(a.size())
const LL INF = 1000 * 1000 * 1000 + 47;
const LL LINF = INF * (LL)INF;
using namespace std;
const LL MAX = 1005;
const LL MAGIC = 50;

int main() 
{
	int H , W , A , B;
	cin >> H >> W >> A >> B;
	for(int i = 0; i < H; i++)
	{
		for(int j = 0; j < W; j++)
			cout << ((i < H - B && j < A) || (i >= H - B && j >= A));
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1280
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;

int N, M, K;

const int MOD = 998244353;

vector<int> fac(300001);
vector<int> ifac(300001);

int mpow(int x, int n){
    int ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

int comb(int a, int b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

signed main() {
  fac[0] = 1;
  ifac[0] = 1;
  for(int i = 0; i<300000; i++){
      fac[i+1] = fac[i]*(i+1) % MOD;
      ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD;
  }

  cin >> N >> M >> K;

  int ans = 0;
  for (int i = 0; i <= K; i++) {
    int t = M * mpow(M - 1, N - i - 1) % MOD;
    t *= comb(N -  1, i);
    ans += t % MOD;
    ans %= MOD;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 7868
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    int dp[m][(1<<n)];
    rep(i,0,m-1)rep(j,0,(1<<n)-1)dp[i][j] = j==0?0:INF;
    int a,b;
    cin >> a >> b;
    int c1, c=0;
    rep(j,0,b-1){
        cin >> c1;
        c1--;
        c |= (1<<c1);
    }
    dp[0][c] = a;
    vector<int> cc(m);
    rep(i,1,m-1){
        int a,b;
        cin >> a >> b;
        int c1,c=0;
        rep(j,0,b-1){
            cin >> c1;
            c1--;
            c |= (1<<c1);
        }
        cc[i] = 0|c;
        // cout << c << endl;
        rep(j,0,(1<<n)-1){
            dp[i][j] = dp[i-1][j];
        }
        rep(j,0,(1<<n)-1){
            dp[i][(j|c)] = min(dp[i-1][j] + a, dp[i][(j|c)]);
        }
    }
    int ans = dp[m-1][(1<<n)-1] == INF?-1:dp[m-1][(1<<n)-1];
    // vecprint(cc);
    // cout << (1<<n) << endl;
    // matprint(dp,m,(1<<n));

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

    return 0;
}

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

int selection_sort(int * nums, int N){
    int swaps = 0;
    for (int i=0; i != N; ++i){
        int mini = i;
        for (int j=i; j!=N; ++j){
            if (nums[j] < nums[mini]) mini = j;
        }
        if (i!=mini){
            int tmp = nums[i];
            nums[i] = nums[mini];
            nums[mini] = tmp;
            ++swaps;            
        }
    }
    return swaps;
}



int main()
{
    int N = 0;
    cin >> N;
    int *nums = new int[N];
    for (auto i=0; i!=N; ++i) cin >> nums[i];
    int swaps = selection_sort(nums, N);
    for (auto i=0; i!=N-1; ++i) cout << nums[i] << ' ';
    cout << nums[N-1] << endl;
    cout << swaps << endl;
    return 0;
}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int count = 0;
        for(int i=1;i<=n;i++){
            String s = Integer.toString(i);
            if((s.length() % 2) == 1){
                count++;
            }
        }
        System.out.println(count);
    }
}

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

namespace {
void Print(char (*C)[4]) {
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= 3; ++j) {
      cout << C[i][j];
    }
    cout << endl;
  }
}
class Temporal {
 public:
  char (*C)[4];
  Temporal(char (*C)[4]) { this->C = C; }
};
bool operator==(const Temporal& left, const Temporal& right) {
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (left.C[i][j] != right.C[i][j]) {
        return false;
      }
    }
  }
  return true;
}
}  // namespace

int main() {
  char C[3][4];
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= 3; ++j) {
      cin >> C[i][j];
    }
    cin.ignore(1);
  }
  char D[3][4];  // Flipped C.
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= 3; ++j) {
      D[i][j] = C[3 - i][4 - j];
    }
  }
  Temporal CC(C), DD(D);
  cout << (CC == DD ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int n,a[10000];
while(true){
scanf("%d",&n);
if(n==0)return 0;
for(int i=0;i<n;i++)scanf("%d",&a[i]);
long long int ans=0;
sort(a,a+n);
for(int i=0;i<n;i++)ans+=(long long)a[i]*(n-1-i);
printf("%lld\n",ans);
}
}

Measured memory_bytes: 1244
#include <iostream>
#include <algorithm>
#define L_MAX 21
using namespace std;
int gem[L_MAX][L_MAX] = {};
int main(void)
{
  int n,m;
  int x,y;
  while(cin>>n,n)
  {
    int px = 10,py = 10;
    for(int i = 0;i < L_MAX;i++)
      for(int j = 0; j < L_MAX;j++)
        gem[i][j] = 0;
    for(int i = 0;i < n;i++){
      cin>>x>>y;
      gem[y][x] = 1;
    }
    cin>>m;
    char dist;int l;
    for(int i = 0;i < m;i++)
    {
      int dx = 0,dy = 0;
      cin>>dist>>l;
      switch(dist)
      {
        case 'N':
          dy = 1;
          break;
        case 'S':
          dy = -1;
          break;
        case 'E':
          dx = 1;
          break;
        case 'W':
          dx = -1;
      }
      if(gem[py][px])n--;
      gem[py][px] = 0;
      for(int j = 0;j < l;j++)
      {
        px+=dx;
        py+=dy;
        if(gem[py][px])n--;
        gem[py][px] = 0;
      }
    }
    if(!n)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=998244353;
using namespace std;
ll n,x,i,j,a[nmax];
ll rs;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x && i==1)rc(0);
		a[x]++;
	}
	if(a[0]!=1)rc(0);
	for(i=1;i<n;i++)if(a[i] && !a[i-1])rc(0);
	rs=1;
	for(i=1;i<n;i++)
	{
		if(!a[i])break;
		for(j=1;j<=a[i];j++)rs=(rs*a[i-1])%mod;
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
struct Corr{
    int y;
    int x;
    int length;
};
vector<int> dy={0,0,-1,1};
vector<int> dx={-1,1,0,0};

int bfs(vector<vector<char>> s,queue<Corr> q,int h, int w){
    int y,x,length,max_length=0;
    vector<vector<int>> len(h,vector<int>(w,0));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++) len[i][j]=1e9;
    }
    while(!q.empty()){
        Corr now = q.front();
        q.pop();
        y=now.y;
        x=now.x;
        length=now.length;
        s[y][x] = '#';
        for(int i=0; i<4; i++){
            Corr next = {y+dy[i],x+dx[i],length+1};
            if(0<=next.y && next.y<h && 0<=next.x && next.x<w && s[next.y][next.x]=='.'){
                s[next.y][next.x] = '#';
                len[next.y][next.x]=length+1;
                q.push(next);
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(len[i][j]==1e9) continue;
            max_length=max(max_length,len[i][j]);
        }
    }
    return max_length;
}
int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<char>> s(h,vector<char>(w));
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) cin>>s[i][j];
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=='#') continue;
            queue<Corr> q;
            Corr start = {i,j,0};
            q.emplace(start);
            ans=max(ans,bfs(s,q,h,w));
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
list_x = list(map(int, input().split()))
 
#iが座標の位置
 
list_ans = []
 
for i in range(min(list_x), max(list_x)+1):
    
    #計算する
    ans = 0
    for j in list_x:
        ans += (i-j)**2
 
    list_ans.append(ans)
  
print(min(list_ans))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	if(s<t)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vec a(n);
  REP(i,n) cin >> a[i];
  
  int cur = 2, ans = a[0]-1;
  FOR(i,1,n){
    if(a[i] == cur){
      cur++;
      continue;
    }
    ans += (a[i]-1)/cur;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
# diverta 2019 Programming Contest
# https://atcoder.jp/contests/diverta2019
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    S = ii2ss(N)
    c0b = 0
    c1a = 0
    c0b1a = 0
    c = 0
    for s in S:
        for i, t in enumerate(s[:-1]):
            if t == 'A':
                if s[i+1] == 'B':
                    c += 1
        if s[0] == 'B' and s[-1] == 'A':
            c0b1a += 1
        elif s[0] == 'B':
            c0b += 1
        elif s[-1] == 'A':
            c1a += 1
    c0b1a_min = min(c0b, c1a)
    c += c0b1a_min
    if c0b1a > 0:
        if c0b > 0 or c1a > 0:
            c += c0b1a
        else:
            c += c0b1a - 1
    print(c)

main()


Measured memory_bytes: 41456
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define ll 				long long
#define ld 				long double
#define vi 				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set
#define umap 			unordered_map
#define maxpq 			priority_queue<int>
#define minpq			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))
#define sumv(a)			accumulate(all(a),0)

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a/(__gcd(a,b)))*b

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;



void solve()
{	

	int n,k,q;
	cin>>n>>k>>q;

	map<int,int>win;

	for(int i=0;i<q;i++)
	{
		int x;
		cin>>x;
		win[x]++;
	}

	for(int i=0;i<n;i++)
	{
		if(k-q+win[i+1]<=0)
		{
			cout<<"No\n";
		}
		else
		{
			cout<<"Yes\n";
		}
	}
	

}	

int32_t main()
{

	fastio
	cout<<setprecision(15)<<fixed;



	int t=1;
	// cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		// cout<<"Case "<<i<<" : "<<endl;
		solve();
	}
	
	#ifndef ONLINE_JUDGE	
		cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	#endif

	return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

long long N; long long K; std::vector<long long> A;
bool ok(long long x) {
    int k = 0;
    rep (i, N) {
        if (x == 0) k += A[i] + 1;
        else k += A[i] / x - (A[i] % x == 0);
    }
    return k <= K;
}

void solve(long long N_, long long K_, std::vector<long long> A_) {
    N = N_;
    K = K_;
    A = A_;

    long long ub = 1LL << 60;
    long long lb = 1;
    long long ans = 1LL << 60;
    while (lb <= ub) {
        long long md = (ub - lb) / 2 + lb;
        if (ok(md)) {
            ub = md;
            ub--;
            ans = min(ans, md);
        } else {
            lb = md;
            lb++;
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, m, e = 1;
    cin >> n;
    for (int i = 1; i <= n / 2; i++)
    {
        e *= 2;
        e %= 1000000007;
    }
    long long a, d[n];
    for (int i = 0; i < n; i++) d[i] = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        d[a]++;
    }
    if (n % 2 == 1)
    {
        m = 0;
        for (int i = 0; i < n; i = i + 2)
        {
            if ((i == 0 && d[i] != 1) || (i > 0 && d[i] != 2))
            {
                m++;
                cout << '0';
                break;
            }
        }
        if (m == 0) cout << e;
    }
    else
    {
        m = 0;
        for (int i = 1; i < n; i = i + 2)
        {
            if (d[i] != 2)
            {
                m++;
                cout << '0';
                break;
            }
        }
        if (m == 0) cout << e;
    }
}

Measured memory_bytes: 4416
#include "bits/stdc++.h"
using namespace std;

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

    string S, T;
    cin >> S >> T;

    string tmp;
    tmp = T.substr(0, T.size() - 1);

    if (S == tmp) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N;
int arr[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

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

    ll ans = 1e18, mtot = 0;
    for (int i = 0; i < N - 1; i++)
    {
        mtot += arr[i];
        ans = min (ans, abs (ctot - 2 * mtot));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
using namespace std;
typedef pair <int, int> ii;

const ll siz = 13;
const ll SIZ = 1e3 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 2e9;
const ll MAXX = 1e18;

int n, m;
int a[SIZ], b[SIZ], c[SIZ][siz];
int f[SIZ][1 << siz];
int ans;

int attempt(int i, int mask)
{
    if (mask == 0)
        return 0;
    if (i == m + 1 && mask) return maxx;
    if (f[i][mask] != -1) return f[i][mask];
    int res = maxx;
    res = min(res, attempt(i + 1, mask));
    int temp_mask = mask;
    for (int j = 1; j <= b[i]; j++)
        if (temp_mask & (1 << (c[i][j] - 1)))
            temp_mask ^= (1 << (c[i][j] - 1));
    res = min(res, attempt(i + 1, temp_mask) + a[i]);
    return f[i][mask] = res;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_4.INP", "r", stdin);
//    freopen ("OUT_4.OUT", "w", stdout);
    memset(f, -1, sizeof(f));
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        cin >> a[i] >> b[i];
        for (int j = 1; j <= b[i]; j++)
            cin >> c[i][j];
    }
    ans = attempt(1, (1 << n) - 1);
    if (ans == maxx) cout << "-1";
    else cout << ans;
    return 0;
}


Measured memory_bytes: 65024