akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 80, inf = 1e7, mid = 80*80; int n, m;
int a[2][maxN][maxN];

// int memo[maxN][maxN][2*maxN*maxN + 1];
bitset<80*(80 + 80 + 1)> memo[maxN][maxN];
// int solve(int i = 0, int j = 0, int d = 0)
// {
//   if (i == n - 1 && j == m - 1) return min(abs(d + a[0][i][j] - a[1][i][j]), abs(d + a[1][i][j] - a[0][i][j]));
//   if (memo[i][j][d] != -1) return memo[i][j][d];
//   int ans = inf;
//   if (i + 1 < n)
//   {
//     ans = min(ans, solve(i + 1, j, abs(d + a[0][i][j] - a[1][i][j])));
//     ans = min(ans, solve(i + 1, j, abs(d + a[1][i][j] - a[0][i][j])));
//   }
//   if (j + 1 < m)
//   {
//     ans = min(ans, solve(i, j + 1, abs(d + a[0][i][j] - a[1][i][j])));
//     ans = min(ans, solve(i, j + 1, abs(d + a[1][i][j] - a[0][i][j])));
//   }
//   return memo[i][j][d] = ans;
// }
int solve()
{
  for (int i = 0; i < n; i ++) for (int j = 0; j < m; j ++) memo[i][j] = 0;
  memo[0][0][mid + abs(a[0][0][0] - a[1][0][0])] = memo[0][0][mid - abs(a[0][0][0] - a[1][0][0])] = true;
  for (int i = 0; i < n; i ++)
    for (int j = 0; j < m; j ++)
    {
      if (i)
        memo[i][j] |= (memo[i - 1][j] >> abs(a[0][i][j] - a[1][i][j])) | (memo[i - 1][j] << abs(a[0][i][j] - a[1][i][j]));
      if (j)
        memo[i][j] |= (memo[i][j - 1] >> abs(a[0][i][j] - a[1][i][j])) | (memo[i][j - 1] << abs(a[0][i][j] - a[1][i][j]));
    }
  for (int i = 0; ; i ++)
    if (memo[n - 1][m - 1][mid + i] || memo[n - 1][m - 1][mid - i])
      return i;
  return inf;
}

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    for (int i = 0; i < 2; i ++)
      for (int j = 0; j < n; j ++)
        for (int k = 0; k < m; k ++)
          scanf("%d", &a[i][j][k]);
    // memset(memo, -1, sizeof(memo));
    int ans = solve();
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;

// class lab{
// private:
//     string labName, address;
//     int memberNumbers;
// public:
//     lab();
//     void changeAddress();
//     void entrance();
//     void graduation();
//     void showLab();
// };


// lab::lab() {
//     string nam, add;
//     int num;
//     cout << "研究室名は？" << endl;
//     cin >> nam;
//     cout << "場所は？" << endl;
//     cin >> add;
//     cout << "人数は？" << endl;
//     cin >> num;
//     labName = nam;
//     address = add;
//     memberNumbers = num;
    
// }

// void lab::changeAddress(){
//     string newAdd;
//     cout << "新しい場所は？" << endl;
//     cin >> newAdd;
//     address = newAdd;
// }

// void lab::entrance(){
//     int ent;
//     cout << "新入生は何人？" << endl;
//     cin >> ent;
//     memberNumbers += ent;
// }

// void lab::graduation(){
//     int gra;
//     cout << "卒業生は何人？" << std::endl;
//     cin >> gra;
//     memberNumbers -= gra;
// }

// void lab::showLab(){
//     cout << labName << "は" << address << "に所在し" << memberNumbers << "人在籍している。" << endl;
// }

// int main(){
//     lab l;
//     string back;
//     do {
//         cin >> back;
//         if(back == "場所変更"){
//             l.changeAddress();
//         } else if (back == "人数変更"){
//             l.entrance();
//             l.graduation();
//         } 
//     }while(back != "終了") ;
//     l.showLab();
//     return 0;
// }

// int g;
// void gcd(int a, int b){
//     int r;
//     r = a % b;
//     if (r !=0){gcd(b,r);}
//     else {g = b;}
// }    
// void set(){
//     int a, b;
//     cin >> a >> b;
//     gcd(a, b);
// }

// int main(){
//     set();
//     cout << g << endl;
// }

int k=0;

void search(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for (int i =0; i < a + 1; i++){
        int dr;
        dr = d - 500 * i;
        if(dr > -1){
            for (int j =0; j < b+ 1; j ++){
                int drr = dr - 100 * j;
                if(drr > -1){    
                    if(drr % 50 == 0){
                        if (drr/50 < c+1){    
                        k += 1;
                    }
                }    
            }
        }
    }    
}
cout << k << endl;
}

int main(){
    search();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
using ll = long long;
using ull = unsigned long long;

int main() {
    string s;
    cin >> s;
    int len = (size(s) - 1) / 2;

    string t;
    rep(i, len){
        t += s[i];
    }

    len = (size(s) + 3) / 2;
    string u;
    FOR(i, len - 1, size(s)){
        u += s[i];
    }

    if(t == u){
        println("Yes");
    }else{
        println("No");
    }
}


Measured memory_bytes: 256
N = int(input())
Data = []
for _ in range(N):
    Data.append([0]*26)

for i in range(N):
    S = input()
    for s in S:
        p = ord(s)-ord('a')
        Data[i][p] += 1

ans = ''
for i in range(26):
    minn = 10**10
    for n in range(N):
        minn = min(minn,Data[n][i])
    ans += (chr(ord('a')+i) * minn)  

print(ans)


Measured memory_bytes: 3064
<?php
  
list($n,$m) = explode(" ",trim(fgets(STDIN)));
$array = array();
for($i=0;$i<$m;$i++){
$food[] = 0;
}
for($i=0;$i<$n;++$i){
$x = explode(" ",trim(fgets(STDIN)));
$array = array_merge($array,array_splice($x,1));
}

$food = array_count_values($array);
$ans = 0;
foreach($food as $value){
if($value ==$n){
++$ans;
}
}
echo $ans;

Measured memory_bytes: 4604
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

using ull_t = unsigned long long;

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> S(H, vector<char>(W, 0));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            char c;
            cin >> S[i][j];
        }
    }

    vector<vector<int>> X(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            if (i == 0 and j == 0)
            {
                X[i][j] = (S[i][j] == '.') ? 0 : 1;
            }
            else
            {
                int nx = (j > 0) ? (X[i][j-1] + (S[i][j-1] == '.' and S[i][j] == '#')) : -1;
                int ny = (i > 0) ? (X[i-1][j] + (S[i-1][j] == '.' and S[i][j] == '#')) : -1;
                X[i][j] = ((ny < 0) or ((nx >= 0) and (nx < ny))) ? nx : ny;
            }
        }
    }

    cout << X[H-1][W-1] << endl;
}


Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;

#define MAX_N (2*100000)
int main() {
    cout.precision(10);
    cout << fixed;
    int K;
    string S;
    cin >> K >>S;
    if (S.size()>K) {
        REP(i,K)
            cout<<S[i];
        cout<<"..."<<endl;
    }else {
        cout<<S<<endl;
    }
}


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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  a += "A";
  b += "B";
  c += "C";
  //cout << c << endl;
  char turn;
  turn = 'a';
  int pa,pb,pc;
  pa = pb = pc =0;
  while(true){
    if(turn=='a'&&a.at(pa)=='A'){cout << 'A' << endl; return 0;}
    else if(turn=='b'&&b.at(pb)=='B'){cout << 'B' << endl; return 0;}
    else if(turn=='c'&&c.at(pc)=='C'){ cout <<  'C' <<  endl; return 0;}
    
    if(turn=='a'){
      turn = a.at(pa);
      pa++;
    }else if(turn=='b'){
      turn = b.at(pb);
      pb++;
    }else{
      turn = c.at(pc);
      pc++;
    }

  }
  return 0;
}

Measured memory_bytes: 256
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/abc073/tasks/abc073_c
/// A_i < 10^9
fn main() {
    let n = read_one::<usize>();
    let mut hm = HashMap::new();

    for _ in 0..n {
        let i = hm.entry(read_one::<usize>())
            .or_insert(0);
        *i += 1;
    }

    let ans = hm.values()
        .filter(|&x| x % 2 != 0)
        .count();
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 12540
#include <iostream>
#include <iomanip>
#include <cmath>
int main() {
    double r;
    std::cin >> r;
    double pi = std::acos(-1.);
    std::cout << std::fixed << std::setprecision(6)
    << pi * r * r << ' ' << 2 * pi * r << std::endl;
}



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





int main() {
  int g;
cin>>g;
  int a=0;
  for(int i=0;i<g;i++)
  {
  int y;
    cin>>y;
  if(y%2==0)
  {
  if(y%3!=0 && y%5!=0)  a=1;
   
  }
    
  }
  
  if(a==0) cout<<"APPROVED";
  if(a==1) cout<<"DENIED";
    }


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

signed main() {
                                                                  
	int n;                                                             
	cin >> n;	
	vector<int> P(n), Q(n);

	for (int i = 0; i < n; i++) cin >> P[i];
	for (int i = 0; i < n; i++) cin >> Q[i];

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

	int first = -1, second = -1;
	int cnt = 1;
	
	do {
		if (a == P) first = cnt;
		if (a == Q) second = cnt;
		cnt++;
	} while (next_permutation(a.begin(), a.end()));

	cout << abs(first - second) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int c[555], s[555], f[555],whenn[555];
int tcop;
int main() {
	int N = 0;
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
		whenn[i] += (c[i] + s[i]);
	}
	for (int i = 0; i < N-1; i++) {
		for(int k=i+1;k<N-1;k++){
			if ((whenn[i] - s[k]) % f[k] == 0&&whenn[i]>=s[k]) {
				whenn[i] += c[k];
			}
			else {
				tcop = s[k];
				while (whenn[i] >= tcop) {
					tcop += f[k];
				}
				whenn[i]= tcop;
				whenn[i] += c[k];
			}
		}
	}
	for (int i = 0; i < N - 1; i++) {
		cout << whenn[i] << endl;
	}
	cout << '0' << endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

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

  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> v;
    int a;
    rep(i, n) {
      cin >> a;
      v.push_back(a);
    }
    sort(ALL(v));

    int sum = 0;
    for(int i = 1; i < n - 1; i++) {
      sum += v[i];
    }
    sum = sum / (n - 2);
    cout << sum << endl;
  }

}



Measured memory_bytes: 3024
#include <iostream>
using namespace std;
int main()
{
    char a[2];
    char b[2];

    cin>>a[0]>>a[1]>>a[2];
    cin>>b[0]>>b[1]>>b[2];

    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

	return 0;
}


Measured memory_bytes: 256
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def AGC028A():
    N, M = map(int, input().split())
    S = input()
    T = input()

    key = lcm(N, M)
    n = key // N
    m = key // M
    n_list = []
    for i in range(0, key, n):
        n_list.append(i)
    m_list = []
    for j in range(0, key, m):
        m_list.append(j)

    #print(n_list, m_list)
    i = 0
    j = 0
    while True:
        if i >= len(n_list) or j >= len(m_list):
            break
        if i >= len(S) or j >= len(T):
            break
        if n_list[i] == m_list[j]:
            if S[i] != T[j]:
                print(-1)
                return 0
        if n_list[i] > m_list[j]:
            j += 1
        elif n_list[i] < m_list[j]:
            i += 1
        else:
            i += 1
            j += 1
    print(key)

AGC028A()

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


#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,m;
    cin>>n>>m;
    if(n==m){cout<<"Yes";}
    else{cout<<"No";}
    
//code ends
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let n: i64 = get_vec_input()[0];
    let count = (1..n + 1)
        .map(|x| get_digit(x))
        .filter(|x| x % 2 != 0)
        .collect::<Vec<i64>>()
        .len();
    println!("{}", count);
}

#[allow(dead_code)]
fn get_digit(value: i64) -> i64 {
    let mut digit = 0i64;
    let mut value = value;
    while value != 0 {
        value /= 10;
        digit += 1;
    }
    digit
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}


Measured memory_bytes: 4352
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
	int N, a, b, Q, K, x, y;
	cin >> N;
	vector<vector<pair<int, long>>> d(N);
	for (int i = 1; i < N; i++) {
		long c;
		cin >> a >> b >> c;
		d[a - 1].emplace_back(b - 1, c);
		d[b - 1].emplace_back(a - 1, c);
	}
	cin >> Q >> K;
	priority_queue<pair<long, int>, vector<pair<long, int>>, greater<pair<long, int>>> e;
	e.emplace(0, K - 1);
	vector<bool> f(N);
	vector<long> g(N, LONG_MAX);
	g[K - 1] = 0;
	while (!e.empty()) {
		pair<long, int> h = e.top();
		e.pop();
		f[h.second] = true;
		for (pair<int, long>& i : d[h.second]) {
			if (f[i.first]) continue;
			if (g[h.second] + i.second < g[i.first]) {
				g[i.first] = g[h.second] + i.second;
				e.emplace(g[i.first], i.first);
			}
		}
	}
	for (int i = 0; i < Q; i++) {
		cin >> x >> y;
		cout << g[x - 1] + g[y - 1] << endl;
	}
}

Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e6;
const ll mod=1e9+7;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pi acos(-1)
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define SIZE 5000 + 1

ll expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}


void solve()
{
   ll n;
   cin>>n;
   while(n)
   {
       if(n%10==7){cout<<"Yes"<<endl;return;}
       n=n/10;
   }
   cout<<"No";
}

int main()
{
  boost;
  ll t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3652
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template<class T>
class segmentTree {
private:
    std::vector<T> data;
    size_t size;

    int getGCD(size_t l, size_t r, size_t k, size_t left, size_t right) const {
        if (right <= l || r <= left)return 0;
        if (l <= left && right <= r)return data[k];
        T a = getGCD(l, r, k * 2 + 1, left, (left + right) / 2);
        T b = getGCD(l, r, k * 2 + 2, (left + right) / 2, right);
        return gcd(a, b);
    }

public:
    template<class Itr>
    segmentTree(Itr first, Itr last) {
        size_t dif = std::distance(first, last);
        size = 1;
        while (size < dif)size <<= 1;
        data.resize(2 * size - 1, 0);
        for (size_t i = 0; i < dif; ++i, ++first)update(i, *first);
    }

    void update(size_t i, int value) {
        i += size - 1;
        data[i] = value;
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = gcd(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    T getGCD(size_t l, size_t r) const {
        return getGCD(l, r, 0, 0, size);
    }

    void show()const {
        for (size_t i = 0; i < 2 * size - 1; ++i) {
            std::cout << data[i] << ",";
            if (!((i + 2) & (i + 1)))std::cout << '\n';
        }
    }

};

template<class Itr>
auto make_segmentTree(Itr first, Itr last) {
    return segmentTree<std::remove_reference_t<decltype(*first)>>(first, last);
}

int main() {

    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (auto& i : A)std::cin >> i;

    auto seg = make_segmentTree(A.begin(), A.end());
    //seg.show();
    int ans = -1;
    for (int i = 0; i < N; ++i) {
        ans = std::max(ans, gcd(seg.getGCD(0, i), seg.getGCD(i + 1, N)));
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 1664
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a <= 5:
        print(0)
    elif 6 <= a <= 12:
        print(b // 2)
    else:
        print(b)
    return

#B
def B():
    r, d, x = LI()
    for i in range(10):
        print(x * r - d)
        x = x * r - d
    return

#C
def C():
    n, m = LI()
    imo = [0 for i in range(n+1)]
    for _ in range(m):
        l, r = LI_()
        imo[l] += 1
        imo[r + 1] -= 1
    for i in range(1,n):
        imo[i] += imo[i - 1]
    ans = 0
    #print(imo)
    for i in imo:
        if i == m:
            ans += 1
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

using namespace std;

char m[256][2];

int main(){
	m['A'][0] = 'X';
	m['A'][1] = 'Y';
	m['X'][1] = 'Z';
	m['Y'][0] = 'X';
	m['Z'][0] = 'W';
	m['Z'][1] = 'B';
	m['W'][0] = 'B';
	m['W'][1] = 'Y';
	m['B'][0] = 'Y';
	m['B'][1] = 'X';
	while(true){
		char p = 'A';
		string str;
		cin >> str;
		if(str[0] == '#')
			return 0;
		//cout << 'A';
		for(int i=0;i<str.size();i++){
			int n = str[i] - '0';
			p = m[p][n];
			//cout << "->" << p;
		}
		//cout << endl;
		if(p == 'B'){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

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

typedef long long ll;

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

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }
    vector<int> cost(N+1),cost2(N),cost3(N);
    ll all = 0;
    REP(i,N+1){
        if ( i == 0 ) {
            cost[0] = abs(A[0]);
        } else if ( i == N ) {
            cost[N] = abs(A[N-1]);
        } else {
            cost[i] = abs(A[i]-A[i-1]);
        }
        all += cost[i];
    }
    REP(i,N){
        if ( i == 0 ){
            cost2[0] = abs(A[1]);
        } else if ( i == N-1 ){
            cost2[N-1] = abs(A[N-2]);
        } else {
            cost2[i] = abs(A[i+1] - A[i-1]);
        }
    }
    REP(i,N){
        cost3[i] = cost[i] + cost[i+1];
    }
    
    ll ans;
    REP(i,N){
        ans = all - cost3[i] + cost2[i];
        cout << ans << endl;
    }
    
    
    
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll N = 5e3 + 10;
const ll Mod = 1e9 + 7;

ll n, m, k;
char s[N][N];

ll add(ll a, ll b) {
  return (a += b) >= Mod ? a - Mod : a;
}

ll sub(ll a, ll b) {
  return (a -= b) < 0 ? a + Mod : a;
}

ll mul(ll a, ll b) {
  return 1ll * a * b % Mod;
}

ll fast_pow(ll a, ll b) {
  b %= Mod - 1;
  ll res = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) {
      res = mul(res, a);
    }
  }
  return res;
}

struct Matrix {
  ll t[2][2];

  Matrix() {
    for (ll i = 0; i < 2; i++) {
      for (ll j = 0; j < 2; j++) {
        t[i][j] = 0;
      }
    }
  }
};

Matrix operator * (const Matrix a, const Matrix b) {
  Matrix c;
  for (ll i = 0; i < 2; i++) {
    for (ll j = 0; j < 2; j++) {
      for (ll k = 0; k < 2; k++) {
        c.t[i][j] = add(c.t[i][j], mul(a.t[i][k], b.t[k][j]));
      }
    }
  }
  return c;
}

Matrix operator ^ (Matrix a, ll b) {
  Matrix res;
  for (ll i = 0; i < 2; i++) {
    res.t[i][i] = 1;
  }
  for (; b; b >>= 1, a = a * a) {
    if (b & 1) {
      res = res * a;
    }
  }
  return res;
}

int main() {
  scanf("%lld %lld %lld", &n, &m, &k);
  ll sum = 0;
  for (ll i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (ll j = 1; j <= m; j++) {
      if (s[i][j] == '#') {
        sum++;
      }
    }
  }
  ll cnt1 = 0, cnt2 = 0;
  for (ll i = 1; i <= n; i++) {
    if (s[i][1] == '#' && s[i][m] == '#') {
      cnt1++;
    }
  } 
  for (ll i = 1; i <= m; i++) {
    if (s[1][i] == '#' && s[n][i] == '#') {
      cnt2++;
    }
  }
  if (cnt1 && cnt2) {
    printf("1\n");
  } else if (!cnt1 && !cnt2) {
    printf("%lld\n", fast_pow(sum, k - 1));
  } else if (cnt1) {
    for (ll i = 1; i <= n; i++) {
      for (ll j = 1; j < m; j++) {
        if (s[i][j] == '#' && s[i][j + 1] == '#') {
          cnt2++;
        }
      }
    }
    Matrix tmp, res;
    tmp.t[0][0] = sum, tmp.t[0][1] = 0;
    tmp.t[1][0] = cnt2, tmp.t[1][1] = cnt1;
    tmp = tmp ^ (k - 1);
    res.t[0][0] = 0   , res.t[0][1] = 1;
    res.t[1][0] = 0   , res.t[1][1] = 0;
    res = res * tmp;
    printf("%lld\n", sub(fast_pow(sum, k - 1), res.t[0][0]));
  } else {
    for (ll i = 1; i <= m; i++) {
      for (ll j = 1; j < n; j++) {
        if (s[j][i] == '#' && s[j + 1][i] == '#') {
          cnt1++;
        }
      }
    }
    Matrix tmp, res;
    tmp.t[0][0] = sum, tmp.t[0][1] = 0;
    tmp.t[1][0] = cnt1, tmp.t[1][1] = cnt2;
    tmp = tmp ^ (k - 1);
    res.t[0][0] = 0   , res.t[0][1] = 1;
    res.t[1][0] = 0   , res.t[1][1] = 0;
    res = res * tmp;
    printf("%lld\n", sub(fast_pow(sum, k - 1), res.t[0][0]));  
  }
  return 0;
}

Measured memory_bytes: 6400
# https://atcoder.jp/contests/abc084/tasks/abc084_d
# エラトステネスの篩を使う以外に考えられないが...
# あと高速化のために累積和も

import sys
read = sys.stdin.readline


def read_a_int():
    return int(read())


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


def ret_erators(N: int):
    # エラトステネスの篩
    is_prime = [True] * (N + 1)

    # 0と1は素数ではない
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, int(N**0.5) + 1):
        if is_prime[i]:
            j = i * 2  # iの倍数は素数ではない
            while j < N + 1:
                is_prime[j] = False
                j += i
    return is_prime


is_prime = ret_erators(10 ** 5)

# make is_like2017
is_like = [0] * (10**5 + 1)
for x in range((10 ** 5) // 2 + 1):
    if not is_prime[x]:
        continue
    n = 2 * x - 1
    if is_prime[n]:
        is_like[n] = 1

# make accum
from itertools import accumulate
is_like_accum = [0] + list(accumulate(is_like))

Q = int(input())
L, R = read_col(Q, 2)


for l, r in zip(L, R):
    print(is_like_accum[r + 1] - is_like_accum[l])


Measured memory_bytes: 17508
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

int main(){
    ll n,k;
    cin >> n >> k;
    ll a=n/k;
    ll ans=min(abs(n-a*k),abs(n-(a+1)*k));
    kaku(ans);
}



Measured memory_bytes: 256
N=int(input())
a=[-1]*(N+1)
for i in range(1,N+1):
  a[i]=int(input())
pos = 1
ans = 0
for _ in range(N):
  if pos == 2:
    print(ans)
    exit(0)
  pos = a[pos]
  ans += 1
  

print(- 1)

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    mp['a'] = 0, mp['b'] = 0, mp['c'] = 0;
    rep(i, s.size()) {
        mp[s[i]]++;
    }
    int abc[3];
    int ma = 0;
    for (auto m : mp) {
        ma = max(ma, m.second);
    }
    for (auto m : mp) {
        int abc = m.second;
        if (ma-abc > 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef unsigned long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 2e5 + 5;

bool M[N];
int A[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, x; cin >> n >> x;
	if (x + 1 == 2 * n || x == 1) die("No");
	if (n == 2) {
		cout << "Yes" << endl;
		cout << 1 << ends << 2 << ends << 3 << endl;
		return 0;
	}
	if (x != 2) {
		A[n - 1] = 1;
		A[n] = 2 * n - 1;
		A[n + 1] = x;
		A[n + 2] = 2;
		M[2 * n - 1] = M[1] = M[2] = M[x] = true;
	} else {
		A[n - 1] = 2 * n - 1;
		A[n] = 1;
		A[n + 1] = 2;
		A[n + 2] = 3;
		M[2 * n - 1] = M[1] = M[2] = M[3] = true;
	}
	cout << "Yes" << endl;
	int p = 1;
	for (int i = 1; i <= 2 * n - 1; i++) {
		if (A[i]) cout << A[i] << endl;
		else {
			while (M[p]) p++;
			M[p] = true;
			cout << p << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1664
from itertools import groupby

S = input()
K = int(input())
grp = [[k, len(list(g))] for k, g in groupby(S)]  # grp[文字][個数]
if len(grp) == 1:
    print(grp[0][1] * K // 2)
else:
    head = grp[0][1]
    tail = grp[-1][1]
    body_sum = 0
    for g in grp[1:len(grp) - 1]:
        body_sum += g[1] // 2 * K
    if grp[0][0] == grp[-1][0]:
        print(head // 2 + tail // 2 + (head + tail) // 2 * (K - 1) + body_sum)
    else:
        print(head // 2 * K + tail // 2 * K + body_sum)


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

int main() {
	int N; cin >> N;
	int a[10010]; 
	for(int i=0; i<N; ++i) cin >> a[i];
	int S=0, j;
	for(int i=0; i<N; ++i){
	    while(a[i]%2==0){
	        a[i] /= 2;
	        ++S;
	    }
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  if(s[0]==s[1] && s[1]==s[2]){
    cout << "No" << endl;
  }
  else cout << "Yes" << endl;
  
  
  return 0;
    

}


Measured memory_bytes: 256
from collections import deque
INFTY = 10**4
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
cnt = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            cnt += 1
dist = [[INFTY for _ in range(W)] for _ in range(H)]
hist = [[0 for _ in range(W)] for _ in range(H)]
dist[0][0] = 0
que = deque([(0,0)])
while que:
    i,j = que.popleft()
    if j+1<W and hist[i][j+1]==0 and S[i][j+1]==".":
        dist[i][j+1] = dist[i][j]+1
        que.append((i,j+1))
        hist[i][j+1] = 1
    if i-1>=0 and hist[i-1][j]==0 and S[i-1][j]==".":
        dist[i-1][j] = dist[i][j]+1
        que.append((i-1,j))
        hist[i-1][j] = 1
    if j-1>=0 and hist[i][j-1]==0 and S[i][j-1]==".":
        dist[i][j-1] = dist[i][j]+1
        que.append((i,j-1))
        hist[i][j-1] = 1
    if i+1<H and hist[i+1][j]==0 and S[i+1][j]==".":
        dist[i+1][j] = dist[i][j]+1
        que.append((i+1,j))
        hist[i+1][j] = 1
if dist[H-1][W-1]==INFTY:
    print(-1)
else:
    print(cnt-2-dist[H-1][W-1]+1)

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    double l;
    cin >> l;
    l /= 3.0;
    printf("%.12lf\n", l * l * l);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int numb=0,numr = 0;
	for(int i = 0;i < s.length();i++){
		if(s[i]=='B') numb++;
		else if(s[i]=='R') numr++;
	}
	if(numr>numb) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   string n;
   string m;
   cin >> n >> m;
  
   
  
   int sum = 0;
   for(int i = 0;i<n.size();i++){
     
     
     if(n[i]==m[i]){
       
       sum++;
     }
   }
  cout << sum << endl;
  
  
   
  return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
cnt = 0
m = 0
for i in range(n):
    if i == 0:
        cnt += 1
        m = h[i]
    elif h[i-1] <= h[i] and h[i] >= m:
        m = h[i]
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
//package atcoder;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(System.in);
        final int X = in.nextInt();
        final int N = in.nextInt();
        final Set<Integer> p = new HashSet<>();

        for (int i = 1; i <= N; ++i) {
            p.add(in.nextInt());
        }

        for (int d = 0; d <= 100; ++d){
            if (!p.contains(X - d)) {
                System.out.println(X - d);
                return;
            }
            if (!p.contains(X + d)) {
                System.out.println(X + d);
                return;
            }
        }
        System.out.println(0);
    }
}


Measured memory_bytes: 35732
//Replacing Integer

#include<bits/stdc++.h>
#define ll long long 
using namespace std;

int main(){
    ll N,K,a,b;
    cin >> N >> K;
    a = N % K;
    b = abs(a -K);
    if(a>=b){cout << b << endl;}
    else{cout << a << endl;}
    return 0;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  ll n;
  cin >> n;
  vector<string> v(n);
  rep(i, n) { cin >> v[i]; }

  map<string, ll> mm;

  rep(i, n) {
    mm[v[i]]++;
  }

  cout << mm.size() << endl;

  return 0;
}

Measured memory_bytes: 25084
// https://atcoder.jp/contests/abc047/tasks/arc063_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.length() - 1) ans += (s[i] != s[i + 1]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		   String s = scanner.next();
		   int N = Integer.parseInt(s);
		   int count  = 0;
		   
		   for(int i = 0; i < s.length();) 
		   {
			   int j = Integer.parseInt(s.substring(i , i + 1));
			   count = count + j;
				i++;   
		   }
		    
		   if(N % count == 0) 
		   {
			   System.out.println("Yes");
		   }
		   else 
		   {
			   System.out.println("No");
		   }
		    scanner.close(); }
		  }

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

struct edge{
  int to;
  int cost;
};
vi dijkstra(vector<vector<edge>> G, int s){
  vi d(10,INF);
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
  d[s] = 0;
  q.push({0,s});
  while(!q.empty()){
    pair<int,int> p = q.top(); q.pop();
    int now = p.second;
    if(d[now] < p.first) continue;
    for(auto next : G[now]){
      if(chmin(d[next.to],d[now]+next.cost)) q.push({d[next.to],next.to});
    }
  }
  return d;
}
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int h,w; cin >> h >> w;
  vector<vector<edge>> G(10);
  rep(i,10) rep(j,10){
    int c; cin >> c;
    if(c == 0) c = INF;
    G[i].push_back({j,c});
  }
  vi dist(10);
  rep(start,10){
    if(start != 1){
      auto res = dijkstra(G,start);
      dist[start] = res[1];
    }
  }
  int ans = 0;
  rep(i,h) rep(j,w){
    int a; cin >> a;
    if(abs(a) != 1) ans += dist[a];
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3676
fun main(args : Array<String>) {
  val remove = mutableListOf<Int>()
  (1..readLine()!!.split(" ")[1].toInt())
    .map { readLine()!!.split(" ").map { it.toInt() } }
    .sortedBy { it[1] }
    .forEach { 
      if (remove.isEmpty()) remove.add(it[1] - 1)
      else if (it[0] > remove.last()) remove.add(it[1] - 1)
    }.run { print(remove.size) }
}

Measured memory_bytes: 83656
import java.util.*;
public class Main{
  static class tutt{
  	int a,b,c;
    tutt(int a,int b,int c){
    	this.a=a;
        this.b=b;
        this.c=c;
    }
  
  }
  static long[][] aa;
  static long maxx(tutt[] tut,int flag,int ind){
  	if(ind>=tut.length){return 0;}
    
    if(aa[ind][flag]!=-1){return aa[ind][flag];}
    
   	if(flag==0){
    	return aa[ind][flag]=Math.max(maxx(tut,1,ind+1)+(long)tut[ind].a,
                                     Math.max(maxx(tut,2,ind+1)+(long)tut[ind].b ,
                                             maxx(tut,3,ind+1)+(long)tut[ind].c  ) );
    }
    else if(flag==1){
    	return aa[ind][flag]=Math.max(maxx(tut,2,ind+1)+(long)tut[ind].b,
                                      maxx(tut,3,ind+1)+(long)tut[ind].c ); 
    }
    else if(flag==2){
    	return aa[ind][flag]=Math.max(maxx(tut,1,ind+1)+(long)tut[ind].a,
                                      maxx(tut,3,ind+1)+(long)tut[ind].c); 
    }
    else{
    	return aa[ind][flag]=Math.max(maxx(tut,1,ind+1)+(long)tut[ind].a,
                                      maxx(tut,2,ind+1)+(long)tut[ind].b); 
    }
    
  }
  
  public static void main(String[] args){
  
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    tutt[] arr=new tutt[n];
    for(int j=0;j<n;j++){
    	tutt temp=new tutt(s.nextInt(),s.nextInt(),s.nextInt() );
        arr[j]=temp;
    }
    aa=new long[n][4];
    for(int j=0;j<n;j++){
    	for(int i=0;i<4;i++){
         	aa[j][i]=-1;
        }
    }
    System.out.println(maxx(arr,0,0));
    
    
  }

}

Measured memory_bytes: 116300
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
//解答写し
int kazu[505][505];
int main(){
  int n,m,q;
  cin>>n>>m>>q;
  rep(i,m){
    int l,r;
    cin>>l>>r;
    kazu[l][r]++;
  }
  for(int i=1;i<505;i++){
    for(int j=1;j<505;j++){
      kazu[i][j]+=kazu[i][j-1];
    }
  }
  rep(i,q){
    int p,q;
    cin>>p>>q;
    int ans=0;
    for(int j=p;j<=q;j++){
      ans+=kazu[j][q]-kazu[j][p-1];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4592
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 200003;
const int P = MOD;
const int G = 2;

namespace Fft {
	typedef double ld;
	typedef complex<ld> cd;

	void dft(vector<cd> &a, int n) {
		vector<int> rev(1 << n);
		for (int i = 1; i < (1 << n); i++) {
			rev[i] = ((i & 1) << (n - 1));
			rev[i] |= (rev[i >> 1] >> 1);
		}
		for (int i = 0; i < (1 << n); i++) {
			if (i < rev[i]) {
				swap(a[i], a[rev[i]]);
			}
		}
		for (int step = 0; step < n; step++) {
			ld alpha = M_PI / (1 << step);
			cd w(cos(alpha), sin(alpha));
			for (int i = 0; i < (1 << n); i += (1 << (step + 1))) {
				cd curw(1, 0);
				for (int j = 0; j < (1 << step); j++) {
					cd u = a[i + j];
					cd v = curw * a[i + j + (1 << step)];
					a[i + j] = u + v;
					a[i + j + (1 << step)] = u - v;
					curw *= w;
				}
			}
		}
	}

	vector<int> mul(const vector<int> &a, const vector<int> &b) {
		int to = (int)max(a.size(), b.size());
		while (__builtin_popcount(to) > 1 || to < (int)(a.size() + b.size())) {
			to++;
		}
		int p = 0;
		while ((1 << p) < to) {
			p++;
		}
		vector<cd> f(to);
		for (int i = 0; i < to; i++) {
			if (i < (int)a.size()) {
				f[i] += cd(a[i], 0);
			} 
			if (i < (int)b.size()) {
				f[i] += cd(0, b[i]);
			}
		}
		dft(f, p);
		for (int i = 0; i < to; i++) {
			f[i] *= f[i];
		}
		dft(f, p);
		reverse(f.begin() + 1, f.end());
		vector<int> ans;
		for (auto &t : f) {
			t /= to;
			ans.push_back(round(t.imag() / 2));
		}
		return ans;
	}
} //namespace Fft

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> wr(P, -1);
	vector<int> pw(P);
	{
		int c = 1;
		for (int i = 0; i < P; i++) {
			wr[c] = i;
			pw[i] = c;
			c = (c * G) % P;
		}
	}
	vector<int> cnt(P);
	for (int i = 0; i < n; i++) {
		if (a[i] > 0) {
			cnt[wr[a[i]]]++;
		}
	}
	vector<int> res = Fft::mul(cnt, cnt);
	int ans = 0;
	{
		for (int i = 0; i < 2 * P; i++) {
			ans += (pw[i % (P - 1)] * res[i]);
		}
	}
	for (int i = 0; i < n; i++) {
		ans -= (a[i] * a[i]) % MOD;
	}
	ans /= 2;
	cout << ans << '\n';
}


Measured memory_bytes: 26000