akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
        using namespace std;
        int main()
        {
           int n,l;
           cin>>n>>l;
          
             int arr[n+1],sum=0;
            for(int i=1;i<=n;i++)
            {
               arr[i]=l+i-1;
               sum+=arr[i];
            }
          
            long int c;
          
             for(int i=1;i<=n;i++)
             {
                 long int diff,sum1=0;
                 for(int j=1;j<=n;j++)
                 {
                     if(i!=j)
                     sum1+=arr[j];
                 }
                  
                    if(i==1)
                    { 
                      diff=abs(sum-sum1);
                        c=sum1;
                    }
                      
                  
                     else if(diff > abs(sum-sum1))
                     {
                        c=sum1;
                        diff=abs(sum-sum1);
                     }
             }
              cout<<c;
        }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<pair<int, int>> A(N);
    
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        A[i] = make_pair(a, i); 
    }

    sort(A.begin(), A.end(), greater<pair<int, int>>());

    int maxIndex = A[0].second;
    int maxA = A[0].first;
    int secondA = A[1].first;
    for(int i = 0; i < N; i++){
        if(i == maxIndex){
            cout << secondA << endl;
        }
        else{
            cout << maxA << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
import heapq
import sys
sys.setrecursionlimit(10**6)
 
N,u,v = map(int, input().split())
 
es = [[] for _ in range(N+1)]
 
for i in range(N-1):
    a,b = map(int, input().split())
    es[a].append(b)
    es[b].append(a)
 
INF = float("inf")
from_u = [INF] * (N+1)
from_u[u] = -1
from_v = [INF] * (N+1)
from_v[v] = -1
 
def solve(prev, curr, distances):
    distances[curr] = distances[prev] + 1
    for next in es[curr]:
        if distances[next] == INF:
            solve(curr, next, distances)
 
solve(u,u,from_u)
solve(v,v,from_v)
 
 
 
ans = 0
for i in range(1,N+1):
    if from_u[i] < from_v[i]:
        # 追い詰めた段階で高橋君が自ら青木君のマスに戻ってくるので、最後の端っこまで追い詰めなくていいから-1
        ans = max(ans, from_v[i]-1)
 
print(ans)

Measured memory_bytes: 101592
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 2e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int ann[MAXN];

int main(){
  fio();
  int  n; cin>>n;
  vector<LL> v(n);

  forn(i,n-1){
   cin>>v[i];
   ann[v[i]]++;
	}	
	for1(i,n) cout<<ann[i]<<endl;
  return 0;
}

Measured memory_bytes: 5448
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
vector< vector<int> > v(100000);
int visited[10010] = {0};
int depth[100010] = {0};
int mini[100010] = {0};
int V,E,s,t;
int inf = 1e9;
vector<int> ans;

int dfs(int n,int m){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0){
			depth[v[n][i]] = depth[n] + 1;
			dfs(v[n][i],n);
		}
	}
	for(int i=0;i<v[n].size();i++){
		if(v[n][i]!=m) mini[n] = min(mini[n],min(depth[n],depth[v[n][i]]));
	}
}

int dfs2(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0){
			dfs2(v[n][i]);
			mini[n] = min(mini[n],mini[v[n][i]]);
			if(n!=0 && depth[n]<=mini[v[n][i]]) ans.push_back(n);
		}
	}
}

int main(){
	cin >> V >> E;
	for(int i=0;i<E;i++){
		cin >> s >> t;
		v[s].push_back(t);
		v[t].push_back(s);
	}
	for(int i=0;i<V;i++) mini[i] = inf;
	dfs(0,-1);
	int count = 0;
	for(int i=0;i<V;i++){
		visited[i] = 0;
		if(depth[i]==1) count++;
	}
	if(count>=2) ans.push_back(0);
	dfs2(0);
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		if(i==0 || ans[i]!=ans[i-1]) cout << ans[i] << endl;
	}
}


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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;
const lint MAX = 1e5 + 10;

lint fac[MAX], finv[MAX], inv[MAX];

void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(lint 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;
    }
}

lint perm(int n, int k) {
    if(n < k) {
        return 0;
    }
    if(n < 0 || k < 0) {
        return 0;
    }
    return (fac[n] * finv[n - k]) % MOD;
}

V<lint> bfs(lint N, lint v0, VV<lint> edge) {

    V<lint> d(N, -1);
    d[v0] = 0;

    deque<lint> q;
    q.emplace_back(v0);

    while(not q.empty()) {
        lint v = q.front();
        q.pop_front();
        for(auto &&nv : edge[v]) {
            if(d[nv] == -1) {
                q.emplace_back(nv);
                d[nv] = d[v] + 1;
            }
        }
    }

    return d;
}

void solve() {
    lint N, K;
    cin >> N >> K;

    VV<lint> edge(N);
    rep(i, N - 1) {
        lint a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }

    auto d = bfs(N, 0, edge);

    VV<lint> dag(N);
    rep(i, N) {
        for(auto &&j : edge[i]) {
            if(d[i] < d[j]) {
                dag[i].emplace_back(j);
            }
        }
    }

    deque<lint> q;
    q.emplace_back(0);

    lint ans = K;
    while(not q.empty()) {
        lint v = q.front();
        q.pop_front();

        if(d[v] == 0) {
            ans *= perm(K - 1, dag[v].size());
            ans %= MOD;
        } else {
            ans *= perm(K - 2, dag[v].size());
            ans %= MOD;
        }

        for(auto &&nv : dag[v]) {
            q.emplace_back(nv);
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    com_init();
    solve();
}

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

int main() {
  int N;
  cin >> N;
  
  string n = to_string(N);
  
  if (n[0] == n[1]) {
    if (n[1] == n[2]) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else if (n[1]==n[2] && n[2]==n[3]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <string>

using std::cin;
using std::cout;
using std::endl;

int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0;i--) fact *= i;
  return fact;
}


void count_order()
{
  int n;
  cin >> n;

  std::vector<int> p(n);
  std::vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];


  int p_cnt = 0, q_cnt = 0;
  for (int i = 0; i < n; i++)
  {
    p_cnt += (p[i]-1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (p[j] > p[i]) p[j]--;
    }
  }
  for (int i = 0; i < n; i++)
  {
    q_cnt += (q[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (q[j] > q[i]) q[j]--;
    }
  }
  cout << std::abs(p_cnt - q_cnt);
}


void welcome_atcoder()
{
  int n, m;
  cin >> n >> m;
  int pena = 0;
  std::vector<int> ac(n + 1, 0);//インデックスを無理やりpに合わせた
  std::vector<int> wa(n + 1, 0);

  for (int i = 0; i < m; i++) 
  {
    int p; 
    std::string s;
    cin >> p >> s;

    if (s == "WA") wa[p]++;
    if (ac[p] == 1) continue;
    if (ac[p] == 0 && s == "AC")
    {
      ac[p] = 1;
      pena += wa[p];
    }
  }

  int ans = 0;
  for (int i = 0; i < n + 1; i++) if (ac[i] == 1) ans++;
  cout << ans << " " << pena << endl;
}


void low_elements()
{
  int n;
  cin >> n;
  std::vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i]; 
  int min = 1000000;
  int cnt = 0;

  for (int i = 0; i < n; i++)
  {
    if (p[i] < min)
    {
      cnt++;
      min = p[i];
    }
  }
  cout << cnt << endl;
}


int main() 
{
  //count_order();
  //welcome_atcoder();
  low_elements();
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s1, s2, s3;
	cin >> s1 >> s2;

	if (s1.length() > s2.length()) cout << "GREATER";
	else if (s1.length() < s2.length()) cout << "LESS";
	else if (s1 == s2) cout << "EQUAL";
	else if (s1 < s2) cout << "LESS";
	else cout << "GREATER";

	
	return 0;
}


Measured memory_bytes: 256
N, T = [int(i) for i in input().split()]


min_cost = 1001
for c, t in [input().split() for _ in range(N)]:
    c, t = int(c), int(t)
    if t > T:
        continue
    min_cost = min(min_cost, c)

ans = min_cost if min_cost < 1001 else "TLE"
print(ans)

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


long long int knapsack(int wt[] , int v[] ,int W , int N)
{
	int i , j;
	long long int t[N + 1][W + 1];
	
	for(i = 0 ; i < N+1; i++)
		t[i][0] = 0;
	for(i = 0 ; i < W + 1; i++)
		t[0][i] = 0;
	
	for(i = 1; i < N+1; i++)
	{
		for(j = 1; j < W + 1; j++)
		{
			if(wt[i-1] <= j)
				t[i][j] = max(v[i-1] + t[i-1][j-wt[i-1]] , t[i-1][j]);
			else
				t[i][j] = t[i-1][j];
		}
	}
	return t[N][W];

}

int main()
{

	int N , i , j ,W;
	cin >> N >> W;
	int w[N] , v[N];
	for(i = 0 ; i < N;i++)
		cin >> w[i] >> v[i];
	cout << knapsack(w , v , W , N) << "\n";


	return 0;
}

Measured memory_bytes: 82484
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

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


Measured memory_bytes: 1020
N = int(input())
l = []
now = [0,0,0]
ans = 'Yes'
for _ in range(N):
    inp = list(map(int,input().split()))
    l.append(inp)

for i in range(N):
    shortest = abs(l[i][1] - now[1]) + abs(l[i][2] - now[2])
    if shortest > l[i][0]-now[0]:
        ans = 'No'
        break
    a = l[i][0] -now[0]- shortest
    if a % 2 !=0:
        ans = 'No'
        break
    else:
        now = l[i]
print(ans)

Measured memory_bytes: 27040
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		Map<Integer, Long> map = new TreeMap<>();
		for(int i = 0 ; i < n ; i++) {
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + b[i]);
			} else {
				map.put(a[i], (long)b[i]);
			}
		}
		for(int key : map.keySet()) {
			k -= map.get(key);
			if(k <= 0) {
				System.out.println(key);
				return;
			}
		}
	}
}


Measured memory_bytes: 89380
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int R0,W0,C,R;

int main() {
	cout << fixed << setprecision(18);
	long long int res=0;
	cin>>R0>>W0>>C>>R;
	
	while(R0!=0){
		res=0;
		while(R0<W0*C){
			R0+=R;
			res++;
		}
		cout<<res<<endl;
		cin>>R0>>W0>>C>>R;
	}
} 


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

int main() {
  int s = 0;
  cin >> s;
  int s1 = s%10;
  int s2 = ((s-s1)%100) / 10;
  int s3 = (s -s1 - s2 * 10)/100;
  cout << s1 + s2 + s3 << endl;
}

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

int pop();
void push(int);
int s2[100],top=0;

int main(){
  int x,a,b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      x = a+b;
      s2[top]=x;
      top++;
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      x = b-a;
      s2[top]=x;
      top++;
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      x = a*b;
      s2[top]=x;
      top++;
    } else {
      x = atoi(s);
      s2[top]=x;
      top++;
    }
  }
  printf("%d\n",x);
  return 0;
}
int pop(){
  top--;
  return s2[top];
}

Measured memory_bytes: 548
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int[][] cf=new int[n+2][26];
		for(int i=n; i>=1; i--){
			for(int j=0; j<26; j++){
				cf[i][j]=cf[i+1][j];
			}
			cf[i][s.charAt(i-1)-'A']++;
		}
		long ans=0;
		for(int i=1; i<n-1; i++){
			for(int j=0; j<i; j++){
				if(s.charAt(i)!=s.charAt(j)){
					if((s.charAt(i)=='R' && s.charAt(j)=='G') || (s.charAt(i)=='G' && s.charAt(j)=='R')){
						ans+=cf[i+2]['B'-'A'];
						if(2*i-j<n && s.charAt(2*i-j)=='B'){
							ans--;
						}
					}else if((s.charAt(i)=='B' && s.charAt(j)=='G') || (s.charAt(i)=='G' && s.charAt(j)=='B')){
						ans+=cf[i+2]['R'-'A'];
						if(2*i-j<n && s.charAt(2*i-j)=='R'){
							ans--;
						}
					}else{
						ans+=cf[i+2]['G'-'A'];
						if(2*i-j<n && s.charAt(2*i-j)=='G'){
							ans--;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 39604
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n > 0){
    n /= k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
 int N;
 int T;
 int t[200000];
 int c;
 int i;
 int ans=0;
 int chk=0;
 cin>>N>>T;
 for(c=0;c<N;c++){
 	cin>>t[c];
 }
 
 for(c=0;c<N-1;c++){
 	chk=t[c+1]-t[c];
 	if(T>chk){
		ans=ans+chk;
	}else{
		ans=ans+T;
 	}
 }
 ans=ans+T;
 
 cout<<ans<<endl;
}

Measured memory_bytes: 1024
fn main() {
    let l = read::<f64>();
    let ans = l * l * l / 27.0;
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using MII = map<int,int>;

tuple<int,int,int> max12(MII &M){
	int v1 = 0, c1 = 0, c2 = 0;
	for(auto p:M)
		if(c1 < p.second){ c2 = c1; tie(v1, c1) = p; }
		else if(c2 < p.second) c2 = p.second;
	return make_tuple(v1, c1, c2);
}

int in(){int x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	MII E,O; rp(i, 0, N/2){ E[in()]++; O[in()]++; }

	int e1, e1c, e2c, o1, o1c, o2c;
	tie(e1, e1c, e2c) = max12(E);
	tie(o1, o1c, o2c) = max12(O);

	int ans = N - (e1!=o1? e1c+o1c: max(e1c+o2c, e2c+o1c));
	cout<< ans <<endl;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(typeof(n) i=(a); i<(n); i++)

int N;
int a[100010];
bool pushed[100010];

int main() {
	cin >> N;
    rep(i, N) cin >> a[i+1];
    
    int i = 1, cnt = 0;
    while(i!=2) {
        if(pushed[i]) {cout << -1 << endl; return 0;}
        pushed[i] = true;
        i = a[i];
        cnt++;
    }
    cout<< cnt << endl;
}


Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BROTN solver = new BROTN();
        solver.solve(1, in, out);
        out.close();
    }

    static class BROTN {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int shift = in.nextInt();
            String s = in.next();
            StringBuilder res = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                int tmp = ((s.charAt(i) - 'A') + shift) % 26;
                char newC = (char) ('A' + tmp);
                res.append(newC);
            }
            out.println(res);
        }

    }
}



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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

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

  ll a, b, h;
  std::cin >> a >> b >> h;

  ll ans = (a + b) * (h / 2);
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////



int main() {

	string S;
	cin >> S;

	vector<int> remain(S.size());

	vector<int> index(2019, 0); //2019の余りの数;

	index[0] = 1;

	int now = 0;
	int ten = 1;
	rep(i, S.size()) {
		ten %= 2019;
		now = now + (S[S.size() - 1 - i] - '0')*ten;		
		now %= 2019;
		ten *= 10;
		remain[S.size() - 1 - i] = now;
		index[now]++;
	}

	long long ans = 0;
	rep(i, 2019) {
		int s = index[i] * (index[i] - 1) / 2;
		ans += s;
	}

	cout << ans << endl;

}


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

#define int long long

const int maxn=1e3+10;
const int maxm=1e5+10;

struct Dinic{
	Dinic(){cnte=1;}
	int cnte;
	int ver[maxm];
	int cap[maxm];
	int cur[maxn];
	int head[maxn];
	int next[maxm];
	void addedge(int x,int y,int c){
		cnte++;
		ver[cnte]=y;
		cap[cnte]=c;
		next[cnte]=head[x];
		head[x]=cnte;
		cnte++;
		ver[cnte]=x;
		cap[cnte]=0;
		next[cnte]=head[y];
		head[y]=cnte;
	}
	int S,T,clk;
	int vis[maxn];
	int depth[maxn];
	bool bfs(){
		vis[S]=++clk;
		std::queue<int> q;
		q.push(S);
		while (!q.empty()){
			int u=q.front();q.pop();
			cur[u]=head[u];
			for (int i=head[u],v;i;i=next[i])
				if (cap[i]&&vis[v=ver[i]]!=clk){
					vis[v]=clk;
					depth[v]=depth[u]+1;
					q.push(v);
				}
		}
		return vis[T]==clk;
	}
	int dfs(int u,int a){
		if (u==T||a==0)
			return a;
		int ret=0;
		for (int &i=cur[u],f,v;i;i=next[i])
			if (depth[v=ver[i]]==depth[u]+1){
				f=dfs(v,std::min(cap[i],a));
				a-=f;
				ret+=f;
				cap[i]-=f;
				cap[i^1]+=f;
				if (a==0)
					break;
			}
		return ret;
	}
	inline int operator () (const int& s,const int& t){
		S=s,T=t;
		int ans=0;
		while (bfs())
			ans+=dfs(S,INT_MAX);
		return ans;
	}
}solver;

int N,S,T;
int sum;
int nodecnt;
int a[maxn];
int idx[maxn];

signed main (){
#ifdef LOCAL
	freopen("input","r",stdin);
#endif
	std::cin >> N;
	S=++nodecnt,T=++nodecnt;
	for (int i=1;i<=N;i++){
		std::cin >> a[i];
		idx[i]=++nodecnt;
	}
	for (int i=1;i<=N;i++){
		if (a[i]>0)sum+=a[i],solver.addedge(S,idx[i],a[i]);
		else solver.addedge(idx[i],T,-a[i]);
		for (int d=1;d<i;d++)
			if (i%d==0)
				solver.addedge(idx[i],idx[d],INT_MAX);
	}
	std::cout << sum-solver(S,T) << '\n';
	return 0;
}



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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;
int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int const N = 200 * 1010;

/********************i**********************************/
int fun(int a, int b){
	if(a == b)return 1;
	return 2;
}
void solve(){
	int n;
	cin >> n;
	map<pair<int, int>, int> ma;
	for(int x = 1; x<= n; x++){
		int u = x;
		int last = x % 10, first = 1;
		if(x % 10 != 0){
			while(u){
				first = u % 10;
				u /=  10;
			}
			ma[{first, last}]++;
		}
	}
	ll ans = 0;
	for(int x = 1; x<= n; x++){
		int u = x;
		int last = x % 10, first = 1;
		if(x % 10 != 0){
			while(u){
				first = u % 10;
				u /=  10;
			}
			if(ma.find({last, first}) != ma.end())ans += ma[{last, first}];
		}
	}

	cout << ans;
}

/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
-- AtCoder Beginner Contest 134 C
import Control.Monad
import Control.Applicative
import Data.List
import Data.Ord

toInt :: String -> Int
toInt x = read x :: Int

getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y

merge :: Ord a => [a] -> [a] -> [a]
merge xs [] = xs
merge [] ys = ys
merge (x : xs) (y : ys)
  | x >= y = x : (merge xs (y : ys))
  | otherwise = y : (merge (x : xs) ys)

halve :: [a] -> ([a], [a])
halve xs = splitAt (div (length xs) 2) xs

msort :: Ord a => [a] -> [a]
msort [] = []
msort [x] = [x]
msort xs = merge (msort ys) (msort zs)
  where (ys, zs) = halve xs

top2 :: [a] -> [a]
top2 (x0 : (x1 : xs)) = [x0, x1]

sw :: Ord a => [a] -> a -> a
sw [x0, x1] x
  | x < x0 = x0
  | otherwise = x1

main :: IO()
main = do
  n <- readLn
  as <- replicateM n readLn
  let bs = top2 $ msort (as :: [Integer])
  mapM_ print $ map (sw bs) as

Measured memory_bytes: 90748
import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d1 = []
    d2 = []
    for i in range(n):
        t = sys.stdin.readline().split()
        tmp = "".join(t)
        d1.append(int(tmp))
    for i in range(n):
        d2.append(na())

    ans = -10**9
    for i in range(1, 2 ** 10):
        cost = 0
        for j in range(n):
            b = i & int(str(d1[j]),2)
            b = list(format(b, "b"))
            b = [int(n) for n in b]
            b = sum(b)
            cost += d2[j][b]

        ans = max(ans, cost)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
int is_r[100000];
int main(void){
    int i,bot,top,ans=0,temp,t1,t2,t4,t5;
    for(i=0;i<100000;i++){
        is_r[i]=0;
    }
    for(i=10000;i<100000;i++){
        temp=i;
        t5=temp%10;
        temp=temp/10;
        t4=temp%10;
        temp=temp/100;
        t2=temp%10;
        temp=temp/10;
        t1=temp;
        if(t1==t5 && t2==t4){
            is_r[i]=1;
        }
    }
    scanf("%d %d",&bot,&top);
    for(i=bot;i<=top;i++){
        ans+=is_r[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println((c / a) * b);
    sc.close();
  }
}

Measured memory_bytes: 23124
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	ll n;
	cin >> n;
	map<string, int> m;
	m["AC"] = 0;
	m["TLE"] = 0;
	m["WA"] = 0;
	m["RE"] = 0;
	while (n--)
	{
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
int pa[MAX];
int ra[MAX];
void init(){
  for(int i=0;i<MAX;i++){
    pa[i]=i;
    ra[i]=0;
  }
}

int find(int x){
  if(pa[x]==x)return x;
  else return pa[x]=find(pa[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(ra[x]<ra[y])swap(x,y);
  pa[y]=x;
  if(ra[x]==ra[y])ra[x]++;
}

bool same(int x,int y){
  return (find(x)==find(y));
}

int N,M;
int K[MAX];
vector<int> G[MAX];

int main(){
  init();
  scanf("%d %d",&N,&M);
  for(int i=0;i<N;i++){
    scanf("%d",&K[i]);
    for(int j=0;j<K[i];j++){
      int id;
      scanf("%d",&id);
      id--;
      if(G[i].size() > 0)unite(G[i].back()+N , id+N);
      G[i].push_back(id);
      unite( i , N+id);
    }
  }
  
  int cnt=0;
  for(int i=0;i<N;i++){
    if(!same(0,i))cnt++;
  }
  
  if(cnt==0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}

int main(void) 
{
	int x; cin >> x;
	int z = x % 100;
	int a = x / 100;
	if (z == 0) {
		cout << 1 << endl;
		return 0;
	}
	else {
		if (z / 5 <= a){
			if (z % 5 == 0) {
				cout << 1 << endl;
				return 0;
			}
			else {
				if (z / 5 + 1 <= a) {
					cout << 1 << endl;
					return 0;
				}
				else {
					cout << 0 << endl;
					return 0;
				}
			}
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n=gets.to_i
res=0
for i in 0..Math.log10(n).to_i
	if(i==Math.log10(n).to_i and (i-1)%2==1)
		res+=(n-10**i+1)
		break
	end
	res+=9*10**i if((i-1)%2==1)
end
p res

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

int main() {
  int N;
  cin >> N;
  int A[30];
  int B[30];
  int C[30];

  for(int i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  for(int i = 1; i <= N; ++i) {
    cin >> B[i];
  }
  for(int i = 1; i <= N - 1; ++i) {
    cin >> C[i];
  }

  int score = 0;
  int prev = -1;
  for(int i = 1; i <= N; ++i) {
    score += B[A[i]];
    if(A[i] - prev == 1) {
      score += C[prev];
    }
    prev = A[i];
  }
  cout << score << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

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

s = ns()
s = list(s)

print(min(s.count('0'),s.count('1'))*2)

Measured memory_bytes: 3956
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
L = [list(map(int, input().split())) for _ in range(M)]

res = min(a) + min(b)
for x, y, c in L:
    tres = a[x - 1] + b[y - 1] - c
    res = min(res, tres)
print(res)


Measured memory_bytes: 82156
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest-
#  Atcoder_Grand_Contest-
#  TODO https://atcoder.jp/contests/abc/tasks/abc_
import time
from contextlib import contextmanager
# from time import sleep
@contextmanager
def timer(title):
	t0 = time.time()
	yield
	print("{} - done in {:.0f}s".format(title,time.time()-t0) )

def  countJoyChild(haveCookie,joyMeterList):
	joyMeterList.sort()
	childsCount = len(joyMeterList)
	sendCookieRangeMax = range(0,childsCount,+1)
	sendCookieChilds = 0
	for i in sendCookieRangeMax :
		haveCookie = haveCookie-joyMeterList[i]
		if 0 <= haveCookie:
			sendCookieChilds = sendCookieChilds + 1
		else:
			break
	if 0 < haveCookie: # => 最後の一人が多すぎる
		sendCookieChilds = sendCookieChilds - 1

	answer = sendCookieChilds
	return answer


if __name__ == '__main__':
	_,X = map(int,input().strip().split(' '))
	A = list(map(int,input().strip().split(' ')))
#	with timer("countJoyChild"):
	solution=countJoyChild(X,A)
	print("{}".format(solution))

Measured memory_bytes: 3696
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>


using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b, a - b, a * b }) << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        sum = 0
        for k in range(d):
            tmp = abs(a[i][k]-a[j][k])
            sum+=tmp**2
        sum = math.sqrt(sum)
        if sum % 1 == 0: 
          cnt += 1
print(cnt)

Measured memory_bytes: 3064
import numpy as np
N, K = map(int, input().split())
mod = 2*K
#field = np.zeros((2*K+1, 2*K+1), dtype='i')
field = [[0]*(2*K+1) for _ in range(2*K+1)]

def gen_pattern(x):
    if x < K-1:
        return [[0, x+1], [x+K+1, 2*K]]
    else:
        return [[x-K+1, x+1]]

for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    if c == 'W':
        y += K
    x %= mod
    y %= mod
    for tmp in [0, K]:
        for l, r in gen_pattern((x+tmp) % mod):
            for b, t in gen_pattern((y+tmp) % mod):
                field[l][b] += 1
                field[l][t] -= 1
                field[r][b] -= 1
                field[r][t] += 1

field = np.array(field)
print(field.cumsum(axis=0).cumsum(axis=1).max())


Measured memory_bytes: 118400
#include<iostream>

using namespace std;

int n, m, k, p;
char a[100][102];
int b[102];

int main() {
	for (int i = 0; i < 102; i++)b[i] = 100;
	cin >> n >> m;
	p = 0;

	for (int i = 0; i < n; i++) {
		k = 0;
		cin >> a[p];
		for (int j = 0; j < m; j++) {
			if (a[p][j] == '.')k++;
		}
		if (k == m)p--;
		p++;
	}
	n = p;
	
	p = 0;
	for (int j = 0; j < m; j++) {
		k = 0;
		for (int i = 0; i < n; i++) {
			if (a[i][j] == '.')k++;
		}
		if (k == n) {
			b[p] = j;
			p++;
		}
	}
	for (int i = 0; i < n; i++) {
		p = 0;
		for (int j = 0; j < m; j++) {
			if (b[p] != j) {
				cout << a[i][j];
			}
			else {
				p++;
			}
		}
		cout << '\n';
	}
	cin >> n;
	return 0;

}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

class Flow{
private:
    struct edge{
        ll to;
        ll cap;
        ll rev;
    };

    ll INF;
    ll v;
    vector<vector<edge>> e;
    vector<bool> used;
    
    void reset_used(){
        for(int i=0;i<used.size();i++){used[i]=false;}
    }
    
    ll dfs(ll where,ll to,ll flow){
        if(where==to){return flow;}
        used[where]=true;
        for(int i=0;i<e[where].size();i++){
            edge &E=e[where][i];
            if(!used[E.to] && E.cap>0){
                ll d=dfs(E.to,to,min(flow,E.cap));
                if(d>0){
                    E.cap-=d;
                    e[E.to][E.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    
public:
    Flow(ll v):v(v){
        e.resize(v);
        used.resize(v,false);
        INF=1e18+7;
    }
    
    void add_edge(ll from,ll to,ll cap){
        e[from].push_back((edge){to,cap,(ll)e[to].size()});
        e[to].push_back((edge){from,0,(ll)e[from].size()-1});
    }
    
    ll max_flow(ll s,ll t){
        vector<vector<edge>> ed=e;
        ll flow=0;
        while(1){
            reset_used();
            ll f=dfs(s,t,INF);
            if(f==0){break;}
            flow+=f;
        }
        e=ed;
        return flow;
    }
};


int main(){
    ll v,e;
    cin>>v>>e;
    Flow f(v);
    while(e--){
        ll u,v,c;
        cin>>u>>v>>c;
        f.add_edge(u,v,c);
    }
    
    cout<<f.max_flow(0,v-1)<<endl;
    
    
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  int d[N];
  for (int i=0; i<N; i++) {
    cin >> d[i];
  }
  
  int ans = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      ans += d[i]*d[j];
    }
  }
  
  for (int i=0; i<N; i++) {
    ans -= d[i]*d[i];
  }
   ans /= 2;
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int a[500];
int r[500];

int min(int a, int b){ return a < b ? a : b; }
int max(int a, int b){ return a > b ? a : b; }

long long cost(int n, int d) {
    for(int i = 0; i < n; i++) r[i] = a[i] % d;
    sort(r, r + n);

    long long ans = 0;
    int s = 0;
    int t = n - 1;
    while(r[s] == 0) s++;
    while(s < t) {
        int dist = min(r[s], d - r[t]);
        ans += dist;
        
        if(r[s] == dist) s++;
        else r[s] -= dist;

        if(d - r[t] == dist) t--;
        else r[t] += dist;
    }
    return ans;
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

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

    int ans = 0;
    for(int d = 1; d * d <= S; d++) {
        if(S % d == 0) {
            if(cost(n, d) <= k) ans = max(ans, d);
            if(cost(n, S / d) <= k) ans = max(ans, S / d);
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

typedef struct{
  int array[100];
  int current;
}STACK;

void push (STACK*, int);
int pop (STACK*);

int main () {

  int x,a,b;
  char op[100];
  STACK num;
  num.current = 0;

  while(scanf("%s",op) != EOF){
    if( op[0] == '+'){
       a = pop(&num);
       b = pop(&num);
       push(&num, a+b);
    }
    else if( op[0] == '-'){
       a = pop(&num);
       b = pop(&num);
       push(&num, b-a);
    }
    else if( op[0] == '*'){
       a = pop(&num);
       b = pop(&num);
       push(&num, a*b);
    }
    else {
      x = atoi(op);
      push(&num,x); 
    }
  }

  printf("%d\n",num.array[1]);

return 0;
}

void push (STACK* s, int x){
  s->current++;
  s->array[s->current] = x;
}

int pop (STACK* s){
  s->current = s->current - 1;
  return s->array[s->current+1];
}

Measured memory_bytes: 548
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int N, d;
	cin>>N>>d;
	vector<pair<ll, P> > h(N);
	set<ll> s;
	REP(i, N) {
		ll x, y, b;
		cin>>x>>y>>b;
		h[i].first = b;
		h[i].second.first = x;
		h[i].second.second = y;
	}
	sort(ALL(h));
	ll ite = 0;
	ll ans = 0;
	priority_queue<P> ux;
	priority_queue<P> lx;
	priority_queue<P> uy;
	priority_queue<P> ly;
	REP(i, h.size()) {
		ll lbr = h[i].first;
		while(h[ite].first <= lbr + d && ite < N) {
			ux.push(P(h[ite].second.first, h[ite].first));
			lx.push(P(-(h[ite].second.first), h[ite].first));
			uy.push(P(h[ite].second.second, h[ite].first));
			ly.push(P(-(h[ite].second.second), h[ite].first));
			++ite;
		}
		ll maxx = -1, maxy = -1, minx = -1, miny = -1;

		while(!ux.empty()) {
			P hoge = ux.top();
			if(hoge.second >= lbr && hoge.second <= lbr + d) {
				maxx = hoge.first;
				break;
			} else {
				ux.pop();
			}
		} while(!lx.empty()) {
			P hoge = lx.top();
			if(hoge.second >= lbr && hoge.second <= lbr + d) {
				minx = -(hoge.first);
				break;
			} else {
				lx.pop();
			}
		} while(!uy.empty()) {
			P hoge = uy.top();
			if(hoge.second >= lbr && hoge.second <= lbr + d) {
				maxy = hoge.first;
				break;
			} else {
				uy.pop();
			}
		} while(!ly.empty()) {
			P hoge = ly.top();
			if(hoge.second >= lbr && hoge.second <= lbr + d) {
				miny = -(hoge.first);
				break;
			} else {
				ly.pop();
			}
		}
		ans = max(ans, (maxx - minx) * (maxy - miny));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 20220
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, Hs):
    Hs.reverse()
    ans = 'Yes'
    for i in range(N - 1):
        if Hs[i] < Hs[i + 1]:
            if abs(Hs[i] - Hs[i + 1]) == 1:
                Hs[i + 1] -= 1
            else:
                ans = 'No'
                break
    print(ans)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    Hs = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, Hs)


Measured memory_bytes: 20464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static List<Tuple<int, int>>[] tos;
		static int[] ans;
		static bool[] done;

		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			tos = new List<Tuple<int, int>>[n];
			for (int i = 0; i < n; i++) {
				tos[i] = new List<Tuple<int, int>>();
			}

			for (int i = 0; i < n - 1; i++) {
				int u = cin.Int() - 1;
				int v = cin.Int() - 1;
				int w = cin.Int();
				tos[u].Add(new Tuple<int, int>(v, w));
				tos[v].Add(new Tuple<int, int>(u, w));
			}

			ans = new int[n];
			done = new bool[n];
			ans[0] = 0;

			Dfs(0);

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.AppendLine(ans[i].ToString());
			}

			Console.WriteLine(sb.ToString());
		}

		static void Dfs(int nn)
		{
			if (done[nn]) {
				return;
			}

			done[nn] = true;
			foreach (var to in tos[nn]) {
				if ((ans[nn] == 0 && (to.Item2 % 2 == 0))
					|| ans[nn] == 1 && (to.Item2 % 2 == 1)) {
					ans[to.Item1] = 0;
				} else {
					ans[to.Item1] = 1;
				}

				Dfs(to.Item1);
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 36888
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)

using namespace std;

int main(){
	int A,B,C,K;
	cin >> A >> B >> C;
	cin >> K;
	int x=0,y;
	while(B <= A){
		B*=2;
		x++;
	}
	y = K - x;
	if(y >= 0){
		C *= pow(2,y);
	}else{
		cout << "No" << endl;
		return 0;
	}
	if(C > B && B > A)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0; 

}


Measured memory_bytes: 4000
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef pair<ll,ll> PLL;

#define REP(x,l,u) for(ll x = l; x < u; x++)
#define RREP(x,l,u) for(ll x = l; x >= u; x--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mst(x,v) memset(x, v, sizeof(x))
#define sz(x) (ll)x.size()

string to_string(string s) {return s;}
string to_string(char c) {string s = string(1, c);return s;}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

void in() {}
template <typename A> void in(A & x) { cin >> x; }
template <typename A, typename B> void in(pair<A,B> & x) { in(x.first); in(x.second); }
template <typename A> void in(vector<A> & x) { REP(i,0,(ll)x.size()) in(x[i]); }
template <typename Head, typename... Tail> void in(Head & H, Tail & ... T) {in(H); in(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

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

const ll nax = 100500;
ll F[nax], INVF[nax];

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	ll h = pow(a, b/2);
	ll ans = b % 2 ? h * h % mod * a : h * h;
	ans %= mod;
	return ans;
}

ll ncr(ll n, ll r) {
	// n! / r! / (n-r)!
	ll ans = F[n];
	ans *= INVF[r];
	ans %= mod;
	ans *= INVF[n-r];
	ans %= mod;
	return ans;
}


void solve() {
	ll n, m;
	in(n, m);

	F[0] = 1;
	REP(i,1,nax) F[i] = (F[i-1] * i) % mod;
	REP(i,0,nax) INVF[i] = pow(F[i], mod-2);

	map<ll,ll> factors;
	ll f = 2;
	while (m != 1 && f*f <= m) {
		while (m % f == 0) {
			factors[f]++;
			m /= f;
		}
		f++;
	}
	if (m != 1) factors[m]++;

	ll ans = 1;
	for (PLL a : factors) {
		ans *= ncr(a.second + n - 1, a.second) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}

signed main() {
	ll t = 1;
	REP(i,0,t) solve();
	return 0;
}

Measured memory_bytes: 1792