akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int M,D;
    cin >> M >> D;
    int cnt;
    for(int i=1;i<=M;i++){
        for(int j=11;j<D+1;j++){
            if((i==(j/10*(j%10))) && j/10>=2 && j%10>=2){
              cnt++;
              cerr<< i << j/10 << j%10;
            }
        }
    }
    cout << cnt;


}

/*



 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define vi vector<int>
#define usi unordered_set<int> 
#define si set<int>
#define umii unordered_map<int, int> 
#define mii map<int, int>
#define all(a) a.begin(), a.end()
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mod (int)(1e9+7)
#define INF INT_MAX
 
 


signed main()
{
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // //freopen("output.txt", "w", stdout);
    // #endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int n; cin >> n;
    int a[n]; for (int i=0; i<n; i++) cin >> a[i];

    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for (int i=1; i<n; i++) {
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void solve();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int q=1;//cin>>q;
    while(q--){
        solve();
    }
    return 0;
}
void solve(){
  string s,t;cin>>s>>t;
  int a=t.length(),g=INT_MAX,p=0,k=0;
 // cout<<s.length()-t.length()<<endl;
 for(int i=0;i<=s.length()-t.length();i++)
  {  k=-1;
    for(int j=i;j<t.length()+i;j++)
    {k++;
        if(s[j]!=t[k])
            p++;
    }
    g=min(p,g);
    p=0;
  }
  cout<<g<<endl;
} 


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

int main(){
  long long n,m,i,j,l,r,zero=0,ans=0,cur=0;
  cin >> n >> m;
  vector<long long> a(n+10);
  vector<pair<long long,long long>> b(m+10);
  
  for(i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(i=0; i<n; i++){
    a[i]=a[i+10];
  }
  for(i=0; i<m; i++){
    cin >> b[i].second >> b[i].first;
  }
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  i=0;
  while(cur<n && i<m){
    b[i].second=min(b[i].second,n-cur);
    for(j=0 ;j<b[i].second; j++){
      a[cur]=max(a[cur],b[i].first);
      cur++;
    }
    i++;
  }
  for(i=0; i<n; i++){
    ans+=a[i];
  }
  cout << ans;
  return 0;

}
  

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        for (int i = 0; i < c.length - 1; i++) {
            if (c[i] == 'A' && c[i+1] == 'C') {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#define N 100000
int partition(int a[],int,int);
int n,a[N];

int partition(int a[],int p,int r) {
  int x,i,j,tmp1,tmp2;
  x = a[r];
  i = p -1 ;
  
  for(j=p;j<=r-1;j++) {
    if(a[j] <= x){
      i++;
      tmp1 = a[i];
      a[i] = a[j];
      a[j] = tmp1;
    }
  }

  tmp2 = a[i+1];
  a[i+1] = a[r];
  a[r] = tmp2;
  
  return i+1; 
}

int main(void) {
  
  int i,m;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) 
    scanf("%d",&a[i]);

  m = partition(a,0,n-1);
  
  for(i=0;i<m;i++)
    printf("%d ",a[i]);
  
  printf("[%d] ",a[m]);
  
  for(i=m+1;i<n-1;i++)
  printf("%d ",a[i]);
  
  printf("%d\n",a[n-1]);
  
  return 0;
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
using namespace std;
int n,q;
int ans[1000000]={0};
vector<int>gr[1000000];
void dfs(int src,int par)
{
    for(int i=0;i<gr[src].size();i++)
    {
        if(gr[src][i]!=par)
        {
           int x=gr[src][i];
            ans[x]+=ans[src];
              dfs(x,src);
        }
        else
        continue;
    }
}
int main()
{
   cin>>n>>q;

      int x=n-1;
    while(x--)
    {
       int u,v;
        cin>>u>>v;
          gr[u].push_back(v);
          gr[v].push_back(u);
    }
      for(int i=1;i<=q;i++)
      {
         int vertex,value;
           cin>>vertex>>value;
           ans[vertex]+=value;
      }
        dfs(1,-1);
      for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
}


Measured memory_bytes: 45696
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 

int main(){

    long long n,k;
    cin>>n>>k;

    double res=0;
    for(int i=1;i<=n;i++){
        long long x=i;
        long long cnt=0;
        while(x < k) x*=2LL, cnt++;

        res += 1.0 / (1LL<<cnt);
    }

    printf("%.16lf\n",res/n);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<double> a(n);
    double sum = 0;
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double mid = sum/(double)n;
    Int res = 0;
    double dif = a[0];
    for (Int i = 0; i < n; i++) {
        if (dif > fabs(a[i] - mid)) {
            dif = fabs(a[i] - mid);
            res = i;
        }
    }
    dump(res);
    return 0;  
}

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

{
 long long a;
  cin>>a;
  long long s = 0;
  for(int i=1; i<=a; i++)
  {
    if(i%3!=0)
    {if(i%5!=0)
     s+=i;
    }
  }
  cout<<s;


}


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

using namespace std;

int main() {
	vector<int>a(4); for (int i = 0; i < 4; i++)cin >> a[i];
	sort(a.begin(), a.end());
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	for(int i = 0; i < n; ++i) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	vector<vector<int>> dp(n, vector<int>(3, 0));
	for(int i = 0; i < 3; ++i) {
		dp[0][i] = a[0][i];
	}
	for(int i = 1; i < n; ++i) {
		for(int j = 0; j < 3; ++j) {
			for(int k = 0; k < 3; ++k) {
				if (j != k) {
					dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
				}
			}
		}
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';
	return 0;
}

Measured memory_bytes: 11136
from collections import defaultdict


def main():
    n, k = map(int, input().split())

    d = defaultdict(lambda: 0)
    for _ in range(n):
        a, b = map(int, input().split())
        d[a] += b

    cnt = 0
    for i, v in sorted(d.items()):
        cnt += v
        if cnt >= k:
            print(i)
            break


if __name__ == "__main__":
    main()

Measured memory_bytes: 14936
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,k;
string s;
int main(){
	cin>>n>>k;
	cin>>s;
	int co=1;
	FOR(i,1,n){
		if(s[i-1]!=s[i])co++;
		
	}
	if(co-2*k<=0){
		cout<<n-1<<endl;
	}else{
		cout<<n-(co-2*k)<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		// 出力
		System.out.println((a*b) - (a+b-1));
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B, C, D , b, c ;
   cin >> N ;
 A = N / 1000 ;
 B = N - 1000 * A ;
 b = B /100 ;
 C = B - b * 100 ;
 c = C / 10 ;
 D = C - c * 10 ;
  if ( (A == b && b == c ) || (b == c && c == D) ) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
n, y = map(int, input().split())
def find(n,y):
    for p in range(n+1):
        for q in range(n-p+1):
            if 9000*p + 4000*q == y - 1000*n:
                return [p,q,n-p-q]
    return [-1,-1,-1]

for i in find(n,y):
    print(i, end=" ")
print()


Measured memory_bytes: 39408
#pragma GCC optimize(2)
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;
#define inf 2147483647
#define IosF ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define N 200004

int main() {
    IosF;
    int x;
    cin >> x;
    if ( x & 1 ) cout << '0' << endl;
    else cout << '1' << endl;
    return 0;
}


Measured memory_bytes: 3644
def solve1():
    n, k = map(int, input().split())

    ans = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            if i % j >= k:
                ans += 1
    print(ans)


def solve():
    n, k = map(int, input().split())

    # k0は例外処理
    if k == 0:
        print(n**2)
        return

    # 割る数Bを増やしながら考える
    # b<=kまでは、割る数がk以下なのであまりは絶対kを超えない
    # K<b以降（b=k+1～n）
    ans = 0
    for b in range(k+1, n+1):
        n_iter = (n+1)//b
        amari = (n+1) % b

        #print(n_iter, b, k, n_iter*(b-k), amari, max(0, amari-k))
        ans += n_iter * (b-k)
        ans += max(0, amari-k)

    # B>=Kのところ
    # どうやってもあまりはK以上にならないので数えない

    print(ans)

solve()

Measured memory_bytes: 3192
def resolve():
    import numpy as np

    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A = np.insert(np.cumsum(A), 0, 0)
    B = np.insert(np.cumsum(B), 0, 0)

    ans = 0
    j = M
    for i in range(N + 1):
        if A[i] > K:
            break
        while A[i] + B[j] > K:
            j -= 1

        ans = max(ans, i + j)

    print(ans)

resolve()


Measured memory_bytes: 58736
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

import math
import bisect
N = int(input())
N_list = sorted(make_divisors(N))
p = bisect.bisect_left(N_list, math.sqrt(N))
n = N_list[p]
print(int(N/n + n - 2))

Measured memory_bytes: 3276
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main(args: Array<String>) {
    val (n, m) = longList()
    if (n * 2 >= m) {
        println((m / 2).toString())
        return
    }
    val r = m - (n * 2)
    println("${(n) + (r / 4)}")
}


Measured memory_bytes: 36340
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "abc160_c.cpp"

int main() {
  int k, n;
  cin >> k >> n;
  vi a(n);
  REP(i, n) { cin >> a[i]; }

  int ma = 0;
  REP(i, n - 1) { ma = max(ma, a[i + 1] - a[i]); }

  ma = max(ma, a[0] + k - a[n - 1]);
  cout << k - ma << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 1050;
const int MAX_C = 40;

int N, C;
int D[MAX_C][MAX_C];
int init[MAX_N][MAX_N];

int D_sum[3][MAX_C];

int main(int argc, char **argv) {
    std::cin >> N >> C;
    for (int c1 = 1; c1 <= C; c1++) {
        for (int c2 = 1; c2 <= C; c2++) {
            std::cin >> D[c1][c2];
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            std::cin >> init[i][j];
        }
    }

    //std::cout << "check" << std::endl;

    for (int i = 0; i < 3; i++) {
        for (int c1 = 1; c1 <= C; c1++) {
            D_sum[i][c1] = 0;
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            for (int c1 = 1; c1 <= C; c1++) {
                D_sum[(i+j)%3][c1] += D[init[i][j]][c1];
            }
        }
    }

    int ret = 500 * 500 * 1000;

    for (int c0 = 1; c0 <= C; c0++) {
        for (int c1 = 1; c1 <= C; c1++) {
            for (int c2 = 1; c2 <= C; c2++) {
                if (c0 == c1 || c1 == c2 || c2 == c0) {
                    continue;
                }
                ret = std::min(ret, D_sum[0][c0] + D_sum[1][c1] + D_sum[2][c2]);
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
 
int main(){
    int K;
    cin >> K;
    int i;
        vector<int> modK(1000010);
    modK.at(0) = 0;
 
    for(i=1;i<=K;i++){
        modK.at(i) = (modK.at(i-1)*10+7)%K;
    }
 
    for(i=1;i<=K;i++){
        if(modK.at(i) == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 7216
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
// -----------------------------------------------------------------
bool is_pal(string s, int l, int r)
{
    while(l<r)
    {   if(s[l]!=s[r])
            return false;
        l++,r--;
    }
    return true;
}
string solve()
{
    string s;
    cin>>s;
    int n = s.size();
    int i;
    if(is_pal(s,0,n-1) && is_pal(s,0,(n-1)/2-1) && is_pal(s,(n+3)/2-1,n-1))
        return "Yes";
    return "No";
}
signed main()
{
    out_of_reach;
    int t=1;
    //  cin>>t;
    string res;
    while(t--)
    {   res =solve();
        cout<<res;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main (){

int n,b,f,r,v,bil1[3][10]={0},bil2[3][10]={0};
int bil3[3][10]={0},bil4[3][10]={0};

cin>>n;
for (int i=0;i<n;i++){
	cin>>b>>f>>r>>v;
	if (b==1){
	bil1[f-1][r-1]+=v;
	}
	else if (b==2){
	bil2[f-1][r-1]+=v;
	}
	else if (b==3){
	bil3[f-1][r-1]+=v;
	}
	else { //b==4
	bil4[f-1][r-1]+=v;
	}
}


for (int j=0;j<3;j++){
	for (int k=0;k<10;k++){
		cout<<" "<<bil1[j][k];
		if (k==9) cout<<endl;
	}
}
cout<<"####################"<<endl;

for (int j=0;j<3;j++){
	for (int k=0;k<10;k++){
		cout<<" "<<bil2[j][k];
		if (k==9) cout<<endl;
	}
}
cout<<"####################"<<endl;

for (int j=0;j<3;j++){
	for (int k=0;k<10;k++){
		cout<<" "<<bil3[j][k];
		if (k==9) cout<<endl;
	}
}
cout<<"####################"<<endl;

for (int j=0;j<3;j++){
	for (int k=0;k<10;k++){
		cout<<" "<<bil4[j][k];
		if (k==9) cout<<endl;
	}
}

return 0;
}




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

namespace agc41
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_agc41A();
        }

        public static void solve_agc41B()
        {

        }

        public static void solve_agc41A()
        {
            long[] nab = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long n = nab[0];
            long a = nab[1];
            long b = nab[2];
            long res = 0;
            long left = Math.Min(a, b);
            long right = Math.Max(a, b);
            if (Math.Abs(a - b) % 2 == 0)
            {
                res = Math.Abs(a - b) / 2;
            }
            else
            {
                long diff = Math.Min(left - 1, n - right);
                res = diff + 1 + (right - left) / 2;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
    int H,W,i;
    i = 1;
    while(i == 1){
        cin >> H >> W;
        if(H == 0 & W == 0) break;
        for(int j = 0; j < H; j++){
            for(int k = 0; k < W; k++){
                if((j + k) % 2 == 0) cout << "#";
                if((j + k) % 2 == 1) cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>

int main()
{
	int a, b, c;

	std::cin >> a >> b >> c;

	if (a < b&&b < c) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;


typedef pair<int, int> pii;

int n, x;
set<pii> st;

void build (int l, int r) {
    if (l <= r) {
        auto ptr = st.lower_bound(pii(l, -1));
        if (ptr != st.begin()) {
            auto ptrl = prev(ptr);
            if (ptrl->second == l - 1) {
                l = ptrl->first;
            }
        }
        if (ptr != st.end() && ptr->first == r + 1) {
            st.erase(ptr);
            r = ptr->second;
        }
        st.insert(pii(l, r));
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;

    st.insert(pii(0, MOD));
    REP (i, n) {
        cin >> x;
        if (st.begin()->first != 0) {
            cout << "No" << endl;
            continue;
        }
        auto ptr = st.lower_bound(pii(x+1, -1));
        if (ptr == st.begin()) {
            cout << "No" << endl;
        } else {
            ptr = prev(ptr);
            if (ptr->second >= x) {
                cout << "Yes" << endl;
                pii cur = *ptr;
                st.erase(ptr);
                build(cur.first, x-1);
                build(x+1, cur.second);
            } else {
                if (ptr->second == 0 && (*next(ptr)) != pii(x+1, MOD)) {
                    cout << "No" << endl;
                    continue;
                }
                cout << "Yes" << endl;
                pii cur = *ptr;
                st.erase(ptr);
                build(cur.first, cur.second - 1);
                build(cur.second + 1, x);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 9964
import sys
sys.setrecursionlimit(10**9)

def BF(edges,n,s):
    inf=float("inf")
    d=[inf for i in range(n+1)]
    d[s]=0
    update=True
    for i in range(n+1):
      update=False
      for v,u,cost in edges:
        if cand[v]!=1 or cand[u]!=1:
          continue
        if d[v]!=inf and d[u]>d[v]+cost:
          d[u]=d[v]+cost
          update=True
      if update==False:
        break
      if i==n:
        return inf
    return -d[-1]

def DFS_1toN(v):
  for u in to[v]:
    if toflag[u]==0:
      toflag[u]=1
      DFS_1toN(u)
      
def DFS_Nto1(v):
  for u in ot[v]:
    if otflag[u]==0:
      otflag[u]=1
      DFS_Nto1(u)
    
n,m,p=map(int,input().split())
g=[]
to=[[] for _ in range(n+1)]
ot=[[] for _ in range(n+1)]
for _ in range(m):
  a,b,c=map(int,input().split())
  g.append([a,b,-(c-p)])
  to[a].append(b)
  ot[b].append(a)
toflag=[0]*(n+1)
toflag[1]=1
DFS_1toN(1)
otflag=[0]*(n+1)
otflag[n]=1
DFS_Nto1(n)
cand=[0]*(n+1)
for i in range(1,n+1):
  cand[i]=toflag[i]*otflag[i]
ans=BF(g,n,1)
if ans==float('inf'):
  print(-1)
else:
  print(max(ans,0))

Measured memory_bytes: 64344
N = int(input())
M = 10**9+7
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter

ct = Counter()
for t in range(2, N+1):
    pf = prime_factorize(t)
    ct.update(pf)

ans = 1
for k,v in ct.items():
    ans *= (v + 1)
    ans %= M

# print(ct)
print(ans)


Measured memory_bytes: 9396
#include"bits/stdc++.h"
    #include<valarray>
    #include<ext/pb_ds/tree_policy.hpp>
    #include<ext/pb_ds/assoc_container.hpp>
    using namespace std;
    using namespace __gnu_pbds;

#define MAX 200002
char buf[MAX];
string s;
int main(){
	scanf("%s",buf);
	s=buf;
	char pv='B';
	int con=0;
	long long int ans=0;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='A'){
			if(pv=='C'){
					pv='B';
					con=0;
			}
			ans+=con;
			continue;
		}
		if(s[i]=='C'){
			if(pv=='B'){
				
			}
			else{
				con=0;
			}
			pv=s[i];
			continue;
		}
		if(pv=='C'){
			con++;
		}
		else{
			con=0;
		}
		pv=s[i];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N,M,R;

  cin>>N>>M>>R;

  vector<int> r;

  rep(i,R){
    int rr;
    cin>>rr;
    r.emplace_back(rr);
  }

  SORT(r);

  const int MAXN=N+1; // warshall_floyd
  int dist[MAXN][MAXN];
  rep(i,MAXN){
    rep(j,MAXN){
      dist[i][j]=INF;
    }
    dist[i][i]=0;
  }
  rep(i,M){
    int a,b,c; cin>>a>>b>>c;
    dist[a][b]=dist[b][a]=c;
  }
  rep(k,MAXN) rep(i,MAXN) rep(j,MAXN) dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
  //warshall_floyd end

  ll ans=INF;

  do{
    ll buff=0;
    rep(i,R-1){
      buff+=dist[r[i]][r[i+1]];
    }
    ans=min(ans,buff);
  } while(next_permutation(r.begin(),r.end()));

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int H,W;
string s[2000];
int u[2000][2000];
int d[2000][2000];
int r[2000][2000];
int l[2000][2000];

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++) cin >> s[i];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            u[i][j] = d[i][j] = r[i][j] = l[i][j] = 0;
        }
    }
    int p;
    for(int i=0;i<H;i++){
        p = 0;
        for(int j=0;j<W;j++){
            if(s[i][j] == '.'){
                r[i][j] = ++p;
            }else{
                p = 0;
            }
        }
    }
    for(int i=0;i<H;i++){
        p = 0;
        for(int j=W-1;j>=0;j--){
            if(s[i][j] == '.'){
                l[i][j] = ++p;
            }else{
                p = 0;
            }
        }
    }
    for(int j=0;j<W;j++){
        p = 0;
        for(int i=0;i<H;i++){
            if(s[i][j] == '.'){
                u[i][j] = ++p;
            }else{
                p = 0;
            }
        }
    }
    for(int j=0;j<W;j++){
        p = 0;
        for(int i=H-1;i>=0;i--){
            if(s[i][j] == '.'){
                d[i][j] = ++p;
            }else{
                p = 0;
            }
        }
    }
    int m = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            m = max(m,u[i][j]+d[i][j]+r[i][j]+l[i][j]-3);
        }
    }
    cout << m << endl;
    return 0;
}

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

#define int long long 

using namespace std;

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)

int beki(int wa,int rr,int warukazu){
    if(rr==0) return 1%warukazu;
    if(rr==1) return wa%warukazu;
    wa%=warukazu;
    if(rr%2==1) return ((int)beki(wa,rr-1,warukazu)*(int)wa)%warukazu;
    int zx=beki(wa,rr/2,warukazu);
    return (zx*zx)%warukazu;
}

void solve()
{
    int n;cin >> n;
    int a=beki(10,n,mod);
    int b=beki(9,n,mod);
    b*=2;
    int c=beki(8,n,mod);
    int ans=(a+mod-b+mod+c)%mod;
    cout << ans << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //int t;cin >> t;while(t--)
    	solve();

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	long long A; string B; 
	cin >> A >> B; 
	long long C = 100 * (B.at(0) - '0') + 10 * (B.at(2) - '0') + (B.at(3) - '0'); 
	cout << A * C / 100 << endl; 
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[10];
int v[10][10];
int perm[10];
int tmp[10];
int n,m;
int H;
int solve(int a){
	if(a==m){
		for(int i=0;i<n;i++){
			tmp[i]=i;
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<n-1;j++){
				if(v[i][j])swap(tmp[j],tmp[j+1]);
			}
		}
		for(int i=0;i<n;i++)if(perm[i]!=tmp[i])return 0;
		return 1;
	}
	int col=p[a];
	for(int i=0;i<H;i++){
		if(v[i][col])continue;
		if(col&&v[i][col-1])continue;
		if(col<n-2&&v[i][col+1])continue;
		v[i][col]=1;
		if(solve(a+1))return 1;
		v[i][col]=0;
	}
	return 0;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	n=a;
	m=b;
	for(int i=0;i<b;i++){
		scanf("%d",p+i);
		p[i]--;
	}
	for(int i=0;i<a;i++)perm[i]=i;
	for(int i=0;i<b;i++){
		swap(perm[p[i]],perm[p[i]+1]);
	}
	for(int i=1;i<b;i++){
		for(int j=0;j<10;j++)for(int k=0;k<10;k++)v[j][k]=0;
		H=i;
		int res=solve(0);
		if(res){
			printf("%d\n",i);return 0;
		}
	}
	printf("%d\n",b);
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#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 ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	string s;
    	cin>>s;
    	int l = s.length();
    	ll fr[2019];
    	memset(fr,0,sizeof(fr));
    	string s1;
    	fr[0]++;
    	int x = 0;
    	n = 0;
    	int p = 1;
    	for(int i=l-1;i>=0;i--){
    		// s1.pb(s[i]);
    		// n = stoi(s1);
    		n = n + (s[i]-'0')*p;
    		// cout<<n<<endl;
    		p *= 10;
    		p %= 2019;
    		n %= 2019;
    		fr[n]++;
    		// s1 = to_string(n);
    	}
    	ll ans = 0;
    	for(int i=0;i<2019;i++){
    		if(fr[i]){
    		ans += fr[i]*(fr[i]-1)/2;
    	}
    }
    	cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
    int N, Q;  string S;
    cin >> N >> Q >> S;
    int L = S.length();
    vector<int> f(L,0);
    
    for(int i=1; i<L; i++){
        if(S[i-1]=='A' && S[i]=='C'){
            f[i] = 1;
        }
    }
    for(int i=1; i<L; i++) f[i] += f[i-1];

    vector<int> l(Q,0), r(Q,0);
    for(int i=0; i<Q; i++) {
        cin >> l[i] >> r[i];
        l[i]--;  r[i]--;
    }
    for(int i=0; i<Q; i++){
        cout << f[r[i]] - f[l[i]] << endl;
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int main() {
	long long n,m,ans;
	scanf("%lld %lld",&n,&m);
	if(n*2<=m) {
		ans=n;
		m-=n*2;
	}
	else {
		printf("%lld",m/2);
		return 0;
	}
	ans+=m/4;
	printf("%lld",ans);
}


Measured memory_bytes: 256
import sys
import bisect
import math
import itertools
from collections import deque
import copy

# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())

    L = [[] for _ in range(N + 1)]

    for j in range(N):
        a = list(map(int, input().split()))
        L[j + 1] = deque(a)


    k =0

    current_revise =set(range(N+1))
    while k<50000000: # １日分の作業

        pre_revise =copy.copy(current_revise)
        current_revise =set()

        for i in pre_revise: #一人分の作業
            if not L[i]:
                continue
            can = L[i][0]
            if L[can][0] == i and i not in current_revise and can not in current_revise:
                L[i].popleft()
                L[can].popleft()

                current_revise.add(i)
                current_revise.add(can)
        k += 1

        if len(current_revise)==0:
            break


    for i in range(N + 1):
        if len(L[i])>0:
            print(-1)
            exit()

    print(k-1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 98476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][2];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<2;j++)
        {
            cin>>a[i][j];
        }
    }
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(a[i][0]==a[i][1])
        {
            count++;
        }
        else
        {
            count=0;
        }
        if(count==3)
        {
            break;
        }
    }
    if(count==3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3632
N = int(input())

l_0 = list(map(int , input().split()))

L = [l_0]

m = None

count = 0

while L != []:
	for l in L:
		lis = l
		m   = min(l)
		for i in range(len(l)):
			lis[i] = lis[i] - m
		count += m
		lis = "_".join( list(map(str , lis)) )
		if lis[0:1] == "0":
			lis = lis[2:]
		lis = lis.split("_0")
		while "" in lis:
			lis.remove("")
		for a in lis:
			if a[0:1] == "_":
				a = a[1:]
			a = list(map(int, a.split("_")))
			L.append(a)
		L.remove(l)
		while [] in L:
			L.remove([])
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			1000011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}
ll fa[M],iv[M];
ll chose(ll n,ll k){
	if(n<k)return 0;
	ll r=fa[n];r=r*iv[k];r%=md;r=r*iv[n-k]%md;
	return r%md;
}

ll way(ll x1,ll y1,ll x2,ll y2){
	if(x1>x2||y1>y2)return 0;
	return chose(y2+x2-y1-x1,x2-x1);

}
int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    fa[0]=iv[0]=1;
    lp(1,M-1){
    	fa[i]=fa[i-1]*i%md;fa[i]%=md;
    	iv[i]=iv[i-1]*exp(i,md-2)%md;iv[i]%=md;
    }
    ll h,w,a,b;

    cin>>h>>w>>a>>b;
    p=0;
    for(i=h-a;i>=1;--i){
    	k=way(1,1,i,b);k%=md;
    	// trace(1,1,i,b);
    	k=k*way(i,b+1,h,w)%md;
    	// trace(i,w-b,h,w);
    	p+=k;
    	// trace(k);

    	p%=md;

    }
    cout<<p%md<<"\n";






    	






    

}



Measured memory_bytes: 15872
#include <stdio.h>

int main()
{
	int i,count[26] = {0};
	char ch;
	
	while(scanf("%c",&ch) != EOF){
		for(i = 0;i < 26;i++){
			if(ch == 'a' + i || ch == 'A' + i){
				count[i]++;
			}
		}
	}
	
	for(i = 0;i < 26;i++){
		printf("%c : %d\n",'a' + i,count[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    int N, T;
    cin >> N >> T;
    vector<ll> t(N);
    for(int i=0; i<N; i++) cin >> t[i];

    ll max_time = 0;
    ll total_time = 0;

    for(int i=0; i<N; i++) {
        if(max_time >= t[i]) {
            total_time += t[i]+T-max_time;
        }
        else {
            total_time += T;
        }
        max_time = t[i]+T;
    }
    cout << total_time << endl;
}

Measured memory_bytes: 4776
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

def rln(s):
    return range(len(s))

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################



h,w = list(map(int, input().split()))
n=int(input())
a = list(map(int, input().split()))
num = []
for i in rln(a):
    for j in range(a[i]):
        num.append(i+1)
#print(num)
ans = [[-1 for i in range(w)]for j in range(h)]
for i in range(h*w):
    x = i//h
    y = i%h if(x%2==0) else h-1-i%h
    ans[y][x] = num[i]

for i in range(h):
    print(' '.join(map(str,ans[i])))


































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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define forz(i,n) for( int i=0;i<n;i++)
#define forl(i, n) for(int i = 0; i<= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
// #define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;

void cpc()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif
}
lli power(lli x, lli y)
{
	lli res = 1;     // Initialize result
	// lli p = mod;
	x = x ; // Update x if it is more than or
	// equal to p

	if (x == 0) return 0; // In case x is divisible by p;

	while (y > 0)
	{
		// If y is odd, multiply x with result
		if (y & 1)
			res = (res * x);

		// y must be even now
		y = y >> 1; // y = y/2
		x = (x * x);
	}
	return res;
}

// lli mod(lli x)
// {
// 	if (x < 0)
// 		x = -x;
// 	return x;
// }



int main()
{
	// cpc();
	// kira;
	lli n , m, ct = 0;
	cin >> n >> m;
	lli arr[n + 1] = {0};

	std::vector<lli> v(n);
	std::vector<pair<lli , lli >> h;
	forz(i, n)
	{
		// lli d;
		cin >> v[i];

	}
	forz(i, m)
	{
		lli a, b;
		cin >> a >> b;
		h.pb(mp(a, b));
		if (v[a - 1] > v[b - 1])
		{
			arr[b] = -1;
		}
		else if (v[b - 1] > v[a - 1])
		{
			arr[a] = -1;
		}
		else
		{
			arr[a] = arr[b] = -1;
		}
	}
	for (int i = 1; i <= n; i ++)
	{
		if (arr[i] == 0)
		{
			ct ++;
		}
	}

	cout << ct << endl;
	return 0;
}

Measured memory_bytes: 6936
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MAXM = 5 + 200000;
const ll INF = 1LL << 60;

struct st {
    int tam;
    vector<ll> tree;
    vector<ll> lazy;
    st(int n) {
        tam = n;
        tree.assign(tam << 2, 0LL);
        lazy.assign(tam << 2, 0LL);
    }
    ll lazy_query(int low, int high, int pos, int& qlow, int& qhigh) {
        int mid = (low + high) >> 1;
        int left = (pos << 1) | 1;
        int right = left + 1;
        if(lazy[pos] != 0) {
            tree[pos] += lazy[pos];
            if(low != high) {
              lazy[left] += lazy[pos];
              lazy[right] += lazy[pos];
            }
            lazy[pos] = 0;
        }
        if (qhigh < low || qlow > high)
            return -INF;
        if (low >= qlow && high <= qhigh)
            return tree[pos];
        ll l = lazy_query(low, mid, left, qlow, qhigh);
        ll r = lazy_query(mid + 1, high, right, qlow, qhigh);
        return max(l, r);
    }
    ll query(int i, int j) {
        return lazy_query(0, tam - 1, 0, i, j);
    }
    void lazy_update(int low, int high, int pos, int& qlow, int& qhigh, ll& cant) {
        int mid = (low + high) >> 1;
        int left = (pos << 1) | 1;
        int right = left + 1;
        if(lazy[pos] != 0) {
            tree[pos] += lazy[pos];
            if(low != high) {
              lazy[left] += lazy[pos];
              lazy[right] += lazy[pos];
            }
            lazy[pos] = 0;
        }
        if(low > qhigh || high < qlow)    return;
        if(low >= qlow && high <= qhigh) {
            tree[pos] += cant;
            if(low != high) {
              lazy[left] += cant;
              lazy[right] += cant;
            }
            return;
        }
        lazy_update(low, mid, left, qlow, qhigh, cant);
        lazy_update(mid + 1, high, right, qlow, qhigh, cant);
        tree[pos] = max(tree[left], tree[right]);
    }
    void update(int i, int j, ll x) {
        lazy_update(0, tam - 1, 0, i, j, x);
    }};


struct Point {
    int l,r,a;
} p[MAXM];

vector<int> sr[MAXM];
int N,M;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> N >> M;
    foi(i,0,M) {
        cin >> p[i].l >> p[i].r >> p[i].a;
        sr[p[i].l].push_back(i);
        sr[1 + p[i].r].push_back(i);
    }
    ll ans = 0LL;
    st s(5+MAXM);
    for(int i = 1; i <= N; ++i) {
        for(int x : sr[i]) {
            if(p[x].l == i) {
                s.update(0, p[x].l - 1, p[x].a);
            } else {
                s.update(0, p[x].l - 1, -p[x].a);
            }
        }
        ll q = s.query(0, i - 1);
        ans = max(ans, q);
        s.update(i,i,q);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 27392
def E(i, x):
    if i == 1:
        return 5*x
    else:
        return (2*i + 1) * x

N, X = map(int, input().split())
G = [int(_) for _ in input().split()]
SumG = [0 for i in range(N)] 
SumG[0] = G[0]
for i in range(N-1):
    SumG[i+1] = SumG[i] + G[i+1]

pick = N * X
cost = float("inf")
for k in range(1, N+1): 
    trush = k * X
    carry = 0
    i, upper, lower = 1, N-1, N-1-k
    while lower >= 0:
        carry += E(i, SumG[upper]-SumG[lower])
        i, upper, lower = i+1, lower, lower - k
    carry += E(i, SumG[upper])
    cost = min(cost, pick + trush + carry)

print(cost)

Measured memory_bytes: 26376
#include <bits/stdc++.h>
//#include <vector>
using namespace std;
 
 
int main(){
    int a;
    bool ans=false;
    cin>>a;
    vector<int> kuku(0);
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            kuku.push_back(i*j);
        }
    }
    
   for(int i=0;i<81;i++){
       if(a==kuku.at(i))ans=true;
       //cout<<kuku.at(i)<<endl;
   }
    if(ans)cout<<"Yes";
    else cout<<"No";
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
class Dice{
    int x[7];
    public:
    void input(int I, int num){
        x[I] = num;
    }
    
    void move(char order){
        int oldx[7];
        for(int i = 0; i <= 7; i ++){
            oldx[i] = x[i];
        }
        if(order == 'N'){
            x[1] = oldx[2];
            x[2] = oldx[6];
            x[6] = oldx[5];
            x[5] = oldx[1];
        } 
        else if(order == 'S'){
            x[1] = oldx[5];
            x[2] = oldx[1];
            x[6] = oldx[2];
            x[5] = oldx[6];
        }
        else if(order == 'W'){
            x[1] = oldx[3];
            x[4] = oldx[1];
            x[6] = oldx[4];
            x[3] = oldx[6];
        }
        else if(order == 'E'){
            x[1] = oldx[4];
            x[4] = oldx[6];
            x[6] = oldx[3];
            x[3] = oldx[1];
        }
    }
    void print(int num){
        cout << x[num] << endl;
    }
};

int main(){
    int val;
    char ch;
    Dice dice;
    for(int i = 1; i<=6;i++){
        cin >> val;
        dice.input(i,val);
    }
    while(cin >> ch){
        dice.move(ch);
    }
    dice.print(1);
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int index = 0;
  int count = 0;
  vector<char> vec(10);
  vec = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
  rep(i, 10)
  {
    rep(j, 10)
    {
      rep(k, 10)
      {
        index = 0;
        rep(x, N)
        {
          if (S[x] == vec[i] && index == 0)
          {
            index++;
          }
          else if (S[x] == vec[j] && index == 1)
          {
            index++;
          }
          else if (S[x] == vec[k] && index == 2)
          {
            count++;
            break;
          }
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3644