akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
    long long n,aa,bb,tmp1,tmp2,tmp3,re=0;
    cin >> n;
    vector<long long> a(n),b(n);
    for (int i=0;i<n;i++) {
        cin >> aa >> bb;
        a[i] = aa;b[i] = bb;
    }
    for (int j=0;j<n;j++) {
        tmp1 = (a[n-1-j]+re) % b[n-1-j];
        if (tmp1== 0) {}
        else {
            tmp2 = (a[n-j-1]+re) / b[n-j-1] + 1;
            tmp3 = tmp2 * b[n-j-1] - (a[n-j-1]+re);
            re += tmp3;
        }
    }
    cout << re << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    long long k;
    cin >> n >> k;

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

    vector<int> r(n, -1);
    for (int i = 0, j = 0; r[i] == -1; i = a[i] - 1, j++) {
        r[i] = j;
    }

    vector<int>::iterator s = max_element(r.begin(), r.end());
    int b = r[a[s - r.begin()] - 1];
    int c = *s - b + 1;

    cout << find(r.begin(), r.end(), (k < b ? k : (k - b) % c + b)) - r.begin() + 1 << endl;
}


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

int main() {
	int n, buf, cnt;
	cnt = 0;
	int ans;
	ans = 0;

	cin >> n;
	vector<int> s;
	for (int i = 0; i < n; i++) {
		cin >> buf;
		s.push_back(buf);
		ans += s[i];
	}
	sort(s.begin(), s.end());
	
	for (int i = 0; i < n; i++) {
		if (ans % 10 != 0) break;
		if (s[i] % 10 != 0) {
			ans -= s[i];
			break;
		} else {
			cnt ++;
		}
		if (cnt >= n-1) {
			cout << 0 << endl;
			return 0;
		}
	}

	cout << ans << endl;
	
	return 0;
}


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

int main() {
  int n, m; cin >> n >> m;
  vector<pair<int, int> > c[n];
  pair<int, int> ans[m];
  for (int i = 0; i < m; i++) {
    int p, y; cin >> p >> y;
    c[p-1].push_back({y, i});
  }
  for (int i = 0; i < n; i++) {
    sort(c[i].begin(), c[i].end());
    for (int j = 0; j < (int) c[i].size(); j++) {
      ans[c[i][j].second] = {i+1, j+1};
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }
  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 998244353
#define all(vec) vec.begin(), vec.end()
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; }

int main(){
  long n,k;
  cin >> n >> k;
  vector<pll> data(k);
  rep(i,k) cin >> data.at(i).first >> data.at(i).second;
  vector<long> dp(500010,0);
  vector<long> imos(500010,0);
  dp.at(1) = 1;
  long acm = 0;
  REP(v,1,n){
    if(v == 1){
      rep(i,k){
        imos.at(v+data.at(i).first) += 1;
        imos.at(v+data.at(i).second+1) -= 1;
      }
    }else{
      acm += imos.at(v);
      acm %= MOD;
      dp.at(v) = acm;
      rep(i,k){
        imos.at(v+data.at(i).first) += acm;
        imos.at(v+data.at(i).first) % MOD;
        imos.at(v+data.at(i).second+1) -= acm;
        imos.at(v+data.at(i).second+1) += MOD;
        imos.at(v+data.at(i).second+1) %= MOD;
      }
    }
  }
  //rep(i,n+1) cout << dp.at(i) << " ";
  //cout << endl;
  //cout << imos.at(n) << endl;
  cout << (acm + imos.at(n)) % MOD << endl;
}

Measured memory_bytes: 11180
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll N,M;
	cin >> N >> M;
	
	ans = (100*(N-M) + 1900*M) * pow(2,M);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int n,m; cin >> n >> m;
  if(n%m == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int n = nextInt(r);

        int[] A = new int[n/2];
        int[] Ac = new int[n/2];
        int[] B = new int[n/2];
        int[] Bc = new int[n/2];
        for (int i = 0; i < n/2; i++) {
            A[i] = nextInt(r);
            count(A, Ac, i);
            B[i] = nextInt(r);
            count(B, Bc, i);
        }

        int Afi = 0;
        int Asi = 0;
        int Bfi = 0;
        int Bsi = 0;
        if (n > 2) {
            if (Ac[1] > Ac[0]) {
                Afi = 1;
            } else {
                Asi = 1;
            }

            if (Bc[1] > Bc[0]) {
                Bfi = 1;
            } else {
                Bsi = 1;
            }
        }

        for (int i = 2; i < n/2; i++) {
            if (Ac[i] > Ac[Afi]) {
                Asi = Afi;
                Afi = i;
            } else if (Ac[i] > Ac[Asi]) {
                Asi = i;
            }

            if (Bc[i] > Bc[Bfi]) {
                Bsi = Bfi;
                Bfi = i;
            } else if (Bc[i] > Bc[Bsi]) {
                Bsi = i;
            }
        }

        int d = 0;
        if (A[Afi] == B[Bfi] && Asi == 0 && Bsi == 0) {
            d = n/2;
        } else if (A[Afi] == B[Bfi] && Ac[Asi] == 0 && Bc[Bsi] == 0) {
            d = n/2;
        } else if (A[Afi] == B[Bfi]) {
            d = Ac[Asi] > Bc[Bsi] ? Ac[Asi] + Bc[Bfi] : Ac[Afi] + Bc[Bsi];
        } else {
            d = Ac[Afi] + Bc[Bfi];
        }
        System.out.println(n-d);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }

    public static void sort(int[] T, int i) {
        for (int j = i; j > 0; j--) {
            if (T[j] > T[j-1]) {
                int tmp = T[j-1];
                T[j-1] = T[j];
                T[j] = tmp;
            } else {
                break;
            }
        }
    }

    public static void count(int[] T, int[] C, int i) {
        for (int j = 0; j < i; j++) {
            if (T[j] == T[i]) {
                C[j]++;
                return;
            }
        }
        C[i]++;
    }
}


Measured memory_bytes: 50924
a, b, c = map(int, input().split(" "))

if a == 5 and b == 7 and c == 5 \
        or a == 5 and b == 5 and c == 7 \
        or a == 7 and b == 5 and c == 5:
    print("YES")
else:
    print("NO")



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

int main() 
{
    int n, x;
    cin >> n >> x;
    vector<int> v(n+1);
    v[0] = x;
    for (int i=1; i<=n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    vector<int> w(n);
    for (int i=0; i<n; i++)
        w[i] = v[i+1]-v[i];
    int g = 0;
    for (int i=0; i<n; i++)
        g = __gcd(g, w[i]);
    cout << g;
    return 0;
}

Measured memory_bytes: 1024
def main():
    N, K = [int(_n) for _n in input().split()]
    A = [int(_n)-1 for _n in input().split()]
    visited = [-1] * N
    loop = []
    current = 0
    siz = 0
    visited[0] = 0
    loop.append(0)
    start = 0
    while True:
        current = A[current]
        siz += 1
        if visited[current] != -1:
            start = visited[current]
            break
        visited[current] = siz
        # print(visited)
        loop.append(current)
    #     print(loop)
    # print(start)
    if K <= start:
        print(loop[K]+1)
    else:
        print(loop[start + (K-start)%(len(loop)-start)]+1)

    
main()

Measured memory_bytes: 94900
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
vector<int> g[200001];
ll score[200001];

void dfs(int v,int pa, ll sum){
    score[v]+=sum;
    for(int i=0;i<g[v].size();i++){
        if(g[v][i]!=pa){
            dfs(g[v][i],v,score[v]);
        }
    }
}
int main(){
    int n,q,a,b,p;
    ll x;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n-1;i++){
        scanf("%d %d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        scanf("%d %lld",&p,&x);
        score[p]+=x;
    }
    dfs(1,-1,0LL);
    for(int i=1;i<=n;i++){
        printf("%lld ",score[i]);
    }
    printf("\n");
}


Measured memory_bytes: 24320
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
void solve(long long N, long long K, std::vector<long long> A){
    LL my_gcd=A[0];
    LL maxval =0;
    REP(i, N){
        my_gcd = euclidean_gcd(my_gcd, A[i]);
        maxval =max(maxval, A[i]);
    }
 
    if(K%my_gcd==0 && K <= maxval){
        cout<<YES<<endl;
    }
    else cout<<NO<<endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto S = sread();
    auto count = new long[][](N + 1, 10);
    foreach (i; 1 .. N + 1)
    {
        count[i - 1][S[i - 1] - '0'] += 1;
        count[i][] = count[i - 1][];
    }
    long ans;
    bool[10] visited1;
    foreach (i; 0 .. S.length)
        if (!visited1[S[i] - '0'])
        {
            long a = S[i] - '0';
            // writeln(a);
            visited1[a] = true;
            bool[10] visited2;
            foreach (j; i + 1 .. S.length)
                if (!visited2[S[j] - '0'])
                {
                    long b = S[j] - '0';
                    // writeln("b", b);
                    visited2[b] = true;
                    foreach (x; 0 .. 10)
                    {
                        if (0 < count[$ - 1][x] - count[j][x])
                        {
                            // writeln(a, b, x);
                            ans++;
                        }
                    }
                }
        }
    writeln(ans);
}


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

int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  rep(i,h){
    rep(j,w){
      if(i<=h-b-1&&j<=w-a-1||i>h-b-1&&j>w-a-1) cout<<0;
      else cout<<1;
    }
    cout<<endl;
  }
  return 0;
}

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

int main(){
    int N;
    while(cin >> N, N != 0){
        int sum = 0;
        int left = 1,right = 1;
        int ans = 0;
        while(right <= N){
            sum += right;
            right++;
            if(right-left >= 2 && sum == N) ans++;
            while(sum > N && left < right){
                sum -= left;
                left++;
                if(right-left >= 2 && sum == N) ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3040
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

ll L1,R1;
int main(void){
    cin >> L1 >> R1;
    if (R1-L1>=2019){
        cout << 0 << endl;
        return 0;
    }
    ll L = L1%2019;
    ll R = R1%2019;
    if (L>=R){
        cout << 0 << endl;
        return 0;
    }
    ll val = 2018;
    for(ll i=L;i<R;i++) for(ll j=i+1;j<=R;j++) val = min(val, (i*j)%2019);
    cout << val << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int tmp;
        int a = s / 1000, b = s % 1000 / 100, c = s % 1000 % 100 / 10, d = s % 10;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    if (i == 0) {
                        tmp = a + b;
                    } else {
                        tmp = a - b;
                    }
                    if (j == 0) {
                        tmp += c;
                    } else {
                        tmp -= c;
                    }
                    if (k == 0) {
                        tmp += d;
                    } else {
                        tmp -= d;
                    }
                    if (tmp == 7) {
                        String op1 = i == 0 ? "+" : "-";
                        String op2 = j == 0 ? "+" : "-";
                        String op3 = k == 0 ? "+" : "-";
                        System.out.println(a + op1 + b + op2 + c + op3 + d + "=7");
                        return;
                    }
                }
            }
        }
    }
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

    string s;
    cin >> s;
    int n = s.size();
    vvi table(s.size()+1, vi(26, 0));
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            table[i][j] = table[i+1][j];
        }
        table[i][s[i]-'a']++;
    }

    int ans = 0;
    rep(i, n) {
        rep(j, 26) {
            if (s[i] - 'a' != j) {
                ans += table[i][j];
            }
        }
    }

    cout << ans + 1 << endl;

    return 0;
}






Measured memory_bytes: 48916
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = INT_MAX;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
const int mxN = 2e5+5;
vii G[mxN];
bool visited[mxN]; 
int dist[mxN];	
int n,m;
void dfs(int u)
{
	visited[u] = true;
	for(auto v:G[u])
	{
		if(visited[v.fi])
			continue;
		dist[v.fi]=dist[u]+v.se;
		dfs(v.fi);
	}
}
vector<pair<pii,int>> check;
signed main()
{
    //freopen(file".inp","r",stdin);
    //freopen(file".out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v,w;
		cin>>u>>v>>w;
		G[u].eb(v,w);
		G[v].eb(u,-w);
		check.eb(mp(mp(u,v),w));
	}
	for(int i=1;i<=n;i++)
		if(!visited[i])
			dfs(i);
	for(auto u:check)
		if(dist[u.fi.se]!=dist[u.fi.fi]+u.se)
			return cout<<"No",0;
	cout<<"Yes";
}


Measured memory_bytes: 26460
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vikas.k
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int[] group = new int[9];

            int N = in.nextInt();

            for (int i = 1; i <= N; i++) {
                int a = in.nextInt() / 400;

                if (a >= 8) {
                    group[8]++;
                } else {
                    group[a]++;
                }
            }

            int min = 0;
            for (int i = 0; i <= 7; i++) {
                if (group[i] > 0) min++;
            }

            if (group[8] > 0) {
                min = Math.max(1, min);
            }

            for (int i = 0; i <= 7; i++) {
                if (group[i] == 0 && group[8] > 0) {
                    group[i]++;
                    group[8]--;
                }
            }

            int max = 0;
            for (int i = 0; i <= 7; i++) {
                if (group[i] > 0) max++;
            }

            max += group[8];

            out.print(min + " " + max);
        }

    }

    static class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;

#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define fRead(x)                freopen(x,"r",stdin)
#define fWrite(x)               freopen (x,"w",stdout)
#define LL                      long long
#define ULL                     unsigned long long
#define pb                      push_back
#define tcase                   cout<<"Case "<<C++<<": ";
#define all(a)                  a.begin(),a.end()
#define Unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end
#define ABS(x)                  ((x)<0?-(x):(x))
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define PI                      acos(-1.0)
#define ff                      first
#define ss                      second
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define FastRead                ios_base::sync_with_stdio(0);cin.tie(NULL);
#define FOR(x, l, r)            for (int x = l; x<=r; ++x)
#define REP(x,r)                for (int x = 0; x <r; ++x)
#define NN                      cout<<"\n";
#define NNN                     cout<<"\n------------------------------\n";

//***********************************************************************//
//                      SHAHED AHMED, CSE'15, IUT                        //
//***********************************************************************//
LL dp[100010][13];
string s;
LL mod = 1e9+7;

LL func(LL pos, LL rem, LL p10) // func(pos,rem) ---> way
{
    if(dp[pos][rem]!=-1) return dp[pos][rem];

    if(pos==s.size() && rem==5)
    {
        return 1;
    }
    else if(pos==s.size()) return 0;

    LL way=0;

    if(s[pos]=='?')
    {
        for(int i=0;i<=9;i++)
        {
            way+=func(pos+1,(rem+i*p10)%13, (p10*10)%13 );
            way%=mod;
        }
    }
    else
    {
        way+=func(pos+1,(rem+(s[pos]-'0')*p10)%13, (p10*10)%13);
        way%=mod;
    }

    return dp[pos][rem]=way;
}

int main()
{
    memset(dp,-1,sizeof dp);
    cin>>s;
    reverse(all(s));

    cout<<func(0,0,1);


}


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

using namespace std;

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define REP(v, n)      FOR(v, 0, n)

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

	int ans_begin = -1;
	int ans_end   = -1;

	if (s.length() == 2) {
		if (s[0] == s[1]) {
			ans_begin = 1;
			ans_end   = 2;
		}
	} else {
		REP (i, s.length() - 2) {
			if ((s[i + 0] == s[i + 1]) ||
				(s[i + 0] == s[i + 2]) ||
				(s[i + 1] == s[i + 2])) {
				ans_begin = i + 1;
				ans_end   = i + 3;
				break;
			}
		}
	}

	cout << ans_begin << " " << ans_end << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vvii adj;

void dijkstra(ll s, vvii adj, vi &d, vi &p) {
    ll n = adj.size();
    d.assign(n, LLMAX);
    p.assign(n, -1);

    d[s] = 0;
    priority_queue<ii, vector<ii>, greater<ii>> q;
    q.push({0, s});
    while (!q.empty()) {
        ll v = q.top().S;
        ll d_v = q.top().F;
        q.pop();
        if (d_v != d[v])
            continue;

        for (auto edge : adj[v]) {
            ll to = edge.F;
            ll len = edge.S;

            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                p[to] = v;
                q.push({d[to], to});
            }
        }
    }
}
vi d,p;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n;
    adj.resize(n);
    for(int i=0;i<n-1;i++){
        cin>>x>>y>>z;x--;y--;
        adj[x].pb(mp(y,z));
        adj[y].pb(mp(x,z));
    }
    dijkstra(0,adj,d,p);
    for(int i=0;i<n;i++){
        if(d[i]%2){
            cout<<0<<endl;
        }
        else{
            cout<<1<<endl;
        }
    }
    

    

    return 0;
}

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

int main() {
  long n, e = 0, o = 0, f = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (!(a % 4)) {
      f++;
      continue;
    }
    a % 2 ? o++ : e++;
  }
  e % 2 ? e = 1 : e = 0;
  cout << ((o + e) - f <= 1 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
const long long INF = 1LL << 60;

template <class T> inline void chmax(T &a, T b) { a < b ? a = b : a; };
template <class T> inline void chmin(T &a, T b) { a > b ? a = b : a; };

int main() {
    int n, k;
    cin >> n >> k;
    ll dp[100100];
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    REP(i, 1, n) {
        REP(j, 1, min(i + 1, k + 1)) {
            chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
}


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

int test(int x, int y){
    if ( x - y < 0) return y - x;
    return x - y;
}

int main(void)
{
    int x,a,b;
    cin >> x >> a >> b;
    if( test(x, a) < test(x, b)){
        printf("A");
    }else{
        printf("B");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char s[120000];
int fa[120000],p,n;
int a[120000];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)a[i]=s[i]=='1';
	if(a[n]==1||a[1]==0){
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(a[n-i]!=a[i]){
			printf("-1\n");
			return 0;
		}
		if(a[i]==1){
			for(int j=p;j<i;j++)fa[j]=i;
			p=i;
		}
	} 
	for(int i=p;i<=n;i++)fa[i]=n;
	for(int i=1;i<n;i++){
		printf("%d %d\n",i,fa[i]);
	}
} 

Measured memory_bytes: 2304
# 06-Repetitive_Processing-Print_Test_Cases.py

# ???????????±???????????????
# ????????????????????£????????§?????????????????????????????°??????????????°?????\??????????????????????????????????????£????????????????????£???????????????????????????????????????
# ???????????\????????????????????????????????°???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????´???????????§??????

# ???????????´??° x ???????????????????????????????????????????????????????????°?????????????????????????????????
# ?????????????????????????????\?????????????????????????????????????????????????????????????????????????????¨?????¨?????????????????????

# Input
# ??\???????????°????????????????????????????§????????????????????????????????????????????????????????????´??° x ??????????????????????§?????????????????????????
# x ??? 0 ?????¨?????\?????????????????????????????????????????????????????????????????????????????£????????????????????????
# Output
# ??????????????????????????¨????????\????????¢?????§ x ???????????????????????????

# Case i: x
# ????????§???i ?????????????§????????????????????????????????????????????????????Case??¨?????? i?????????????????????????????\??????????????????
# ?????????:?????????????????¨??´??° x ?????????????????????????????\????????????????????????????????\????????????????????????????????????

# Sample Input
# 3
# 5
# 11
# 7
# 8
# 19
# 0
# Sample Output
# Case 1: 3
# Case 2: 5
# Case 3: 11
# Case 4: 7
# Case 5: 8
# Case 6: 19

data=[]
i=0

# print("Input.")
while 1:
	data.append(int(input()))
	if data[i]==0:
		break;
	i=i+1

j=i

for i in range(j):
	print("Case {0}: {1}".format(i+1, data[i]))

Measured memory_bytes: 8060
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)

	if a < 6 {
		fmt.Println(0)
	} else if a < 13 {
		fmt.Println(b/2)
	} else {
		fmt.Println(b)
	}
}


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

int main(){
	int k,len,i,j;
	bool f=false;
	long long sum=0;
	string n;
	cin>>n>>k;
	len=n.size();
	switch(k){
		case 1:
			cout<<(len-1)*9+n[0]-'0';
			break;
		case 2:
			for(i=1;i<len;i++){
				sum+=9*9*(i-1);
			}
			sum+=(n[0]-'1')*9*(len-1);
			for(i=1;i<len;i++){
				if(n[i]!='0'){
					sum+=n[i]-'0';
					sum+=(len-i-1)*9;
					cout<<sum;
					f=true;
					break;
				}
			}
			if(f==false) cout<<sum;
			break;
		case 3:
			for(i=1;i<len;i++){
				sum+=729*(i-1)*(i-2)/2;
			}
			sum+=(n[0]-'1')*81*(len-1)*(len-2)/2;
			for(i=1;i<len;i++){
				if(n[i]!='0'){
					sum+=(n[i]-'1')*9*(len-i-1);
					for(j=i+1;j<len;j++){
						if(n[j]!='0'){
							sum+=n[j]-'0';
							sum+=(len-j-1)*9;
							break;
						}
					}
					sum+=(len-i-1)*81*(len-i-2)/2;
					cout<<sum;
					f=true;
					break;
				}
			}
			if(f==false) cout<<sum;
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    string s, t;
    cin >> s >> t;
    s.insert(0, " ");

    vector<int[26]> next(s.size());

    int tmp[26];
    for(int i=0; i<26; i++) {
        tmp[i] = -1;
    }

    for(int i=s.size()-1; i>=0; i--) {
        for(int j=0; j<26; j++) {
            if(tmp[j] < 0) {
                next[i][j] = tmp[j];
            } else {
                next[i][j] = tmp[j] - i;
            }
        }
        tmp[s[i]-'a'] = i;
    }

    int64_t now = 0;
    int64_t ans = 0;
    for(int i=0; i<t.size(); i++) {
        int64_t jump = next[now][t[i]-'a'];
        if(now == 0 && jump == -1) {
            cout << -1 << endl;
            return 0;
        } else if(jump >= 0) {
            now += jump;
            ans += jump;
        } else {
            ans += s.size()-1-now;
            now = 0;
            --i;
        }
    }

    cout << ans << endl;
    return 0;
}


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

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

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

vector<string> fi;
ll H,W;
const ll INF = 1LL<<60;


ll solve(){

  vector<vector<long long>> dp(H, vector<long long>(W, INF) );
 
  if(fi[0][0]=='#')dp[0][0]=1;
  else dp[0][0]=0;
  
  rep(i,H){
    rep(j,W){
      rep(dir,2){
        
        int ni=i+dx[dir];
        int nj=j+dy[dir];
        
        if( ni>=H || nj>=W ) continue;
        int add=0;
		if( fi[ni][nj]=='#' && fi[i][j]=='.')add=1;
        chmin( dp[ni][nj], dp[i][j]+add );
        
      }
    }
  }

  return dp[H-1][W-1];
  
}

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

  fi.resize(H);
  
  rep(i,H)cin>>fi[i];
  
  cout<<solve()<<endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

// 余裕を持たせないと WA になる
const int MAX_N = 110000;

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

  vector<int> dp(MAX_N, n);  // INF の気持ち
  dp[0] = 0;

  // 貰う DP --- dp[i] に遷移を集める
  for (int i = 1; i <= n; i++) {
    // 1, 6, 6^2, ..., を試す (i を超えない範囲で)
    for (int pow6 = 1; pow6 <= i; pow6 *= 6)
      dp[i] = min(dp[i], dp[i - pow6] + 1);

    // 1, 9, 9^2, ..., を試す (i を超えない範囲で)
    for (int pow9 = 1; pow9 <= i; pow9 *= 9)
      dp[i] = min(dp[i], dp[i - pow9] + 1);
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    int l,r;
    cin >> n >> m;
    int s=1,e=n; 
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        s=max(s,l);
        e=min(e,r);
        if(s>e){
            cout << 0 << endl;
            exit(0);
        }
        

    }
    cout << e-s+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define INF (int)1e9
#define EPS 1e-6
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long int lli;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<char, lli> mcl;
typedef unordered_map<lli, lli> mll;
typedef unordered_set<lli> usl;
typedef unordered_set<char> usc;
typedef unordered_set<pll> uspll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef map<int,int> mpii;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<double, double> pdd;
const double pi = 3.14159265358979323;

vector<lli> a_vec;
vector<lli> b_vec;
vector<lli> c_vec;
lli a, b, c;
lli dp[200][200][200];
		
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc, n;
	string s;
	cin >> s;
	int ans = 0;
	int mymax = -1;
	REP(i, s.length()){
		if(s[i] == 'R')
			ans++;
		else{
			if(ans > mymax)
				mymax = ans;
			ans = 0;
		}
	}
	mymax = max(mymax, ans);
	cout << mymax;
			
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int cnt=0;
  for(int i=0;i<n;++i)
  {
    int a;
    cin>>a;
    if(a%2==1)cnt++;
  }
  if(cnt%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        List<String> list = Arrays.asList(
                "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
        );

        Scanner scanner = new Scanner(System.in);
        String input = scanner.next().toLowerCase();

        int i = list.indexOf(input);
        System.out.println(list.get(i + 1));
    }
}

Measured memory_bytes: 21844
from sys import stdin
def S(): return stdin.readline().rstrip()

def g(s):
    l = len(s)
    n = 2**l
    sum = 0
    for j in range(n):
        buff = ''
        for i in range(l):
            if j&(1<<i):
                buff += '+'
            else:
                buff += s[i]
        buff = buff.split('+')
        for _ in range(len(buff)):
            tmp = buff.pop()
            if tmp!='':
                sum += int(tmp)
    return sum


s = S()
ans = g(s)
print(ans)

Measured memory_bytes: 3064
#define TEST_MODE true
     
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
     
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;				\
							   c > 0 ? i < b : i > b;	\
							   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
     
#ifdef LOCAL_ENV
     
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif
     
#else
const bool test = false;
#define dump(x) 
#endif
     
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
     
//.....................
const int MAX = (int)2e5 + 5;
     
// vector<string> split(const string &str, char sep)
// {
//   vector<string> v;
//   stringstream ss(str);
//   string buffer;
//   while (getline(ss, buffer, sep))
// 	{
// 	  v.push_back(buffer);
// 	}
//   return v;
// }
     
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
     
void solve();
     
signed main()
{
  cout << fixed << setprecision(20);
  solve();
  while (true)
	{
	  char s[MAX];
	  if (scanf("%s", s) == EOF)
		break;
	  int n = strlen(s);
	  for (int i = n - 1; i > -1; i--)
		{
		  ungetc(s[i], stdin);
		}
	  solve();
	}
  return 0;
}
     
string s;

void solve() {
  cin >> s;
  int cnt[30] = {};
  rep(i, (int)s.size()) {
	cnt[s[i] - 'a']++;
  }
  string res = [&](){
	rep(i, 30) {
	  if (cnt[i] > 1) return "no";
	}
	return "yes";
  }();
  cout << res << endl;
}

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

ll func(ll c, ll x) {
	if (c < 0) c = 0;
	ll res = c / x;
	return res;
}

int main() {
	ll a, b, x; cin >> a >> b >> x;
	ll ans = 0;
	if (a == 0) {
		a++;
		ans += 1;
	}
	ans += func(b, x) - func(a - 1, x);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
package main

import (
        "bufio"
        "os"
        "strconv"
)

func main() {
        scanner := bufio.NewScanner(os.Stdin)
        scanner.Split(bufio.ScanWords)
        writer := bufio.NewWriter(os.Stdout)
        defer writer.Flush()

        scanner.Scan()
        N, _ := strconv.Atoi(scanner.Text())
        scanner.Scan()
        K, _ := strconv.Atoi(scanner.Text())

        Nok := 0
        for i := 0; i < N; i++ {
                scanner.Scan()
                hi, _ := strconv.Atoi(scanner.Text())
                if hi >= K {
                        Nok++
                }
        }
        writer.WriteString(strconv.Itoa(Nok))
}


Measured memory_bytes: 896
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    L = [[] for _ in range(K)]
    for t in range(K):
        l, r = map(int, input().split())
        for j in range(l, r + 1):
            L[t].append(j)

    lc = [0] * K
    mod = 998244353

    dp = [0] * (N + 1)
    dp[0] = 1
    for i in range(1, N + 1):

        for k in range(K):
            CL = L[k]
            if len(CL) == 1:
                lc[k] = dp[i - CL[0]] % mod
            else:
                if CL[-1] > i:
                    lc[k] = lc[k] % mod + dp[i - L[k][0]] % mod
                else:
                    lc[k] = (lc[k] + dp[i - L[k][0]] - dp[i - L[k][-1] - 1]) % mod
            dp[i] = lc[k] + dp[i] % mod

    print(dp[N - 1] % mod)


if __name__ == "__main__":
    main()

# \n


Measured memory_bytes: 88336
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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; }

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
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, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, w;
    cin >> n >> w;
    vector<P>  wv(n);
    rep(i, n) cin >> wv[i].first >> wv[i].second;

    vector<vector<int> > dp(n + 1, vector<int>(100001, INF));
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 100001) {
            if (j - wv[i].second >= 0) chmin(dp[i + 1][j], dp[i][j - wv[i].second] + wv[i].first);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    int ans = 0;
    rep(i, 100001) {
        if (dp[n][i] <= w)
            ans = max(ans, i);
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 43392