akhauriyash/Code-Regression huggingface dataset:
using System;
 
class Program
{
    static void Main()
    {
        var data1 = Console.ReadLine().Split(' ');
        int n = int.Parse(data1[0]);
        int m = int.Parse(data1[1]);
        int l = int.Parse(data1[2]);
 
        long[,] A = new long[n, m];
        long[,] B = new long[m, l];
        long[,] C = new long[n, l];
 
        for (int i = 0; i < n; i++)
        {
            var data2 = Console.ReadLine().Split(' ');
            for (int j = 0; j < m; j++)
            {
                A[i, j] = int.Parse(data2[j]);
            }
        }
 
        for (int i = 0; i < m; i++)
        {
            var data3 = Console.ReadLine().Split(' ');
            for (int j = 0; j < l; j++)
            {
                B[i, j] = int.Parse(data3[j]);
            }
        }
 
        int N, M, L;
 
        for(N = 0; N < n; N++)
        {
            for (M = 0; M < m; M++)
            {
                for (L = 0; L < l; L++)
                {
                    C[N, L] += A[N, M] * B[M, L];
                }
            }
        }
 
        for (N = 0; N < n; N++)
        {
            for (L = 0; L < l - 1; L++)
            {
                Console.Write(C[N, L] + " ");
            }
            Console.WriteLine(C[N, l - 1]);
        }
    }
}

Measured memory_bytes: 6236
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int main(){
  int N, M;
  cin >> N >> M;
  int a[N];
  int b, c;
  rep(i, N){
    cin >> a[i];
  }
  pair<int, int>p[M];
  rep(i, M){
    cin >> b >> c;
    p[i] = make_pair(c, b);
  }
  sort(a, a+N); sort(p, p+M, greater<pair<int, int>>());
  int k = 0;
  ll sum = 0;
  rep(i, M){
    rep(j, p[i].second){
      if(p[i].first > a[k]){
        a[k] = p[i].first;
      }
      k++;
      if(k==N) goto NEXT;
    }
  }
  NEXT:;
  rep(i, N){
    sum += a[i];
  }
  cout << sum << endl;
      
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};
int main(void) {
    int n, m; cin >> n >> m;
    vector<mint> dp(n+1,0);
    map<int,int> mp;
    rep(i, m) {
        int a; cin >> a;
        mp[a] = 1;
    }
    dp[0] = 1;
    for(int i=1; i<=n; i++) {
        if(mp[i]) continue;
        dp[i] += dp[i-1];
        if(i>1) dp[i] += dp[i-2];
    }
    cout << dp[n].x;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    int ma = -1000000;
    int mi = 1000000;
    rep(i,n){
        sum += a[i];
        ma = max(ma,a[i]);
        mi = min(mi,a[i]);
    }
    cout << mi << " " << ma << " " << sum << endl;

}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> eng(N);
    for(auto& i : eng)cin >> i.first >> i.second;
    mt19937_64 mt(random_device{}());
    uniform_int_distribution<long> uid(-2000000, 2000000);
    unsigned long ans{0};
    for(unsigned long i = 0; i < 1000; ++i){
        long x{uid(mt)}, y{uid(mt)};
        long a{0}, b{0};
        for(const auto& engine : eng){
            if(x * engine.first + y * engine.second >= 0){
                a += engine.first;
                b += engine.second;
            }
        }
        if(ans < a * a + b * b)ans = a * a + b * b;
    }
    printf("%.12Lf\n", sqrt(static_cast<long double>(ans)));
    return 0;
}

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

using namespace std;

int main()
{
  int  N,V[50],C[50],R=0;

  cin >> N ;
  
  for (int i=0;i<N;i++){
        cin >> V[i] ;}
        
  for (int i=0;i<N;i++){
        cin >> C[i] ;}

  for (int i=0;i<N;i++){    
        
        if(V[i]>C[i])
            R+=(V[i]-C[i]);
        
  }
cout << R;
return 0;
}

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

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

	vector<int> s(100000, 0);
	int64_t sum = 0;

	vector<int>a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		s[a[i]]++;
		sum += a[i];
	}

	cin >> q;
	vector<int>b(q);
	vector<int>c(q);
	for (int i = 0; i < q; i++)
	{
		cin >> b[i] >> c[i];
	}

	for (int i = 0; i < q; i++)
	{

		s[c[i]] += s[b[i]];
		sum += (c[i] - b[i]) * s[b[i]];
		s[b[i]] = 0;

		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 4844
A, B, C, X, Y = map(int, input().split())
if A+B <= 2*C:
    print(A*X+B*Y)
else:
    if X <= Y:
        print(min(C*2*X+B*(Y-X),C*2*Y,A*X+B*Y))
    else:
        print(min(C*2*Y+A*(X-Y),C*2*X,A*X+B*Y))


Measured memory_bytes: 3060
n, q = map(int, input().split())
n = [0]*(n+1)
maxv = winner = 0
for _ in range(q):
    a, v = map(int, input().split())
    n[a] += v
    if v < 0 and a == winner:
        maxv = max(n)
        winner = n.index(maxv)
    elif n[a] > maxv:
            maxv, winner = n[a], a
    elif n[a] == maxv:
            winner = min(winner, a)
    print(winner, maxv)

Measured memory_bytes: 15240
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define v_in(v) for(auto&& i : v) cin >> i
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;


int main(void){
    FAST_IO
    
    ll n;
    string s;
    cin >> n >> s;
    if(n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }

    n /= 2;
    rep(i,n){
        if(s[i] != s[i+n]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int res, a, b; cin >> res >> a >> b;
	res -= a;
	for (int i = 0; res >= b; i++) {
		res -= b;
	}
	cout << res << endl;
	return 0;
}

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

int N, M, ac, pe, p;
string S;

int main() {
  cin >> N >> M;
  vector<int> wa(N + 1, 1);
  while (M-- && cin >> p >> S) if (wa[p]) {
    if (S == "AC") ac++, pe += --wa[p], wa[p] = 0;
    else wa[p]++;
  }

  cout << ac << " " << pe;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int n;
int main(){
  cin >> n;
  int ans = 0;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    ans += b - a + 1;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}


#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  vector<vector<ll>> c(3);
  rep(i, 3){
    rep(j, 3){
      ll p;
      cin >> p;
      c[i].push_back(p);
    }
  }
  // dump(c);
  ll a1, a2;
  a1 = c[0][1] - c[0][0];
  a2 = c[0][2] - c[0][0];
  rep(i, 3){
    if(!(a1 ==  c[i][1] - c[i][0] && a2 == c[i][2] - c[i][0])){
      cout << "No";
      return 0;
    }
  }

  a1 = c[1][0] - c[0][0];
  a2 = c[2][0] - c[0][0];
  rep(i, 3){
    if(!(a1 ==  c[1][i] - c[0][i] && a2 == c[2][i] - c[0][i])){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
#endif


Measured memory_bytes: 256
#ABC061-C-たくさんの数式
s = input()

n = len(s) - 1
wa = []

for i in range(2**n):
    #jビットシフト
    tmp = ""
        
    for j in range(n+1):
        tmp += s[j]
        if ((i >> j) & 1):
            tmp += '+'
    wa.append(eval("".join(tmp)))
    
        

print(sum(wa))

Measured memory_bytes: 3060
import math
X = int(input())
if X ==2:
    print(2)
else:
    s = 0
    for i in range(X,10**7):
        for j in range(2,math.ceil(i ** 0.5)+1):
            if i % j ==0:
                s += 1
        if s == 0:
            print(i)
            break
        else:
            s = 0

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int n,k;
    std::cin >> n>>k;
    VEC(ll,a,n);
    int ans=0;
    sort(all(a),greater<ll>());
    rep(i,min(k,n))a[i]=0ll;
    std::cout << sum(all(a),0ll) << std::endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n;

int main(){
	cin >> n;
	
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	i64 ans = n/10;
	ans += n/50;
	for(i64 i = 250; i <= n; i*=5){
		ans += n / i;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define INF 10000000
typedef long long ll;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
using namespace std;


int n, a, b, c;
vector<int> l;

int dfs(int pos, int aa, int bb, int cc)
{
    // 停止条件
    if (pos == n)
    {
        if (min({aa, bb, cc}) > 0)
        {
            return abs(a - aa) + abs(b - bb) + abs(c - cc) - 30;
        }
        else
        {
            return INF;
        }
    }

    int ret1 = dfs(pos + 1, aa, bb, cc);
    int ret2 = dfs(pos + 1, aa + l[pos], bb, cc) + 10;
    int ret3 = dfs(pos + 1, aa, bb + l[pos], cc) + 10;
    int ret4 = dfs(pos + 1, aa, bb, cc + l[pos]) + 10;

    // それぞれの分岐からの戻り値の処理を行う関数
    return min({ret1, ret2, ret3, ret4});
}

int main()
{

    cin >> n >> a >> b >> c;
    l.resize(n);
    rep(i, n) cin >> l[i];
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll fact[SIZE*2];

void init_fact(){
  fact[0] = 1;

  for(int i=1;i<SIZE*2;i++){
    fact[i] = (fact[i-1] * i)%mod;
  }
}

ll factorial(int n,int M){
  if(n<=1) return 1;
  
  return fact[n];
 }

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1)
    ret=(ret*k)%M;
  
  return ret;
}


//nCm nPm nHm (mod M)

/*Combination*/
int C(int n,int m,int M){
  if(n<m) return 0;
  if(m==0 || n==m) return 1;
  
  ll chi = factorial(n,M);
  ll mot = (factorial(m,M) * factorial(n-m,M))%M;
  
  mot = power((int)mot,M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}
/*Permutation*/
int P(int n,int m,int M){
  if(n<m) return 0;
  if(m==0) return 1;
  
  ll chi = factorial(n,M);
  ll mot = factorial(n-m,M);
  
  
  mot = power((int)mot, M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}

/*Combination with Repetitions*/
int H(int n,int m,int M){
  if(n==0 && m==0) return 1;
  return C(n+m-1,m,M);
}


int main(){
  int h,w;
  int a,b;

  ll ans = 0;

  init_fact();
  
  scanf("%d%d%d%d",&h,&w,&a,&b);
  h--; w--;

  for(int i=0;i<=(h-a);i++){
    ans = (ans + ((ll)C((b-1)+i,i,mod) * C((w-b)+(h-i),w-b,mod))%mod)%mod;
  }

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


Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
using namespace std;

const int MOD = 1e9 + 7;
vector<int> G[100005];
long long cnt[100005][2];

void dfs(int i, int par) {
    long long white = 1ll, black = 1ll;
    for (auto it : G[i]) {
        if (it != par) {
            dfs(it, i);
            (white *= (cnt[it][0] + cnt[it][1])) %= MOD;
            (black *= cnt[it][0]) %= MOD;
        }
    }
    cnt[i][0] = white;
    cnt[i][1] = black;
}

int main() {
    int n;
    scanf("%d", &n);
    int x, y;
    for (int i = 1; i < n; ++i) {
        scanf("%d%d", &x, &y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(1, 0);
    printf("%I64d\n", (cnt[1][0] + cnt[1][1]) % MOD);
    return 0;
}

Measured memory_bytes: 14208
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		long x = scanner.nextLong();
		if(a%x == 0){
			System.out.println(b/x - a/x + 1);
		}else {
			System.out.println(b/x - a/x);
		}
	}
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll a, b, c;
    ll x, y;
    cin >> a >> b >> c >> x >> y;
    ll mx = max(x,y);
    ll ans = 1e15;
    for(ll i = 0 ; i <= 2*mx+2 ; i+=2){
        ans = min(ans, i*c + max(0ll,x-i/2)*a + max(0ll,y-i/2)*b);
    }
    cout << ans;
    
}

Measured memory_bytes: 256
base = ord('a')
az = [chr(j) for j in range(base, base+26)]
def crack(s):
    i = -1
    while True:
        new = []
        for c in s:
            if 96 < ord(c) < 123:
                new.append(az[(ord(c)-19+i)%26])
            else:
                new.append(c)
        i -= 1
        yield ''.join(new)
while True:
    try:
        s = input()
    except:
        break
    c = crack(s)
    while True:
        ans = next(c)
        if 'the' in ans or 'this' in ans or 'that' in ans:
            print(ans)
            break

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

int main() {

    int n,k;

    cin >> n >> k;

    vector<int> v;

    for(int i=0; i<n; i++){
        int l;
        cin >> l;
        v.push_back(l);
    }

    sort(v.begin(),v.end(),greater<int>());

    int ans = 0;

    for(int i=0; i<k; i++){
        ans += v[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 400001
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};
main(){
    int h=in(),w=in();
    int n=in();
    vec v[N];
    rep(i,n){
        int x=in(),y=in();
        v[y].pb(x);
    }
    rep2(i,1,w){
        v[i].pb(h+1);
        sort(ALL(v[i]));
    }
    int ans=1e9;
    int now=1;
    rep2(i,1,w){
        int id=upper_bound(ALL(v[i]),now)-v[i].begin();
        if(i<w){
            if(v[i+1][0]>now+1){
                now=now+1;
            }
            else{
                int t=lower_bound(ALL(v[i+1]),now+1)-v[i+1].begin();
                if(v[i+1][t]!=now+1){
                  now++;
                }
                else{
                while(t<v[i+1].size()&&v[i+1][t+1]==v[i+1][t]+1){
                    t++;
                }
                now=v[i+1][t]+1;

                }
            }
        }

        ans=min(ans,v[i][id]-1);
            if(now>=h)break;
    }
    cout<<ans;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int N, value, sum = 0;
    cin >> N;
    value = N;
    while (value > 0) {
        sum += value % 10;
        value /= 10;
    }
    // cout << sum << endl;
    if (N % sum == 0) {
        Yes;
    } else {
        No;
    }
}


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    string S;
    cin >> S;
    vector<bool> alphabets(26, false);
    for(int i = 0; i < S.size(); i++){
        alphabets[S[i] - 'a'] = true;
    }
    for(int i = 0; i < 26; i++){
        if(!alphabets[i]){
            cout << S << char(i + 'a') << endl;
            return 0;
        }
    }
    if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    string before_S = S;
    next_permutation(all(S));
    while(S.substr(0, S.size() - 1) > before_S){
        S.pop_back();
    }
    cout << S << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

const double PI = 3.14159265358979323846;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	double tan = (((double)2 * b) / a) - ((double)2 * x) / ((double)a * a * a);
	if (a * tan > b) tan = (double)a * b * b / ((double)2 * x);
	double ans = atan(tan);
	cout << fixed << setprecision(15) << ans / PI * 180 << endl;

}



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

vector<pair<int,int>> group;
int main(){
    string s;
    int k,n,ans=0;
    cin>>n>>k>>s;
    
    for(int i=0;i<n;){
        char k=s[i];
        int c=0;
        while(1){
            c++;
            if(s[i]==k)
                i++;
            else
                break;
        }
        //cout<<i<<' '<<c<<'\n';
        group.push_back({k-'0',c-1});
    }
    int cur=0,m=k;
    
    if((group.size()%2==1)+group.size()/2<=k){
        printf("%d",n);
        return 0;
    }
    for(int i=0;i<group.size();i++){
        if(group[i].first==0){
            cur+=group[i].second;
            if(m==0){
                cur-=group[i-2*k].second;
                if(i-2*k-1>=0)
                    cur-=group[i-2*k-1].second;
                m++;
            }
            m--;
            
        }else{
            cur+=group[i].second;
        }
        ans=max(ans,cur);
    }
    
    printf("%d",ans);
    
}


Measured memory_bytes: 1528
#include <iostream>

using namespace std;

void solve()
{
	int sum1 = 0;
	int sum2 = 0;
	for(int i = 0; i < 4; ++i)
	{
		int temp;
		cin >> temp;
		sum1 += temp;
	}
	for(int i = 0; i < 4; ++i)
	{
		int temp;
		cin >> temp;
		sum2 += temp;
	}
	if(sum1 >= sum2)
	{
		cout << sum1 << endl;
	}
	else
	{
		cout << sum2 << endl;
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
} 
signed main(){
    fast();
    int n;
    cin >> n;
    string s;
    n >= 30? s = "Yes" : s = "No";
    cout << s << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 3652
var N,s,i,a,b,c,d:integer;
     G:array[1..100] of integer;
begin 
read(N);
s:=0;a:=0;d:=10000;
 for i := 1 to N do
 begin
read(G[i]);
s:=s+G[i];  //sは総和
 end;
 for i := 1 to N do 
begin
 a:= a+G[i];   //a 刻み和
 b:= s-a;      //b 残り
 c:= abs(a-b);  //絶対値
 if c<=d then d:=c;
 end;
 write(d);
end.

Measured memory_bytes: 128
#include <stdio.h>

int w, h;
int t[52][52];
int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};

void solve(int x, int y){
  int i;
  int nx, ny;

  t[y][x] = 0;

  for(i = 0; i < 8; i++){
    nx = x + dx[i];
    ny = y + dy[i];

    if(nx < 0 || w <= nx || ny < 0 || h <= ny || t[ny][nx] == 0) continue;

    solve(nx, ny);
  }
}

int main(void){
  int i, j;
  int ans = 0;

  while(scanf("%d %d", &w, &h), w || h){
    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
        scanf("%d", &t[i][j]);
      }
    }

    ans = 0;

    for(i = 0; i < h; i++){
      for(j = 0; j < w; j++){
        if(t[i][j] == 1){
          solve(j, i);
          ans++;
        }
      }
    }

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

  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i=0; i<n; i++) {
    cin >> t.at(i);
  }
  
  int m;
  cin >> m;
  vector<int> p(m), x(m);
  for (int i=0; i<m; i++) {
    cin >> p.at(i) >> x.at(i);
  }
  
  for (int i=0; i<m; i++) { // 飲むドリンク
    int sum = 0;
    for (int j=0; j<n; j++) { // 問題
      if (p.at(i)-1==j)
        sum += x.at(i);
      else
        sum += t.at(j);
    }
    cout << sum << endl;
  }
}

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

template <typename T>
vector<T> dijkstra(const vector<vector<pair<int, T>>> &G, int source) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;

    vector<T> dist(G.size(), INF);
    dist[source] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, source);

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;

        for(auto edge : G[v]) {
            if(dist[edge.first] > dist[v] + edge.second) {
                dist[edge.first] = dist[v] + edge.second;
                que.emplace(dist[edge.first], edge.first);
            }
        }
    }

    return dist;
}

int main() {
    int n,m,s,t;
    cin >> n >> m >> s >> t; --s; --t;
    vector<vector<pair<int, long long>>> Ge(n), Gs(n);
    for(int i=0; i<m; ++i) {
        int u,v,a,b;
        cin >> u >> v >> a >> b; --u; --v;
        Ge[u].emplace_back(v, a);
        Ge[v].emplace_back(u, a);
        Gs[u].emplace_back(v, b);
        Gs[v].emplace_back(u, b);
    }

    auto de = dijkstra(Ge, s);
    auto ds = dijkstra(Gs, t);

    vector<pair<long long, int>> A;
    A.reserve(n + 1);
    for(int i=0; i<n; ++i) A.emplace_back(1000000000000000 - de[i] - ds[i], i);
    A.emplace_back(n, 0);
    sort(begin(A), end(A), greater<pair<long long, int>>());

    int cur = 0;
    for(int i=0; i<n; ++i) {
        while(A[cur].second < i) ++cur;
        cout << A[cur].first << '\n';
    }
}

Measured memory_bytes: 19836
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int m,b,i,j,a,c,d;
    cin>>m>>b;
    int chart[b+1][m+1];
    vector<int> manju;
    int box_capa[b],box_price[b];
    for(i=0;i<m;i++){
        int t;
        cin>>t;
        manju.push_back(t);
    }
   sort(manju.begin(),manju.end(),greater<int>());

    for(i=0;i<b;i++)
    cin>>box_capa[i]>>box_price[i];
    for(i=0;i<b+1;i++){
        int manjusum=0;
        for(j=0;j<m+1;j++){
            if(i==0||j==0){
                chart[i][j]=0;
                continue;
            }
            if(j<=box_capa[i-1]){
                 manjusum=manjusum+manju[j-1];
                 a=chart[i-1][0]+manjusum-box_price[i-1];
            }
            else{
                 manjusum= manjusum+manju[j-1]-manju[j-1-box_capa[i-1]];
                 a=chart[i-1][j-box_capa[i-1]]+manjusum-box_price[i-1];
            }
            c=chart[i][j-1];
            d=chart[i-1][j];
            if(c<=a&&d<=a)
            chart[i][j]=a;
            else if(a<=c&&d<=c)
            chart[i][j]=c;
            else
            chart[i][j]=d;
            
        }
    }
   cout<<chart[b][m]<<endl;
}



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

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	char a,b;
	cin>>a>>b;
	if (a=='H'){
		cout<<b;
	}
	else {
		if (b=='H'){
			cout<<"D";
		}
		else {
			cout<<"H";
		}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  bool ans = false;
  for (int a = 0; a <= 100; ++a) {
    for (int b = 0; b <= 100; ++b) {
      if (7*a + 4*b == N) ans = true; // 合計金額が X に一致したら答えをインクリメント
    }
  }
  cout << (ans? "Yes" : "No") << endl;
  return 0;
  
    
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        init(n+10);
        int k = sc.nextInt();
        k = Math.min(k, n-1);

        long res = 1;
        for(int i=1; i<=k; i++) {
            long add = conv(n, i) * conv(n-1, i) % mod;
            res += add;
            res %= mod;
        }
        System.out.println(res);


    }

    static long mod = 1000000007;
    static long[] fac;
    static long[] finv;
    static long[] inv;
    static void init(int max) {
        fac = new long[max];
        finv = new long[max];
        inv = new long[max];
        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[(int)mod%i] * (mod / i) % mod;
            finv[i] = finv[i-1] * inv[i] % mod;
        }
    }
    static long conv(int n, int k) {
        if(n<k || n<0 || k<0) return 0;
        return fac[n] * (finv[k]*finv[n-k]%mod) % mod;
    }


}

Measured memory_bytes: 28116
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<unordered_map>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m,i,o=0;
	cin>>n>>m;
	set<int> s;
	vector<pair<int,int> > v;
	for(i=1;i<=m;i++)
		s.insert(i);
	for(i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		v.pb({y,x});
	}
	sort(v.begin(),v.end(),greater<pair<int,int>>());
	for(i=0;i<v.size();i++)
	{
		if(!s.size())
			break;
		auto itr=s.lower_bound(v[i].second);
		if(itr!=s.end())
		{
			o+=v[i].first;
			s.erase(itr);
		}
	}
	cout<<o<<endl;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge{
    int from, to;
    lint cost;
};

int main(){
    int n, m;
    cin >> n >> m;
    lint dis[110][110];
    rep(i, n){
        rep(j, n){
            dis[i][j] = LLINF;
        }
    }
    vector<edge> edges;
    rep(i, m){
        edge e;
        cin >> e.from >> e.to >> e.cost;
        --e.from;
        --e.to;
        dis[e.from][e.to] = e.cost;
        dis[e.to][e.from] = e.cost;
        edges.push_back(e);
    }
    rep(k, n){
        rep(i, n){
            rep(j, n){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, m){
        edge e = edges[i];
        if(e.cost > dis[e.from][e.to]){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	if (A % 2 == 0 && A == B && B == C) printf("-1\n");
	else {
		int a, b, c, count = 0;
		while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
			count++;
			a = (B + C) / 2;
			b = (C + A) / 2;
			c = (A + B) / 2;
			A = a;
			B = b;
			C = c;
		}
		printf("%d\n", count);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{
	   return a<x.a;
	}
} x[100005];
priority_queue<int> q;
int main(){
	int n,m,i,j=1,s=0;
	cin>>n>>m;
	for(i=1;i<=n;++i)
	   cin>>x[i].a>>x[i].b;
	sort(x+1,x+n+1);
	for(i=1;i<=m;++i){
		for(;x[j].a==i&&j<=n;++j)
		   q.push(x[j].b);
		if(!q.empty()){
		   s += q.top();
		   q.pop();
		}
	}
	cout<<s;
	return 0;
}

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

vector<bool> IsPrime(110000,true);

void sieve(ll max){
  if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
    IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
  } 
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  ll smax = sqrt(max);
  for(ll i=2; i<=smax; ++i) // 0からsqrt(max)まで調べる
    if(IsPrime[i]) // iが素数ならば
      for(ll j=2; i*j<=max; ++j) // (max以下の)iの倍数は
        IsPrime[i*j] = false;      // 素数ではない
}

int main() {
  ll X;
  cin >> X;
  sieve(110000);
  int i = X;
  for ( ; !IsPrime[i]; ++i );
  cout << i << endl;
}


Measured memory_bytes: 256
using System;
class Program{
    static void Main(string[] args){
        string[] num = Console.ReadLine().Split(' ');
        int x = int.Parse(num[0]); int y = int.Parse(num[1]); int z =int.Parse(num[2]);
        int reserve = x-z;
        Console.WriteLine(reserve / (y+z));
    }
}

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

using namespace std;
using ll = long long;
vector<int> s;
void dfs(vector<int> graph[], int vis[], int v)
{
    vis[v] = 1;
    s.push_back(v);
    for(auto j : graph[v])
        if(!vis[j])
            dfs(graph, vis, j);
}
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> graph[n+1];
    int i;
    for(i=0;i<m;i++)
    {
        int x,y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    vector<int> blc[n+1];
    for(i=0;i<k;i++)
    {
        int x, y;
        cin >> x >> y;
        blc[x].push_back(y);
        blc[y].push_back(x);
    }
    int vis[n+1] = {0};
    int nums[n+1];
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(graph, vis, i);
            sort(s.begin(), s.end());
            for(auto j : s)
            {
                nums[j] = s.size() - 1 - graph[j].size();
                for(auto num : blc[j])
                    if(binary_search(s.begin(), s.end(),num))
                        nums[j]--;
            }
            s.clear();   
        }
    }
    for(i=1;i<=n;i++)
        cout << nums[i] << " ";
    cout << '\n';    
}

Measured memory_bytes: 13820
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int n = 5;
  vector<int> que(n);
  rep(i, n) cin >> que[i];

  vector<int> index(n);
  rep(i, n) index[i] = i;
  int ans = INF;
  do{
    int time = 0;
    rep(i, n){
      time += que[index[i]];
      if (time % 10 != 0 && i != n - 1) time = (time / 10 + 1) * 10;
    }
    ans = min(ans, time);
  }while (next_permutation(index.begin(), index.end()));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string a;
    cin>>k>>a;
    int len=a.size();
    if(k<len)
    {
        for(int i=0;i<k;i++)
        {
            printf("%c",a[i]);
        }
        cout<<"..."<<endl;
    }
    else cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3576
char*p="012345678036147258048246",f,s[11];main(i){for(;read(0,s,10);i||puts("d"))for(i=24;i>1;f-'s'&&f==s[p[i+1]-48]&f==s[p[i+2]-48]&&puts(&f,i=1))f=s[p[i-=3]-48];}

Measured memory_bytes: 0
// ref. https://img.atcoder.jp/exawizards2019/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll n, q;
string s;
vector<pair<char, char>> spells; // pair of <t, d>

// Check the destination of x. Return true if x does not reach to -1.
bool checkL(ll x) {
  rep(i, q) {
    char t, d;
    tie(t, d) = spells[i];
    if (s[x] == t) { // match
      if (d == 'L') { --x; } else { ++x; }
    }
    if (x < 0) { return false; }
    if (x >= n) { return true; }
  }
  return true;
}

// Check the destination of x. Return true if x does not reach to n.
bool checkR(ll x) {
  rep(i, q) {
    char t, d;
    tie(t, d) = spells[i];
    if (s[x] == t) { // match
      if (d == 'L') { --x; } else { ++x; }
    }
    if (x >= n) { return false; }
    if (x < 0) { return true; }
  }
  return true;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  cin >> n >> q;
  cin >> s;
  spells.resize(q);
  rep(i, q) {
    cin >> spells[i].first >> spells[i].second;
  }

  // Here, we do binary search to calculate left boundary.
  ll left;
  {
    ll l = -1, r = n;
    // search in (l, r]
    while (r-l > 1) {
      ll mid = (r+l)/2;
      if (checkL(mid)) { // mid does not go to -1
        r = mid;
      } else {
        l = mid;
      }
    }
    // Here, l is out. r is in.
    left = r;
  }

  // Here, we do binary search to calculate right boundary
  ll right;
  {
    ll l = -1, r = n;
    // search in [l, r)
    while (r-l > 1) {
      ll mid = (r+l)/2;
      if (checkR(mid)) { // mid does not go to n
        l = mid;
      } else {
        r = mid;
      }
    }
    // Here, r is out. l is in.
    right = l;
  }

  if (right >= left) {
    cout << (right-left+1) << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 976
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
  string S;
  cin >> S;
  bool f[26];
  for (int i = 0; i < 26; i++) { f[i] = false; }
  for (int i = 0; i < S.size(); i++) {
    f[S[i] - 'a'] = true;
  }

  for (int i = 0; i < 26; i++) {
    if (!f[i]) {
      cout << (char)((int)'a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define ll long long
#define R register
ll x,y;
int main()
{
	cin>>x>>y;
	if(x>0)printf("Positive\n");
	else if(y>=0)printf("Zero\n");
	else if((x&1)^(y&1))printf("Positive\n");
	else printf("Negative\n");
	return 0;
}

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

int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1) result -= result / n;
    return result;
}

int main(){
    int n;
    cin >> n;
    cout << phi(n) << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) cin >> d.at(i);

	vector<int> num(100, 0);
	for(int i = 0; i < n; i++) {
		num.at(d.at(i) - 1)++;
	}

	int ans = 0;
	for(int i = 0; i < 100; i++) {
		if(num.at(i) > 0) ans++;
	}

	cout << ans << endl;

 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	bool ok = false;
	if (abs(a - c) <= d)
		ok = true;
	else if (abs(a - b) <= d && abs(b - c) <= d)
		ok = true;
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

	solve();
}


Measured memory_bytes: 256
result = "Yes"


N = int(input())
ls = []
for i in range(N):
    ls.append(list(map(int, input().split())))

ls.sort(key = lambda x:x[1])

s = 0

for i in range(N):
    if ls[i][0] > ls[i][1]:
        result = "No"
        break
    s += ls[i][0]
    if s > ls[i][1]:
        result = "No"
        break

print(result)

Measured memory_bytes: 88152
import itertools

N = int(input())
count = {c: 0 for c in ['M', 'A', 'R', 'C', 'H']}

for _ in range(N):
    S = input()
    if S[0] in ['M', 'A', 'R', 'C', 'H']:
        count[S[0]] += 1

num = [count[c] for c in count]
ans = 0
for v in itertools.combinations(num, 3):
    ans += (v[0] * v[1] * v[2])
print(ans)

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

using ll = std::int64_t;
const ll mod = 1e9 + 7;
const size_t SIZE = 1e6 + 10;
bool used[SIZE];

ll mod_pow(ll n, ll k) {
  ll ret = 1, cur = n;
  while (k) {
    if (k & 1) ret = ret * cur % mod;
    cur = cur * cur % mod;
    k /= 2;
  }
  return ret;
}

ll mod_inv(ll n) { return mod_pow(n, mod - 2); }

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int &e : A) std::cin >> e;
  std::map<int, ll> cnt_max;
  auto update = [&](int k, ll v) {
    ll maxv = std::max(v, cnt_max[k]);
    cnt_max[k] = maxv;
  };
  
  for (int e : A) {
    int orig = e;
    for (int i = 2; i * i <= orig; i++) {
      ll cnt = 0;
      while (e % i == 0) {
        cnt++;
        e /= i;
      }
      if (cnt) update(i, cnt);
    }
    if (1 < e) update(e, 1);
  }
  
  ll mul = 1;
  for (auto &&e : cnt_max) {
    int k;
    ll v;
    std::tie(k, v) = e;
    mul = mul * mod_pow(k, v) % mod;
  }
 
  ll ans = 0;
  for (int e : A) ans += mul * mod_inv(e) % mod;
  std::cout << ans % mod << std::endl;
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s,t;cin>>s>>t;int a=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)){
      a=1;
    }
  }
  if(a==1){
    cout << "No"<<endl;
  }else{
    cout << "Yes"<<endl;
  }
}

Measured memory_bytes: 3596
co = input()

c1 = 0
c2 = 0
for i in range(len(co)):
  if i%2 == 0:
    if co[i] == '0':
      c1 += 1
    else:
      c2 += 1
  else:
    if co[i] == '1':
      c1 += 1
    else:
      c2 += 1
print(c1 if c1<=c2 else c2)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

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

bool kaibun(int n) {
	int a[5];
	for (int i = 0; i < 5; i++) {
		a[i] = n % 10;
		n /= 10;
	}
	if (a[0] == a[4] && a[1] == a[3]) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int n, x;
	cin >> n >> x;
	vector<int>a(n);
	int cnt = n;
	rep(i, n){
		cin >> a[i];
		x -= a[i];
	}
	sort(a.begin(), a.end());
	cnt += x / a[0];
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256