akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>

using namespace std;

const int MAX_N = 10;
const int MAX_D = 10;

int main()
{
    int X[MAX_N][MAX_D];
    int N, D;
    cin >> N >> D;
    for(int n=0;n<N;n++){
        for(int d=0;d<D;d++){
            cin >> X[n][d];
        }
    }

    int length_sq, value, count=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            length_sq=0;
            for(int d=0;d<D;d++){
                length_sq += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]);
            }
            value = 1;
            while(value*value < 16001){
                if(value*value == length_sq){
                    count++;
                    break;
                }
                value++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli a, b;
	cin>>a>>b;
	if(a >= 10 || b >= 10)
		cout<<-1<<"\n";
	else
		cout<<a*b<<"\n";
}

int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S  = sc.nextLine();
    Deque<Character> deq = new ArrayDeque<>();
    for(int i = 0; i < S.length(); i++){
      if(S.charAt(i) == 'S'){
        deq.push(S.charAt(i));
      }else{
        if(deq.size() == 0 || deq.peek() != 'S'){
          deq.push(S.charAt(i));
        }else{
          deq.pop();
        }
      }
    }
    System.out.println(deq.size());
  }
}


Measured memory_bytes: 28940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=100;i>=0;i--){
    int sum=0;
    for(int j=0;j<n;j++){
      if(a[j]>=i)sum++;
    }
    if(sum>=i){
      cout<<i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int a;
    vector<int> vec;
    
    
    cin >> a;
    
    
    for(int i = 0; i < a; ++i){
        int b;
        cin >> b;
        vec.push_back(b);
    }
    
    int count = 0;
    int hight = 0;
    
    for(int value : vec){
        if(value >= hight){
            ++count;
            hight = value;
            
        }
            
    }
    
    printf("%d", count);
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Node{
  int key;
  int id,parent,left,right;
};


Node A[100000];

void heap(Node A[],int H){
  for(int i=1;i<=H;i++){
    if(i==1){
      A[i].left=A[2*i].key;
      A[i].right=A[2*i+1].key;
    }
    else {
      A[i].parent=A[i/2].key;
      A[i].left=A[2*i].key;
      A[i].right=A[2*i+1].key;
    }
  }
}


int main(){
  int H=0;
  cin>>H;
  for(int i=1;i<=H;i++){
    cin>>A[i].key;
    A[i].id=i;
  }
  heap(A,H);
  for(int i=1;i<=H;i++){
    cout<<"node "<<A[i].id<<": key = "<<A[i].key<<", ";
    if(i==1){
      cout<<"left key = "<<A[i].left<<", right key = "<<A[i].right<<", "<<endl;
    }
    else{
      if(A[i].left==0&&A[i].right!=0){
	cout<<"parent key = "<<A[i].parent<<", right key = "<<A[i].right<<", "<<endl;
      }
      else if(A[i].left!=0&&A[i].right==0){
	cout<<"parent key = "<<A[i].parent<<", left key = "<<A[i].left<<", "<<endl;
      }
      else if(A[i].left==0&&A[i].right==0){
	cout<<"parent key = "<<A[i].parent<<", "<<endl;
      }
      else {
	cout<<"parent key = "<<A[i].parent<<", left key = "<<A[i].left<<", right key = "<<A[i].right<<", "<<endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>
#include <math.h>
#include <string.h>
#define _USE_MATH_DEFINES


int main()
{
    int r,g,b,card;
    scanf("%d",&r);
    scanf("%d",&g);
    scanf("%d",&b);

    card=100*r+10*g+b;

    if(card%4==0)
	printf("YES\n");
    else
	printf("NO\n");

    return 0;
}




Measured memory_bytes: 128
// c++include
#include <iostream>
#include <algorithm>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(ll i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	string step;
	cin >> step;
	int flag = 0;
	for (int i = 0; step[i] != '\0'; i++) {
		if ((i + 1) % 2 == 0) {
			if (step[i] == 'R') {
				flag = 1;
				break;
			}
		}
		if ((i + 1) % 2 == 1) {
			if (step[i] == 'L') {
				flag = 1;
				break;
			}
		}
	}
	if (flag == 1)
		cout << "No";
	else
		cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int n;
    cin >> n;
    int d1[101], d2[101];
    for(int i = 0; i < n; i++) cin >> d1[i] >> d2[i];
    int count = 0;
    for(int i = 0; i < n; i++){
        if(d1[i] == d2[i]){
            count++;
            if(count == 3){
                cout << "Yes" << endl;
                return 0;
            }
        }
        else {
            count = 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const int N = 1e3 + 10 ;
char ch[N][N] ;
int dx[4] = {0 , 0 , -1 , 1} ;
int dy[4] = {-1 , 1 , 0 , 0} ;
map<pair<int,int> , pair<int,int>> parent ;
map<pair<int,int> , map<pair<int,int> , int>> g ;
int n , m ;

void dfs(pair<int,int> cur , pair<int,int> p){
	for(int i = 0 ; i < 4 ; i++){
		int cx = cur.first + dx[i] ;
		int cy = cur.second + dy[i] ;
		if(cx < 0 || cx >= n || cy < 0 || cy >= m || ch[cx][cy] == '#') continue ; 
		if(parent.count({cx,cy})) continue ;
		parent[{cx , cy}] = p ;
		dfs({cx , cy} , p) ;
	}
}

int	bfs(pair<int,int> s , pair<int,int> d){
	queue<pair< pair<int,int>  , int>> q ;
	q.push({s , 0}) ;
	map<pair<int,int> , int> visited ;
	visited[s] = true ;
	while(q.size()){
		auto [cur , dis] = q.front() ;
		q.pop() ;
		if(cur == d) return dis;
		for(auto i : g[cur]){
				if(visited[i.first]) continue ;
				visited[i.first] = 1 ;
				q.push({i.first , dis + 1}) ;
		}
	}
	return -1 ;
}

int32_t main(){
	cin >> n >> m ;
	pair<int,int> s , d ;
	cin >> s.first >> s.second ;
	cin >> d.first >> d.second ;
	s.first-- , s.second-- ;
	d.first-- , d.second-- ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			cin >> ch[i][j] ;
		}
	}
	for(int i = 0  ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			if(ch[i][j] == '#') continue ;
			if(parent.count({i,j})) continue ;
			dfs({i,j} , {i,j}) ;
		}
	}
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			if(!parent.count({i,j})) parent[{i,j}] = {i,j} ;
		}
	}
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			int p = i - 2 , q = j - 2 ;
			if(ch[i][j] == '#') continue ;
			for(int f = p ; f < p + 5 ; f++){
				for(int s = q ; s < q + 5 ; s++){
					if(f < 0 || f >= n || s < 0 || s >= m) continue ;
					if(ch[f][s] == '#') continue ;
					g[parent[{i,j}]][parent[{f,s}]] = 1 ;
				}
			}
		} 
	}
	cout << bfs(parent[s],parent[d]) ;
	return 0 ;
}



Measured memory_bytes: 124388
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int p[1010];
int x[1010];

vector<int> g[1010];
int l[1010];

bool s[5010];

void calc(int v) {
    int sum = 0;
    for (int u : g[v]) {
        calc(u);
        sum += x[u] + l[u];
        if (l[u] >= inf) {
            l[v] = inf;
            return;
        }
    }
    memset(s, false, sizeof(s));
    s[0] = true;
    for (int u : g[v]) {
        for (int i = 5000; i >= 0; i--) {
            if (s[i]) {
                s[i] = false;
                if (i + x[u] <= 5000) s[i+x[u]] = true;
                if (i + l[u] <= 5000) s[i+l[u]] = true;
            }
        }
    }
    int m = inf;
    for (int i = 0; i <= x[v]; i++) {
        if (s[i])
            m = i;
    }
    l[v] = (m < inf ? sum-m : inf);
}

bool solve() {
    for (int i = 1; i < n; i++) {
        g[p[i]].push_back(i);
    }
    calc(0);
    // for (int i = 0; i < n; i++) cout << i << ": " << l[i] << endl;
    return l[0] < inf;
}

void input() {
    cin >> n;
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < n; i++) cin >> x[i];
}

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

    input();
    cout << (solve()?"POSSIBLE":"IMPOSSIBLE") << endl;
}


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

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

const int N = 1005;
ll x[N][3], a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin>>x[i][j];
		}
	}
	ll ans = 0;
	for(int mask = 0; mask < 8; mask++){
		for(int i = 0; i < n; i++){
			a[i] = 0;
			for(int j = 0; j < 3; j++){
				if(mask&(1<<j))a[i] += x[i][j];
				else a[i] -= x[i][j];
			}
		}
		sort(a, a + n, greater<ll>());
		ll sum = accumulate(a, a + m, 0LL);
		ans = max(ans, sum);
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i = (int)(s-1); i >= (int)(e); --i)

const int MAX_N = 110;
ll dp_cal[MAX_N][MAX_N];
ll dp_h[MAX_N * MAX_N];
ll dp_de[MAX_N][MAX_N];

int main() {
	int S, T, U, N, O, D;
	cin >> S >> T >> U >> N >> O >> D;
	// cout << S << " " << T << " " << U << " " << O << " " << D << endl;
	vector<int> e(T), c(T);
	rep(i, T) cin >> e[i] >> c[i];
	vector<int> h(N), a(N);
	rep(i, N) cin >> h[i] >> a[i];

	// dp_col[i][j] := use hp i, j trainings =>  max get cal
	rep(i, MAX_N) rep(j, MAX_N )dp_cal[i][j] = -1;
	dp_cal[0][0] = 0;
	rep(i, T) {
		repr(k, U) {
			repr(j, MAX_N) {
				int tmp = j - e[i];
				if (tmp < 0 || dp_cal[tmp][k] < 0) continue;
				dp_cal[j][k + 1] = max(dp_cal[j][k + 1], dp_cal[tmp][k] + c[i]);
			}
		}
	}

	// dp_h[i] := eat cal i, max get happy
	rep(i, MAX_N * MAX_N) dp_h[i] = 0;
	dp_h[0] = 0;
	rep(i, N) {
		rep(j, MAX_N * MAX_N - a[i]) {
			// if(dp_h[j] < 0) continue;
			dp_h[j + a[i]] = max({dp_h[j + a[i]], dp_h[j] + h[i]});
		}
	}

	// dp_de[i][j] := day i, hp j => max get happy
	rep(i, MAX_N) rep(j, MAX_N) dp_de[i][j] = -1;
	dp_de[0][S] = 0;
	rep(i, D) {
		rep(hp, S + 1) {
			if (dp_de[i][hp] < 0) continue;
			int HP = min(S, hp + O);
			rep(use_hp, HP + 1) {
				ll cal = dp_cal[use_hp][U];
				if (cal < 0) continue;
				int nxtHP = HP - use_hp;
				dp_de[i + 1][nxtHP] = max(dp_de[i + 1][nxtHP], dp_de[i][hp] + dp_h[cal]);
			}
		}
	}
	ll ans = -1;
	rep(i, S + 1) {
		ans = max(ans, dp_de[D][i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3408
#include <iostream>

using namespace std;

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

int main() {
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++){
        if(n / i < 10 && n % i == 0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    ll N, C;
    cin >> N >> C;
    ll x[MAX], v[MAX];
    ll s[MAX]={};   //先頭からのカロリーの累積和
    ll r[MAX]={};   //後ろからのカロリーの累積和
    ll si[MAX]={};  //si[i]:i番目まででs[k]-x[k]が最大となるような位置k (k<=i)
    ll ssi[MAX]={}; //ssi[i]:i番目まででs[k]-x[k]*2が最大となるような位置k (k<=i)
    ll i;
    
    x[0]=0; v[0]=0;
    for(i=1; i<=N; i++) cin >> x[i] >> v[i];
    x[N+1]=C; v[N+1]=0;
    
    for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];
    for(i=N; i>=1; i--) r[i]=r[i+1]+v[i];
    
    ll mx=0, mi=0;
    for(i=1; i<=N; i++) {       //si[i]を求める
        if(s[i]-x[i]>mx) {
            mx=s[i]-x[i];
            mi=i;
        }
        si[i]=mi;
    }
    
    mx=0; mi=0;
    for(i=1; i<=N; i++) {       //ssi[i]を求める
        if(s[i]-x[i]*2>mx) {
            mx=s[i]-x[i]*2;
            mi=i;
        }
        ssi[i]=mi;
    }
    
    ll ans=0;
    for(ll b=1; b<=N+1; b++) {
        chmax(ans, s[si[b-1]]-x[si[b-1]]+r[b]-(C-x[b])*2);  //OA+2OBの場合
        chmax(ans, s[ssi[b-1]]-x[ssi[b-1]]*2+r[b]-(C-x[b]));//2OA+OBの場合
    }
    pt(ans);
}





Measured memory_bytes: 4992
#include<cstdio>
#include<cstdlib>
#include<cstring>
char s[100001];
char p[100001]="FESTIVAL";
int main()
{
  scanf("%s",s);
  for(int i=0; i<strlen(s)-8; ++i) putchar(s[i]);
//  printf("%s%s",s,p);
}

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

int main ()
{

  while(1)
  {
    int n = 0, x = 0, count = 0;
    cin >> n >> x;

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

    for(int i = 1; i <= n - 2; i++)
    {
      for(int j = i + 1; j <= n - 1; j++)
      {
        for(int k = j + 1; k <= n - 0; k++)
        {
          if(i + j + k == x)
          {
            count++;
          }
        }
      }
    }

    cout << count << endl;

  }

  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)


int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int res = 0;
	FOR(i, l, r) {
		if (i%d == 0) {
			res++;
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3584
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 087 C "Candies"
 *   https://abc087.contest.atcoder.jp/tasks/arc090_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int[][] A = in.nextIntArray(2, N);

		int sum1 = A[0][0];
		int sum2 = 0;
		for (int i = 0; i < N; i++) {
			sum2 += A[1][i];
		}

		int ans = sum1 + sum2;
		for (int i = 1; i < N; i++) {
			sum1 += A[0][i];
			sum2 -= A[1][i - 1];
			ans = Math.max(ans, sum1 + sum2);
		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;

typedef long long ll;


//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

int x[3];
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    REP(i, 0, 3) cin >> x[i];
    sort(x, x + 3);
    if(x[0]%2 == x[1]%2 && x[1]%2 == x[2]%2){
        cout << (x[2] - x[0]) / 2 + (x[2] - x[1]) / 2 << endl;
    }else if(x[0]%2 == x[1]%2 && x[1]%2 != x[2]%2){
        cout << (x[2] - x[0]) / 2 + (x[2] - x[1]) / 2 + 1 << endl;
    }else{
        cout << (x[2] - x[0]) / 2 + (x[2] - x[1]) / 2 + 2 << endl;
    }

}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  string S; cin >> S;
  REP(n,S.size()) {
    if(n%2 == 0 && S[n] == 'L') {
      cout << "No" << endl;
      return 0;
    } else if(n%2 == 1 && S[n] == 'R') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e3 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, k; 
ll fac[N], inv[N];
ll powmod(ll a, ll b) 
{
	a %= mod;
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
void init(int n)
{
	fac[0] = 1;
	for(int i=1;i<=n;i++) fac[i] = fac[i-1]*i%mod;
	inv[n] = powmod(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i] = inv[i+1]*(i+1)%mod;
}
ll comp(ll a,ll b)
{
	if(a<b||b<0||a<0) return 0;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	init(n);
 	for(int i=1; i<=k; i++)
 	{
 		ll ans = comp(n-k+1, i)*comp(k-1, i-1)%mod;
 		ans = (ans + mod)%mod;
 		cout << ans << '\n';
 	}
	return 0;
}


Measured memory_bytes: 256
import re

while True:
    s, c = input().split()
    if c == 'X':
        break

    if '_' in s:
        t = s.split('_')
    else:
        t = re.findall(r'^[a-z]+|[A-Z][a-z]*', s)

    if c == 'D':
        t = '_'.join(map(str.lower, t))
    else:
        t = ''.join(map(str.capitalize, t))
        if c == 'L':
            t = t[0].lower() + t[1:]

    print(t)



Measured memory_bytes: 6516
def ip():return list(map(int,input().split()))

n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
    temp=ip()
    c.append(temp[0])
    a.append(temp[1:])

ans=12*10**5+1
for i in range(1,2**n):
    f=bin(i)[2:]
    sum=[0]*m
    while len(f)<n:f='0'+f
    s=0
    for j in range(n):
        if f[j]=='1':
            s+=c[j]
            for h in range(m):
                sum[h]+=a[j][h]
    F=True
    for h in range(m):
        if sum[h]<x:F=False
    if F==True:ans=min(ans,s)
print(ans) if ans!=12*10**5+1 else print(-1)








Measured memory_bytes: 68764
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys
import numpy as np

INF = float('inf')


def solve(N: int, x: "List[int]", y: "List[int]"):
    def distance(x1, y1, x2, y2):
        return np.linalg.norm(np.array([x1, y1]) - np.array([x2, y2]))

    l = [[distance(x[i], y[i], x[j], y[j]) if j >
          i else 0 for j in range(N)] for i in range(N - 1)]

    return np.average([sum(l[r[i]][r[i+1]] if r[i] < r[i+1] else l[r[i+1]][r[i]] for i in range(N-1))
                       for r in its.permutations(range(N))])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    print(f'{solve(N, x, y)}')


if __name__ == '__main__':
    main()


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

#define MAX 200

int main(void)
{
    char string[MAX + 1];
    int h, repeat_num[100];

    // while (scanf("%s", string) != '-')
    for (;;)
    {
        scanf("%s", string);
        if (string[0] == '-')
            return 0;
        scanf("%d", &h);
        for (int i = 0; i < h; i++)
        {
            scanf("%d", &repeat_num[i]);
        }

        char replace;
        int i, j, k;
        for (i = 0; i < h; i++)
        {
            for (j = 0; j < repeat_num[i]; j++)
            {
                for (k = 0; k < strlen(string) - 1; k++)
                {
                    replace = string[k];
                    string[k] = string[k + 1];
                    string[k + 1] = replace;
                }
                // printf("TEST %d: %s\n", j, string);
            }
        }
        printf("%s\n", string);
    }
    return (0);
}


Measured memory_bytes: 2120
N = int(input())
H = list(map(int,input().split()))

max_count = 0
count = 0
try:
	for i in range(len(H)):
		if H[i] >= H[i+1]:
			# print(H[i],H[i+1],count+1)
			count += 1
		else:
			# print(H[i],H[i+1],0)
			max_count = max(max_count,count)
			count = 0
except:
	max_count = max(max_count,count)
print(max_count)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N;
  cin >> N;
  long long mon = 100LL,count = 0;
  while(mon < N){
    mon += mon / 100LL;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3612
import sys
import collections
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N,K,Q=nm()
Al=[0]*Q
ans_l=[K-Q]*N
for i in range(Q):
    #Al[i]=int(input())
    ans_l[int(input())-1]+=1
    


for i in range(N):
    #print(Al.count(i+1))
    #print('No' if (K-Q+Al.count(i+1)<1) else 'Yes')
    print('No' if (ans_l[i]<1) else 'Yes')

Measured memory_bytes: 7740
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  string s;cin>>s;
  int ans1 = 0;
  int ans2 = 0;
  int n=s.size();
  fol(i,n){
    if(s[i]=='0'){
      if(i%2){
        ans2++;
      }else{
        ans1++;
      }
    }else{
      if(i%2){
        ans1++;
      }else{
        ans2++;
      }
    }
  }
  cout << min(ans1,ans2) <<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int ans;

    if(A>B) {
        ans = A;
        A = A - 1;
    }else{
        ans = B;   
        B = B - 1;
    }
    
    if(A>B) {
        ans += A;
    }else{
        ans += B;
    }

    cout << ans << endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()) {
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

//ABC89 D
int main(void) {
	ll h, w, d;
	cin >> h >> w >> d;
	vector<pair<ll, ll>> a = vector<pair<ll, ll>>(h * w + 1);
	rep(i, 1, h+1) {
		rep(j, 1, w+1) {
			ll num;
			cin >> num;
			a[num] = make_pair(i, j);
		}
	}
	vector<ll> ruiseki = vector<ll>(h * w + 1, 0);
	rep(i, 1, d + 1) {
		for (ll j = i+d; j < h * w + 1; j += d) {
			pair<ll, ll> nowP = a[j - d];
			pair<ll, ll> nextP = a[j];
			ruiseki[j] = ruiseki[j - d] + abs(nowP.first - nextP.first) + abs(nowP.second - nextP.second);
		}
	}
	ll q;
	cin >> q;
	rep(i, 0, q) {
		ll l, r;
		cin >> l >> r;
		cout << ruiseki[r] - ruiseki[l] << endl;
	}
}

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

int main(){

  int a[4][4];
  for(int b=0;b<4;b++){
    cin >> a[0][b];
  }
  for(int c=0;c<4;c++){
    cin >> a[1][c];
  }

  if((a[0][0]+a[0][1]+a[0][2]+a[0][3]) > (a[1][0]+a[1][1]+a[1][2]+a[1][3])){
    cout << a[0][0]+a[0][1]+a[0][2]+a[0][3] << endl;
  }
  else{
    cout << a[1][0]+a[1][1]+a[1][2]+a[1][3] << endl;
  }

  return 0;
}

Measured memory_bytes: 3096
n = gets.to_i
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
d = ->(p) {
  sum = 0
  n.times {|i| sum += (x[i] - y[i]).abs ** p}
  sum ** (1 / p.to_f)
}

1.upto(3) {|i| puts d.(i)}
puts x.zip(y).map {|x, y| (x - y).abs.to_f}.max


Measured memory_bytes: 6916
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

const int MAX_N = 200000;
int N, Q;
vector<int> table[MAX_N];
int cnt[MAX_N];
int ret[MAX_N];

void dfs(int node, int par, int score) {
    score += cnt[node];
    ret[node] = score;

    for (int next : table[node]) {
        if (next == par) continue;
        dfs(next, node, score);
    }
}

signed main() {
    cin >> N >> Q;
    for (int j = 0; j < N - 1; j++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        table[a].push_back(b);
        table[b].push_back(a);
    }

    for (int q = 0; q < Q; q++) {
        int p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }

    dfs(0, -1, 0);

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

Measured memory_bytes: 25600
#include <bits/stdc++.h>
 
int main(){
  int num1,num2;
  std::string str;
  std::cin >> num1 >> num2 >> str;
  for(int i = 0;i <num1 + num2;i++ ){
    if(i==num1){
      if(!(str[i]=='-')){std::cout << "No"<< '\n' ;return 0;}
    }
    else{
      if(!(str[i]>=0x30 && str[i]<=0x39)){std::cout << "No"<< '\n' ;return 0;}
    }
  }
  std::cout << "Yes" << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n) cin >> l.at(i);
  int sum = 0;
  int count = 1;
  rep(i,n){
    sum+=l.at(i);
    if(sum>x) break;
    count++;
  }
  cout << count << endl;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;
    cout << 6 - (a + b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 998244353;
constexpr ll modsize = 1000010;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc() {
	if (modsize == 0) abort();
	fac[0] = 1; fac[1] = 1; inv[1] = 1;
	facinv[0] = 1; facinv[1] = 1;
	for (ll i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modinv(ll a) {
	if (a == 0) abort();
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0 || n == 0 && k > 0) return 0;
	if (n == 0 && k == 0) return 1;
	return fac[n + k - 1] * facinv[k] % mod * facinv[n - 1] % mod;
}

ll solve(ll n, ll m, ll k) {
	ll cnt = modcomb(n, m); ll res = cnt;
	rep(i, k) {
		if (i & 1) {
			cnt += modcomb(i, i / 2)*modcomb(n - i - 1, m - i / 2 - 1) % mod;
			if (cnt >= mod) cnt -= mod;
		}
		else {
			cnt -= modcomb(i, i / 2)*modcomb(n - i - 1, m - i / 2) % mod;
			if (cnt < 0) cnt += mod;
		}
		res += cnt;
		if (res >= mod) res -= mod;
	}
	return res;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	modcalc();

	ll n, m;
	cin >> n >> m;
	if (n < m) swap(n, m);
	ll ans = solve(n + m - 1, m - 1, 2 * (m - 1)) + solve(n + m - 1, n - 1, n + m - 1);
	for (ll i = 1; i <= m; i++) ans += modcomb(2 * i - 1, i) * modcomb(n + m - 2 * i, m - i) % mod;
	ans %= mod;
	ans *= modinv(modcomb(n + m, m)); ans %= mod;
	cout << ans << '\n';
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 998244353;
ll mod(ll a){	return a % M;	}
void plmod(ll &a,ll b){	a = (a + b) % M;	return;	}

#define MAX_N 2000
#define MAX_K 2000

ll c[MAX_N + MAX_K][MAX_N + 1];
ll p[MAX_K + 1];

void choose(int x){
	for(int n = 0; n < x; ++n) for(int k = 0;k <= min(n, MAX_N); ++k){
		if(k == n || k == 0) c[n][k] = 1LL;
		else c[n][k] = mod(c[n - 1][k - 1] + c[n - 1][k]);
	}
}

void power(int x){
	p[0] = 1LL;
	for(int i = 1; i <= x; ++i) p[i] = mod(p[i - 1] * 2LL);
}

ll f(int s, int k, int n){
	ll ret = 0LL;
	int t = k - 2*s;
	for(int j = max(0, 1-t); j <= min(s, n); ++j) plmod(ret, mod(mod(c[s][j] * p[j]) * c[n + t - 1][n - j]));
	return ret;
}

int main(){
	int k, n;
	scanf("%d %d", &k, &n);
	choose(k + n);
	power(k);
	for(int i = 2; i <= 2*k; ++i){
		if(i%2 == 1) cout << f(((i-1)/2) - max(1, i-k) + 1, k, n) << endl;
		else cout << mod(f((i/2)-1 - max(1, i-k) + 1, k - 1, n) + f((i/2)-1 - max(1, i-k) + 1, k - 1, n - 1)) << endl;
	}
	return 0;
}


Measured memory_bytes: 61440
#include<stdio.h>
#include<string.h>
main()
{
int n,i,j;
char ch[100];
scanf("%d",&n);
scanf("%s",ch);
i=strlen(ch);
if(i>n)
{
for(j=0;j<n;j++)
{
printf("%c",ch[j]);
}
printf("...\n");
}
else printf("%s\n",ch);
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];
    for(int i = N-2; i >= 0; i--)
    {
        if(H[i] - H[i+1] > 1)
        {
            No; return;
        }
        else if(H[i] > H[i+1]) H[i]--;
    }
    Yes; 
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main()
{
	int n;
	long long k;
	int a[200000];
	map<int, ll> b;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int dst = 1;
	int loop = 0;

	for (ll i = 1; i <= k; i++)
	{
		dst = a[dst - 1];
		auto it = b.find(dst);
		if (it != b.end())
		{
			loop = i - it->second;

			k = i + (k - i) % loop;
		}
		else
		{
			b[dst] = i;
		}
	}
	cout << dst << endl;
}

Measured memory_bytes: 14404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long a;
  long long answer = 0;
  for(int i = 0 ; i < N; ++i){
    cin >> a;
    answer += a - 1;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

int main(){
    int n, t, x;
    cin >> n;
    set<int> as;
    for(int i = 0; i < n; i++){
        cin >> t >> x;
        if (t == 0){
            as.insert(x);
            cout << as.size() << endl;;
        }else if (as.find(x) != as.end()){
            cout << '1' << endl;
        }else{
            cout << '0' << endl;
        }
    }
}


Measured memory_bytes: 12524
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let _n: usize = util::get();
    let mut a: Vec<usize> = util::gets();
    a.sort_by_key(|&x| -(x as i64));
    let grouped: Vec<(usize, usize)> = {
        let mut res = a.iter().fold(
            (Vec::new(), (0, 0)),
            |(mut v, (l, c)), &len| if l == len {
                (v, (l, c + 1))
            } else {
                v.push((l, c));
                (v, (len, 1))
            },
        );
        res.0.push(res.1);
        res.0.into_iter().filter(|&(_, c)| c >= 2).collect()
    };

    println!(
        "{}",
        if grouped.len() > 0 && grouped[0].1 >= 4 {
            grouped[0].0 * grouped[0].0
        } else if grouped.len() >= 2 {
            grouped[0].0 * grouped[1].0
        } else {
            0
        }
    );
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  REV(A);
  ll count=1;
  ll ans=1;
  FOR(i,1,n){
    if(A[i-1]<=A[i]){
      count++;
    }
    else{
      chmax(ans,count);
      count=1;
    }
  }
  chmax(ans,count);
  co(ans-1)
}

Measured memory_bytes: 1792
p = 10**9 + 7
S = input()
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(2)]
dp[0][0] = 1 # i = N - 1のケースでうまくいくための処置
r = 0

for i in range(N - 1,  -1,  -1):  # 小さい桁から順に
    w = 1 if i == N - 1 else (w * 10) % 13 # 各桁の重み
    r = 1 - r  # dpの0行目と1行目を交互に使う
    if S[i] == '?':
        for j in range(13):
            for k in range(10): # ?の値が0, 1, ..., 9のとき
                dp[r][(j + w * k) % 13] += dp[1 - r][j]
                if dp[r][(j + w * k) % 13] >= p:
                    dp[r][(j + w * k) % 13] -= p
    else:
        k = int(S[i])
        for j in range(13):
            dp[r][(j + w * k) % 13] = dp[1 - r][j]

    dp[1 - r] = [0] * 13

print(dp[r][5])


Measured memory_bytes: 44012
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int[] c = new int[n];
    int[][] a = new int[n][m];
    for(int i = 0; i < n; i++) {
      c[i] = sc.nextInt();
      for(int j = 0; j < m; j++) {
        a[i][j] = sc.nextInt();
      }
    }
    int ans = (int)Math.pow(10, 7);
    for(int i = 1; i < (int)Math.pow(2, n); i++) {
      int t = 0;
      int[] tt = new int[m];
      for(int j = 0; j < n; j++) {
        if((i & (1 << j)) != 0) {
          t += c[j];
          for(int k = 0; k < m; k++) {
            tt[k] += a[j][k];
          }
        }
      }
      int q = 0;
      for(int j = 0; j < m; j++) {
        if(tt[j] >= x) q++;
      }
      if(q == m) ans = Math.min(ans, t);
    }
    if(ans == (int)Math.pow(10, 7)) ans = -1;
    System.out.println(ans);
  }
}

Measured memory_bytes: 37320