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

int main() {

int N,M;
  cin>>N>>M;
  vector<vector<char>> A(N,vector<char>(M));
  for(int i=0; i<N;i++){
    for(int j=0; j<M;j++){
      cin>>A.at(i).at(j);}}
  
    for(int i=0; i<N;i++){
      if(i==0){for(int k=0;k<M+2;k++){cout<<'#';}cout<<endl;}
    for(int j=0; j<M;j++){
      if(j==0){cout<<'#';}
      cout<<A.at(i).at(j);
      if(j==M-1){cout<<'#'<<endl;}
      }
      if(i==N-1){for(int k=0;k<M+2;k++){cout<<'#';}cout<<endl;}
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         300005
    const ll MOD = 1000000000 + 7;
    map<pair<int , int> , int> mp;
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           int h , w , n ;
           cin >> h >> w >> n;
           
           vector<int> row(h , 0) , col(w , 0);
           
           
           for(int i = 0 ; i < n ; i++)
           {
               int a , b;
               cin >> a >> b;
               a--, b--;
               mp[make_pair(a ,b)] = 1;
               row[a]++,col[b]++;
           }
           int mr = 0 , mc = 0;
           
           for(int x : row)mr = max(mr , x);
           for(int x : col)mc = max(mc , x);
           
           int mx = mr + mc;
           
           vector<int> ih , iw;
           for(int i = 0 ; i < h ; i++) if(row[i] == mr) ih.push_back(i);
           for(int i = 0 ; i < w ; i++) if(col[i] == mc) iw.push_back(i);
           
           for(int x : ih)
           {
               for(int y : iw)
               {
                   if(mp[{x ,y}])continue;
                   else
                   {
                       cout << mx << endl;
                       return 0;
                   }
               }
           } 
           
           cout << mx - 1 << endl;
        }
    }



Measured memory_bytes: 28488
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    int n;
    IN n;
    vector<int> v(n);
    loop(i,0,n)
    {
        IN v[i];
    }
    int ans=1;
    int last=v[0];
    loop(i,1,n)
    {
        if(v[i]<last)
        {
            ans++;
            last=v[i];
        }
    }
    OUT ans;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);

		String str = input.readLine( );
		String[] s = str.split("");

		int answer = 0;
		int sum = 0;

		for(int i=0; i<n; i++){
			if(s[i].equals("I")){
				sum = sum+1;
				if(answer<sum){
					answer = sum;
				}
			}else {
				sum = sum-1;
			}
		}

		System.out.println(answer);
	}

}


Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;
int h,w;
string s[11111];
int d[111][111];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void bfs(int sx,int sy){
	queue<P> que;
	que.push({sx,sy});
	d[sx][sy]=0;
	while(que.size()){
		P p=que.front();que.pop();
		rep(i,4){
			int nx=p.first+dx[i],ny=p.second+dy[i];
			if(d[nx][ny]==INF && s[nx][ny]=='.' && nx>=0 && nx<h && ny>=0 && ny<w){
				que.push({nx,ny});
				d[nx][ny]=d[p.first][p.second]+1;
			}
		}
	}
}
signed main(){
    cin>>h>>w;
    rep(i,h)cin>>s[i];
    int ans=0;
    rep(i,h)rep(j,w){
    	rep(k,h)rep(l,w)d[k][l]=INF;
    	if(s[i][j]=='.')bfs(i,j);
    	rep(k,h)rep(l,w){
    		if(d[k][l]!=INF)ans=max(d[k][l],ans);
    	}
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 384
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let N = readInt ()
let a =
  readStr().ToCharArray()
  |> Array.map (fun c -> (int c) - (int '1'))

let bm2 n r = n = (r ||| (n-r))

let odd (input: _ array) =
  [0..(N-1)]
  |> List.filter (bm2 (N-1))
  |> List.map (fun i -> input.[i] % 2)
  |> List.fold (^^^) 0
  |> function
  | 0 -> false
  | 1 -> true
  | _ -> failwith "invalid" 

let have1 = Array.exists ((=) 1)
if odd a then 1 else if have1 a then 0 else if a |> Array.map (flip (/) 2) |> odd then 2 else 0
|> printfn "%d"

Measured memory_bytes: 74532
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[111]={},c=0;
	cin>>n;
	FOR(i,0,n){
		int t;
		cin>>t;
		if(a[t]==0)c++;
		a[t]=1;
	}
	cout<<c<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  cin >> n;
  cout << n * 32 << endl;
	return 0;
}


Measured memory_bytes: 3164
/**
 * @brief AtCoder Regular Contest 061<br>
 * C- たくさんの数式 / Many Formulas
 *
 * bit全検索パターン
 * @see https://arc061.contest.atcoder.jp/tasks/arc061_a
 */
#include <iostream>
using namespace std;

int main() {
  string S; cin >> S;
  size_t len{S.size()};

  long total{};
  for (size_t i{}; i < (1 << (len - 1)); ++i) {
    long temp = S[0] & 0xF;
    for (size_t j{}; j < len - 1; ++j) {
      if (i & (1 << j)) {
        total += temp;
        temp = 0;
      }
      temp *= 10;
      temp += S[j + 1] & 0xF;
    }
    total += temp;
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

ans = [1]* n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        ans[b-1] = 0
        
    if h[a-1] <= h[b-1]:
        ans[a-1] = 0
        
print(ans.count(1))

Measured memory_bytes: 84988
#include <iostream>

using namespace std;
static const int mx=107;
static const int inf=(1<<21);

int n,m[mx][mx];

int prim()
{
	int u,minv;
	int d[mx],p[mx],color[mx];
	
	for(int i=0;i<n;i++)
	{
		d[i]=inf;
		p[i]=-1;
		color[i]=0;
	}
	d[0]=0;
	
	while (1) {
		minv=inf;
		u=-1;
		for(int i=0;i<n;i++)
		{
			if(minv>d[i]&&color[i]!=2)
			{
				u=i;
				minv=d[i];
			}
		}
		if(u==-1)break;
		color[u]=2;
		for(int v=0;v<n;v++)
		{
			if(color[v]!=2&&m[u][v]!=inf)
			{
				if(d[v]>m[u][v])
				{
					d[v]=m[u][v];
					p[v]=u;
					color[v]=1;
				}
			}
		}
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(p[i]!=-1)sum+=m[i][p[i]];
	}
	return sum;
}
int main(int argc, char *argv[]) {
	cin>>n;
	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			int e;
			cin>>e;
			m[i][j]=(e==-1)?inf:e;
		}
	}
	cout<<prim()<<endl;
	return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << "\n"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e2 + 3;
const ll M = 1e5 + 3;

ll n, k, a[N];
bool dp[M];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n >> k;
	for (ll i = 1; i <= n; ++i) cin >> a[i];
	sort(a+1, a+1 + n);
	
	for (ll i = 1; i <= k; ++i) {
		for (ll j = 1; j <= n; ++j) {
			if (i - a[j] < 0) break;
			if (!dp[i - a[j]]) {
				dp[i] = true;
				break;
			}
		}
	}
	cout << (dp[k] ? "First" : "Second");
	
	return 0;
}


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

int main()
{
    int K,A,B;
    cin >> K >> A >> B;
    int temp = 0;
    int flag = 0;

    for(int i =0; ;i++){
        temp = i * K;
        if(temp > B) break;
        if(A <= temp && temp <= B){
            flag = 1;
            break;
        } 
    }

    if(flag == 1){
        cout << "OK" << endl; 
    }else{
        cout << "NG" << endl;
    }

}

Measured memory_bytes: 3680
def p(t):
    print(f'{t:.6f}')

n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

D1=0
D2=0
D3=0
D4=0

for i in range(n):
    d=x[i]-y[i]
    if d<0:
        d=-d
    
    D1+=d
    D2+=d**2
    D3+=d**3
    if d>D4:
        D4=d
        
p(D1)
p(D2**(1/2))
p(D3**(1/3))
p(D4)


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

using namespace std;
using ll = long long;

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) cin >> a;

    if (A[0] > 0) fail();

    ll ans = A[N - 1];
    for (int i = N - 2; i >= 0; --i) {
        if (A[i + 1] - A[i] > 1) fail();
        if (A[i + 1] - A[i] == 1) continue;
        ans += A[i];
    }

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


Measured memory_bytes: 1792
/*
ID: allengu01
TASK: 
LANG: C++
*/

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;



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

	cout << max({ dp[n][0], dp[n][1], dp[n][2] });
	return 0;
}



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

using namespace std;
const int N=3e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    a[0]--;
    for(int i=1;i<n;i++)
    {
        if(a[i-1]>a[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(a[i]>a[i-1])
            a[i]--;
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 640
A, B, C, D = map(int, input().split())
cnt = 0
while True:
    if cnt % 2 == 0:
        C -= B
        if C <= 0:
            print('Yes')
            exit()
    else:
        A -= D
        if A <= 0:
            print('No')
            exit()
    cnt += 1


Measured memory_bytes: 9176
#include<stdio.h>
int main(void){
  int i,j,n,h,count=0,max=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h);
    if(max<=h) {
      max=h;
     count++;
    } 
  }
  printf("%d",count);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<ll> x, y;

ll get(int l, vector<ll> z)
{
    ll rtn = 0ll;
    ll val = 0ll;
    REP(i,l-1) {
        val += l - 1 - 2 * i;
        rtn += (z[i+1] - z[i]) * val ;
        rtn %= MOD;
    }
    return rtn;
}


int main()
{
    int n, m;
    cin>>n>>m;
    REP(i,n) {
        ll tmp;
        cin>>tmp;
        x.push_back(tmp);
    }
    REP(i,m) {
        ll tmp;
        cin>>tmp;
        y.push_back(tmp);
    }

    ll ans = 1ll;
    ans *= get(n, x);
    ans %= MOD;
    ans *= get(m, y);
    ans %= MOD;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 2676
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


S=int(input())
inf=10**9+7
temp=1
ans=0


quot=S//3
remain=S%3
while quot>0:
    ans+=cmb(remain+quot-1,quot-1)
    quot-=1
    remain+=3
    ans%=inf
print(ans)
exit()

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

int main(void){
  string s; cin >> s;
  if((s.at(2)==s.at(3)) && (s.at(4)==s.at(5))) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

int main (void)
{
  char s[200000];
  scanf("%s",s);
  int len = strlen(s);
  int min , max;
  
  for(int i =0;i < len;i ++){
    if(s[i]=='A'){
     min=i;
     break;
    }}
  
  for(int i =len;i>0;i--){
    if(s[i]=='Z'){
      max=i;
      break;
    }}
  
 printf("%d",max-min+1);
 return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		t = reverse(t);
		System.out.println(String.valueOf(s).compareTo(String.valueOf(t)) < 0 ? "Yes" : "No");
	}

	public static char[] reverse(char... c){
		char[] r = new char[c.length];
		for(int i = 0; i < c.length; i++){
			r[i] = c[c.length -1 -i];
		}
		return r;
	}
}


Measured memory_bytes: 21332
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = INT_MAX;
const ll linf = 3e18;
const double eps = 1e-9;

struct SegTree { // ??????min,max
    int n;
    vector<int> Max;
    vector<int> Min;
    void init(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        Min.resize(2 * n);
        //Max.resize(2 * n);
        for (int i = 0; i < 2 * n - 1; ++i) {
            Min[i] = inf;
            //Max[i] = -inf;
        }
    }
    void update(int idx, int val) {
        idx += n - 1;
        Min[idx] = val;
        //Max[idx] = val;
        while (idx > 0) {
            idx = (idx - 1) / 2;
            Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
            //Max[idx] = max(Max[idx * 2 + 1], Max[idx * 2 + 2]);
        }
    }
    int get_min(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)???min
        if (r == -1) r = n;
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return Min[k];
        int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
    int get_max(int a, int b, int k = 0, int l = 0, int r = -1) { // [a, b)???max
        if (r == -1) r = n;
        if (r <= a || b <= l) return -inf;
        if (a <= l && r <= b) return Max[k];
        int vl = get_max(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = get_max(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    }
};

signed main()
{
    omajinai;

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

    SegTree seg;

    seg.init(n);

    rep(i, q) {
        int type, x, y;
        cin >> type >> x >> y;

        if (type % 2 == 0) {
            seg.update(x, y);
        } else {
            cout << seg.get_min(x, y + 1) << endl;
        }
    }
}

Measured memory_bytes: 2060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn exe(n: usize, sc_list: Vec<((usize, usize))>) -> i32 {
    for num in 0..999 {
        if n == 1 && (num >= 10) {
            break;
        }
        if n == 2 && num < 10 {
            continue;
        }
        if n == 2 && num >= 100 {
            break;
        }
        if n == 3 && num < 100 {
            continue;
        }
        let mut all_ok = true;
        for j in 0..sc_list.len() {
            let sc = sc_list[j];
            let mut num_str = Vec::new();
            for c in num.to_string().chars() {
                num_str.push(c.to_string().parse::<i32>().unwrap());
            }
            if num_str[sc.0 - 1] != sc.1 as i32 {
                all_ok = false;
            }
        }
        if all_ok {
            return num;
        }
    }
    -1
}

fn main() {
    input! {
        n: usize,
        m: usize,
        sc_list: [(usize, usize); m],
    }
    println!("{}", exe(n, sc_list));
}


Measured memory_bytes: 4352
from itertools import product


n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, key=lambda l: l[2], reverse=True)

for cx, cy in product(range(101), repeat=2):
    x0, y0, h0 = xyh[0]
    ch = h0 + abs(x0 - cx) + abs(y0 - cy)
    for x, y, h in xyh:
        if h != max(ch - abs(x - cx) - abs(y - cy), 0):
            break
    else:
        print(cx, cy, ch)
        break


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

int main() {
    string S,T;
    int a,flag;
    flag = 0;
    cin >> S;
    cin >> T;
    
    a = S.size();
    for(int i = 0;i < a; i++){
    	if(S.at(i) == T.at(i)){
        	continue;
        }
        else{
        	flag = 1;
        	break;
        }
    }
    if(flag == 0 && a == T.size() - 1){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3628
// C program to convert a number from any base
// to decimal
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fore(i, l, n) for(int i = l; i < n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

int main()
{
    fastIO
    int n;
    cin >> n;
    vector<int> arr(n, 0);

    fore(i, 0, n)
        cin >> arr[i];

    sort(arr.begin(), arr.end());

    ll ans = 0;

    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            int num = arr[i] + arr[j];
            auto it = upper_bound(arr.begin(), arr.end(), num - 1);
            it--;
            if(*it >= num)
                it--;

            ll ind = it - arr.begin();
//            cout << *it << " "<< ind << " ind\" << num << " " << j<< endl;

            if(ind <= j)
                continue;
            else
                ans += (ind - j);
        }
//        cout << "=============="<<endl;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1) ans += 300000;
    if(x == 2) ans += 200000;
    if(x == 3) ans += 100000;
    if(y == 1) ans += 300000;
    if(y == 2) ans += 200000;
    if(y == 3) ans += 100000;
    if(x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int r = Integer.parseInt(sc.next());
        int g = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int calc = r * 100 + g * 10 + b;
        if (calc % 4 == 0) {
            out.printf("YES\n");
        } else {
            out.printf("NO\n");
        }
        out.flush();
    }
}

Measured memory_bytes: 23764
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N,D;
	cin>>N>>D;
	D = 2*D+1;
	cout<<N/D+(N%D==0?0:1)<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(10**9)
input=sys.stdin.readline

def dfs(u,s):
  visited[u]=True
  ans_list[u]=s+dic_score[u]
  
  for v in tree_list[u]:
    if not visited[v]:
      dfs(v,ans_list[u])    
  return s

N,Q=map(int,input().split())

tree_list=[[] for _ in range(N+1)]
for i in range(N-1):
  a,b=map(int,input().split())
  tree_list[a].append(b)
  tree_list[b].append(a)
#print(tree_list)

dic_score=defaultdict(int)
for i in range(Q):
  p,x=map(int,input().split())
  dic_score[p]+=x

ans_list=[0]*(N+1)
visited=[False]*(N+1)
dfs(1,0)

print(*ans_list[1:])

Measured memory_bytes: 257268
#include <iostream>
#include <string>

using namespace std;

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

  int point_t = 0;
  int point_h = 0;
  string card_t;
  string card_h;
  for (int i = 0; i < n; ++i) {
    cin >> card_t >> card_h;
  
    if (card_t == card_h) {
      ++point_t;
      ++point_h;
      continue;
    }

    if (card_t < card_h)
      point_h += 3;
    else
      point_t += 3;
  }

  cout << point_t << " " << point_h << endl;
  return 0;
}

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

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

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

    bool flag = true;
    for(int i=0; i<n; i++){
        if(a[i] % 2 == 0 
        && a[i] % 3 != 0 
        && a[i] % 5 != 0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(unsigned int i = 0; i < (unsigned int)(n); i++)
using namespace std;

int main(){
  int N;
  cin >> N;

  int count = 0;
  rep(i,3){
    if(N%10==7){
      count++;
    }
    N=N/10;
  }
  if(count == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3624
#
# abc150 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10
ZABCDBABCQ"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """19
THREEONEFOURONEFIVE"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """33
ABCCABCBABCCABACBCBBABCBCBCBCABCB"""
        output = """5"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = input()
    print(S.count("ABC"))


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16240
#include<stdio.h>

void trace(int A[], int N){

	int i;
 for(i=0;i<N;i++){
   if(i>0)printf(" ");
   printf("%d", A[i]);
 }
printf("\n");
}

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

}

int main(){
	int N,i,j;
	int A[100];
	
	scanf("%d", &N);
	for(i=0; i<N; i++) scanf("%d", &A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	
	return 0;
	
	
}

Measured memory_bytes: 2748
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int a;
	cin>>a;
	string s;
	cin>>s;
	if(s.size()<=a)cout<<s<<endl;
	else cout<<s.substr(0,a)+"..."<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<list> 
#include <stdio.h>

using namespace std;

int main()
{
	string str;
	list<string> L;
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		if (str[6] == 'L')
		{
			L.pop_back();
		}
		else if (str[6] == 'F')
		{
			L.pop_front();
		}		
		else if (str[0] == 'd')
		{
			cin >> str;
			for (list<string>::iterator it = L.begin(); it != L.end(); it++)
			{
				if (*it == str)
				{
					L.erase(it);
					break;					
				}

			}
		}

		else 
		{

			cin >> str;
			L.push_front(str);
		}
	}
	
	int i = 0;
	for (list<string>::iterator it = L.begin(); it != L.end(); it++)
	{
		if (i++) cout << ' ';
		cout << *it;
	}

	cout << endl;

}


Measured memory_bytes: 81268
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        
        out.println(n*n*n);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22996
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInt()
	b := scanInt()
	c := scanInt()

	if c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b) {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans1 = a[0]
dif = 1e10
for i in a:
    if i==ans1:
        continue
    if abs(i-ans1//2)<dif:
        ans2 = i
        dif = abs(i-ans1//2)

print(ans1, ans2)

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

int main(){
    int S;
    int h, m, s;
    
    cin >> S;
    h = S / 3600;
    m = (S - h * 3600)/60;
    s = S - h * 3600 - m * 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3096
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

min_price = min(a) + min(b)
for _ in range(M):
    x, y, c = map(int, input().split())
    discount_price = a[x-1] + b[y-1] - c
    if min_price > discount_price:
        min_price = discount_price
        
print(min_price)


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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

	
int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	sort(all(s));
	if(s=="abc") puts("Yes");
	else puts("No");
	return 0;
	
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main () {
    int n, k;
    cin >> n >> k;
    set<int> m;
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int a; cin >> a;
            m.insert(a);
        }
    }
    cout << n - m.size() << endl;
     
    return 0;
}

Measured memory_bytes: 3184
N = int(input())
K = N % 2 + 1
A = tuple(map(int, input().split()))
table = [[-float("inf")] * (K + 2) for _ in range(N + 1)]
table[0][0] = 0
for i in range(N):
    for j in range(K + 1):
        table[i + 1][j] = max(table[i][j] + (A[i] if not (i + j) % 2 else 0), table[i + 1][j])
        table[i + 1][j + 1] = max(table[i][j], table[i + 1][j + 1])
print(table[N][K])


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

class MatrixChainMultiplication {
private:
	int n, *r, *c;
	int memory[100][100];
public:
	MatrixChainMultiplication(int _n, int _r[], int _c[]) {
		n = _n;
		r = _r;
		c = _c;
		for (int i=0; i<n; i++) {
			for (int j=1; j<=n; j++) {
				memory[i][j] = INT_MAX;
			}
		}
	}
	int count(int start, int end) {
		if (memory[start][end] != INT_MAX)
			return memory[start][end];
		
		if (start + 1 == end) {
			memory[start][end] = 0;
		} else {
			int temp;
			for (int i=start+1; i<end; i++) {
				temp = count(start, i) + count(i, end) + (r[start] * r[i] * c[end - 1]);
				if (memory[start][end] > temp) memory[start][end] = temp;
			}
		}
		return memory[start][end];
	}
};

int main() {
	int n, r[100], c[100];
	
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> r[i] >> c[i];
	}
	
	auto mcm = MatrixChainMultiplication(n, r, c);
	
	cout << mcm.count(0, n) << '\n';
	
	return 0;
}

Measured memory_bytes: 3148
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        out.println((5*n+6)/7<=(3*n)/4?"Yes":"No");
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

typedef pair<int,int> P;

const int INF=numeric_limits<int>::max();
const int N=1e5+5;
int n,m,dist[N];
vector<P> adj[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;++i){
		int l,r,d;
		cin>>l>>r>>d;
		adj[l].emplace_back(r,d);
		adj[r].emplace_back(l,-d);
	}
	for(int i=1;i<=n;++i) dist[i]=INF;
	for(int i=1;i<=n;++i)
		if(dist[i]==INF){
			dist[i]=0;
			queue<int> Q;
			Q.push(i);
			while(!Q.empty()){
				int u=Q.front();
				Q.pop();
				for(P nxt:adj[u]){
					int v=nxt.first;
					int d=nxt.second;
					if(dist[v]==INF){
						dist[v]=dist[u]+d;
						Q.push(v);
					}
					else if(dist[v]!=dist[u]+d){
						return cout<<"No\n",0;
					}
				}
			}
		}
	cout<<"Yes\n";
}




Measured memory_bytes: 12708
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int pow = 1;
		int[] num = {3,5,7};
		for(int i=1; i<=9; i++){
			pow *= 3;
			for(int j=0; j<=pow; j++){
				int[] check753 = {0,0,0};
				int num753 = 0;
				int p = j;
				int q;
				int o = 1;
				for(int k=0; k<i; k++){
					q = p % 3;
					num753 += num[q] * o;
					check753[q]++;
					p = (p-q)/3;
					o *= 10;
				}
				if(num753 > n){
					break;
				}
				int checker = 1;
				for(int k=0; k<3; k++){
					checker *= check753[k];
				}
				if(checker > 0){
					ans++;
				}
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 24148
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
string s;
ll memo[100100][4] = {0};
ll dp(ll i, ll j){
    if(i == s.size() && j == 3) return 1;
    if(i == s.size()) return 0;
    if(memo[i][j] != -1) return memo[i][j];

    ll res = 0;
    if(s[i] == '?'){
        if(j != 3) res += dp(i + 1, j + 1);
        res %= MOD;
        res += dp(i + 1, j) * 3;
        res %= MOD;
    } else {
        if(s[i] == 'C' && j == 2){
            res += dp(i + 1, j + 1);
        } else if(s[i] == 'B' && j == 1){
            res += dp(i + 1, j + 1);
        } else if(s[i] == 'A' && j == 0){
            res += dp(i + 1, j + 1);
        }
        res %= MOD;
        res += dp(i + 1, j);
        res %= MOD;
    }
    res %= MOD;
    return memo[i][j] = res;
}
int main(void){
    cin >> s;
    for(int i = 0; i <= s.size(); i++){
        for(int j = 0; j < 4; j++){
            memo[i][j] = -1;
        }
    }
    cout << dp(0, 0) % MOD << endl;
}

Measured memory_bytes: 8320
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;

int main() {
  int l;
  cin >> l;
  printf("%.12f\n", pow(l, 3) / 27.0);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int MAX = 101010;
LL A[MAX];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &A[i]);
    
    // 2. 品物の販売個数が最大になるようにする.
    LL ans = 0, cPrice = 0, resPrice = 0;
    rep(i, N){
        // 先頭の人には, 価格1 の品物を, (A[0] - 1)個 販売.
        if(i == 0){
            ans += A[i] - 1;
            A[0] = 1;
            resPrice = 2;
            continue;
        }
        
        // すでに販売したメンバーの残価格(resPrice)を比較して, 販売価格をチェック.
        // 等しかったら, メンバーの残価格を, インクリメント.
        if(A[i] == resPrice){
            resPrice++;
            continue;
        }
        
        // 2番目以降の人にも販売.
        LL c = A[i] / resPrice;
        if(A[i] ==  c * resPrice){
            // 価格(resPrice + 1) を 1個販売し, 残りを, 価格resPrice で, 販売.
            if(A[i] > resPrice + 1){
                ans++;
                A[i] -= (resPrice + 1);
                ans += A[i] / resPrice;
                A[i] %= resPrice;
                resPrice = max(resPrice, A[i] + 1);
            }
        }else{
            ans += c;
            A[i] %= resPrice;
            resPrice = max(resPrice, A[i] + 1);
        }
    }
    // rep(i, N) printf("%lld ", A[i]);
    // puts("");
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 1024
#include<stdio.h>

#define MAX 10000
#define NIL -1

void preParse(int);
void inParse(int);
void postParse(int);

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int n;

int main(){

  int i, v, l, r, root;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    T[i].p = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) root = i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

void preParse(int u){

  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);

}

void inParse(int u){

  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);

}

void postParse(int u){

  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

Measured memory_bytes: 620
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

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

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int N;
  cin >> N;
  cout << 1000*((N+999)/1000) - N << '\n';
}


Measured memory_bytes: 3636