akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;
#define re register int
int n,a[100003],res;
inline void rea(re&dd)
{
	dd=0;re ch=getchar();
	while(ch<48||ch>57)ch=getchar();
	while(ch>=48&&ch<=57)dd=(dd<<3)+(dd<<1)+(ch^48),ch=getchar();
}
int main()
{
	rea(n);
	for(re i=1;i<=n;++i)rea(a[i]),res^=a[i];
	if(!res)printf("Yes");
	else printf("No");
	return 0;
}

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

int main() {
  int N;
  vector<int> next;
  vector<bool> pushed;
  int count = 0;
  int now = 1;
  
  cin >> N;
  next = vector<int>(N);
  pushed = vector<bool>(N,false);
  
  for (int i=0;i<N;i++) {
    cin >> next.at(i);
  }
  
  while ( true ) {
    if (pushed.at(now-1)) {
      count = -1;
      break;
    }
    if (now==2) break;
    pushed.at(now - 1) = true;
    count++;
    now = next.at(now-1);
  }
  
  cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
#define ALL(X) X.begin(), X.end()
using lint = long long;
template <typename T>
void print_container(std::vector<T> vec)
{
    for (auto iter = vec.begin(); iter != vec.end(); ++iter)
    {
        std::cout << *iter << " ";
    }
    std::cout << std::endl;
}

auto divs(lint x)
{
    std::vector<lint> out;
    lint num = 1;

    while (num < sqrt(x) + 0.01)
    {
        if (x % num == 0)
        {
            if (x / num == num)
            {
                out.push_back(num);
            }
            else if (x / num > num)
            {
                out.push_back(num);
                out.push_back(x / num);
            }
        }
        num++;
    }

    std::sort(ALL(out));

    return out;
}

int main()
{
    lint n;
    scanf("%lld", &n);

    auto divs_n = divs(n);

    std::set<lint> ans;

    for (auto div : divs_n)
    {
        if (div == 1)
            continue;
        lint ncp = n;
        if ((ncp - 1) % div == 0)
        {
            ans.insert(div);
            continue;
        }
        while ((ncp % div) == 0)
        {
            ncp /= div;
            if ((ncp - 1) % div == 0)
            {
                ans.insert(div);
                break;
            }
        }
    }

    auto divs_mk = divs(n - 1);

    for (auto div : divs_mk)
    {
        if (div == 1)
            continue;
        ans.insert(div);
    }

    std::cout << ans.size() << "\n";

    return 0;
}


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


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int OO = 100000000,n,m;
int dp[100009];
vector<vector<int>>edges(1e5);
int ans(int i){
    int &ret=dp[i];
    if(~ret)return ret;
    if(i==n+1||edges[i].empty())return 0;
    ret =0;
    for (int j = 0; j <edges[i].size() ; ++j) {
        ret=max (ret,1+ans(edges[i][j]));
    }
    return ret;
}
ll conver(string s){
    ll ret=0;
    for (int i = 0; i <s.size() ; ++i) {
        ret*=10;
        ret+=(s[i]-48);
    }
//    cout<<ret<<endl;
    return ret;
}


int main() {
    fast();
    string s;
   cin>>s;
    ll ans=0;
    //cout<<(1<<5);
    int si=(1<<((int)s.size()-1));
    for (int i = 0; i<si  ; ++i) {
    string tmp="";
    ll tmpo=i;
    //cout<<i<<endl;
        for (int j = 0; j < s.size(); ++j) {
            tmp+=s[j];
            if(tmpo&1)ans+=(conver(tmp)),tmp="";
            tmpo>>=1;
            //cout<<tmp<<" "<<tmpo<<endl;
        }
        ans+=conver(tmp);
    }
cout<<ans;

}

Measured memory_bytes: 2560
//
//  main.cpp
//

// https://atcoder.jp/contests/abc124/tasks/abc124_d

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    int N, K;
    cin >> N >> K;
    string bits;
    cin >> bits;
    int left = 0;
    int right = 0;
    int num_of_standing_component = 0;
    int ans = 0;
    while (right < bits.size()) {
        bool enter_standing = false;
        if (right == 0 && bits[0] == '0') {
            enter_standing = true;
        }
        if (right > 0 && bits[right-1] == '1' && bits[right] == '0') {
            enter_standing = true;
        }
        right++;
        if (enter_standing) {
            num_of_standing_component++;
        }
        while (num_of_standing_component > K) {
            bool go_out_standing = false;
            if (bits[left] == '0' && (left + 1 == right || bits[left + 1] == '1')) {
                go_out_standing = true;
            }
            left++;
            if (go_out_standing) {
                num_of_standing_component--;
            }
        }
        ans = max(ans, right - left);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#memoryが少ない例。下手に２次元とかでやるより良いってこと？
H, W, D = [int(i) for i in input().split()]
px = [0] * 90001
py = [0] * 90001

for i in range(H):
    a = [int(i) for i in input().split()]
    for j, v in enumerate(a):
        px[v] = j
        py[v] = i

d = [0] * 90001
for i in range(D + 1, 90001):
    d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D])

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    ans = d[R] - d[L]
    print(ans)


Measured memory_bytes: 9264
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  Int ans=0;
  while(1){
    if(*max_element(h.begin(),h.end())==0) break;
    for(Int i=0;i<n;i++){
      if(h[i]==0) continue;
      for(Int j=i;j<n;j++){
        if(h[j]==0) break;
        h[j]--;
      }
      break;
    }
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

namespace Competition
{
    public class Program
    {
        public long sum = 0;
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.Read;
            Console.WriteLine(bfs(s, 0));
        }

        public long bfs(string s, long n)
        {
            long ret = 0;

            if(s.Length == 1) return n + long.Parse(s);

            ret = n + long.Parse(s);

            for(int i = 1; i < s.Length; i++)
            {
                ret += bfs(s.Substring(i), n + long.Parse(s.Substring(0, i)));
            }
            
            return ret;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        /* 1.ローカルのストリームからデータを読み込む
           2.ローカルのストリームからデータがなくなれば
           　本流のストリームからデータを読み込む
           3.getではreturnがないといけないのでdequeueを実行
        */
        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i) inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine{get{return _stream.ReadLine();}}
        public int ReadInt{get{return int.Parse(Read);}}
        public long ReadLong{get{return long.Parse(Read);}}
        public double ReadDouble{get{return double.Parse(Read);}}
        public string[] ReadStrArray(long N){var ret = new string[N]; for(long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N){var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N){var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}

    }
}


Measured memory_bytes: 11220
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int x1[2], x2[2], x3[2], x4[2];
    cin >> x1[0] >> x1[1] >> x2[0] >> x2[1];

    x3[0] = x2[0]-(x2[1]-x1[1]);
    x3[1] = x2[1]+(x2[0]-x1[0]);
    x4[0] = x3[0]-(x2[0]-x1[0]);
    x4[1] = x3[1]-(x2[1]-x1[1]);
    
    cout << x3[0] << ' ' << x3[1] << ' ' << x4[0] << ' ' << x4[1] << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [input() for _ in range(N)]
b=A[0][0]
for i in range(N):
  if b==A[i][0]:
    b=A[i][-1]
  else:
    print("No")
    exit()
A.sort()
for i in range(N-1):
  if A[i]==A[i+1]:
    print("No")
    exit()
print("Yes")

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

#define llong long long 
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define ii pair<int, int>

#define maxn 111
int n;
int a[maxn];
llong p[maxn][11];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  rep(i, n) {
    rep(f, 10) {
      int x; cin >> x;
      a[i] |= x << f;
    }
  }
  rep(i, n) rep(f, 11) cin >> p[i][f];
  llong ans = LLONG_MIN;
  rep1(i, (1 << 10) - 1) {
    llong t = 0;
    rep(f, n) t += p[f][__builtin_popcount(i & a[f])];
    ans = max(ans, t);
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};

int pow(int x,int p)
{
  int res=1;
  while(p)
  {
    if(p&1)
    {
      res=(res*x)%mod;
    }
    p>>=1;
    x=(x*x)%mod;
  }
  return res;
}

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

 

int n;
cin>>n;

vector<int>v(n);  map<int,int>mp;


for(int i=0;i<n;i++)
{
  cin>>v[i];

  int x=v[i];
  for(int j=2;j*j<=v[i]&&x>1;j++)
   {
     if(x%j==0)
     {
       int cnt=0;
       while(x%j==0)
       {
         cnt++; x/=j;
       }
       mp[j]=max(mp[j],cnt);
     }
   }
   if(x>1)mp[x]=max(mp[x],1ll);

}
vector<pii>vp;
for(auto i : mp)
{
  vp.push_back({i.first,i.second});
}

int ans=0;

for(int i=0;i<n;i++)
{
    int val=1;
   for(auto j : vp)
   {
     int x=j.first;  int cnt=0;
     while(v[i]%x==0)
     {
       cnt++; v[i]/=x;
     }

     val=(val*pow(x,j.second-cnt))%mod;
   }
   ans=(val+ans)%mod;

}
cout<<ans<<"\n";
   
}


Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
P = list(map(float,input().split()))
dp = [[0] * (n+1) for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
  pi = P[i]
  for j in range(n):
    dp[i+1][j+1] += dp[i][j] * pi
    dp[i+1][j] += dp[i][j] * (1 - pi)
print(sum(dp[n][n//2+1:]))
# print(dp)
    

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

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << ' ';
    if (A+B < N) {
        cout << 0 << endl;
    }
    else if (A == B and A == N) {
        cout << N << endl;
    }
    else {
        cout << (A+B)-N << endl;
    }
}


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

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }

  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
}comb(1000005);

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

  mint ans=0;
  for(int k=1; k<=s/3; k++){
    int m = s-3*k;
    mint add = comb(m+k-1,k-1);
    ans += add;
  }
  cout << ans;
}

Measured memory_bytes: 18636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<vector<int>> cnt(N, vector<int>(26));
    Rep(i, N) {
        string S;
        cin >> S;
        Rep(j, S.size()) {
            cnt[i][S[j] - 'a']++;
        }
    }
    string ans = "";
    Rep(i, 26) {
        int count = 10000;
        Rep(j, N) {
            count = min(count, cnt[j][i]);
        }
        Rep(j, count) {
            ans += 'a' + i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int h;
    int w;
    while(1)
    {
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(int i=0;i<h; i++)
        {
            for(int s=0; s<w; s++)
            {
                if(s==0||s==w-1||i==0||i==h-1)
                cout<<"#";
                else
                    cout<<".";
                
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 1;
        int min = sc.nextInt();
        int[] p = new int[N];
        p[0] = min;
        
        for(int i = 1; i < N; i++) {
            p[i] = sc.nextInt();
            if(min >= p[i]) {
                count++;
                min = p[i];
            }
        }
        
        System.out.println(count);
        
    }
}

Measured memory_bytes: 66904
from typing import List

class UnionFind:
	def __init__(self, V: int) -> None:
		self.V: int = V
		self.pi: List[int] = [i for i in range(V)]
		self.rank: int = [0 for _ in range(V)]

	def findSet(self, x: int) -> int:
		if x != self.pi[x]:
			self.pi[x] = self.findSet(self.pi[x])
		return self.pi[x]

	def same(self, x: int, y: int) -> bool:
		return self.findSet(x) == self.findSet(y)

	def link(self, x: int, y: int) -> None:
		if self.rank[x] > self.rank[y]:
			self.pi[y] = x
		else:
			self.pi[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

	def unite(self, x: int, y: int) -> None:
		self.link(self.findSet(x), self.findSet(y))


if __name__ == "__main__":
	n, q = map(int, input().split())
	UF = UnionFind(n)
	for _ in range(q):
		com, x, y = map(int, input().split())
		if com == 0:
			UF.unite(x, y)
		else:
			if UF.same(x, y):
				print(1)
			else:
				print(0)


Measured memory_bytes: 7644
import std.algorithm;
import std.array;
import std.stdio;
import std.conv;
import std.string;

void main(){
    readln;
    int[] array = readln.split.map!(to!int).array;
    array.map!(to!string).join(" ").writeln;
    foreach(i; 1..array.length){
        int key = array[i];
        size_t j = i;
        while(j > 0 && array[j - 1] > key){
            array[j] = array[j - 1];
            --j;
        }
        array[j] = key;
        array.map!(to!string).join(" ").writeln;
    }
}

Measured memory_bytes: 1808
mod = 998244353
from bisect import bisect_left as bisect
from operator import itemgetter
N = int(input())
XD = [list(map(int,input().split())) for _ in range(N)]
XD.sort(key=itemgetter(0))
X = [XD[i][0] for i in range(N)]
D = [XD[i][1] for i in range(N)]

N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [INF]*(4*N0)

def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

def query(l, r):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

for i in range(N-1,-1,-1):
    x,d = XD[i]
    j = bisect(X,x+d)
    update(i,-i)
    update(i,query(i,j))

dp = [1]*(N+1)

for i in range(N-1,-1,-1):
    j = -query(i,i+1)
    dp[i] = dp[i+1] + dp[j+1]
    dp[i] %= mod

print(dp[0])


Measured memory_bytes: 116516
#define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1; y = 0;
    if (b != 0){
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return g;
}


ll mod_inverse(ll a, ll m){
    ll x, y;
    if(extgcd(a, m, x, y) != 1) return 0;
    return (m + x % m) % m;
}

const ll p1 = 999979;
const ll p2 = 999983;

ll lcm(ll a, ll b){ return a/__gcd(a,b)*b; }

int main(){
    int N; cin >> N;
    ll x1=0, x2=0;
    rep(i,N){
        ll o,y;
        cin>>o>>y;
        if(o==1){
            x1+=y;
            x2+=y;
        }
        if(o==2){
            x1 = x1-y+p1;
            x2 = x2-y+p2;
        }
        if(o==3){
            x1*=y ;
            x2*=y ;
        }
        if(o==4){
            x1*=mod_inverse(y,p1) ;
            x2*=mod_inverse(y,p2) ;
        }
        x1%=p1, x2%=p2;
    }
    ll a,b;
    extgcd(p1,p2,a,b);
    ll x = p1*a*x2 + p2*b*x1;
    x%=lcm(p1,p2);
    if(x >= 1LL<<31) x-=lcm(p1,p2);;
    cout << x << endl;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, a, b;
  cin >> x >> a >> b;
  cout << (abs(x - a) > abs(x - b) ? 'B' : 'A') << endl;
}

Measured memory_bytes: 3580
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a) {
  a %= mod;
  if (a < 0) a += mod;
  ll b = mod, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += mod;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
ll fastmod(ll x)
{
    return x<mod?x:x%mod;
}
int32_t main()
{
    IOS

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

Measured memory_bytes: 3640
sa = input()
sb = input()
sc = input()

prev = sa[0]
sa = sa[1:len(sa)]

while True:
    if prev == 'a':
        if len(sa) == 0: break
        prev = sa[0]
        sa = sa[1:len(sa)]
    elif prev == 'b':
        if len(sb) == 0: break
        prev = sb[0]
        sb = sb[1:len(sb)]
    else:
        if len(sc) == 0: break
        prev = sc[0]
        sc = sc[1:len(sc)]
print(prev.upper())

Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s = input()
n = int(s)
l = list(s)
sn=0
for i in range(0,len(l)):
  sn=sn+int(l[i])


if n%sn==0:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
a, b, c = map(int, input().split())
ans = 0
if a == b == c and a%2 == 0:
  print(-1)
else:
  while (a%2 or b%2 or c%2) == 0 :
    tmp1 = a
    tmp2 = b
    a = b/2 + c/2
    b = tmp1/2 + c/2
    c = tmp1/2 + tmp2/2
    ans += 1
  print(ans)

Measured memory_bytes: 3064
s = input()
memo = []
pre, c = s[0], 0
for si in s:
    if si != pre:
        memo.append(c)
    c += 1
    pre = si
memo.append(c)

n = len(s)
ans = n
for mi in memo:
    ans = min(ans, max(mi, n - mi))
print(ans)


Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    int sum=0;
    cin >> N;
    int A[N+2];
    A[0]=0;
    A[N+1]=0;
    for(int i=1;i<N+1;i++) cin >> A[i];
    
    for(int i=1;i<N+2;i++){
        sum+=abs(A[i]-A[i-1]);
    }
    for(int i=1;i<N+1;i++){
        if((A[i-1]>A[i] && A[i]>A[i+1]) || (A[i-1]<A[i] && A[i]<A[i+1])){
            cout << sum << endl;
        }else{
            cout << sum-2*min(abs(A[i]-A[i-1]),abs(A[i]-A[i+1])) << endl;
        }
    }

    



}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <numeric>


using namespace std;

#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b

long long int A,B,C,K;

int main() {

    cin >> A >> B >> C >> K;

    if (K <= A) {
        cout << K << endl;
    }else if (K <= (A+B)){
        cout << A << endl;
    }else{
        long long int ans = 2 * A - K + B;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
/*
 * abc153b.cpp
 * Copyright (C) 2020 itachi <itachi@itachi-Z510>
 *
 * Distributed under terms of the MIT license.
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int h,n;
    int val;
    cin >> h >> n;
    while (n--) {
        cin >> val;
        h -= val;
    }
    if (h>0) cout << "No"; else cout << "Yes";
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

int N;
int x;
int a[100010];

int main2() {
  cin >> N >> x;
  REP(i, N) cin >> a[i];

  ll ans = 0;
  for (int i = 1; i < N; i++) {
    if (a[i-1] + a[i] > x) {
      int d = a[i-1] + a[i] - x;
      int d1 = min(a[i], d);
      ans += d1;
      a[i] -= d1;
    }
    if (a[i-1] > x) {
      int d = a[i-1] - x;
      ans += d;
      a[i-1] -= d;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	static int H, W;
	static char[][] map;
	static int[][] num;
	static myQueue<Point> que = new myQueue<Point>(10000);

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		map = new char[H][W];
		num = new int[H][W];
		int periodCnt = 0;

		for (int i = 0; i < H; i++) {
			String temp = sc.next();
			for (int j = 0; j < W; j++) {
				map[i][j] = temp.charAt(j);
				if (map[i][j] == '.') {
					periodCnt++;
				}
			}

		}
		que.offer(new Point(0, 0));
		num[0][0] = 0;
		map[0][0] = 'x';

		while (!que.isEmpty()) {
			Point a = que.poll();
			int n = num[a.x][a.y] + 1;

			solve(a.x + 1, a.y, n);
			solve(a.x - 1, a.y, n);
			solve(a.x, a.y + 1, n);
			solve(a.x, a.y - 1, n);
		}

		if (map[H - 1][W - 1] != 'x') {
			System.out.println(-1);
		} else {
			System.out.println(periodCnt - num[H - 1][W - 1] - 1);
		}
		sc.close();
	}

	public static void solve(int x, int y, int n) {
		if (x < 0 || H <= x || y < 0 || W <= y || map[x][y] == '#' || map[x][y] == 'x') {
			return;
		}
		map[x][y] = 'x';
		num[x][y] = n;
		que.offer(new Point(x, y));
	}


	static class Point {
		int x;
		int y;
		Point (int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	static class myQueue<T> {
		private Object[] values;
		private int head = 0;
		private int tail = 0;

		myQueue(int size) {
			values = new Object[size+1];
		}

		boolean offer(T data) {
			if (data == null)
				return false;
			if (((tail + 1) % values.length) == head) {
				return false;
			}
			values[tail++] = data;
			tail = tail % values.length;
			return true;
		}

		T poll() {
			T data = null;
			if (tail != head) {
				data = (T) values[head++];
				head = head % values.length;
			}
			return data;
		}

		boolean isEmpty() {
			return (tail == head);
		}
	}
}


Measured memory_bytes: 21972
import math

while True:
    data = input().split()
    x,y,s = int(data[0]),int(data[1]),int(data[2])
    if x == 0 and y == 0 and s == 0: break
    b_tax = (100+x)/100
    a_tax = ((100+y)/100)
    eps = 0.000000001
    maxSumPrice = 0
    for p1 in range(1,s):
        for p2 in range(p1,s):
            sumPrice = math.floor(p1*b_tax + eps) + math.floor(p2*b_tax + eps)
            if sumPrice == s:
                sumPrice_aTaxin = math.floor(p1*a_tax + eps) + math.floor(p2*a_tax + eps)
                maxSumPrice = max(maxSumPrice,sumPrice_aTaxin)
    print(maxSumPrice)


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;

int main()
{
  int n, m;
  int maxi = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++){
    int tot = 0;
    for (int j = 0; j < m; j++) tot += in();
    maxi = max(maxi, tot);
  }
  cout << maxi << endl;

  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

	int64 M, D;
	cin >> M >> D;
	int64 res = 0;
	FOR(i, 1, M+1) {
	    FOR(j, 1, D+1) {
	        if (i == (j/10)*(j%10) && j/10 >= 2 && j%10 >= 2) {
	            res++;
	        }
	    }
	}
	cout << res << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  int sum = 0;
  int tmp = n;
  while(tmp > 0)
  {
    sum += tmp % 10;
    tmp /= 10;
  }
  cout << (n % sum == 0 ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

//二項係数ライブラリ
const int MAX = 1000000;
const int MOD = 1000000007;

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

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//前処理COMinit()忘れずに

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

    int m, n;
    bool flg = false;
    for(int i = 0; i <= Y; i++){
        if(2 * X - 3 * i == Y){
            m = X - 2 * i; n = i;
            flg = true;
            break;
        }
    }

    if(!flg){
        cout << 0 << endl;
        exit(0);
    }

    COMinit();
    cout << COM(m + n, m) << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll modi = 1e9+7;
const ll mxn = 5e5+5;	
ll fact[mxn],inv[mxn],ifact[mxn];

void solve(){
	ll n,m;
	cin >> n >> m;
	fact[0] = fact[1] = inv[0] = inv[1] = ifact[0]=ifact[1] = 1LL;
	for(ll i =2;i<mxn;i++){
		fact[i] = fact[i-1]*i%modi;
		inv[i] = (modi - (modi/i)*inv[modi%i]%modi)%modi;
		ifact[i] = ifact[i-1]*inv[i]%modi;
	}

	auto ncr =[&](ll n, ll r){
		if(r>n)
			 return 0ll;

		return (fact[n]*ifact[n-r]%modi)*ifact[r]%modi;
	};

	ll ans = 0;
	ll cur = 1;
	for(ll i =0;i<=n;i++){
		ans = (ans + modi + cur*(ncr(n,i)*ncr(m-i,n-i)%modi)*fact[n-i]%modi)%modi;
		cur  = -cur;
	}
	cout << (ans*ncr(m,n)%modi)*fact[n]%modi << endl;

	
}	

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 15364
#include<iostream>
#include<stdio.h>
using namespace std;

int n, A[50];

int solve(int i, int m) {
    
    if (m == 0) return 1;
    
    if (i >= n) return 0;
    
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    
    return res;
    
}

int main() {
    
    int q, M, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i ++) {
        
        scanf("%d", &A[i]);
        
    }
    
    scanf("%d", &q);
    
    for (i = 0; i < q; i ++) {
        
        scanf("%d", &M);
        
        if (solve(0, M)) {
            
            printf("yes\n");
            
        } else {
            
            printf("no\n");
            
        }
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3152
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt(), b=sc.nextInt(), c=sc.nextInt();
    if(a<b){
      if(b<c){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
    }
    else{
      System.out.println("No");
    }
  }
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int r,g,b,k;
	cin>>r>>g>>b;
	cin>>k;
	while(k>0){
		if(g<=r){
			g=g*2;
			k--;
		}
		else{
			b=b*2;
			k--;
		}
	}
	if(r>=g || r>=b || g>=b){
		cout<<"No"<<"\n";
	}
	else{
		cout<<"Yes"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3628
N = int(input())
MOD = 10 ** 9 + 7
res = pow(10, N, MOD) - 2 * pow(9, N, MOD) + pow(8, N, MOD)
if res < 0:
    while res < 0:
        res += MOD
elif res > MOD:
    while res > MOD:
        res -= MOD
print(res)


Measured memory_bytes: 8976
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,ans=0;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[a[i]-1]-1==i) ans++;
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 640
k,n = map(int, input().split())
a = list(map(int, input().split()))
d = 0
e = abs(k-a[-1])
    
for i in range(n-1):
    d = max(d, abs(a[i]-a[i+1]))
d = max(d, abs(a[0]+k-a[-1]))

print(k-d)

Measured memory_bytes: 25452
from _collections import defaultdict
n=int(input())
A=list(map(int,input().split()))

X=[A[0]]
for i in range(1,n):
    X.append(X[-1]+A[i])
Y=defaultdict(int)
for x in X:
    Y[x]+=1
ans=0
for y in Y.values():
    ans+=(y-1)*y//2
print(ans+Y[0])

Measured memory_bytes: 41448
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=5e5+10;
int n,ans,cnt;
int s[N],f[N][3],suml[N],sumr[N];
char ch[N];
int main()
{
	memset(f,189,sizeof(f));
	f[0][0]=0;
	scanf("%d%s",&n,ch+1);
	for(int i=1;i<=n;i++)s[i]=ch[i]-'0';
	for(int i=1;i<=n;i++)
	{
		if(s[i]==1){sumr[cnt]++;continue;};
		cnt++;suml[cnt]=sumr[cnt-1];
	}
	for(int i=1;i<=cnt;i++)
	{
		f[i][0]=max(f[i-1][0],max(f[i-1][1],f[i-1][2]));
		f[i][1]=suml[i]&&sumr[i]?
				max(f[i-1][0]+suml[i],f[i-1][1]+suml[i]-1):-inf;
		f[i][2]=suml[i]&&sumr[i]?
				max(max(f[i-1][0]+sumr[i],suml[i]>=2?f[i-1][1]+sumr[i]:0),f[i-1][2]+sumr[i]-1):-inf;
		ans=max(max(ans,f[i][0]),max(f[i][1],f[i][2]));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 12416
// C - 白昼夢 / Daydream
#include <bits/stdc++.h>
using namespace std;

int solve();
string S;
vector<string> st = {"dream",  "dreamer", "erase", "eraser"};

int main(){
  cin >> S;
  solve();
}


int solve(){
  reverse(S.begin(), S.end());
  for(int i = 0; i<4;i++){
    reverse(st.at(i).begin(), st.at(i).end());
  }

  bool can = true;

  for(int i = 0; i<S.size();){
    bool can2 = false;
    for(int j  = 0 ; j<4;  j++){
      string d = st.at(j);
      if(S.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }

    if(!can2){
      can = false;
      break;
    }
  }

  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			y[i] = sc.nextInt();
		}
		sc.close();

		int[] absXY = new int[n];

		double chebyshev = 0;
		for (int i = 0; i < n; i++) {
			absXY[i] = Math.abs(x[i]-y[i]);
			chebyshev = Math.max(chebyshev, absXY[i]);
		}

		for (int p = 1; p <= 3; p++) {
			long tmp = 0;
			for (int i = 0; i < n; i++) {
				tmp += Math.pow(absXY[i], p);
			}
			double dist = Math.pow(tmp, 1.0/p);
			System.out.println(dist);
		}

		System.out.println(chebyshev);

	}
}

Measured memory_bytes: 26388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,m;
  cin>>n>>m;
  vector<int> id(n+2);
  rep(t,m) {
    int l,r;
    cin>>l>>r;
    id[l]++;
    id[r+1]--;
  }
  repeat(i,1,n+2)
    id[i]+=id[i-1];
  int ans=0;
  repeat(i,1,n+1)
    if(id[i]==m)
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
input = readlines()
n, k = input.shift.chomp.split("\s").map{|x| x.to_i}
list = input.shift.chomp.split("\s").map{|x| x.to_i}

(k..n).each do |term|
  ti = term - 1
  next if k == term
  if k == 1
    puts list[ti] > list[ti - 1] ? 'Yes' : 'No'
    next
  end
  if list[ti] > list[ti - k]
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 33924
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	double wei;
	for(;cin>>wei;){
		if(wei<=48)cout<<"light fly\n";
		else if(wei<=51)cout<<"fly\n";
		else if(wei<=54)cout<<"bantam\n";
		else if(wei<=57)cout<<"feather\n";
		else if(wei<=60)cout<<"light\n";
		else if(wei<=64)cout<<"light welter\n";
		else if(wei<=69)cout<<"welter\n";
		else if(wei<=75)cout<<"light middle\n";
		else if(wei<=81)cout<<"middle\n";
		else if(wei<=91)cout<<"light heavy\n";
		else cout<<"heavy\n";
	}
	return 0;
}

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

int main()
{
  int r, c;
  int rowsum, allsum, tmp;
  int colsum[100] = {0};

  cin >> r >> c;

  allsum = 0;
  for (int i = 0; i < r; i++) {
    rowsum = 0;
    for (int j = 0; j < c; j++) {
      cin >> tmp;
      rowsum += tmp;
      colsum[j] += tmp;
      allsum += tmp;
      cout << tmp << " ";
    }
    cout << rowsum << endl;
  }
  for (int i = 0; i < c; i++) cout << colsum[i] << " ";
  cout << allsum << endl;
  
  return 0;
}



Measured memory_bytes: 3076
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
// set<int>st{ 3,1,4,1,5,9,2,6,5,3,5 };
//     for (auto itr = st.begin(); itr != st.end(); ++itr) {
//         cout << *itr;
//     }
#include <bits/stdc++.h>
#include <regex>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int h,w,m;
  cin>>h>>w>>m;
  vector<int>hh(h);
  vector<int>ww(w);
  set<P>each;
  int hi,wi;

  P p;
  int hnum=0;
  int wnum=0;
  rep(i,m){
    cin>>hi>>wi;
    p=make_pair(hi-1,wi-1);
   // cout<<p.first<<" "<<p.second<<endl;
    each.insert(p);
    hh.at(hi-1)=hh.at(hi-1)+1;
    ww.at(wi-1)=ww.at(wi-1)+1;
   // cout<<wi<<" "<<ww.at(wi-1)<<endl;
    if(hh.at(hi-1)>hnum){
      hnum=hh.at(hi-1);}
    if(ww.at(wi-1)>wnum){
      wnum=ww.at(wi-1);}
  }
  vector<int> hpoint;
  vector<int> wpoint;
  rep(i,h){
    if(hh.at(i)==hnum){
     hpoint.push_back(i);
    }
  }
  rep(i,w){
    if(ww.at(i)==wnum){
   //   cout<<i<<" "<<ww.at(i)<<" "<<wnum<<endl;
     wpoint.push_back(i);
    }
  }
  bool flag=false;
  rep(i,hpoint.size()){
    rep(j,wpoint.size()){
      p=make_pair(hpoint.at(i),wpoint.at(j));
      if(!each.count(p)){
       flag = true;
       //cout<<hpoint.at(i)<<" "<<wpoint.at(j)<<endl;
        goto SKIP;
      }
    }
  }
  SKIP:;
  if(flag){
    cout<<hnum+wnum<<endl;
    return 0;
  }else{
    cout<<hnum+wnum-1<<endl;
  }
}

Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    string s,h,t;
    int q;
    cin>>s>>q;
    bool parity = false;
    while (q--) {
        int query;
        cin>>query;
        if (query == 1) parity = !parity;
        else{
            int f;
            char c;
            cin >> f >> c;
            if (f == 1)
                (parity ? t : h) += c;
            else
                (parity ? h : t) += c;
            
        }
    }
    if(parity){
        reverse(s.begin(), s.end());
        reverse(t.begin(), t.end());
        s = t + s + h;
    } else {
        reverse(h.begin(), h.end());
        s = h + s + t;
    }
    cout << s << "\n";
}

Measured memory_bytes: 1348
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAX 200000

int main() {
    int n;
    string s;
    cin >>n;
    cin >> s;
    int left_black[MAX], right_white[MAX];
    int b=0, w=0;

    for(int i=0; i<n; i++) {
        
        if (s[i] == '#'){
            b++;
        } 

        if (s[n-1-i] == '.') {
            w++;
        }

        left_black[i] = b;
        right_white[n-1-i] = w;
    }


    int ans = MAX;

    for(int i=0; i<n-1; i++) {
        ans = min(ans, left_black[i] + right_white[i+1]);
    }

    ans = min(ans, left_black[n-1]);
    ans = min(ans, right_white[0]);

    cout << ans << endl;
}
        


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	int A=n/500;
	ans+=1000*A;
	n-=A*500;
	A=n/5;
	ans+=5*A;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

data = [int(s) for s in input().split()]
count = 0
for i in range(n):
  if (i+1)!= data[i]:
    count += 1
if count<= 2:
  print("YES")
else:
  print("NO")
    
  
"""
mx = max(data)
mn = min(data)

if (mx == n-1 and mn == 0) or 
  for i in range(1,n-1):
    if data[i] < data[i+1]:
      continue
    else:
      print("No")
      exit()
"""      


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

from fractions import gcd
from math import ceil,floor
import collections

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))


A = list(map(int, input().split()))

if (sum(A))>=22:
    print("bust")
else:
    print("win")



Measured memory_bytes: 66028
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

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

	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}

	int mx=arr[0];
	int ans=0;
	for(int i=1;i<n;i++){
		if(arr[i] <= mx){
			ans+=(mx-arr[i]);
		}
		else
		{
			mx=arr[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5196