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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << (n == 1 ? 0 : 1) << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
int main(){
	int A,B;
	scanf("%d%d",&A,&B);
	if(A<=0 && B>=0)
		puts("Zero");
	else
	if(A>0)
		puts("Positive");
	else{
		int C = B-A;
		puts(C%2 ? "Positive" : "Negative");
	}
	return 0;
}

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

int main(){
  int poi1=0,poi2=0; //point
  string ani1,ani2; //animal
  int num;
  
  cin >> num;
  while (num) {
    num--;
    
    cin >> ani1 >> ani2;
    if (ani1 > ani2) poi1 += 3;
    else if (ani1 < ani2) poi2 += 3;
    else {
      poi1++;
      poi2++;
    }
  }
  cout << poi1 << " " << poi2 << endl;
  
  return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const int inf = 1e9;
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key;
    rep(i, m) {
        int a, b, k = 0;
        cin >> a >> b;
        rep(ii, b) {
            int c;
            cin >> c;
            k |= 1 << (c - 1);
        }
        key.emplace_back(a, k);
    }
    int bits = 1 << n;
    vector<int> dp(bits, inf);
    dp[0] = 0;
    rep(i, m) {
        rep(ii, bits) {
            dp[ii | key[i].second] = min(dp[ii | key[i].second], dp[ii] + key[i].first);
        }
    }
    if (dp[bits - 1] == inf) {
        cout << -1 << endl;
    }
    else {
        cout << dp[bits - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(stdin.lock());
    let n: usize = r.read_line().parse().unwrap();
    let s = r.read_line().as_bytes();
    if n % 2 != 0 {
        println!("No");
        return;
    }

    let h = n / 2;
    if s[..h] == s[h..] {
        println!("Yes");
    } else {
        println!("No");
    }
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


Measured memory_bytes: 4352
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   N : Integer;
   A : Integer;
   B : Integer;
begin
   Get (N);
   Get (A);
   Get (B);
   if N*A < B then
      Put_Line (Integer'Image (N*A));
   else
      Put_Line (Integer'Image (B));
   end if;
end Solve;

Measured memory_bytes: 3680
//***Bismillahir Rahmanir Rahim***//

//*********************************//
//******Ashraful Haque Toni********//
//********Dept. of CSE,JnU*********//
//email:ashrafulhaquetoni@gmail.com//
//*******contact:01640690531*******//
//*********************************//


#include<bits/stdc++.h>

using namespace std;

#define         ash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         pb push_back
#define         mp make_pair
#define         sc(n) scanf("%d",&n);
#define         scl(n) scanf("%I64d",&n);
#define         sc2(m,n) scanf("%d%d",&m,&n);
#define         sc2l(m,n) scanf("%I64d%I64d",&m,&n);
#define         pf printf
#define         Big(x,y) max(x,y);
#define         Small(x,y) min(x,y);
#define         input(array,size) for(int i=0;i<size;i++)cin>>array[i];
#define         newline pf("\n");
#define         f(s,l,in) for(ll i=s;i<l;i+=in)
#define         Max INT_MAX
#define         Min INT_MIN
#define         pi acos(-1.0)
#define         Memset(a,val) memset(a,val,sizeof(a));

typedef long long ll;


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



    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LLI;


int main()
{
	int n;
	cin >> n;
	
	string s;
	LLI arr[5]{};
	LLI sum = 0;
	
	for(int i = 0; i < n; i++)
	{
		cin >> s;
		if( s[0] == 'M' )
			arr[0]++;
		else if( s[0] == 'A' )
			arr[1]++;
		else if( s[0] == 'R' )
			arr[2]++;
		else if( s[0] == 'C' )
			arr[3]++;
		else if( s[0] == 'H' )
			arr[4]++;
	}
	for(int i = 0; i < 3; i++)
		for(int j = i+1; j < 4; j++)
			for(int k = j+1; k < 5; k++)
				sum += arr[i]*arr[j]*arr[k];
	cout << sum;
}

Measured memory_bytes: 3652
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	string a, b, c;
	cin >> a >> b >> c;

	cout << "A" << b[0] << "C";

	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 FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll x;
	cin >> x;
	ll m = 100;
	for (int i = 1; ; ++i) {
	  m += m / 100;
	  if (m >= x) {
		cout << i << endl;
		return 0;
	  }
	}
    
    return 0;
}


Measured memory_bytes: 3660
sx,sy,tx,ty = map(int, open(0).read().split())
dx = tx - sx
dy = ty - sy
ans = ['L'] + (['U']*(dy+1)) + (['R']*(dx+1)) + ['D','R'] + (['D']*(dy+1)) + (['L']*(dx+1)) + ['U'] + (['U']*(dy)) + (['R']*(dx)) + (['D']*(dy)) + (['L']*(dx))
print(''.join(ans))

Measured memory_bytes: 9156
#include <cstdio>
#include <algorithm>
using namespace std;
long long dp[100001];
int w[102];
int v[102];
int main()
{
    int n, weight;
    scanf("%d%d", &n, &weight);
    for (int i = 0; i < n; i++)
        scanf("%d%d", &w[i], &v[i]);
    for (int i = 0; i <= weight; i++)
        dp[i] = 0;
    for (int i = 0; i < n; i++)
        for (int j = weight; j >= w[i]; j--)
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    printf("%lld", dp[weight]);
}

Measured memory_bytes: 896
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double a = scan.nextDouble();
			double b = scan.nextDouble();
			double c = scan.nextDouble();
			double d = scan.nextDouble();
			double e = scan.nextDouble();
			double f = scan.nextDouble();
			
			b = b / a;
			c = c / a;
				
			e = e - b * d;
			f = f - c * d;
			d = 0;
						
			f = f / e;
			e = 1;
			
			c = c - f*b;			
			b = 0;
			
			BigDecimal x = new BigDecimal(c);
			BigDecimal y = new BigDecimal(f);
			
			x = x.setScale(3, RoundingMode.DOWN);
			y = y.setScale(3, RoundingMode.DOWN);
			
			System.out.println(x+" "+y);
		}
		
		
	}
}

Measured memory_bytes: 28696
#include <iostream>
#include <vector>
#include <stack>
#include <string>

using namespace std;

static const int N = 100000;
static const int NIL = -1;

class ListGraph {
private:
    vector<int> Graph[N];
    int Group[N];
    int n;

public:
    ListGraph()
    {
        cin >> n;
        int m;
        cin >> m;
        int u, v;
        for(int i = 0; i < m; i++)
        {
            cin >> u >> v;
            Graph[u].push_back(v);
            Graph[v].push_back(u);
        }
    }

    void dfs(int start, int group)
    {
        stack<int> stack;
        stack.push(start);
        Group[start] = group;
        while(!stack.empty())
        {
            int u = stack.top();
            stack.pop();
            for(int i = 0; i < Graph[u].size(); i++) // uの全隣接頂点に対して
            {
                int v = Graph[u][i];
                if(Group[v] == NIL) // 未訪問(グループ未定)のとき
                {
                    Group[v] = group; // 自分のグループに含める
                    stack.push(v);
                }
            }
        }
    }

    void grouping()
    {
        int id = 1;
        for(int i = 0; i < n; i++)
            Group[i] = NIL;
        for(int u = 0; u < n; u++)
        {
            if(Group[u] == NIL)
                dfs(u, id++);
        }
    }

    string answer(int start, int goal)
    {
        if(Group[start] == Group[goal])
            return "yes";
        else
            return "no";
    }
};

int main()
{
    ListGraph graph;
    graph.grouping();
    int question;
    cin >> question;
    int start, goal;
    for(int i = 0; i < question; i++)
    {
        cin >> start >> goal;
        cout << graph.answer(start, goal) << endl;
    }
}


Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

int32_t main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n ;
    cin >> n;
    int ans = n * (n - 1);
    ans >>= 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
import heapq

N, M = map(int, input().split())
l = [0 for i in range(N)]

for i in range(N):
    A, B = map(int, input().split())
    l[i] = [A,-B]
l.sort()

tmp = []
ans = 0
j = 0

for i in range(1, M + 1):
    while j < N:
        A, B = l[j][0], -l[j][1]
        memo = [-B, A]
        if A <= i:
            heapq.heappush(tmp, memo)
            j += 1
        else:
            break
    if len(tmp) > 0:
        ans -= heapq.heappop(tmp)[0]
print(ans)

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

using ll = long long int;

const int MAX_N = (int)(1000 + 5);

int n, m;
ll x[MAX_N], y[MAX_N], z[MAX_N];

int sign[2] = {-1, 1};
ll tmp[MAX_N];

ll ans = -114514;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld %lld", &(x[i]), &(y[i]), &(z[i]));
  }

  ll ans = -114514;
  for (int i = 0; i < 2; ++i) for (int j = 0; j < 2; ++j) for (int k = 0; k < 2; ++k) {
    for (int ind = 0; ind < n; ++ind) {
      tmp[ind] = sign[i] * x[ind] + sign[j] * y[ind] + sign[k] * z[ind];
    }
    sort(tmp, tmp + n, greater<ll>());
    ll cur = 0;
    for (int ind = 0; ind < m; ++ind) {
      cur += tmp[ind];
    }
    ans = max(ans, cur);
  }

  printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    string s;
    cin>>s;

    ll ans=0;

    ll ind=0,ct=0;
    while(ind<s.size())
    {
        if(s[ind]=='A' || s[ind]=='G' || s[ind]=='C' || s[ind]=='T')
        {
            ct++;
        }
        else
        {
            ans=max(ans,ct);
            ct=0;
        }
        ind++;
    }
    cout<<max(ans,ct)<<"\n";

    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,A;
  A=0;
  char s[5];
  scanf("%s", s);
  int i;
  for(i=0;i<3;i++){
    if(s[i]=='1'){
     A++; 
    }
  }
  printf("%d\n",A);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>

using namespace std;

namespace {

class Cube {
 private:
  enum Face {
    TOP,     // 1
    FRONT,   // 2
    RIGHT,   // 3
    LEFT,    // 4
    BACK,    // 5
    BOTTOM,  // 6
  };

 public:
  Cube(const int* face) { copy(face, face + 6, face_); }

  // to east
  void rotate_x() { rotate(TOP, LEFT, BOTTOM, RIGHT); }
  // to north
  void rotate_y() { rotate(TOP, FRONT, BOTTOM, BACK); }

  void rotate_z() { rotate(FRONT, LEFT, BACK, RIGHT); }

  int top() const { return face_[TOP]; }
  int front() const { return face_[FRONT]; }
  int right() const { return face_[RIGHT]; }

 private:
  void rotate(Face f1, Face f2, Face f3, Face f4) {
    const int t = face_[f1];
    face_[f1] = face_[f2];
    face_[f2] = face_[f3];
    face_[f3] = face_[f4];
    face_[f4] = t;
  }

  int face_[6];
};

int find(Cube& c, int top, int front) {
  // http://www.prefield.com/algorithm/misc/dice.html
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 4; ++j) {
      if (c.top() == top && c.front() == front)
        return c.right();
      c.rotate_z();
    }
    if (i % 2 == 1)
      c.rotate_x();
    else
      c.rotate_y();
  }
  return -1;
}

}  // namespace

int main() {
  int face[6];
  int q;
  for (int i = 0; i < 6; ++i) {
    cin >> face[i];
  }
  cin >> q;

  Cube c(face);
  int top, front;
  for (int i = 0; i < q; ++i) {
    cin >> top >> front;
    cout << find(c, top, front) << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
bool cmp(const P &a, const P &b) {
    if (a.first != b.first)
        return a.first > b.first;
    else
        return a.second < b.second;
}
int main() {
    int n, m; cin >> n >> m;
    vector<P> x(m);
    rep(i, m) {
        cin >> x[i].first >> x[i].second;
        x[i].second--;
    }
    sort(x.begin(), x.end(), cmp);
    //rep(i, m) printf("%d %d\n",x[i].first, x[i].second);
    P seki = x.back(); x.pop_back();
    int ans = 1;
    while (!x.empty()) {
        int l = seki.first;
        int r = seki.second;
        P cur = x.back();
        if(max(l,cur.first)<=min(r,cur.second)) {
            seki = P(max(l,cur.first),min(r,cur.second));
            x.pop_back();
        } else {
            seki = x.back();
            ans++;
        }
    }
    cout << ans;
}



Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>
#include <algorithm>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll t;
    ll x = 1;
    rp(i,n){
      cin >> t;
      x = (x/__gcd(x,t))*t;
    }
    cout << x << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars, Usize1};

fn main() {
    input! {
        h: usize,
        w: usize,
        k: i64,
        s: (Usize1, Usize1),
        g: (Usize1, Usize1),
        c: [Chars; h],
    };
    let mut d = vec![vec![None; w]; h];
    let mut pq = std::collections::BinaryHeap::new();
    d[s.0][s.1] = Some(0);
    pq.push(std::cmp::Reverse((0, s.0, s.1)));
    while let Some(std::cmp::Reverse((cost, y, x))) = pq.pop() {
        for &(dy, dx) in [(-1, 0), (0, 1), (1, 0), (0, -1)].iter() {
            for k_i in 1..=k {
                let (ny, nx, ncost) = (
                    dy as i64 * k_i + y as i64,
                    dx as i64 * k_i + x as i64,
                    cost + 1,
                );
                if (0..h as i64).contains(&ny) && (0..w as i64).contains(&nx) {
                    let (ny, nx) = (ny as usize, nx as usize);
                    if c[ny][nx] == '@' {
                        break;
                    }
                    match d[ny][nx] {
                        Some(w_o) if ncost > w_o => break,
                        Some(w_o) if ncost == w_o => continue,
                        None | Some(_) => {
                            d[ny][nx] = Some(ncost);
                            pq.push(std::cmp::Reverse((ncost, ny, nx)));
                        }
                    }
                }
            }
        }
    }
    println!("{}", d[g.0][g.1].unwrap_or(-1));
}


Measured memory_bytes: 17556
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        sc.close();

        // 主処理
        String result = "UNRESTORABLE";
        StringBuilder sb = new StringBuilder(s);
        for (int i = s.length() - t.length(); 0 <= i; i--) {
            String regex = sb.substring(i, i + t.length()).replaceAll("\\?", ".").toString();
            if (t.matches(regex)) {
                String word = sb.replace(i, i + t.length(), t).toString();
                result = word.replaceAll("\\?", "a").toString();
                break;
            }
        }
        result = result.replace("?", "a");

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;

public static class P
{
    public static void Main()
    {
        Console.WriteLine(7 - Array.IndexOf(new string[] { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" }, Console.ReadLine()));
    }
}

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

ll solve() {
    ll N, K, a;
    cin >> N >> K;
    vector<ll> D(K);
    vector<vector<ll>> A(K);
    vector<ll> c(N);
    for ( int i = 0; i < K; i++ ) {
        cin >> D[i];
        for ( int j = 0; j < D[i]; j++ ) {
            cin >> a;
            c[a-1]++;
        }
    }
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( c[i] == 0 ) ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
N,X = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

# 各都市と出発座標の差を配列にする
difs = x.map { |m| (m-X).abs }

# 出発座標と都市の座標の最大公約数が答え
puts difs.inject { |a,b| a.gcd(b) }

Measured memory_bytes: 9220
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int n; cin >> n;
  string s; cin >> s;
  int ans=1;
  
  rep(i,n-1){
    if (s[i]!=s[i+1]){ans++;}
  }
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 512
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 1; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

string S;

int main() {
    cin >> S;

    bool flag = true;
    REP(i, S.size()) {
        if (S[i] == S[i-1]) {
            flag = false;
            break;
        }
    }

    string ans;
    if (flag) {
        ans = "Good";
    } else {
        ans = "Bad";
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
class Node:
    __slots__ = ['value', 'left', 'right']
    def __init__(self, value = None, left = None, right = None):
        self.value = value
        self.left = left
        self.right = right
class BinTree:
    __slots__ = ['_tree', 'result']
    def __init__(self):
        self._tree = None
    def insert(self, value):
        p = None
        c = self._tree
        while c is not None:
            p = c
            if value < c.value:
                c = c.left
            else:
                c = c.right
        if p is None:
            self._tree = Node(value)
        elif value < p.value:
            p.left = Node(value)
        else:
            p.right = Node(value)
    def find(self, value):
        c = self._tree
        while c is not None:
            if value == c.value:
                return True
            elif value < c.value:
                c = c.left
            else:
                c = c.right
        return False
    def preoder_walk(self):
        self.result = []
        def preoder(node):
            if node is not None:
                self.result.append(node.value)
                preoder(node.left)
                preoder(node.right)
        preoder(self._tree)
        print(" " + " ".join(map(str, self.result)))
    def inorder_walk(self):
        self.result = []
        def inorder(node):
            if node is not None:
                inorder(node.left)
                self.result.append(node.value)
                inorder(node.right)
        inorder(self._tree)
        print(" " + " ".join(map(str, self.result)))
n = int(input())
tree = BinTree()
for _ in range(n):
    com = readline().split()
    if com[0] == "insert":
        tree.insert(int(com[1]))
    elif com[0] == "find":
        print("yes" if tree.find(int(com[1])) else "no")
    else:
        tree.inorder_walk()
        tree.preoder_walk()



Measured memory_bytes: 77240
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;
const ll inf = 1e18;

ll n, m, k, t;

ll C[4];

map <ll, ll> M;

ll solve(ll x) {
    // cout << x << " X" << endl;
    if (x == 0) {
        return 0;
    }
    if (x > inf) {
        return inf;
    }
    if (M.find(x) != M.end()) {
        return M[x];
    }
    M[x] = inf;
    vector <ll> K = {2LL, 3LL, 5LL};
    ll ans;
    if (x < inf / C[3]) {
        ans = x * C[3];
    }
    else {
        ans = inf;
    }
    for (int i = 0; i < 3; i++) {
        ll k = K[i];
        ll x1 = x / k;
        ans = min(ans, solve(x1) + C[i] + C[3] * (x - k * x1));
        ll x2 = (x + k - 1) / k;
        ans = min(ans, solve(x2) + C[i] + C[3] * (x2 * k - x));
    }
    M[x] = ans;
    // cout << "ANS " << x << " " << ans << endl;
    return ans;
}

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b, c;
    cin >> t;
    for (ll it = 0; it < t; it++) {
        cin >> n >> C[0] >> C[1] >> C[2] >> C[3];
        cout << solve(n) << endl;
        M.clear();
    }
    return 0;
}


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

int main() { 
  string N;
  cin >> N;
  
  if(N[N.length()-1] == '3') {
    cout << "bon" << endl; 
  }
  else if(N[N.length()-1] == '0' ||
         N[N.length()-1] == '1' ||
         N[N.length()-1] == '6' ||
         N[N.length()-1] == '8') {
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
  
  return 0; 
}

Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main() {
  int N;cin >> N;
  int a[N+1];rep(i,N) cin >> a[i+1];
  vector<int> ans(N+1,0);

  for(int i = N; i>0; i--) {
    int tmp = 0;
    for(int j=2*i; j <= N; j+=i) {
      if(ans[j]) tmp++;
    }
    tmp%=2;
    // cout << tmp << endl;
    if(a[i] == tmp) continue;
    else ans[i] = 1;
  }
  int cnt=0;
  rep(i,N) if(ans[i+1]) cnt++;cout << cnt << endl;
  rep(i,N) if(ans[i+1]) cout << i+1 << endl;
  

  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) (x.begin(),x.end())
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)
 
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
 
    int h,w, a, b; cin >> h >> w >> a >> b;
    vi col(w,0), row(h,0);
    bool grid[1000][1000] = {};

    forr(i,0,b) forr(j,0,a) grid[i][j] = true;
    forr(i,b,h) forr(j,a,w) grid[i][j] = true;

    forr(i,0,h) {
        forr(j,0,w) cout << grid[i][j];
        cout << '\n';
    } 

    return 0;
}


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

int main(){
    int D=0,N,X;
    int L;
    cin >> N >> X;
    for ( int i = 0; i < N; i++){
        cin >> L;
        D += L;
        if ( D > X){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << N + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, k+1) rep(y, k+1) {
        int z = s-x-y;
        if (z>=0 && z<=k) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}



 int mi[100005];
int main() {
    int K;int i;
    cin>>K;
    rep(i,K) mi[i]=1<<30;
    priority_queue<pair<int,int>> P;
    for(i=1;i<=9;i++) {
        mi[i%K]=min(mi[i%K],i);
        P.push({-mi[i%K],i%K});
    }
    
    while(P.size()) {
        int cur=P.top().second;
        int cost=-P.top().first;
        P.pop();
        if(cost!=mi[cur]) continue;
        rep(i,10) {
            int nc=cost+i;
            int nex=(cur*10+i)%K;
            if(mi[nex]>nc) {
                mi[nex]=nc;
                P.push({-mi[nex],nex});
            }
        }
    }
    
    cout<<mi[0]<<endl;
    
    return 0;
}








Measured memory_bytes: 2804
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var abc=input.trim().split(" ").map(Number);
var a=abc[0];
var b=abc[1];
var c=abc[2];
var time=1;
var flag=true;
var nokori=a;
for(var i=0;i<3600;i++){
   if(flag && time%60==c){console.log(time);break;}
   time++;
   nokori--;
   if(nokori==0){flag=!flag;nokori=flag?a:b;}
}
if(i==60*60)console.log(-1);

Measured memory_bytes: 7380
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;
vector<ll> v[200010];
ll mod = 1000000007,inv[200010],fact[200010],fi[200010],a[200010] = {};
set<pair<ll,ll>> s;
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<200010;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<200010;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]*fi[k]%mod*fi[n-k]%mod;
	}
}

int main(){
	ll i,j,n,x,y;
	cin >> n >> x >> y;
	inverse();
	for(i=0;i<n;i++){
		ll a,b;
		cin >> a >> b; a--;
		v[a].push_back(b);
	}
	for(i=0;i<n;i++) sort(v[i].begin(),v[i].end());
	for(i=0;i<n;i++){
		for(j=0;j<v[i].size();j++){
			if(v[i][0] + v[i][j]<=x) v[i][j] = v[i][0];
		}
		if(v[i].size()) s.insert({v[i][0],i});
	}
	pair<ll,ll> p = *s.begin(); s.erase(p);
	pair<ll,ll> q = *s.begin();
	for(i=0;i<n;i++){
		v[i].push_back(1000000000000);
		if(i!=p.second){
			for(j=0;j<v[i].size();j++){
				if(p.first + v[i][j]>y){
					a[i] = j;
					break;
				}
			}
		}else{
			for(j=0;j<v[i].size();j++){
				if(q.first + v[i][j]>y){
					a[i] = j;
					break;
				}
			}
		}
	}
	ll sum = 0,ans = 1;
	for(i=0;i<n;i++) sum += a[i];
	for(i=0;i<n;i++){
		(ans *= comb(sum,a[i])) %= mod;
		sum -= a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 27008
#include<cstdio>
int x,y,l,r,mid;
long long ans=1e9;
long long mi(long long a,long long b){return a>b?b:a;}
int main()
{
	scanf("%d%d",&x,&y);
	l=0;
	r=1000000;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(mid*2019>=x&&mid*2019<=y)
		{
			puts("0");
			return 0;
		}
		if(mid*2019>y)r=mid-1;
		if(mid*2019<x)l=mid+1;
	}
	for(int i=x;i<=y;i++)
		for(int j=i+1;j<=y;j++)
			ans=mi(ans,i*1ll*j%2019);
	printf("%d",ans);
	return 0;
}


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

int main() {
	int K, X;
	cin >> K >> X;

	for( int i = X-K+1; i < X+K; ++i ) {
		cout << i;

		if( i < X+K-1 ) { cout << ' '; }
	}

	cout << endl;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_row_list(n)

    count = 0

    for l, r in num_list:
        count += r - l + 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 78832
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
 
class unionfind {
	vector<int> par, rank;
 
public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);
 
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
 
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;
 
		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}
 
	bool same(int x, int y) { return (find(x) == find(y)); }
} uf;
 
const int MN = 200010;
 
using P = pair<ll, int>;
 
vector<pii> g[MN];
int col[MN];
ll X[MN];
vector<P> dp[MN];
 
void mergevec(vector<P>& a, vector<P> b) {
	for (auto p : b) {
		a.eb(p);
	}
	sort(ALL(a));
 
	set<int> st;
	vector<P> res;
 
	for (P p : a) {
		if (res.size() == 2) {
			break;
		}
		if (!st.count(p.se)) {
			st.insert(p.se);
			res.eb(p);
		}
	}
	a = res;
}
 
void dfs_up(int v, int p) {
	dp[v].eb(X[v], col[v]);
 
	for (pii e : g[v]) {
		if (e.fi != p) {
			dfs_up(e.fi, v);
 
			vector<P> nx;
 
			for (auto t : dp[e.fi]) {
				nx.eb(t.fi + e.se, t.se);
			}
 
			mergevec(dp[v], nx);
		}
	}
}
 
void dfs_down(int v, int p, int pw) {
	if (p != -1) {
		vector<P> nx;
		for (auto t : dp[p]) {
			nx.eb(t.fi + pw, t.se);
		}
		mergevec(dp[v], nx);
	}
 
	for (pii e : g[v]) {
		if (e.fi != p) {
			dfs_down(e.fi, v, e.se);
		}
	}
}
 
int N, D;
 
int main() {
	cin >> N >> D;
	rep(i, N) cin >> X[i];
 
	rep(i, N-1) {
		int a = i;
		int b = i + 1;
		int c = D;
		g[a].eb(b, c);
		g[b].eb(a, c);
	}
 
	uf.init(N);
	rep(i, N) {
		col[i] = i;
	}
 
	ll ans = 0;
 
	while (true) {
		bool one = true;
		for (int i = 1; i < N; ++i) {
			if (col[i] != col[0]) {
				one = false;
			}
		}
		if (one) {
			break;
		}
 
		rep(i, N) {
			dp[i].clear();
		}
 
		vector<P> mt(N, mp(LLONG_MAX, -1));
 
		dfs_up(0, -1);
		dfs_down(0, -1, -1);
 
		rep(i, N) {
			for (P p : dp[i]) {
				if (p.se != col[i]) {
					mt[col[i]] = min(mt[col[i]], mp(p.fi + X[i], p.se));
					break;
				}
			}
		}
 
		rep(i, N) if (mt[i] != mp(LLONG_MAX, -1)) {
			int u = i, v = mt[i].se;
			ll cost = mt[i].fi;
			if (!uf.same(u, v)) {
				uf.unite(u, v);
				ans += cost;
			}
		}
 
		rep(i, N) {
			col[i] = uf.find(col[i]);
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 72960
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 +7;

int main() {
    
    
    ll n;
    string s;
    cin >> n >> s;
    
    char st = '^';
    string ret = "";
    for (int i = 0; i < n; ++i)
    {
        if (s[i] != st)
        {
            st = s[i];
            ret += st;
            continue;
        }
    }
    
    cout << ret.size() << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

inline int waste(int a, int b, int m) { return (((a % m) + (b % m)) % m); }
inline int worse(int a, int b, int m) { return (((a % m) * (b % m)) % m); }
inline int worst(int a, int b, int m) { return (((a % m) - (b % m) + m) % m);}

using namespace std;

void func(int n)
{
    if(n==0){
      return;
    }
    n--;
    func(n/26);
    char x = 'a'+(n%26);
    cout << x;
}
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   int n;
   cin >> n;
   func(n);
}

Measured memory_bytes: 3644
#ABC131 B

N,L = map(int,input().split())
aji = []
for i in range(N):
    aji.append(L+i)
if L < 0 and L+N-1 > 0:
    print(sum(aji))
elif L+N-1 <= 0:
    print(sum(aji) - (L+N-1))
elif L >= 0:
    print(sum(aji) - L)

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

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define min_pq priority_queue<pll, vector<pll>, greater<pll> >
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define modulo %
#define moduloe %=

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
ll add(ll a, ll b) {a+=b; while(a >= mod) a-= mod; while(a<0) a+= mod;}
ll mul(ll a, ll b) {return (a * 1LL *b % mod);}
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

vi g[nn];
int c[nn], ans[nn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        int m, x ,y, an;
        cin>>n>>m;
        rep(i, m)
        {
            cin>>x>>y;
            g[x].pb(y);
            c[y]++;
        }

        queue<int>q;
        for(i=1;i<=n;i++)
        {
            if(c[i] == 0)
                q.push(i);
        }


        while(!q.empty())
        {
            int top = q.front();
            q.pop();
            for(auto u : g[top])
            {
                c[u]--;
                ans[u] = max(ans[u], ans[top] + 1);
                if(c[u] == 0)
                    q.push(u);
            }
        }

        an = 0;
        rep1(i, 1, n)
            an = max(an, ans[i]);
        cout<<an<<endl;

    }
    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 17408
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[][]=new int[n][3];
    int[][] dp=new int[n][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        a[i][j]=sc.nextInt();
        if(i==0){
          dp[i][j]=a[i][j];
        }
      }
    }
    for(int i=1;i<n;i++){
      for(int j=0;j<3;j++){
        if(j==0){
           dp[i][j]=a[i][j]+Math.max(dp[i-1][j+1],dp[i-1][j+2]);
        }
        else if(j==1){
           dp[i][j]=a[i][j]+Math.max(dp[i-1][j-1],dp[i-1][j+1]);
        }
        else if(j==2){
           dp[i][j]=a[i][j]+Math.max(dp[i-1][j-1],dp[i-1][j-2]);
        }
      }
    }
    System.out.print(Math.max(dp[n-1][2],Math.max(dp[n-1][1],dp[n-1][0])));
  }
}

Measured memory_bytes: 100536
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Lower | diff Lower.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Lower.cpp && ./a.out

/*
 
 9/1/2019
 
 5:12-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  int res=0,cur=0;
  REP(i,N-1) {
    if(A[i+1]<=A[i]) ++cur;
    else cur=0;
    SMAX(res,cur);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


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

const ll MAX = 500000;
const ll INF = 1LL<<60;

ll cnt;

ll partition(vector<ll> &seq, ll p, ll right) {
    ll x = seq.at(right);
    ll i = p - 1;
    for( ll j = p; j < right; j++) {
        if( seq.at(j) <= x) {
            i++;
            ll temp = seq.at(i); seq.at(i) = seq.at(j); seq.at(j) = temp;
        }
    }
    ll temp = seq.at(i+1); seq.at(i+1) = seq.at(right); seq.at(right) = temp; 

    return i + 1;
}

signed main() {
    ll n; cin >> n; 
    vector<ll> seq(MAX);
    for( ll i = 0; i < n; i++ ) cin >> seq.at(i);

    ll p = partition(seq, 0, n-1);
    for( ll i = 0; i < n; i++) {
        if( i == p ) cout << '[' << seq.at(i) << ']';
        else cout << seq.at(i);
        if(i < n-1) printf(" ");
    }
    cout << endl;

    return 0;
}





Measured memory_bytes: 6796
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	ll N;
	cin>>N;
	ll L[100];
	L[0]=2,L[1]=1;
	for(int i=0; i<=90; i++){
		L[i+2]=L[i+1]+L[i];
	}
	cout<<L[N]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 100005
ll inf = 1e14;
int mod = 998244353;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll dp[105][N];
ll arr[N][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, w;
  cin >> n >> w;
  for (ll i = 1; i <= n; i++)
    cin >> arr[i][0] >> arr[i][1];

  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= w; j++)
      dp[i][j] = -inf;
  }

  dp[0][0] = 0;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 0; j <= w; j++) {
      dp[i][j] = dp[i - 1][j];
      if (arr[i][0] <= j)
        dp[i][j] = max(dp[i][j], dp[i - 1][j - arr[i][0]] + arr[i][1]);
    }
  }

  ll res = 0;
  for (ll i = 0; i <= w; i++)
    res = max(res, dp[n][i]);
  cout << res << en;
  return 0;
}


Measured memory_bytes: 80768