akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int AB[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
 
 
	int N = getint(), M = getint();
	rep(i, M) {
		int a = getint(), b = getint();
		chmax(AB[b], a);
	}
 
	int kotae = 0;
	int kitta = 1;
	rep1(i, N) {
		if (kitta <= AB[i]) {
			kitta = i;
			kotae++;
		}
	}
	printf("%d\n", kotae);
 
	Would you please return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def dist(x1,y1,x2,y2):
	return abs(x1-x2)+abs(y1-y2)

def main():
	#N = int(input())
	S = input().rstrip()
	
	res = 0
	l,r = 0,0
	for s in S:
		d = int(s)
		l += 9 if r else d-1
		r += d
	
	res = max(l,r)
	print(res)
	#sT = "No Yes".split()
	#print(sT[res])
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 9212
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s;
  cin >> s;
  int n = s.size();

  cout << s[0];
  cout << n-2;
  cout << s[n-1] << endl;;

}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    string S,T;
    cin >> S >> T;
    
    ll length = S.size();
    string tmp = S;
    rep(i,length){
        S[0] = tmp[length-1];
        for(ll j=1;j<length;j++){
            S[j] = tmp[j-1];
        }

        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
        tmp = S;
    }

    cout << "No" << endl;

}



Measured memory_bytes: 3448
using System;
using System.Linq;

namespace _0107
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0 && x[2] == 0)
                {
                    break;
                }
                int n = int.Parse(Console.ReadLine());
                Array.Sort(x);
                int center = x[1] * 2 / 3;
                for (int i = 0; i < n; i++)
                {
                    int a = int.Parse(Console.ReadLine());
                    Console.WriteLine(a > center ? "OK" : "NA");
                }
            }
        }
    }
}

Measured memory_bytes: 9444
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,k;
int main()
{
    int ans=1;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        ans=fmin(ans*2,ans+k);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int sd10(ll n){
    int sum = 0;
    while(n){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(void){
    Cin(int, n);
    Couty(n % sd10(n) == 0);
}


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



int main(void){
    
    int a,b,c,k,i;
    cin>>a>>b>>k;
    c=b-a+1;
    //map<int,int>ans;
    if(c<2*k){
        for(i=a;i<=b;++i)cout<<i<<"\n";
    }
    
    else{
        for(i=0;i<k;++i){
            //ans[i]=a+i;
            cout<<a+i<<"\n";
        }
        //cout<<c<<"\n";
        for(i=b-k+1;i<=b;++i){
            cout<<i<<"\n";
        }
    }
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

#define SZ(x) ((int)x.size())
//#define debug

const int N = (int)2e5+5;
int n, m;
ii a[N];

struct segtree {
private:
	int lazy[1 << 19], tree[1 << 19], arr[N], type;
	void lazy_update(int k, int l, int r) {
		if (lazy[k] == 0) {
			return;
		}
		tree[k] += lazy[k];
		if (l != r) {
			lazy[k << 1] += lazy[k];
			lazy[k << 1 | 1] += lazy[k];
		}
		lazy[k] = 0;
	}
	void merge_tree(int k, int l, int r) {
		tree[k] = min(tree[l], tree[r]);
	}
	void build(int k, int l, int r) {
		if (l > r) {
			return;
		}
		if (l == r) {
			tree[k] = m - l + 1;
			return;
		}
		int mid = (l + r) >> 1;
		build(k << 1, l, mid);
		build(k << 1 | 1, mid + 1, r);
		merge_tree(k, k << 1, k << 1 | 1);
	}
public:
	void init() {
		build(1, 1, m + 1);
	}
	void update(int k, int l, int r, int L, int R, int val) {
		lazy_update(k, l, r);
		if (l > r || l > R || r < L) return;
		if (L <= l && r <= R) {
			lazy[k] += val;
			lazy_update(k, l, r);
			return;
		}
		int mid = (l + r) >> 1;
		update(k << 1, l, mid, L, R, val);
		update(k << 1 | 1, mid + 1, r, L, R, val);
		merge_tree(k, k << 1, k << 1 | 1);
	}
	int query(int k, int l, int r, int L, int R) {
		if (l > r || l > R || r < L) return (int)1e9+7;
		lazy_update(k, l, r);
		if (L <= l && r <= R) {
			return tree[k];
		}
		int mid = (l + r) >> 1;
		int lf = query(k << 1, l, mid, L, R);
		int rt = query(k << 1 | 1, mid + 1, r, L, R);
		return min(lf, rt);
	}
} tree;

int main() {
#ifdef debug
	freopen("inp.txt", "rt", stdin);
#endif
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i].first, &a[i].second);
	}
	tree.init();
	sort(a + 1, a + n + 1);
	int cnt = 0, ans = max(0, n - m);
	for (int i = 1; i <= n;) {
		int x = a[i].first;
		for (; i <= n && x == a[i].first; ++i) {
			tree.update(1, 1, m + 1, 1, a[i].second, -1);
		}
		int tmp_val = tree.query(1, 1, m + 1, x + 2, m + 1) + x;
		if (tmp_val >= 0) {
			continue;
		}
		ans = max(ans, -tmp_val);
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 6656
#include <iostream>

using namespace std;

main(){
  int n,d,x,r=0;
  cin>>n;
  long long A[n+2];
  A[0] = 0,A[n+1] = 0;
  for(int i=0;i<=n;i++){
    cin>>A[i+1];
    r+=abs(A[i] - A[i+1]);
  }
  for(int i=0;i<n;i++){
    cout<< r - abs(A[i] - A[i+1]) - abs(A[i+1] - A[i+2]) +abs(A[i] - A[i+2])<<endl;
  }
  return 0;
  
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
   
    int n; int k;cin>>n>>k;
    map<int,int> m;
    fore(i,0,k){
        int cur;cin>>cur;
        m.insert(make_pair(cur,0));
    }
    fore(i,n,10*n){
        string cur = to_string(i);
        bool can = true;
        fore(j,0,cur.length()){
            int act = cur[j]-'0';
            if(m.find(act)!=m.end()){
                can = false;break;
            }
        }if(can){
            cout<<cur<<"\n";
            break;
        }

    }

    return 0;
}



Measured memory_bytes: 256
#include <cstring>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int dp[1000000 + 100000];
int solve(int n){
  if(n < 10) return 0;
  if(dp[n] != -1) return dp[n];

  int now = 0;
  int nn = n;

  int next = 0;

  int tmp = 1;
  while(true){
    now += tmp * (nn % 10);
    nn /= 10;

    if(nn == 0) break;
    next = max(next, now * nn);
    tmp *= 10;
  }

  return dp[n] = solve(next) + 1;
}

int main(){
  const int q = getInt();
  memset(dp, -1, sizeof(dp));

  REP(i,q)
    printf("%d\n", solve(getInt()));

  return 0;
}

Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl


signed main(void){
    int N,K;
    int x[114514],y[114514];
    char c[114514];
    const int MEM = 2019;
    int imos[MEM][MEM];
    cin >> N >> K;
    REP(i,N){
        cin >> x[i] >> y[i] >> c[i];
        if(c[i]=='B'){
            y[i]+=K;
        }
        x[i]%=2*K;
        y[i]%=2*K;
    }
    REP(i,N){
        imos[x[i]+1][y[i]+1]++;
    }
    REP(i,2*K+1){
        REP(j,2*K){
            imos[i][j+1]+=imos[i][j];
        }
    }
    REP(i,2*K){
        REP(j,2*K+1){
            imos[i+1][j]+=imos[i][j];
        }
    }
    
    //RREP(j,2*K+1){REP(i,2*K+1){cout << imos[i][j] << " ";}cout << endl;}cout<<endl;
    
    int Ans=0;
    REP(i,K){REP(j,K){
      int sum=0;
      sum+=imos[i+K][j+K]-imos[i+K][j]-imos[i][j+K]+imos[i][j];
      sum+=imos[i][j]-imos[i][0]-imos[0][j]+imos[0][0];
      sum+=imos[i][2*K]-imos[i][j+K]-imos[0][2*K]+imos[0][j+K];
      sum+=imos[2*K][j]-imos[2*K][0]-imos[i+K][j]+imos[i+K][0];
      sum+=imos[2*K][2*K]-imos[2*K][j+K]-imos[i+K][2*K]+imos[i+K][j+K];
      Ans=max(Ans,max(sum,N-sum));
      //cout << i <<" "<< j << " " << sum <<endl; 
    }}
    
    cout << Ans << endl;
    return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;

  int ans = 0;
  rep(i, 3) {
    if (s[i] == t[i])
      ans++;
  }

  cout << ans << endl;

  return 0;
}


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



int main() 
{
  ll A; cin>>A;
  string S; cin>>S;
  ll B=(S.at(0)-'0')*100+(S.at(2)-'0')*10+(S.at(3)-'0')*1;
  cout<<(A*B)/100<<endl;
  return 0;
}


Measured memory_bytes: 3640
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJCGL_1C().doIt();
	}

	class AOJCGL_1C{
		int CCW(Point2D a,Point2D b,Point2D target){ //a-bの直線はtargetの右か左か
			Point2D q = new Point2D.Double(b.getX()-a.getX(),b.getY()-a.getY());
			Point2D r = new Point2D.Double(target.getX()-a.getX(),target.getY()-a.getY());
			if(cross(q, r)>0)return -1;//左側
			else if(cross(q,r)<0)return 1;//右側
			else return 0;//重なっている
		}

		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY()-p1.getY()*p2.getX();
		}

		int OnLine(Point2D p0,Point2D p1,Point2D p2){
			double a1 = p1.getX() - p0.getX();
			double b1 = p1.getY() - p0.getY();
			double a2 = p2.getX() - p0.getX();
			double b2 = p2.getY() - p0.getY();
			if (a1 * a2 <= 0 && b1 * b2 <= 0 && (a1 * a1 + b1 * b1 != 0 && a2 * a2 + b2 * b2 != 0))return -1;
			else if (Math.hypot(a1, b1) < Math.hypot(a2, b2))return 1;
			else return 0;
		}

		void doIt(){
			Point2D p0 = new Point2D.Double(in.nextDouble(),in.nextDouble());
			Point2D p1 = new Point2D.Double(in.nextDouble(),in.nextDouble());
			int q = in.nextInt();
			for(int i=0;i<q;i++){
				Point2D p2 = new Point2D.Double(in.nextDouble(), in.nextDouble());
				int d = CCW(p0, p1, p2);
				if(d>0)System.out.println("CLOCKWISE");
				else if(d<0)System.out.println("COUNTER_CLOCKWISE");
				else{
					int s = OnLine(p0, p1, p2);
					if(s<0)System.out.println("ONLINE_BACK");
					else if(s>0)System.out.println("ONLINE_FRONT");
					else if(s==0)System.out.println("ON_SEGMENT");
				}
			}
		}
	}

}

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

int main(void){
    int a, b, c, k, total=0, i, judge1 = 0, judge2 = 0;
    scanf("%d%d%d%d",&a,&b,&c,&k);

    for(i=0;i<a;i++){
        total += 1;
        if(i+1>=k){
            judge1 = 1;
            break;
        }
    }
    
    if(judge1 == 0){
        for(i=a;i<a+b;i++){
            if(i+1>=k){
                judge2 = 1;
            }
        }
    }

    if(judge1 == 0 && judge2 == 0){
        for(i=a+b;i<a+b+c;i++){
            total -= 1;
            if(i+1>=k){
                break;
            }
        }
    }

    printf("%d",total);
    
    return 0;
}

Measured memory_bytes: 1708
def solve():
    S = input()
    if S == 'SUN':
        print(7)
    elif S == 'MON':
        print(6)
    elif S == 'TUE':
        print(5)
    elif S == 'WED':
        print(4)
    elif S == 'THU':
        print(3)
    elif S == 'FRI':
        print(2)
    elif S == 'SAT':
        print(1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
def main():
    n, k = map(int, input().split())
    MOD = 10 ** 9 + 7
    ans = 0
    cnt = [0] * (k + 1)
    for i in range(1, k + 1):
        cnt[i] = pow(k // i, n, MOD)
    for i in range(k, 0, -1):
        for j in range(2, k // i + 1):
            cnt[i] -= cnt[i * j]
    ans = 0
    for i, c in enumerate(cnt):
        ans += i * c
        ans %= MOD
    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 74548
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        xy1: (Usize1, Usize1),
        xy2: (Usize1, Usize1),
        c: [Chars; h],
    }

    let mut dist = vec![vec![None; w]; h];
    dist[xy1.0][xy1.1] = Some(0);
    let mut q = std::collections::VecDeque::new();
    let mut s = std::collections::BTreeSet::new();
    q.push_back(xy1);
    s.insert(xy1);
    while let Some((i, j)) = q.pop_front() {
        let d = dist[i][j].unwrap();
        for x in 1..=k {
            if i < x {
                break;
            }
            let ni = i-x;
            if c[ni][j] == '@' || matches!(dist[ni][j], Some(x) if x <= d) {
                break;
            }
            dist[ni][j] = Some(d+1);
            if s.insert((ni, j)) {
                q.push_back((ni, j));
            }
        }
        for x in 1..=k {
            if i+x >= h {
                break;
            }
            let ni = i+x;
            if c[ni][j] == '@' || matches!(dist[ni][j], Some(x) if x <= d) {
                break;
            }
            dist[ni][j] = Some(d+1);
            if s.insert((ni, j)) {
                q.push_back((ni, j));
            }
        }
        for x in 1..=k {
            if j < x {
                break;
            }
            let nj = j-x;
            if c[i][nj] == '@' || matches!(dist[i][nj], Some(x) if x <= d) {
                break;
            }
            dist[i][nj] = Some(d+1);
            if s.insert((i, nj)) {
                q.push_back((i, nj));
            }
        }
        for x in 1..=k {
            if j+x >= w {
                break;
            }
            let nj = j+x;
            if c[i][nj] == '@' || matches!(dist[i][nj], Some(x) if x <= d) {
                break;
            }
            dist[i][nj] = Some(d+1);
            if s.insert((i, nj)) {
                q.push_back((i, nj));
            }
        }
    }
    println!("{}", dist[xy2.0][xy2.1].unwrap_or(-1));
}


Measured memory_bytes: 51636
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    if(n>=64) cout << 64 << endl;
    else if(n>=32) cout << 32 << endl;
    else if(n>=16) cout << 16 << endl;
    else if(n>=8) cout << 8 << endl;
    else if(n>=4) cout << 4 << endl;
    else if(n>=2) cout << 2 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
s = input()
a = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] in ["R", "U", "D"]:
        a += 1
    elif i % 2 == 1 and s[i] in ["L", "U", "D"]:
        a += 1
    else:
        print("No")
        break
if a == len(s):
    print("Yes")

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
int main(void)
{
	int a,b,c;
	int rec=0;
	int loz=0;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(a==b) loz++;
		if(a*a+b*b==c*c) rec++;
	}
	cout << rec << endl;
	cout << loz << endl;
	return 0;
}

Measured memory_bytes: 0
n=int(input())
a=[-1]+list(map(int,input().split()))

t=((n+1)+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]

#print(a)
#print(ans)

for i in range(t-1,0,-1):
 t_sum=sum(ans[i+i::i])
# print(i,a[i],t_sum)
 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1

#print(ans)

m=ans.count(1)
ans_l=[]
for i in range(n+1):
 if ans[i]==1:
  ans_l.append(i)
print(m)
if ans_l:
 print(*ans_l)

Measured memory_bytes: 14128
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())
S = [0] + list(map(int, input().split()))
T = [0] + list(map(int, input().split()))
 
dp_cum = [[0] * (M+1) for _ in range(N+1)]
dp_cum[0][0] = 1
for n in range(N+1):
    dp_cum[n][0] = 1
for m in range(M+1):
    dp_cum[0][m] = 1
  
for n in range(1,N+1):
    for m in range(1,M+1):
        now = 0
        if S[n] == T[m]:
            now = dp_cum[n-1][m-1]
        dp_cum[n][m] = dp_cum[n-1][m] + dp_cum[n][m-1] - dp_cum[n-1][m-1] + now
        dp_cum[n][m] %= MOD
print(dp_cum[N][M]) 

Measured memory_bytes: 96012
#include <iostream>
#include <map>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> ar;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		ar[a]++;
		ar[a - 1]++;
		ar[a + 1]++;
	}
	int mx = 0;
	for (map<int, int>::iterator it = ar.begin(); it != ar.end(); ++it) {
		mx = max(mx, it->second);
	}
	cout << mx << endl;
}

Measured memory_bytes: 4736
def main():
    mod = 10 ** 9 + 7

    K = map(int, iter(input()))
    D = int(input())

    s = 0
    dp = [0] * D
    for k in K:
        ndp = [0] * D
        for d in range(10):
            for i, dpi in enumerate(dp):
                ndp[(i + d) % D] += dpi

        for d in range(k):
            ndp[(s + d) % D] += 1

        s = (s + k) % D
        dp = [x % mod for x in ndp]

    print((dp[0] - (s != 0)) % mod)

main()

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

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,3)  if(s[i] == 'o') cnt++;
  cout << 700+cnt*100;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r;
    else cout << r + (100 * (10 - n));
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

const ll N_MAX = 3000005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<1) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

ll f(ll x, ll y){
	ll res = 0;
	res += combination(x+y+2, x+1);
	res -= 1;
	res += mod;
	res %= mod;
	return res;
}

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

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    ll res = 0;

    res += f(r2, c2);
    res %= mod;

    res -= f(r2, c1-1);
    res += mod;
    res %= mod;

    res -= f(r1-1, c2);
    res += mod;
    res %= mod;

    res += f(r1-1, c1-1);
    res %= mod;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 70528
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  bool can = false;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (4*i + 7*j == N) {
        can = true;
      }
    }
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.Array.IO
import Data.List
import Control.Monad

main = do
  [n, w] <- map read . words <$> getLine :: IO [Int]
  input <- sortBy (\x y -> compare (head x) (head y)) <$> getInt2DListBC
  table <- newArray ((1, 0), (4, 100)) 0 :: IO (IOUArray (Int, Int) Int)
  let [ww, vv] = transpose input
      num = map length . group $ ww
      wList = map head . group $ ww
      vList = split num vv
  foldM (memoize vList) table [1..length num]
  ans <- solve table w wList num
  print $ maximum ans

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

split :: [Int] -> [Int] -> [[Int]]
split [] _     = []
split (n:ns) v = (reverse . sort . take n $ v) : (split ns $ drop n v)

solve :: IOUArray (Int, Int) Int -> Int -> [Int] -> [Int] -> IO [Int]
solve table w wList num = do
  case length wList of
    1 -> do
      let pattern = [[i] | i <- [0..(num !! 0)]]
      return =<< mapM (solve' table w wList) pattern
    2 -> do
      let pattern = [[i, j] | i <- [0..(num !! 0)], j <- [0..(num !! 1)]]
      return =<< mapM (solve' table w wList) pattern
    3 -> do
      let pattern = [[i, j, k] | i <- [0..(num !! 0)], j <- [0..(num !! 1)], k <- [0..(num !! 2)]]
      return =<< mapM (solve' table w wList) pattern
    4 -> do
      let pattern = [[i, j, k, l] | i <- [0..(num !! 0)], j <- [0..(num !! 1)], k <- [0..(num !! 2)], l <- [0..(num !! 3)]]
      return =<< mapM (solve' table w wList) pattern

solve' :: IOUArray (Int, Int) Int -> Int -> [Int] -> [Int] -> IO Int
solve' memo w wList p
  | w < (sum $ zipWith (*) wList p) = return 0
  | otherwise = do
    s <- mapM (readArray memo) $ zip [1..4] p
    return $ sum s

memoize :: [[Int]] -> IOUArray (Int, Int) Int -> Int -> IO (IOUArray (Int, Int) Int)
memoize v memo i = do
  foldM (sumValue i) memo $ zip [1..100] (v !! (i-1))
  return memo

sumValue :: Int -> IOUArray (Int, Int) Int -> (Int, Int) -> IO (IOUArray (Int, Int) Int)
sumValue w memo (i, v) = do
  s <- readArray memo (w, i-1)
  writeArray memo (w, i) $ s + v
  return memo


Measured memory_bytes: 56700
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string x, y, z;
    cin >> x >> y >> z;
    transform(x.begin(), x.end(), x.begin(), ::toupper);
    transform(y.begin(), y.end(), y.begin(), ::toupper);
    transform(z.begin(), z.end(), z.begin(), ::toupper);

    cout << x[0] << y[0] << z[0] << endl;

    return 0;
}

Measured memory_bytes: 256
class Tag
  def solve(d, v, w, t)
    if v > w && d <= (v - w) * t then
      "YES"
    else
      "NO"
    end
  end

  def run
    a, v = gets.chomp.split(/\s+/).map(&:to_i)
    b, w = gets.chomp.split(/\s+/).map(&:to_i)
    t = gets.chomp.to_i
    puts solve((a - b).abs, v, w, t)
  end
end

if $0 == __FILE__
  Tag.new.run
end


Measured memory_bytes: 14256
#include<iostream>
#include <vector>
#include <cstring>
#include <deque>
#define Long long long int
#define For(i,a,b) for(int i=a;i<=b;i++)
#define ForR(i,a,b) for(int i=a;i>=b;i--)
#define e5 100009
#define maxD 10
using namespace std;

bool isAddToEnd[100100];
int dem = 0;
deque<int> mydeque;
void func(Long c){
	if(c == 0) return;
	dem ++;
	if(c%2==0){		
		isAddToEnd[dem] = true;
		func(c/2);
	}	else	{
		isAddToEnd[dem] = false;
		func(c-1);
	}
}
main(){
	Long N;
	cin >> N;
	func(N+1);
//	For(i,1,dem){
//		cout << isAddToEnd[i] << " ;"; 
//	}
	ForR(i,dem-1,1){
		if(isAddToEnd[i]) mydeque.push_back(dem-i);
		else	mydeque.push_front(dem-i);
	}
//	cout << " size :" << mydeque.size();
	For(i,1,dem-1){
		mydeque.push_back(i);
//		cout << "push : " << i+1;
	}	
	cout << 2*(dem-1) << endl;
	For(i,0,2*(dem-1)-1){
		cout << mydeque[i] << " ";
	}
}

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

int main() {

	int A,B,C,K,ans=0;
	cin>>A>>B>>C>>K;
	if(A>=K){
		cout<<K<<endl;
		return 0;
	}
	else {
		K-=A;
		ans+=A;
	}
	if(B>=K){
		cout<<ans<<endl;
		return 0;
	}
	else {
		K-=B;
	}
	cout<<ans-K<<endl;
}


Measured memory_bytes: 3636
n = gets.to_i
fs = n.times.map { gets.split.map(&:to_i) }
ps = n.times.map { gets.split.map(&:to_i) }

ans = -10000000000
([0, 1].repeated_permutation(10).to_a - [[0] * 10]).each do |s|
  tmp = 0
  n.times do |i|
    cnt = 0
    10.times do |j|
      cnt += s[j] * fs[i][j]
    end
    tmp += ps[i][cnt]
  end

  ans = tmp if ans < tmp
end
puts ans

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
using namespace std;

int main()
{
__

int n;

cin >> n;

cout << (n*n*n) << '\n';


return 0;
}


Measured memory_bytes: 256
L, R = list(map(int, input().split()))
RR = R + 1
ans = []

for i in range(L, R):
    for j in range(i + 1, RR):
        a = i * j % 2019
        ans.append(a)
        if a == 0:
            break
    # breakされなかったら
    else:
        continue
    break
print(min(ans))        


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

int main(){
    int a, b, save;
    while(1){
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        if (b < a) save = a, a = b, b = save;
        cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

class Combination{
    public:
        int N;
        vector<vector<long long>> cmb;
        Combination(int n):N(n),cmb(n,vector<long long>(n,0)){
            for(int i=0;i<N;i++){
                cmb[i][0]=1;
                for(int j=1;j<=i;j++) cmb[i][j]=cmb[i-1][j-1]+cmb[i-1][j];
            }
        }

        long long operator()(int i,int j) const{
            return cmb[i][j];
        }
};

typedef long double ld;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    reverse(all(v));
    ///cout << n << " " << a << " " << b << endl;
    ///cout << "----------" << endl;
    ///for(int i=0;i<n;i++){
    ///    cout << v[i] << endl;
    ///    if(i==a-1) cout << "----------" << endl;
    ///}


    ld sum=0;
    rep(i,a) sum+=v[i];

    ld ave = sum/a;
    printf("%.20Lf\n",ave);

    map<ll,ll> vmp,mp;
    rep(i,n) vmp[v[i]]++;
    rep(i,a) mp[v[i]]++;

    Combination nCr(100);
    ll ans=1;
    auto mn = (*(mp.begin())).first;
    auto mx = (*(mp.rbegin())).first;

    debug2(mn,mx);
    if(mn==mx){
        //cout << "pass1" << endl;
        ans=0;
        for(int i=a;i<=b;i++){
            //cout << mn << " " << vmp[mn] << " " << i << " " << nCr(vmp[mn],i) << endl;
            ans += nCr(vmp[mn],i);
        }
    }else{
        //cout << "pass2" << endl;
        ans = nCr(vmp[mn],mp[mn]);
    }

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


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main {
static int[][] memo;
static int I,J;
static String h,s;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   h=sc.nextLine();
	   s=sc.nextLine();
	   I=h.length();
	   J=s.length();
	   memo=new int[3003][3003];
	   for(int []a:memo)
		   Arrays.fill(a,-1);
	   solve(0,0);
	   trace(0,0);
	}
	static int solve(int i, int j)
	{
		if(i >= I || j >= J)
		{
			return 0;
		}
		if(memo[i][j] != -1)	return memo[i][j];
		int opt1 = solve(i + 1, j);
		int opt2 = solve(i, j + 1);
		int opt3 = s.charAt(j) == h.charAt(i) ? solve(i + 1, j + 1) + 1 : 0;
		return memo[i][j] = Math.max(opt1, Math.max(opt2, opt3));
	}
	static void trace(int i, int j)
	{
		if(i >= I || j >= J)	return;
		
		int opt1 = solve(i + 1, j);
		int opt2 = solve(i, j + 1);
		if(s.charAt(j) == h.charAt(i))
		{
			System.out.print(s.charAt(j));
			trace(i + 1, j + 1);
			return; 
		}
		else if(opt2 > opt1)
			trace(i, j + 1);
		else
			trace(i + 1, j);
	 
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 82652
#include <iostream>
using namespace std;
int main(void){
   int a,b;
   cin>>a; cin>>b;

   if( a < b ) {
   cout<<"a < b";
 }
 else if( a > b ) {
   cout<<"a > b";
 }
 else {
   cout<<"a == b";
 }
 cout<<endl;
}


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

#define HASH 5000011

typedef struct List {
	struct List *next;
	char *s;
	int l;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i;
	long long x = 0;
	for (i = 0; s[i] != 0; i++) x = (x * 10007 + s[i] - 'a') % HASH;
	return (int)x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].l = l[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, dp[26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 10007, HASH);
	for (k = 1, pow[0] = 10007; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (k = 0; k < 26; k++) {
				if (dp[k] == 0) continue;
				T[j] = 'a' + k;
				for (p = hash[h[i]]; p != NULL; p = p->next) if (p->l == l[i] - j && p->s[0] == T[j] && lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (T[j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

int digitsum(int n)
{
  int sum=0;
  while(n>0)
  {sum+=n%10;
   n/=10;}
  return sum;
}

int main()
{
  int a,b;
  cin>>a;
  b=a/2;
  int min=INT_MAX,min2;
  for(int i=1;i<=b;i++)
  {
    min2=digitsum(i)+digitsum(a-i);
    if(min2<min) min=min2;
  }
  cout<<min<<endl;
  return 0;
 }
  

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

int main()
{
    long N, A, B;
    cin >> N >> A >> B;

    long blueAndRedNum = N / (A + B);
    long diff = N - blueAndRedNum * (A + B);

    long res = blueAndRedNum * A;
    res += min(diff, A);
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int a,b,t;
  cin>>a>>b>>t;
  int ans;
  ans = (t/a)*b;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 100;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//shuffle(permutation.begin(), permutation.end(), rng);
//uniform_int_distribution<int>(l, r)(rng);
int n, k;
bool sudah[MAXN];
int A[MAXN], res;
vi v;

void dfs(int now) {
	sudah[now] = 1;
	if (now == 1) {
		v.pb(now);	
		return;
	}
	if (!sudah[A[now]]) dfs(A[now]);
	v.pb(now);
}

int DP[MAXN];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	FOR(i, 1, n) cin >> A[i];
	if (A[1] != 1) {
		A[1] = 1; res++;
	}
	FOR(i, 1, n) if (!sudah[i]) dfs(i);
	reverse(v.begin(), v.end());
	REP(i, v.size() - 1) {
		int now = v[i];
		if (DP[now] == k - 1) {
			if (A[now] == 1);
			else {
				A[now] = 1;
				res++;
			}
		}
		else {
			DP[A[now]] = max(DP[A[now]], DP[now] + 1);
		}
	}
	cout << res << '\n';
}

Measured memory_bytes: 4728
#include<stdio.h>

int pos[][3]={
	{1,2,3},{1,3,5},{1,4,2},{1,5,4},
	{2,1,4},{2,3,1},{2,4,6},{2,6,3},
	{3,1,2},{3,2,6},{3,5,1},{3,6,5},
	{4,1,5},{4,2,1},{4,5,6},{4,6,2},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,3,2},{6,4,5},{6,5,3},
};

int d1[7],d2[7];
int main(){
	for(int i=1;i<=6;i++)scanf("%d",d1+i);
	for(int i=1;i<=6;i++)scanf("%d",d2+i);
	for(int i=0;i<24;i++){
		int flag=1;
		for(int j=0;j<3;j++)flag&=d1[j+1]==d2[pos[i][j]];
		for(int j=3;j<6;j++)flag&=d1[j+1]==d2[7-pos[i][5-j]];
		if(flag){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=LLONG_MAX;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  int p[n];
  REP(i,n){
    cin>>p[i];
  }
  int ans=0;
  REP(i,n){
    if(i==0 || i==n-1){
      continue;
    }else{
      if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1])){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    int N; cin >> N;
    map<int, int> M;
    int ma = -1;
    rep(i,N) {
        int d; cin >> d;
        if (i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        }
        M[d]++;
        if (ma < d) ma = d;
    }
    if (M[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    ll res = 1;
    for (int i = 1; i <= ma; i++) {
        if (M[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
        res *= modpow(M[i], M[i+1], 998244353);
        res %= 998244353;
    }
    cout << res << endl;
}


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

int main() {
	char s;
	cin >> s;
	if (isupper(s)) cout << 'A' << endl;
	else cout << 'a' << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;

  if(v<=w) drop("NO");
  Int d=abs(a-b);
  Int s=v-w;
  if(s*t>=d) drop("YES");
  drop("NO");
  return 0;
}


Measured memory_bytes: 3652
count = 0
ans = []
dic = {}
n = int(input())
for i in range(n):
    s = input()
    number = dic.get(s, 0) + 1
    count = max(count, number)
    dic[s] = number
for key in dic:
    if dic[key] == count:
        ans.append(key)
ans.sort()
for k in ans:
    print(k)

Measured memory_bytes: 32140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)


class SEGMENTS{
private:
    
    struct seg{
        int l,r;
        bool operator < (seg obj)const {
            if(r!=obj.r) return r<obj.r;
            else return l<obj.l;
        }
    };
    
    set<seg> dat;
    
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
    
public:
    
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end() || r<=it->l)break;
            
            int li = it->l;
            int ri = it->r;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                int tl = li, tr = ri;
                if( isInclude(l,r,li,ri) ){
                    dat.erase(it);
                    if(li!=l) dat.insert(seg{li,l});
                    if(r!=ri) dat.insert(seg{r,ri});
                }else{
                    if(li<=l&&l<ri) tr = l;
                    if(l<=li&&li<r) tl = r;
                    dat.erase(it);
                    if(tl!=tr) dat.insert(seg{tl,tr});
                }
            }
        }
    }
    
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end() || r<it->l)break;
            
            if( isInclude(it->l,it->r,l,r) ) dat.erase(it);
            else{
                l = min(l,it->l);
                r = max(r,it->r);
            }
        }
        
        auto it = dat.lower_bound(seg{(int)-INF,l});
        if( it!=dat.end() && it->r == l ){
            l = it->l;
            dat.erase(it);
        }
        if(l!=r)dat.insert(seg{l,r});
    }
    
    int size(){ return dat.size(); }
    
    void output(){ for(auto e:dat)cout<<e.l<<" "<<e.r<<endl;cout<<endl; }
};

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    SEGMENTS st;
    
    for(int i=0;i<n;){
        if(s[i]=='0')i++;
        else{
            int l=i;
            while(i<n && s[i]=='1') i++;
            st.insert(l,i);
        }
    }
    
    int q;
    cin>>q;
    while(q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        
        if(b==0)    st.erase(l,r);
        else        st.insert(l,r);
        
        cout<<st.size()<<endl;
    }
}

Measured memory_bytes: 4136