akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
#define ldouble long double
#define vin vector<int> 
#define rep(i,a,n) for(i=a;i<n;i++)
#define INF (int)1000000007

//setprecision()<<

using namespace std;

void fin(int i,int n,vin &a){
    rep(i,0,n){
        cin>>a.at(i);
    } 
} 

void dfs(vector<vector<int> > &vec,int v,vector<bool> &seen,vector<int> &result){
    //int i;
    seen.at(v)=true;
    // rep(i,0,vec.at(v).size()){
    //     result.at(vec.at(v).at(i))+=result.at(v);
    // }

    for(int next_v=0;next_v<vec.at(v).size();next_v++){
        if(seen.at(vec.at(v).at(next_v))){
            continue;
        }
        result.at(vec.at(v).at(next_v))+=result.at(v);
        dfs(vec,vec.at(v).at(next_v),seen,result);
    }
}

signed main() {
    int i;
    int N,Q;
    cin>>N>>Q;
    vector<vector<int> > ab(N);
    vector<bool> seen(N);
    seen.assign(N,false);
    vector<int> result(N);
    rep(i,0,N-1){
        int a,b;
        cin>>a>>b;
        ab.at(a-1).push_back(b-1);
        ab.at(b-1).push_back(a-1);
    }
    rep(i,0,Q){
        int a,b;
        cin>>a>>b;
        result.at(a-1)+=b;
    }

    dfs(ab,0,seen,result);

    rep(i,0,N){
        cout<<result.at(i)<<endl;
    }
return 0;
}

Measured memory_bytes: 33664
def main():
    x, y = map(int, input().split())
    if x * y < 0:
        ans = abs(abs(x)-abs(y)) + 1
    elif x < y:
        ans = y - x
    elif x == 0 or y == 0:
        ans = x - y + 1
    else:
        ans = x - y + 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
x,y = map(int,input().split())

if (x+y)%3 != 0:
  print(0)
  exit()
if 2*x < y:
  print(0)
  exit()
if 2*y < x:
  print(0)
  exit()
  
mod = 10**9+7
n = (2*x-y)//3
m = (2*y-x)//3

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) 
  
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print(comb(n+m,n,mod))

Measured memory_bytes: 3064
n = gets.chomp.to_i
ws = gets.chomp.split(' ').map(&:to_i)

ans = 100
(0...n-1).each do |i|
    w1 = ws[(0..i)].reduce(:+)
    w2 = ws[(i+1..n-1)].reduce(:+)
    amt = (w1 - w2).abs
    ans = amt if amt < ans
end

puts ans


Measured memory_bytes: 3836
INF = 10 ** 9 + 7

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

# 単体のA内で発生するケース
inv = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] > A[j]:
            inv += 1
inv = inv * K

# 異なるA間で発生するケース
ini = 0
for k in range(N):
    for l in range(N):
        if A[k] > A[l]:
            ini += 1
ini = ini * K * (K-1) // 2
ans = (inv+ini) % INF
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 998244353
ll n,m,arr[sz],brr[sz],k,l,crr[sz],t,i,j,hi,lo,mi;
vector<ll>v;
char c[sz];
int main()
{
 scanf("%lld",&n);
 j=26;
 for(i=1;;i++)
 {
     if(n>j)
        n-=j,j*=26;
     else if(n==j)
     {
         for(j=1;j<=i;j++)
            printf("z");
         return 0;
     }
     else
     {
         j/=26;
         for(k=1;k<=i;k++)
         {
             for(l=0;l<26;l++)
             {
                 if(n>j)
                    n-=j;
                 else
                 {
                     printf("%c",l+'a');
                     break;
                 }
             }
             j/=26;
         }
         return 0;
         k=0;
         m=0;
         while(n>0)
         {
             l=n%26;
             if(n>26)
             n+=26-l;
             n/=26;
             if(l==0 && n>0)
             {
                 c[k]='z';
             }
            else if(l==0 || n==0)
             {
                 if(n==0 && l!=0)
                    c[k++]='a'+l;
                 for(k;k<i;k++)
                    c[k]='a';
                for(k=i-1;k>=0;k--)
                    printf("%c",c[k]);
                return 0;
             }
             else
                c[k]='a'+l;
                k++;
         }
         for(k=i-1;k>=0;k--)
            printf("%c",c[k]);
         return 0;
     }
 }
}


Measured memory_bytes: 3824
while gets
	n,k = $_.split.map(&:to_i)
	break if n == 0 
	l = gets.split.to_a.map(&:to_i)
	n.times do
		m = gets.split.to_a.map(&:to_i)
		k.times do |i|
			l[i] -= m[i]
		end
	end
	puts l.all?{|i| i >= 0} ? "Yes" : "No"
end

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
 string s;
int main(){
  cin >> s;
  for (size_t i = 0; i < 4; i++) {
    cout << s[i];
  }
  cout << ' ';
  for (size_t i = 4; i < s.length(); i++) {
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
  string s ;
  cin >> s ;
  
  if(s[0]==s[1] && s[1]==s[2])
    cout << "No" << endl ;
  else
    cout << "Yes" << endl ;
    return 0;
}


Measured memory_bytes: 256
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define endl 			"\n"
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(100);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();
	map<string, int>m;
	string s;
	w(t)
	{
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;


	return 0;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;


    int n;
    cin>>n;
    int cnt1=0,cnt2=26,cnt3=1;
    while(1){
        if(cnt1+cnt2>=n)break;
        cnt1+=cnt2;
        cnt2*=26;
        cnt3++;
    }
    n-=cnt1;
    rep(i,cnt3){
        cnt2/=26;
        cout<<(char)((n-1)/cnt2+'a');
        n-=(int)((n-1)/cnt2)*cnt2;
    }
    cout<<endl;
}


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

using namespace std;

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

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

void swap1(int &x, int &y) {
  x ^= y;
  y ^= x;
  x ^= y;
}

void swap2(int &x, int &y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  vector<int> A(3);
  for (int i = 0; i < 3; i++)
    cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[0] * A[1] / 2 << endl;
}


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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,x,t;
  scanf("%d%d%d",&n,&x,&t);

  printf("%d\n",t*(n/x+!!(n%x)));

  return 0;
}


Measured memory_bytes: 1688
/*

* author:mel0n
* le epic style 
*
*

*/

#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define lli long long int
#define pi pair<int,int>
#define all(x) (x).begin(),(x).end()

using namespace std;



int main()
{
char a;
cin>>a;
if(isupper(a))
	cout<<"A"<<endl;
else
	cout<<"a"<<endl;



}



Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
int a[200005],b[200005];
int tmp[200005];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n) cin>>a[i]>>b[i];
	sort(a+1,a+n+1);
	ll low;
	if (n%2) low=a[n/2+1];
	else low=a[n/2]+a[n/2+1];
	sort(b+1,b+n+1);
	ll hi;
	if (n%2) hi=b[n/2+1];
	else hi=b[n/2]+b[n/2+1];
	cout<<hi-low+1<<endl;
	return 0; 
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll H, W, K;
    cin >> H >> W >> K;
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;
    x2--;
    y1--;
    y2--;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];
    vector<vector<ll>> cost(H, vector<ll>(W, 0));

    queue<pair<P, ll>> que;
    cost[x1][y1] = INF;
    que.push({{x1, y1}, 0});
    while (!que.empty()) {
        auto q = que.front();
        que.pop();
        P p = q.first;
        ll c = q.second;
        rep(i, 4) {
            rep2(k, 1, K + 1) {
                ll x = p.first + k * dx[i];
                ll y = p.second + k * dy[i];
                if (x >= 0 && x < H && y >= 0 && y < W) {
                    if (grid[x][y] == '.') {
                        if (cost[x][y] == 0) {
                            cost[x][y] = c + 1;
                            que.push({{x, y}, cost[x][y]});
                        } else {
                            if (cost[x][y] < q.second + 1) {
                                break;
                            }
                        }
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
        }
    }
    ll ans = cost[x2][y2];
    if (ans == 0) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 19832
#!/usr/bin/env python3
import sys
from typing import NamedTuple, List

class Game(NamedTuple):
    c: List[int]
    s: List[List[int]]

def solve(D: int, c: "List[int]", s: "List[List[int]]", t: "List[int]"):
    from functools import reduce        
    ans = [0]
    lasts = [0] * 26
    sum_c = sum(c)
    daily_loss = sum_c
    bits = [BIT(D*2) for _ in range(26)]    
    for day, tt in enumerate(t, 1):
        a = s[day-1][tt-1]
        lasts[tt-1] = day
        for i in range(26):
            bits[i].add(day, lasts[i]*c[i])
        a -= daily_loss
        a += sum(b.sum(day)-b.sum(day-1) for b in bits)
        ans.append(ans[-1]+a)
        daily_loss += sum_c
    return ans[1:]

# https://kopricky.github.io/code/For_Python/bit.html
class BIT:
    def __init__(self, node_size):
        self._node = node_size+1
        self.bit = [0]*self._node
 
    def add(self, index, add_val):
        index += 1
        while index < self._node:
            self.bit[index] += add_val
            index += index & -index
 
    def sum(self, index):
        index += 1
        res = 0
        while index > 0:
            res += self.bit[index]
            index -= index & -index
        return res

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    c = [int(next(tokens)) for _ in range(26)]  # type: "List[int]"
    s = [[int(next(tokens)) for _ in range(26)] for _ in range(D)]  # type: "List[List[int]]"
    t = [int(next(tokens)) for _ in range(D)]  # type: "List[int]"
    print(*solve(D, c, s, t), sep="\n")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 10828
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    ios_base::sync_with_stdio(false);

    int n,q;
    cin >> n >> q;
    UnionFind tree(n);
    rep(i,q) {
        int c,a,b;
        cin >> c >> a >> b;
        if (c==0) tree.unite(a,b);
        else cout << tree.same(a,b) << endl;
    }

    return 0;   
}



Measured memory_bytes: 3232
n = int(input())
a = []
for i in range(2):
    a.append(list(map(int, input().split())))

# print(a)
ans = 0
for i in range(1, n+1):
    total = sum(a[0][:i])+sum(a[1][i-1:])
    if total > ans:
        ans = total

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  string s;
  cin>>s;
  for(ll i=0;i<3;i++)
  {
    if(i==1)
    {
      if(s[i]=='B')
        cout<<"R";
      else
        cout<<"B";
    }
    else
      cout<<s[i];
  }
  return 0;
}


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

using namespace std;

void solve() {
    int N;
    cin >> N;
    int P, min_P, ans;
    min_P  = INT_MAX;
    ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> P;
        if(P <= min_P) {
            ans++;
            min_P = P;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3596
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string[] a = Console.ReadLine().Split(' ');
                int x = int.Parse(a[0]);
                int y = int.Parse(a[1]);

                if (x == 0 && y == 0) break;
                else if (x <= y) Console.WriteLine("{0} {1}", x, y);
                else Console.WriteLine("{0} {1}", y, x);
            }
        }
    }
}


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

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; ++i) {
        int t; cin >> t; a[i] = t;
    }
    sort(a.begin(), a.end());
    for (auto it = a.begin(); it != a.end(); it++) {
        if (it != a.begin()) cout << ' ';
        cout << *it;
    }
    cout << endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int n;
  cin >> n;
  vi result(26, INT_INF);
  for(int i = 0; i < n; i++){
    string S;
    cin >> S;
    vi counter(26, 0);
    for(int j = 0; j < S.size(); j++){
      counter.at(S.at(j)-'a')++;
    }
    for(int j = 0; j < 26; j++){
      chmin(result.at(j), counter.at(j));
    }
  }
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < result.at(i); j++){
      cout << (char)(i+'a');
    }
  }
  cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

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

	int ans0=0, ans1=0;
	for(int i=0; i<S.size(); i++){
		if(i%2){
			ans0 += S[i]=='0'?1:0;
			ans1 += S[i]=='1'?1:0;
		} else {
			ans0 += S[i]=='1'?1:0;
			ans1 += S[i]=='0'?1:0;
		}
	}

	cout << min(ans0, ans1) << endl;

	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        var min = A.Min();
        var max = A.Max();
        Console.WriteLine(max - min);
    }
}


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

t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
if a1>b1:
    a1,b1=b1,a1
    a2,b2=b2,a2
if a1*t1+a2*t2<b1*t1+b2*t2:
    print(0)
    exit()
elif a1*t1+a2*t2 == b1*t1+b2*t2:
    print("infinity")
    exit()
dis=t2*(a2-b2)+t1*(a1-b1)
ans=(t1*(b1-a1))//dis
anssub = (t1*(b1-a1))%dis
if anssub==0:
    sub=0
else:
    sub=1
print(ans*2+sub)


Measured memory_bytes: 3932
#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;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int n, k;
  cin >> n >> k;
  int a[n];
  int sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  k -= sum;
  int ans = n;
  sort(a, a + n);
  ans = ans + k / a[0];
  cout << ans << endl;
  
  
      
    
  return 0;
}

Measured memory_bytes: 3648
/*
[abc129] D - Lamp
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_HW = 2000;

int H, W;
bool m[MAX_HW + 2][MAX_HW + 2];
int d[4][MAX_HW + 2][MAX_HW + 2];

ll solve() {
    for (int j = 1; j <= W; j++) {
        d[0][0][j] = 0;
        for (int i = 1; i <= H; i++) {
            d[0][i][j] = m[i][j] ? i : d[0][i - 1][j];
        }
        d[2][H + 1][j] = H + 1;
        for (int i = H; i > 0; i--) {
            d[2][i][j] = m[i][j] ? i : d[2][i + 1][j];
        }
    }
    for (int i = 1; i <= H; i++) {
        d[1][i][W + 1] = W + 1;
        for (int j = W; j > 0; j--) {
            d[1][i][j] = m[i][j] ? j : d[1][i][j + 1];
        }
        d[3][i][0] = 0;
        for (int j = 1; j <= W; j++) {
            d[3][i][j] = m[i][j] ? j : d[3][i][j - 1];
        }
    }

    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (!m[i][j]) {
                int cand =
                    d[2][i][j] - d[0][i][j] + d[1][i][j] - d[3][i][j] - 3;
                ans = max(ans, cand);
            }
        }
    }
    return ans;
}

int main() {
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= W; j++) {
            m[i][j] = (s[j - 1] == '#');
        }
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 66816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1<<30;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[8]={1,0,-1,0,1,1,-1,-1} , dy[8]={0,1,0,-1,1,-1,1,-1} ;

int main(){
    int n,m;
    cin>>n>>m;
    pint a[m];
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        a[i]={y,x};
    }
    int cnt=0;
    int pos=-1;
    sort(a,a+m);
    rep(i,m){
        if(a[i].second>pos){
            cnt++;
            pos=a[i].first-1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<algorithm>
using namespace std;
int n,a,b;


int main(){
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	string s;
	cin >> s;
	if(s == "ARC") {
		cout << "ABC";
	}
	else {
		cout << "ARC\n";
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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 int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int H,W;cin>>H>>W;
    char M[H][W];
    REP(i,H)REP(j,W)cin>>M[i][j];
    bool ok=true;
    REP(i,H){
        REP(j,W){
            if(M[i][j]=='.')continue;
            bool check=false;
            if(i-1>=0){
                if(M[i-1][j]=='#')check=true;
            }
            if(i+1<H){
                if(M[i+1][j]=='#')check=true;
            }
            if(j-1>=0){
                if(M[i][j-1]=='#')check=true;
            }
            if(j+1<W){
                if(M[i][j+1]=='#')check=true;
            }
            if(!check){
                ok=false;
                break;
            }
        }
        if(!ok)break;
    }
    cout<<(ok?"Yes":"No")<<endl;
}

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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  
  int ans = 0;
  range(i, 1, N + 1) {
    int cnt = 0;
    int t = i;
    while (t) cnt++, t /= 10;
    
    if (cnt & 1) ans++;
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(a)  (a).begin(),(a).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

vll Eratosthenes(ll N){
    vll arr(N + 1, 1);
  	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}
    return arr;
}


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

    ll cnt = 0;
    vll s(100010), p = Eratosthenes(100010);
    p[0] = p[1] = 0;
    FOR(i, 1, 100010){
        if(p[i] && p[(i + 1) / 2]) s[i] = s[i - 1] + 1;
        else s[i] = s[i - 1];
    }
    ll q;
    cin >> q;
    ll l, r;
    REP(i, q){
        cin >> l >> r;
        ll res = s[r] - s[l - 1];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n, ans = 0, m;
    cin >> n;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        ans += x;
        m = max(m, x);
    }
    ans -= m / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<bitset>

int main(void) {
	int ABCD[4];

	for (int i = 0; i < 4; i++)
		std::cin >> ABCD[i];

	int AB = ABCD[0] * ABCD[1];
	int CD = ABCD[2] * ABCD[3];

	int res = (AB > CD) ? AB : CD;

	std::cout << res << std::endl;

	getchar();
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h]
    }
    let xy = [
        [-1i32, 1i32],
        [0i32, 1i32],
        [1i32, 1i32],
        [-1i32, 0i32],
        [1i32, 0i32],
        [-1i32, -1i32],
        [0i32, -1i32],
        [1i32, -1i32],
    ];
    let mut s = s;
    for y in 0..h {
        for x in 0..w {
            if s[y][x] == '#' {
                continue;
            }
            let mut n = 0;
            for i in 0..8 {
                let xx = x as i32 + xy[i][0] as i32;
                let yy = y as i32 + xy[i][1] as i32;
                if xx < 0 || w as i32 <= xx {
                    continue;
                }
                if yy < 0 || h as i32 <= yy {
                    continue;
                }
                if s[yy as usize][xx as usize] == '#' {
                    n += 1;
                }
            }
            s[y][x] = format!("{}", n).chars().nth(0).unwrap();
        }
    }
    for y in 0..h {
        for x in 0..w {
            print!("{}", s[y][x]);
        }
        println!()
    }
}


Measured memory_bytes: 4352
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        if a*500+b*100 <= X:
            if (X -a*500-b*100)%50 == 0 and (X -a*500-b*100)//50 <= C:
                ans += 1
print(ans)

Measured memory_bytes: 9144
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp.to!(char[]);
  auto t = readln.chomp.to!(char[]);

  const no = "UNRESTORABLE";
  if (t.length > s.length) {
    writeln(no);
    return;
  }
  char[][] cand;
  for (size_t i = 0; i + t.length <= s.length; i++) {
    bool ok = true;
    foreach (j; 0 .. t.length) {
      if (s[i + j] != '?') {
        ok &= s[i + j] == t[j];
      }
    }
    if (ok) {
      auto u = s[0 .. i] ~ t ~ s[i + t.length .. $];
      foreach (ref c; u)
        if (c == '?')
          c = 'a';
      cand ~= u;
    }
  }
  if (cand.length > 0) {
    sort(cand);
    writeln(cand[0]);
  } else {
    writeln(no);
  }

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
n = int(input())
for i in range(n):
    if (i+1)%3==0:
        print(" "+str(i+1), end="")
    else:
        x = i+1
        while(x>0):
            if x%10==3:
                print(" "+str(i+1), end="")
                break
            else:
                x = x//10
print("")

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

using namespace std;
typedef long long ll;

// マクロ
#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N   10005
#define MAX_H 105

int H, W, N;
int ans[MAX_H][MAX_H];
vector< pair<int, int> > color;     // i:色の個数 j:色id
int main()
{
    MINUS(ans);
    cin >> H >> W >> N;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        color.push_back(make_pair(tmp, i+1));
    }
    SORT(color);
    int c_ind = 0;
    REP(i, H) {
        if(i % 2 == 0) {
            REP(j, W) {
                ans[i][j] = color[c_ind].second;
                color[c_ind].first--;
                if(color[c_ind].first <= 0) { c_ind++; }
            }
        } else {
            for(int j = W-1; j >= 0; --j) {
                ans[i][j] = color[c_ind].second;
                color[c_ind].first--;
                if(color[c_ind].first <= 0) { c_ind++; }
            }
        }
    }
    REP(i, H) {
        REP(j, W) {
            printf("%d", ans[i][j]);
            if(j == W-1) { printf("\n"); }
            else { printf(" "); }
        }
    }
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int H,W,m;cin >>H>>W>>m;
    int mxh=0,mxw=0;
    ll MX=300010;
    vector<int>ch(MX,0);
    vector<int>cw(MX,0);
    map<P,bool>mp;
    for (int i = 0; i < m; ++i) {
        int h,w;cin >>h>>w;
        h--;w--;
        ch[h]++;cw[w]++;
        mxh=max(mxh,ch[h]);
        mxw=max(mxw,cw[w]);
        mp[{h,w}]=true;
    }
    vector<int>x;
    vector<int>y;
    for (int i = 0; i <=H; ++i) {
        if(mxh==ch[i])x.push_back(i);
    }
    for (int j = 0; j <=W; ++j) {
        if(mxw==cw[j])y.push_back(j);
    }
    ll ans=mxh+mxw;
    bool exist=false;
    ll k=x.size()*y.size();//交点の数
    if(k>m){
        cout <<ans<<endl;
        return 0;
    }
    for(auto i:x){
        for(auto j:y){
            if(!mp[{i,j}])exist=true;
        }
    }
    if(!exist)ans--;
    cout <<ans <<endl;
}


Measured memory_bytes: 28432
def C():
    A, B, C, nA, nB = map(int, input().split())
    minAB = min(nA, nB)
    # 3, 2 --> 1, 0
    ns = [nA - minAB, nB - minAB]
    amounts = [
        A * nA + B * nB,
        minAB * 2 * C + ns[0] * A + ns[1] * B,
        max(nA, nB) * 2 * C
    ]
    return min(amounts)

print(C())


Measured memory_bytes: 3060
#include<stdio.h>
#define min(a,b) (a<b?a:b)
main(){
  int s=0;
  int c;
  int ans=10000;
  for(int i=0;(c=getchar())!=EOF&&c!='\n';i++){
    s=(s%100)*10+(c-'0');
    if(i>=2)ans=min(ans,abs(s-753));
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int h, n;
	cin >> h >> n;
	rep(i, n) {
		int a;
		cin >> a;
		h -= a;
	}
	cout << (h <= 0 ? "Yes" : "No") << endl;



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) {
    return a < b ? b = a, true : false;
}
template<typename T> bool chmax(T a, T &b) {
    return a > b ? b = a, true : false;
}

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*----------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    str s;
    std::cin >> s;
  
    s[3] = '8';
  
    std::cout << s << '\n';
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}

//素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
  ll N,cnt=0;
  cin >> N;
  auto lis = prime_factorize(N);
  for (auto t:lis) {
    ll add=1;
    while (true) {
      if (add*(add+1)/2>t.second) {
        cnt+=add-1;
        break;
      }
      else add++;
    }
  }
  cout << cnt << endl;
}

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

string s,s1;

int main()
{
	cin>>s>>s1;
	if(s==s1)
	{
		printf("Yes");
		return 0;
	}
	int len=s.size();
	if(len!=s1.size())
	{
		printf("No");
		return 0;
	}
	for(int i=1; i<len; i++)
	{
		s=s[len-1]+s;
		s.erase(len,1);
		if(s==s1)
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())

MOD = 998244353

PAT = []
for _ in range(K):
  l,r = map(int, input().split())
  PAT.append((l,r))
  
IMOS = [0] * (N+10)
IMOS[1] = 1
for i in range(0,N):
  if IMOS[i] == 0:
    continue
  for l,r in PAT:
    if i+l > N+1:
      continue
    IMOS[i+l] += IMOS[i]
    if i+r-1 > N+1:
      continue
    IMOS[i+r+1] -= IMOS[i]
  #print(i, IMOS)
  IMOS[i+1] += IMOS[i]
  IMOS[i+1] %= MOD
  
print((IMOS[N] - IMOS[N-1]) % MOD)
    


Measured memory_bytes: 16948
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng {
    using namespace boost;
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int N;
    cin >> N;
    set<string> S;
    for (int i : irange(N)) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << nl;
}


Measured memory_bytes: 19124
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

main(){
	int n=1,m=1,b[100],c[100];
	
	char a[100][100];
	
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0) break;
		for(int i=0 ; i<n ; i++){
			scanf("%s",a[i]);
		}
		
		int i=0,j=0,o=0,u=0;
		
		while(1){
			if(a[i][j]=='>') j++;
			if(a[i][j]=='<') j--;
			if(a[i][j]=='v') i++;
			if(a[i][j]=='^') i--;
			if(a[i][j]=='.'){
				u=0; break;
			}
			b[o]=i;
			c[o]=j;
			for(int p=0; p<o ; p++){
				if(b[p]==i && c[p]==j){
					 u++;
				}
			}
			o++;
			if(u>0) break;
		}
		
		if(u==1) printf("LOOP\n");
			else printf("%d %d\n",j,i);
		u=0;
	}

}

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

#define int long long
const int N = 5e3 + 3;

int dp[N], A[N];

signed main(){
	int n, a, b;
	cin >> n >> a >> b;
    
    memset(dp , 22, sizeof dp);
    dp[0] = 0;
    for(int i=1; i<=n; i++){
        cin >> A[i];
        int t = 0;
        int mx = 0;
        for(int j=i-1; j>=0; j--){
            if(A[j] > A[i]) t++;
        	else mx = max(mx , A[j]);
            if(mx == A[j])
                dp[i] = min(dp[i] , dp[j] + a*t + b*(i-j-1-t));
        }
    }
    
    int mx = 0;
    int ans = 1LL << 60;
    for(int i=n; i>=1; i--){
        if(mx < A[i]){
            mx = A[i];
            ans = min(ans , dp[i] + (n-i)*b);
        }
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 3712