akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
const int INF = 1e9;

using P = pair<int,int>;

int main(void){
    int n;
    cin >> n;
    vector<P> p(n);
    multiset<int> bl, br;
    rep(i,n) {
        int l, r;
        cin >> l >> r;
        r++;
        p[i] = {l,r};
        bl.insert(l);
        br.insert(r);
    }
    sort(all(p));

    int res = 0;
    int al = 0, ar = INF;
    rep(i,n-1){
        int l = p[i].first;
        int r = p[i].second;
        al = max(al, l);
        ar = min(ar, r);
        bl.erase(bl.find(l));
        br.erase(br.find(r));

        int pointL = max(0, ar-al);
        int pointR = max(0, (*br.begin())-(*bl.rbegin()));
        res = max(res, pointL + pointR);
    }

    multiset<int> sl,sr;
    rep(i,n){
        sl.insert(p[i].first);
        sr.insert(p[i].second);
    }
    rep(i,n){
        int l = p[i].first;
        int r = p[i].second;
        sl.erase(sl.find(l));
        sr.erase(sr.find(r));
        res = max(res, (r-l) + max(0, (*sr.begin())-(*sl.rbegin())));
        sl.insert(l);
        sr.insert(r);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>
int main(void) {
  int a11, a12, a13, a21, a22, a23, a31, a32, a33;
  scanf("%d %d %d", &a11, &a12, &a13);
  scanf("%d %d %d", &a21, &a22, &a23);
  scanf("%d %d %d", &a31, &a32, &a33);
  int n, i, x;
  scanf("%d", &n);
  for (i = n; i > 0; i--) {  // n回繰り返す
    scanf("%d", &x);
    if (a11 == x) a11 = 0;
    if (a12 == x) a12 = 0;
    if (a13 == x) a13 = 0;
    if (a21 == x) a21 = 0;
    if (a22 == x) a22 = 0;
    if (a23 == x) a23 = 0;
    if (a31 == x) a31 = 0;
    if (a32 == x) a32 = 0;
    if (a33 == x) a33 = 0;
  }
  //ビンゴか判定する
  if (a11 + a12 + a13 == 0 || a21 + a22 + a23 == 0 || a31 + a32 + a33 == 0)
    printf("Yes\n");
  else if (a11 + a21 + a31 == 0 || a12 + a22 + a32 == 0 || a13 + a23 + a33 == 0)
    printf("Yes\n");
  else if (a11 + a22 + a33 == 0 || a31 + a22 + a13 == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 128
def solve():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    ret = 0
    total = 0
    for i in range(N)[::-1]:
        diff = (-1*(AB[i][0]+ret))%AB[i][1]
        ret += diff
        
    print(ret)
    
solve()

Measured memory_bytes: 27124
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;
import java.awt.Point;
import java.util.Map;
import java.util.HashMap;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] dn = br.readLine().split(" ");
        int d = Integer.parseInt(dn[0]);
        int n = Integer.parseInt(dn[1]);
        int[] kion = new int[d+1];
        int[] a = new int[n+1];
        int[] b = new int[n+1];
        int[] c = new int[n+1];
        
        for (int i = 0; i < d; i++) {
            kion[i+1] = Integer.parseInt(br.readLine());
        }
        
        for (int i = 0; i < n; i++) {
            String[] line = br.readLine().split(" ");
            a[i+1] = Integer.parseInt(line[0]);
            b[i+1] = Integer.parseInt(line[1]);
            c[i+1] = Integer.parseInt(line[2]);
        }
        
        int[][] dp = new int[d+1][n+1];
        
        for (int i = 1; i <= n; i++) {
            dp[1][i] = 0;
        }
        
        for (int i = 2; i <= d; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    if (kion[i] < a[j] || b[j] < kion[i]) continue;
                    if (kion[i-1] < a[k] || b[k] < kion[i-1]) continue;
                    dp[i][j] = Math.max(dp[i-1][k]+Math.abs(c[j]-c[k]), dp[i][j]);
                }
            }
        }
        
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            ans = Math.max(ans, dp[d][i]);
        }
        System.out.println(ans);
    }
}






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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

int main()
{
    boost;
    int n,h[N],i,ans[N],k;
    
    cin>>n>>k;
    for(i=0;i<n;i++) cin>>h[i];
    
    ans[0]=0;ans[1]=abs(h[1]-h[0]); 
    
    for(i=2;i<n;i++)
    {
        ans[i]=inf;
        for(int j=1;i-j>=0 and j<=k;j++)
            ans[i] = min(ans[i],ans[i-j] + abs(h[i-j]-h[i])) ; 
    }
    
    cout<<ans[n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
// 最長共通部分列 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_LEN 1000
// 無効な値の定義
const int INV = -1;

int longestCommonSubstring(string a, string b);

int main(void)
{

    int q, len;
    string first_str, second_str;

    cin >> q;

    for(int i = 0; i < q; i++)
    {
        cin >> first_str;
        cin >> second_str;

        len = longestCommonSubstring(first_str, second_str);
        printf("%d\n", len);
    }



    return 0;
}

// 最長共通部分列を算出する関数
int longestCommonSubstring(string str_a, string str_b)

{
    int dp[MAX_LEN + 1][MAX_LEN + 1];
    int a_len, b_len;

    a_len = str_a.size();
    b_len = str_b.size();

    // 文字列の先頭に空白を挿入する
    str_a = " " + str_a;
    str_b = " " + str_b;

    for(int i = 0; i <= a_len; i++)
    {
        dp[i][0] = 0;
    }

    for(int j = 0; j <= b_len; j++)
    {
        dp[0][j] = 0;
    }

    // 最長共通部分列の算出
    for(int i = 1; i <= a_len; i++)
    {
        for(int j = 1; j <= b_len; j++)
        {
            if( str_a[i] == str_b[j] )
            {
                // 最後の文字が一致している時
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else
            {
                // 最後の文字が一致していない時
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

	return dp[a_len][b_len];
}



Measured memory_bytes: 7112
n, k = map(int, input().split())
MOD = 10**9 + 7

from math import factorial
class Facts():
    """
    階乗のメモ化
    組み合わせ数、順列数の計算を高速に行う
    """
    def __init__(self, max_num=2*10**5, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        self.ifact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p
            self.ifact[i] = self.power_func(self.fact[i], self.p-2)

    def comb(self, n, k):
        """ nCk mod p を求める """
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = self.fact[n]
        return (a*self.ifact[k] * self.ifact[n-k]) % self.p


    def power_func(self, a, b):
        """ a^b mod p　を繰り返し二乗法で求める """
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

facts = Facts()

ans = 0
for i in range(min(n, k+1)):
    ans += (facts.comb(n, i) * facts.comb(n-1, i)) % MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 54504
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; ++i){
        if (((i % 10) == (i / 10000)%10) and ((i/10 % 10) == (i / 1000)%10))
        {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define MAX 1e9+7
int main() {
	ll n,m;
	cin>>n>>m;
	vector<vector<char> > grid(n+1, vector<char>(m+1));
	for(int i=1; i<=n; i++)
	for(int j=1; j<=m; j++)
		cin>>grid[i][j];
		
	vector<vector<int> > dp(n+1, vector<int>(m+1,MAX));
	if(grid[1][1]=='#') dp[1][1] = 1;
	else dp[1][1] = 0;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(i==1 && j==1) continue;
			if(grid[i][j]=='#')
			{
				dp[i][j] = min(dp[i][j], dp[i][j-1] + (grid[i][j] != grid[i][j-1]));
				dp[i][j] = min(dp[i][j], dp[i-1][j] + (grid[i][j] != grid[i-1][j]));
			}
			else
			{
				dp[i][j] = min({dp[i][j], dp[i-1][j], dp[i][j-1]});
			}
		}
	}
	cout<<dp[n][m];
	return 0;
}

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

inline int read(){
    int w=1,s=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if (ch=='-') w=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();}
    return s*w;
}

int a[400][400],f[400],vis[400],num[4100];

int main(){
    int n=read(),m=read();
    int ans=999999;
    int maxx=0,pos;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++) a[i][j]=read();
    for(int i=1;i<=n;i++) num[i]=1;
    for(int i=1;i<=m;i++){
        maxx=0;
        memset(f,0,sizeof(f));
          for(int j=1;j<=n;j++) {
              f[a[j][num[j]]]++;
              if (f[a[j][num[j]]]>maxx) {
                  maxx=f[a[j][num[j]]];
                  pos=a[j][num[j]];
                  
              }
          }
         vis[pos]=1;
         ans=min(ans,maxx);
         for(int j=1;j<=n;j++){
         while(vis[a[j][num[j]]]==1) {num[j]++;}
         }
    }
    cout<<ans;
    return 0;
}

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

int eulerPhi(int n);

int main(){
    int n; cin >> n;
    cout << eulerPhi(n) << endl;
    return 0;
}

int eulerPhi(int n){
    if(n == 0) return 0;
    int ans = n;
    for(int i = 2; i*i <= n; i++){
        if(n%i == 0){
            ans = ans/i*(i-1);
            while(n%i == 0) n/=i;
        }
    }
    if(n > 1) ans = ans/n*(n-1); // nが1でなければそれは素因数
    return ans;

}


Measured memory_bytes: 3104
n = int(input())
w = list(map(int, input().split()))

ans = 0
was = sum(w)
ws = 0

for i in range(n):
    ws += w[i]
    if i == 0:
        ws = w[0]
        ans = abs(was - ws * 2)
    if ans > abs(was - ws * 2):
        ans = abs(was - ws * 2)

print(ans)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 100000
typedef pair<int,int> P;
struct edge{
    int to,cost;
};
int V;
vector<edge> G[MAX_V];
bool used[MAX_V];

//priority_queue使用版，0(ElogV)
int prim(){
    priority_queue<P, vector<P>, greater<P>> que;
    memset(used, 0, sizeof(used));
    que.push(P(0,0));
    ll res = 0;
    while(!que.empty()) {
        int cst = que.top().first, v = que.top().second;
        que.pop();
        if(used[v]) continue;
        used[v] = 1;
        //cout << "v:" << v << " cst:" << cst << endl;
        res += cst;
        REP(i,G[v].size()) que.push(P(G[v][i].cost, G[v][i].to));
    }
    return res;
}

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> V;
    vector<pair<int,int>> vx(V),vy(V);
    REP(i,V){
        cin >> vx[i].first >> vy[i].first;
        vx[i].second = vy[i].second = i;
    }
    sort(vx.begin(),vx.end());
    REP(i,V-1){
        G[vx[i].second].push_back(edge{vx[i+1].second,vx[i+1].first-vx[i].first});
        G[vx[i+1].second].push_back(edge{vx[i].second,vx[i+1].first-vx[i].first});
    }
    sort(vy.begin(),vy.end());
    REP(i,V-1){
        G[vy[i].second].push_back(edge{vy[i+1].second,vy[i+1].first-vy[i].first});
        G[vy[i+1].second].push_back(edge{vy[i].second,vy[i+1].first-vy[i].first});
    }

    /*
    REP(i,V){
        REP(j,G[i].size()){
            cout << "G[" << i << "][" << G[i][j].to << "]:" << G[i][j].cost << "\n";
        }
    }
    */

    cout << prim() << "\n";
    return 0;
}


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

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

void solve(ll N, ll C, vector<ll> s, vector<ll> t, vector<ll> c){
    ll P[40][100010];
    fill(P[0], P[40], 0);
    rep(i, N) {
        for(int j=s[i]; j<=t[i]; j++) {
            P[c[i]][j] = 1;
        }
    }
    ll Q[100010];
    fill(Q, Q+100010, 0);
    rep(i, 40) {
        rep(j, 100010) {
            Q[j] += P[i][j];
        }
    }
    ll mx = 0;
    rep(i, 100010) {
        mx = max(mx, Q[i]);
    }
    cout << mx << endl;
}

int main() {
  ll N;
    scanf("%lld",&N);
    ll C;
    scanf("%lld",&C);
    vector<ll> s(N);
    vector<ll> t(N);
    vector<ll> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
        scanf("%lld",&c[i]);
    }
  solve(N, C, move(s), move(t), move(c));
  return 0;
}


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

using namespace std;

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

	int n, i, j, k, ans;
	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << "\n";

	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long int
#define N 100
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.141592653
#define cot cout.tie(0)
#define endl "\n"
using namespace std;
/**
  * @author :: Sawlani
  *
  */

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

    vector<int> a1,a2;
    f(i,1,n)
    {
        ll x,y;
        cin >> x >> y;

        a1.push_back(x+y);
        a2.push_back(x-y);
    }

    ll ans=*max_element(all(a1))-*min_element(all(a1));
    ll ans2=*max_element(all(a2))-*min_element(all(a2));
    ans2=max(ans,ans2);

    cout << ans2 << endl;
}

Measured memory_bytes: 5084
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	if p1, p2 := a*n, b; p1 >= p2 {
		fmt.Println(p2)
	} else {
		fmt.Println(p1)
	}
}


Measured memory_bytes: 512
#n=int(input())
#s=input()
#a,b=map(int,input().split())
#A=[list(map(int,input().split()))for i in range(n)]
s=list(input())
n=len(s)
compare=["0","1"]
compare_reverse=["1","0"]
if n%2==0:
    compare=compare*(n//2)
    compare_reverse=compare_reverse*(n//2)
else:
    compare=compare*(n//2)
    compare.append("0")
    compare_reverse=compare_reverse*(n//2)
    compare_reverse.append("1")
ans=0
ans_reverse=0
for i,j in zip(s,compare):
    if i!=j:
        ans+=1
for i,j in zip(s,compare_reverse):
    if i!=j:
        ans_reverse+=1
print(min(ans,ans_reverse))


Measured memory_bytes: 5548
N = int(input())
A = list(map(int, input().split()))

ans = True
for v in A:
    if v % 2 == 0:
        if v % 3 == 0 or v % 5 == 0:
            ans = ans and True
        else:
            ans = ans and False

if ans:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <functional>

#define rep(i,n) for(int i=0;i<n;i++)
#define scanInt(i) scanf("%d", &i)

using namespace std;

int main(){
	string input, output;
	cin >> input;
	rep(i,4){
		cout << input[i];
	}
	cout << " ";
	for(int i=4; i<12; i++){
		cout << input[i];
	}
	cout << endl;
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        int n = in.nextInt();
        int r = in.nextInt();
    
        if (10 <= n) {
            System.out.println(r);
        } else {
            System.out.println(r + (100 * (10 - n)));
        }
        
        
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;


namespace _506_String
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				//input
				int operatorCount = int.Parse (Console.ReadLine ());

				if (operatorCount == 0)
				{
					break;
				}

				string inputNum = Console.ReadLine ();

				//process
				List<int> outputList = new List<int> (100 / 2);

				//break
				for (int strIndex = 0; strIndex < inputNum.Length; strIndex++)
				{
					int num = int.Parse (inputNum[strIndex].ToString ());
					outputList.Add (num);
				}

				//make
				for (int lp = 0; lp < operatorCount; lp++)
				{
					List<int> newList = new List<int> (outputList.Count * 2);
					int chCount = 1;
					int ch = outputList[0];

					for (int listIndex = 1; listIndex < outputList.Count; listIndex++)
					{
						//match
						if (outputList[listIndex] == ch)
						{
							chCount++;
						}
						//do not match
						else
						{
							//write
							string tmp = chCount.ToString ();
							foreach (var item in tmp)
							{
								newList.Add (int.Parse (item.ToString ()));
							}

							newList.Add(ch);

							//initialize
							ch = outputList[listIndex];
							chCount = 1;
						}
					}

					//write
					string tmp2 = chCount.ToString ();
					foreach (var item in tmp2)
					{
						newList.Add (int.Parse (item.ToString ()));
					}
					newList.Add (ch);

					outputList = new List<int> (newList);

				}

				//output
				foreach (var item in outputList)
				{
					Console.Write (item);					
				}
				Console.WriteLine ();
			}
		}
	}
}

Measured memory_bytes: 10288
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var S = ReadLine();
            var num = 1;
            var pre = S[0];
            for(var i=1;i<N;++i)
                if(pre!=S[i])
                {
                    pre = S[i];
                    ++num;
                }
            WriteLine(num);
        }
    }
}

Measured memory_bytes: 13396
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32,
        a: i32,
        b: i32,
    };
    println!(
        "{}",
        if (b - a )%2 ==0{
            "Alice"
        } else {
            "Borys"
        }
    );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  ll a, v, b, w, t;
  cin >> a >> v >> b >>  w >> t;
  
  ll res =b, res1 = a;
  for(int i=1; i<=t; ++i){
    
    if(a < b){
      res  += w;
      res1 += v;
      if(res <= res1){
        cout << "YES" << endl;
        return 0;
      }
    }

    if(b < a){
      res -= w;
      res1 -= v;
      if(abs(res) <= abs(res1)){
        cout << "YES" << endl;
        return 0;
      }
    }

  }
  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)

const int INF = 1e9;

int main(){
    int H, W, h, w; cin >> H >> W >> h >> w;
    if(H%h==0 and W%w==0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    rep(i, 0, H){
        rep(j, 0, W){
            if(i%h==0 and j%w==0) cout << INF - 1;
            else if(i%h==h-1 and j%w==w-1) cout << -INF;
            else cout << 0;
            if(j != W - 1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Main {

    private static int N,M,R;
    private static int[] TOWNS;
    private static final int INF = 100000000;
    private static int[][] costs;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        R = sc.nextInt();
        TOWNS = new int[R];
        for(int i = 0; i < R; i++) {
            TOWNS[i] = sc.nextInt() - 1;
        }
        costs = new int[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                costs[i][j] = i==j ? 0 : INF;
            }
        }
        for(int i = 0; i < M; i++) {
            int a,b,c;
            a = sc.nextInt()-1;
            b = sc.nextInt()-1;
            c = sc.nextInt();
            costs[a][b] = costs[b][a] = c;
        }
        //Warshall-Floyd
        for(int k = 0; k < N; k++){
            for(int i = 0; i < N; i++) {
                for(int j = 0; j < N; j++) {
                    costs[i][j] = Math.min(costs[i][j], costs[i][k] + costs[k][j]);
                }
            }
        }
        //DFS
        LinkedList<DfsNode> stack = new LinkedList<>();
        stack.add(new DfsNode());
        List<List<Integer>> perms = new ArrayList<>();
        while(!stack.isEmpty()) {
            DfsNode node = stack.pop();
            if(node.route.size() == R) {
                perms.add(node.route);
                continue;
            }
            for(int i = 0; i < R; i++) {
                if(node.isVisited(i)) continue;
                stack.add(node.child(i));
            }
        }

        int ans = INF;
        for(List<Integer> perm : perms) {
            int dist = 0;
            for(int i = 0; i < R-1; i++) {
                dist += costs[TOWNS[perm.get(i)]][TOWNS[perm.get(i+1)]];
            }
            ans = Math.min(ans, dist);
        }
        System.out.println(ans);
    }

    private static class DfsNode {
        ArrayList<Integer> route;
        DfsNode() {
            this(new ArrayList<Integer>());
        }
        DfsNode(ArrayList<Integer> route) {
            this.route = (ArrayList<Integer>)route.clone();
        }
        DfsNode child(int i) {
            DfsNode child = new DfsNode(this.route);
            child.route.add(i);
            return child;
        }
        boolean isVisited(int i) {
            return this.route.contains(i);
        }
    }
}


Measured memory_bytes: 47836
D = list(map(int, input().split()))

y = D[2] - D[0]
x = D[1] - D[3]

s = str(D[2] + x) + " " + str(D[3] + y) + " "\
	+ str(D[0] + x) + " " + str(D[1] + y)
print(s)

Measured memory_bytes: 2940
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
 
ans = sum(A)
d = Counter(A) #Counterで要素をまとめる
 
for i in range(Q):
    b, c = map(int,input().split())
    tmp = d[b] #bの総数を記憶
    d[b] = 0 #bの総数を0にする
    d[c] += tmp #cの総数にbの総数を足す
    ans += (c-b)*tmp #合計の補正
    print(ans)

Measured memory_bytes: 23912
import math
inp = int(input())
searchMax = int(math.sqrt(inp))
min = 100
for i in range(1, searchMax + 1, 1):
    if inp % i == 0:
        maxLen = len(str(i)) if len(str(i)) > len(str(int(inp / i))) else len(str(int(inp / i)))
        min = min if min < maxLen else maxLen
print(min)

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 18;

int a[MAX];
int pos[MAX];
int nxt[MAX];
int used[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	LL k;
	cin >> n >> k;
	FOR(i, 0, n)
		cin >> a[i];
	RFOR(i, n, 0)
		pos[a[i]] = i;
	RFOR(i, n, 0)
	{
		nxt[i] = pos[a[i]];
		pos[a[i]] = i;
	}
	nxt[n] = -1;
	FILL(used, -1);
	used[n] = 0;
	int cur = n;
	int t;
	for(int i = 1; ; i++)
	{
		do
		{
			cur = nxt[cur] + 1;
		} while(cur < n && nxt[cur] > cur);
		if(used[cur] != -1)
		{
			t = i - used[cur];
			break;
		}
		used[cur] = i;
	}
	int iter = k % t;
	int ptr = 0;
	while(used[ptr] != iter)
		ptr++;
	for(int i = ptr; i < n;)
	{
		if(nxt[i] > i)
			i = nxt[i] + 1;
		else
			cout << a[i++] << " ";
	}
	return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	vector<ll> vl;
	for(int i=0;i<m;i++)
	{
		ll a;cin>>a;vl.push_back(a);	
	} 
	sort(vl.begin(),vl.end());
	vector<ll> dist;
	for(int i=0;i<m-1;i++)
	{
		dist.push_back(vl[i+1]-vl[i]);
	}
	sort(dist.begin(),dist.end());
	ll sum = 0;
	for(int i=0;i<m-n;i++)
	{
		sum+=dist[i];
	}
	cout<<sum<<endl;
 } 

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

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

Measured memory_bytes: 3912
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, w;
    cin >> n >> w;
    vector<pair<ll, ll>> ob(n);
    for (int i=0; i<n; i++) {
        cin >> ob.at(i).first >> ob.at(i).second;
    }
    int w1 = ob.at(0).first;
    vector<vector<ll>> vals(4);
    for (int i=0; i<4; i++) {
        vals.at(i).push_back(0);
    }
    for (int i=0; i<n; i++) {
        int tmp = ob.at(i).first - w1;
        vals.at(tmp).push_back(ob.at(i).second);
    }
    for (int i=0; i<4; i++) {
        sort(vals.at(i).begin(), vals.at(i).end());
        reverse(vals.at(i).begin() + 1, vals.at(i).end());
    }
    for (int i=0; i<4; i++) {
        for (int j=2; j<(int)vals.at(i).size(); j++) {
            vals.at(i).at(j) += vals.at(i).at(j-1);
        }
    }
    ll res = -1;
    for (int i=0; i<(int)vals.at(0).size(); i++) {
        for (int j=0; j<(int)vals.at(1).size(); j++) {
            for (int k=0; k<(int)vals.at(2).size(); k++) {
                for (int l=0; l<(int)vals.at(3).size(); l++) {
                    if ((ll)w1 * i + (ll)(w1+1) * j + (ll)(w1+2) * k + (ll)(w1+3) * l <= w) {
                        chmax(res, vals.at(0).at(i) + vals.at(1).at(j) + vals.at(2).at(k) + vals.at(3).at(l));
                    }
                }
            }
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long int N,M;
    cin>>N>>M;
    long long int H[N];
    long long int P[N];
    for(int i=0;i<N;i++){
        cin>>H[i];
        P[i]=1;
    }
    long long int count=N;
    for(int i=0;i<M;i++){
        long long int A,B;
        cin>>A>>B;
        if(H[A-1]>H[B-1]){
            P[B-1]=0;
        }
        else if(H[A-1]<H[B-1]){
            P[A-1]=0;
        }
        else {
            P[A-1]=0;
            P[B-1]=0;
        }
    }
    for(int i=0;i<N;i++){
        if(P[i]==0){
            count--;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
vi all;
inline int getid(int x)
{
	return lower_bound(all.begin(),all.end(),x)-all.begin();
}
const int maxn=2e5+7;
pi pt[maxn];
vc<pi> line[maxn],col[maxn];
set<pi> sline[maxn],scol[maxn];
queue<pi> q;
map<pi,bool> vis;
ll ans;
ll solveline(int id,ll L,ll R)
{
	auto it=sline[id].lower_bound(make_pair(L,all[id]));
	while(it!=sline[id].end()&&(*it)<=make_pair(R,all[id]))
	{
		auto v=(*it);
		if(!vis.count(v))
		{
			q.push(v);
			vis[v]=1;
		}
		it++;
		sline[id].erase(v);
	}
	return lower_bound(line[id].begin(),line[id].end(),make_pair(R+1,all[id]))-lower_bound(line[id].begin(),line[id].end(),make_pair(L,all[id]));
}
ll solvecol(int id,ll D,ll U)
{
	D++;
	U--;
	if(D>U) return 0;
	auto it=scol[id].lower_bound(make_pair(all[id],D));
	while(it!=scol[id].end()&&(*it)<=make_pair(all[id],U))
	{
		auto v=(*it);
		if(!vis.count(v))
		{
			q.push(v);
			vis[v]=1;
		}
		it++;
		scol[id].erase(v);
	}
	return lower_bound(col[id].begin(),col[id].end(),make_pair(all[id],U+1))-lower_bound(col[id].begin(),col[id].end(),make_pair(all[id],D));
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=1,x,y;i<=n;i++)
	{
		cin>>x>>y;
		pt[i].first=x+y;
		pt[i].second=x-y;
		all.push_back(pt[i].first);
		all.push_back(pt[i].second);
	}
	mkuni(all);
	for(int i=1;i<=n;i++)
	{
		int x=getid(pt[i].first),y=getid(pt[i].second);
		line[y].push_back(pt[i]);
		col[x].push_back(pt[i]);
		sline[y].insert(pt[i]);
		scol[x].insert(pt[i]);
	}
	int sz=all.size();
	for(int i=0;i<=sz;i++)
	{
		sort(line[i].begin(),line[i].end());
		sort(col[i].begin(),col[i].end());
	}
	q.push(pt[a]);
	vis[pt[a]]=1;
	ll dis=max(abs(pt[a].first-pt[b].first),abs(pt[a].second-pt[b].second));
	while(!q.empty())
	{
		auto u=q.front();q.pop();
		ll U=u.second+dis,D=u.second-dis,L=u.first-dis,R=u.first+dis;
		{
			int id=getid(U);
			if(all[id]==U)
				ans+=solveline(id,L,R);
		}
		{
			int id=getid(D);
			if(all[id]==D)
				ans+=solveline(id,L,R);
		}
		{
			int id=getid(L);
			if(all[id]==L)
				ans+=solvecol(id,D,U);
		}
		{
			int id=getid(R);
			if(all[id]==R)
				ans+=solvecol(id,D,U);
		}
	}
	cout<<ans/2<<endl;

}


Measured memory_bytes: 51184
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

#r, s, pで勝つ時のスコア
dp = [[0] * 3 for _ in range(K)]


for i in range(K):
    if T[i] == 's':
        dp[i][0] = R
    elif T[i] == 'p':
        dp[i][1] = S
    else:
        dp[i][2] = P
# print (dp)
for i in range(K, N):
    k = i % K
    if T[i] == 's': #筐体がチョキを出す時
        dp[k][0], dp[k][1], dp[k][2] = max(dp[k][1], dp[k][2]) + R, max(dp[k][0], dp[k][2]), max(dp[k][0], dp[k][1])
    elif T[i] == 'p': #筐体がパーを出す時
        dp[k][0], dp[k][1], dp[k][2] = max(dp[k][1], dp[k][2]), max(dp[k][0], dp[k][2]) + S, max(dp[k][0], dp[k][1])
    else:
        dp[k][0], dp[k][1], dp[k][2] = max(dp[k][1], dp[k][2]), max(dp[k][0], dp[k][2]), max(dp[k][0], dp[k][1]) + P
    # print (dp)
ans = 0
for tmp in dp:
    ans += max(tmp)
# print (dp)
print (ans)

Measured memory_bytes: 13096
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 6000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,k;
	cin>>n>>k;
	vector< pair<int,int> > a;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		a.pb(mp(x,y));
	}
	sort( a.begin(), a.end() );
	ll ans = LINF;
	for(int i=0;i<=n-k;i++){
		for(int j=i+k-1;j<n;j++){
			int lx = a[j].first - a[i].first;
			vector<int> ys;
			for(int p=i;p<=j;p++){
				ys.pb( a[p].second );
			}
			sort( ys.begin(),ys.end() );
			int ly = LINF;
			for(int p=0;p<=ys.size()-k;p++){
				ly = min( ly, ys[p+k-1] - ys[p]);
			}
			ll tmp = lx * ly;
			if( ans > tmp ) ans = tmp;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    ll ai;
    cin >> N;
    bool winDog = true;
    for(ll i=0;i<N;i++){
        cin >> ai;
        if(ai%2==1) winDog = false;
    }
    if(!winDog){ cout<<"first"<<endl;}
    else       { cout<<"second"<<endl;}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

//#define PI 3.14159265358979323846

int main()
{
    int a, b, ans;
    char op;
    while (true)
    {
        cin >> a >> op >> b;
        if (op == '?')
        {
            break;
        }

        switch (op)
        {
        case '+':
            ans = a + b;
            break;
        case '-':
            ans = a - b;
            break;
        case '*':
            ans = a * b;
            break;
        case '/':
            ans = a / b;
            break;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout << setprecision(x);
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define inf 200000000

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<vector<ll>> f(n), p(n);
	ll in1;
	REP(i, n){
		REP(k, 10){
			cin >> in1;
			f[i].push_back(in1);
		}
	}
	ll in2;
	REP(i, n){
		REP(k, 11){
			cin >> in2;
			p[i].push_back(in2);
		}
	}

	//1 << 32 をintでやっちゃだめlong long でやりましょう
	//あとlong long に代入するときは(1LL) をかけるのもおすすめ
	//j: 0b0000000101 だとしたら、時間帯0と2に空いている
	// dight9876543210
	// 1 =0b0000000001
	//2^10 - 1 =0b1111111111 右からkbit目は時間帯kにおいてjoisinoお姉さんの店が空いているかどうかを表している
	//  1<<k =0b1000000000 (k = 9)
    ll ans = -INT64_MAX*0.99;
	for (ll j = 1; j < 1024 /* = (2^10)*/; j++){ //joisinoの店のかいへい
        ll temp = 0;
		for (ll i = 0; i < n; ++i){ //ｎこの店
			ll c = 0;
			/*
            // 店iとjoisinoお姉さんの開く店の両方が営業している時間帯の個数をciとする
            
			//時間帯ｋにおいてjoisinoお姉さんの店が空いている=> j(2)の右からk桁目で１
            // j:=時間帯kにおいてjoisinoお姉さんの店が空いているかどうかを表している
            //     9876543210
            // j:= 1010101011
            // AND 0000100000 = 1<<k
            //     0000100000
            */
           // 
           // p[i][c] := ???
			for (ll k = 0; k < 10; ++k){
				if (f[i][k] && (j & (1 << k))) ++c;
				
			}
            temp += p[i][c]; 
		}
        if(temp>ans) ans = temp;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    long int c = 0;
    for(long int i = 1;i <= b;i++){
        if(i*a % b == 0){
            c = i*a;
            break;
        }
    }
    cout << c;
}


Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

X = I()

if 400 <= X <= 599:
    print('8')
elif 600 <= X <= 799:
    print('7')
elif 800 <= X <= 999:
    print('6')
elif 1000 <= X <= 1199:
    print('5')
elif 1200 <= X <= 1399:
    print('4')
elif 1400 <= X <= 1599:
    print('3')
elif 1600 <= X <= 1799:
    print('2')
elif 1800 <= X <= 1999:
    print('1')

Measured memory_bytes: 9208
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] numbers = new int[N];
    int count = 0;
    for (int i = 0; i < N; i++) {
      numbers[i] = sc.nextInt();
      while (numbers[i] % 2 == 0) {
        numbers[i] /= 2;
        count++;
      }
 
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 36040
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}




int main()
{
  int N, M;
  cin >> N >> M ;
  int s[100001];

  REP(i, 0, 100001)
  {
    s[i] = 0;
  }

  REP(i,0,M){
    int L, M;
    cin >> L >> M;
    L--;
    M--;
    s[L]++;
    s[M+1]--;
  }

  REP(i,0,100000){
    s[i + 1] += s[i];
  }
  int ans = 0;
  REP(i, 0, 100001)
  {
    if(s[i]==M){
      ans++;
    }
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 640
N = gets.to_i
k = (1..N).find{|k|
  k + (k * (k-1))/2 == N
}
if k.nil?
  puts "No"; exit
end
puts "Yes"
puts k+1
puts "#{k} " + (1..k).to_a.join(' ')
sets = Array.new(k){|i| [i+1] }
n = k+1
for u in 0...k
  for v in (u+1)...k
    sets[u] << n
    sets[v] << n
    n += 1
  end
end
sets.each do |set|
  puts "#{k} " + set.join(' ')
end

Measured memory_bytes: 5372
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for (char ch : s.toCharArray()) {
			if (ch == 'o') {
				count++;
			}
		}
		System.out.println(700 + (count * 100));
	}
}

Measured memory_bytes: 21716
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,a,b;

main(){
	cin>>n>>a>>b;
	if((b-a)%2)dump("Borys");
	else dump("Alice");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char S[10] = { 0 };
	char T[10] = {0};

	scanf("%s", S);
	scanf("%s", T);


	for (int i = 0; S[i] != '\0'; i++) {
		if (S[i] != T[i]) {
			printf("No");
			return 0;
		}
	}

	printf("Yes");
	
	return 0;
}


Measured memory_bytes: 2068
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int X;
	int Y;
	int Z;
	cin >> X >> Y >> Z;
	cout << Z << endl;
	cout << X << endl; 
	cout<<Y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

typedef long long ll;
ll n, x, d1[N]{1}, d2[N]{1};

ll f(ll p) {
	ll re = 0;
	if (x <= 0) return 0;
	if (d1[p] <= x) {x -= d1[p]; return d2[p];}
	x--;
	re += f(p - 1) + f(0) + f(p - 1);
	x--;
	return re;
}

int main()
{
	ll i;
	cin >> n >> x;
	for (i = 1; i <= n; i++) {
		d1[i] = d1[i - 1] * 2 + 3;
		d2[i] = d2[i - 1] * 2 + 1;
	}
    cout << f(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++)
  {
    cin >> b[i];
    b[i]--;
  }
  vector<int> ans;
  while (0 < b.size())
  {
    int pos = -1;
    for (int i = 0; i < b.size(); i++)
    {
      if (b[i] == i)
        pos = i;
    }
    if (pos == -1)
    {
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(pos);
    b.erase(b.begin() + pos);
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i] + 1 << endl;
  return 0;
}

Measured memory_bytes: 256